| 1 | // Base terminals and fragments for common language constructs |
| 2 | // Terminal Precedence: Lazy to Greedy |
| 3 | // When imported, the terminals are considered after the terminals in the importing grammar |
| 4 | // Note: Hence, to add a terminal greedier than the common terminals, import it separately after the common import |
| 5 | |
| 6 | EOL returns string: NEWLINE+ | EOF; |
| 7 | |
| 8 | fragment TitleAndAccessibilities: |
| 9 | ((accDescr=ACC_DESCR | accTitle=ACC_TITLE | title=TITLE) EOL)+ |
| 10 | ; |
| 11 | |
| 12 | terminal BOOLEAN returns boolean: 'true' | 'false'; |
| 13 | |
| 14 | terminal ACC_DESCR: /[\t ]*accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/; |
| 15 | terminal ACC_TITLE: /[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/; |
| 16 | terminal TITLE: /[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/; |
| 17 | |
| 18 | terminal FLOAT returns number: /[0-9]+\.[0-9]+(?!\.)/; |
| 19 | terminal INT returns number: /0|[1-9][0-9]*(?!\.)/; |
| 20 | terminal NUMBER returns number: FLOAT | INT; |
| 21 | |
| 22 | terminal STRING returns string: /"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/; |
| 23 | |
| 24 | // Alphanumerics with underscores and dashes |
| 25 | // Must start with an alphanumeric or an underscore |
| 26 | // Cant end with a dash |
| 27 | terminal ID returns string: /[\w]([-\w]*\w)?/; |
| 28 | |
| 29 | terminal NEWLINE: /\r?\n/; |
| 30 | |
| 31 | hidden terminal WHITESPACE: /[\t ]+/; |
| 32 | hidden terminal YAML: /---[\t ]*\r?\n(?:[\S\s]*?\r?\n)?---(?:\r?\n|(?!\S))/; |
| 33 | hidden terminal DIRECTIVE: /[\t ]*%%{[\S\s]*?}%%(?:\r?\n|(?!\S))/; |
| 34 | hidden terminal SINGLE_LINE_COMMENT: /[\t ]*%%[^\n\r]*/; |
| 35 | |