-
Notifications
You must be signed in to change notification settings - Fork 6
/
CartoSym-CSS-Lexer.g4
144 lines (124 loc) · 4 KB
/
CartoSym-CSS-Lexer.g4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
lexer grammar CartoSymCSSLexer;
channels { WHITESPACE, COMMENTS }
LCBR: '{';
RCBR: '}';
DOT: '.';
SEMI: ';';
LSBR: '[';
RSBR: ']';
LPAR: '(';
RPAR: ')';
COMMA: ',';
EQ: '=';
LT: '<';
LTEQ: '<=';
GT: '>';
GTEQ: '>=';
IN: 'in';
NOT: 'not';
IS: 'is';
LIKE: 'like';
BETWEEN: 'between';
QUESTION: '?';
COLON: ':';
AND: 'and';
OR: 'or';
MUL: '*';
DIV: '/';
IDIV: 'div';
MOD: '%';
POW: '^';
MINUS: '-';
PLUS: '+';
// Numeric Literals
UNIT:
'px' |
'm' |
'ft' |
'pc' |
'pt' |
'em' |
'inch' |
'cm' |
'mm';
HEX_LITERAL :
'#' ([0-9] | [a-f] | [A-F])+;
NUMERIC_LITERAL :
( [0-9]+ ('.' ([0-9]+)? )? |
'.' [0-9]+ )
('E' ('+'|'-')? [0-9]+)?;
// Character Literals
fragment WHITESPACE: '\u0009' // Character tabulation
| '\u000A' // Line feed
| '\u000B' // Line tabulation
| '\u000C' // Form feed
| '\u000D' // Carriage return
| '\u0020' // Space
| '\u0085' // Next line
| '\u00A0' // No-break space
| '\u1680' // Ogham space mark
| '\u2000' // En quad
| '\u2001' // Em quad
| '\u2002' // En space
| '\u2003' // Em space
| '\u2004' // Three-per-em space
| '\u2005' // Four-per-em space
| '\u2006' // Six-per-em space
| '\u2007' // Figure space
| '\u2008' // Punctuation space
| '\u2009' // Thin space
| '\u200A' // Hair space
| '\u2028' // Line separator
| '\u2029' // Paragraph separator
| '\u202F' // Narrow no-break space
| '\u205F' // Medium mathematical space
| '\u3000'; // Ideographic space
fragment CHARACTER : CHARACTER_NODLBQUOTE | '"' | ESCAPED_QUOTE;
fragment CHARACTER_NODLBQUOTE : ALPHA_NODBLQUOTE | [0-9] | WHITESPACE;
CHARACTER_LITERAL : '\'' CHARACTER* '\'';
fragment ESCAPED_QUOTE :'\'\'' | '\\\'';
fragment ALPHA_NODBLQUOTE : '\u0007'..'\u0008' // bell, bs
| '\u0021' // !
| '\u0023'..'\u0026' // #, $, %, &
| '\u0028'..'\u002F' // (, ), *, +, comma, -, ., /
| '\u003A'..'\u0084' // --+
| '\u0086'..'\u009F' // |
| '\u00A1'..'\u167F' // |
| '\u1681'..'\u1FFF' // |
| '\u200B'..'\u2027' // +-> :,;,<,=,>,?,@,A-Z,[,\,],^,_,`,a-z,...
| '\u202A'..'\u202E' // |
| '\u2030'..'\u205E' // |
| '\u2060'..'\u2FFF' // |
| '\u3001'..'\uD7FF' // --+
| '\uE000'..'\uFFFD' // See (CQL2) note 8.
;
// Identifiers
IDENTIFIER: UNQUOTED_IDENTIFIER | '"' CHARACTER_NODLBQUOTE* '"';
fragment UNQUOTED_IDENTIFIER: IDENTIFIER_START IDENTIFIER_PART*;
fragment IDENTIFIER_PART: IDENTIFIER_START
| [0-9] // 0-9
| '\u0300'..'\u036F' // combining and diacritical marks
| '\u203F'..'\u2040'; // ‿ and ⁀
fragment IDENTIFIER_START:
'\u005F' // underscore
| '\u0041'..'\u005A' // A-Z
| '\u0061'..'\u007A' // a-z
| '\u00C0'..'\u00D6' // À-Ö Latin-1 Supplement Letters
| '\u00D8'..'\u00F6' // Ø-ö Latin-1 Supplement Letters
| '\u00F8'..'\u02FF' // ø-ÿ Latin-1 Supplement Letters
| '\u0370'..'\u037D' // Ͱ-ͽ Greek and Coptic (without ';')
| '\u037F'..'\u1FFE' // See (CQL2) note 1.
| '\u200C'..'\u200D' // zero width non-joiner and joiner
| '\u2070'..'\u218F' // See (CQL2) note 2.
| '\u2C00'..'\u2FEF' // See (CQL2) note 3.
| '\u3001'..'\uD7FF' // See (CQL2) note 4.
| '\uF900'..'\uFDCF' // See (CQL2) note 5.
| '\uFDF0'..'\uFFFD' // See (CQL2) note 6.
;
COMMENT
: '/*' .*? '*/' -> channel(COMMENTS)
;
LINE_COMMENT
: '//' ~[\r\n]* -> channel(COMMENTS)
;
WS : [ \t\r\n]+ -> channel(WHITESPACE); // skip spaces, tabs, newlines