1.4 KB35 lines
Blame
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
6EOL returns string: NEWLINE+ | EOF;
7
8fragment TitleAndAccessibilities:
9 ((accDescr=ACC_DESCR | accTitle=ACC_TITLE | title=TITLE) EOL)+
10;
11
12terminal BOOLEAN returns boolean: 'true' | 'false';
13
14terminal ACC_DESCR: /[\t ]*accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/;
15terminal ACC_TITLE: /[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/;
16terminal TITLE: /[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/;
17
18terminal FLOAT returns number: /[0-9]+\.[0-9]+(?!\.)/;
19terminal INT returns number: /0|[1-9][0-9]*(?!\.)/;
20terminal NUMBER returns number: FLOAT | INT;
21
22terminal 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
27terminal ID returns string: /[\w]([-\w]*\w)?/;
28
29terminal NEWLINE: /\r?\n/;
30
31hidden terminal WHITESPACE: /[\t ]+/;
32hidden terminal YAML: /---[\t ]*\r?\n(?:[\S\s]*?\r?\n)?---(?:\r?\n|(?!\S))/;
33hidden terminal DIRECTIVE: /[\t ]*%%{[\S\s]*?}%%(?:\r?\n|(?!\S))/;
34hidden terminal SINGLE_LINE_COMMENT: /[\t ]*%%[^\n\r]*/;
35