OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of csslib.parser; | 5 part of csslib.parser; |
6 | 6 |
7 // TODO(terry): Need to be consistent with tokens either they're ASCII tokens | 7 // TODO(terry): Need to be consistent with tokens either they're ASCII tokens |
8 // e.g., ASTERISK or they're CSS e.g., PSEUDO, COMBINATOR_*. | 8 // e.g., ASTERISK or they're CSS e.g., PSEUDO, COMBINATOR_*. |
9 class TokenKind { | 9 class TokenKind { |
10 // Common shared tokens used in TokenizerBase. | 10 // Common shared tokens used in TokenizerBase. |
11 static const int UNUSED = 0; // Unused place holder... | 11 static const int UNUSED = 0; // Unused place holder... |
12 static const int END_OF_FILE = 1; // EOF | 12 static const int END_OF_FILE = 1; // EOF |
13 static const int LPAREN = 2; // ( | 13 static const int LPAREN = 2; // ( |
14 static const int RPAREN = 3; // ) | 14 static const int RPAREN = 3; // ) |
15 static const int LBRACK = 4; // [ | 15 static const int LBRACK = 4; // [ |
16 static const int RBRACK = 5; // ] | 16 static const int RBRACK = 5; // ] |
17 static const int LBRACE = 6; // { | 17 static const int LBRACE = 6; // { |
18 static const int RBRACE = 7; // } | 18 static const int RBRACE = 7; // } |
19 static const int DOT = 8; // . | 19 static const int DOT = 8; // . |
20 static const int SEMICOLON = 9; // ; | 20 static const int SEMICOLON = 9; // ; |
21 | 21 |
22 // Unique tokens for CSS. | 22 // Unique tokens for CSS. |
23 static const int AT = 10; // @ | 23 static const int AT = 10; // @ |
24 static const int HASH = 11; // # | 24 static const int HASH = 11; // # |
25 static const int PLUS = 12; // + | 25 static const int PLUS = 12; // + |
26 static const int GREATER = 13; // > | 26 static const int GREATER = 13; // > |
27 static const int TILDE = 14; // ~ | 27 static const int TILDE = 14; // ~ |
28 static const int ASTERISK = 15; // * | 28 static const int ASTERISK = 15; // * |
29 static const int NAMESPACE = 16; // | | 29 static const int NAMESPACE = 16; // | |
30 static const int COLON = 17; // : | 30 static const int COLON = 17; // : |
31 static const int PRIVATE_NAME = 18; // _ prefix private class or id | 31 static const int PRIVATE_NAME = 18; // _ prefix private class or id |
32 static const int COMMA = 19; // , | 32 static const int COMMA = 19; // , |
33 static const int SPACE = 20; | 33 static const int SPACE = 20; |
34 static const int TAB = 21; // /t | 34 static const int TAB = 21; // /t |
35 static const int NEWLINE = 22; // /n | 35 static const int NEWLINE = 22; // /n |
36 static const int RETURN = 23; // /r | 36 static const int RETURN = 23; // /r |
37 static const int PERCENT = 24; // % | 37 static const int PERCENT = 24; // % |
38 static const int SINGLE_QUOTE = 25; // ' | 38 static const int SINGLE_QUOTE = 25; // ' |
39 static const int DOUBLE_QUOTE = 26; // " | 39 static const int DOUBLE_QUOTE = 26; // " |
40 static const int SLASH = 27; // / | 40 static const int SLASH = 27; // / |
41 static const int EQUALS = 28; // = | 41 static const int EQUALS = 28; // = |
42 static const int CARET = 30; // ^ | 42 static const int CARET = 30; // ^ |
43 static const int DOLLAR = 31; // $ | 43 static const int DOLLAR = 31; // $ |
44 static const int LESS = 32; // < | 44 static const int LESS = 32; // < |
45 static const int BANG = 33; // ! | 45 static const int BANG = 33; // ! |
46 static const int MINUS = 34; // - | 46 static const int MINUS = 34; // - |
47 static const int BACKSLASH = 35; // \ | 47 static const int BACKSLASH = 35; // \ |
48 static const int AMPERSAND = 36; // & | 48 static const int AMPERSAND = 36; // & |
49 | 49 |
50 // WARNING: Tokens from this point and above must have the corresponding ASCII | 50 // WARNING: Tokens from this point and above must have the corresponding ASCII |
51 // character in the TokenChar list at the bottom of this file. The | 51 // character in the TokenChar list at the bottom of this file. The |
52 // order of the above tokens should be the same order as TokenChar. | 52 // order of the above tokens should be the same order as TokenChar. |
53 | 53 |
54 /** [TokenKind] representing integer tokens. */ | 54 /** [TokenKind] representing integer tokens. */ |
55 static const int INTEGER = 60; | 55 static const int INTEGER = 60; |
56 | 56 |
57 /** [TokenKind] representing hex integer tokens. */ | 57 /** [TokenKind] representing hex integer tokens. */ |
58 static const int HEX_INTEGER = 61; | 58 static const int HEX_INTEGER = 61; |
59 | 59 |
60 /** [TokenKind] representing double tokens. */ | 60 /** [TokenKind] representing double tokens. */ |
61 static const int DOUBLE = 62; | 61 static const int DOUBLE = 62; |
62 | 62 |
63 /** [TokenKind] representing whitespace tokens. */ | 63 /** [TokenKind] representing whitespace tokens. */ |
64 static const int WHITESPACE = 63; | 64 static const int WHITESPACE = 63; |
65 | 65 |
66 /** [TokenKind] representing comment tokens. */ | 66 /** [TokenKind] representing comment tokens. */ |
67 static const int COMMENT = 64; | 67 static const int COMMENT = 64; |
68 | 68 |
69 /** [TokenKind] representing error tokens. */ | 69 /** [TokenKind] representing error tokens. */ |
70 static const int ERROR = 65; | 70 static const int ERROR = 65; |
71 | 71 |
72 /** [TokenKind] representing incomplete string tokens. */ | 72 /** [TokenKind] representing incomplete string tokens. */ |
73 static const int INCOMPLETE_STRING = 66; | 73 static const int INCOMPLETE_STRING = 66; |
74 | 74 |
75 /** [TokenKind] representing incomplete comment tokens. */ | 75 /** [TokenKind] representing incomplete comment tokens. */ |
76 static const int INCOMPLETE_COMMENT = 67; | 76 static const int INCOMPLETE_COMMENT = 67; |
77 | 77 |
78 static const int VAR_DEFINITION = 400; // var-NNN-NNN | 78 static const int VAR_DEFINITION = 400; // var-NNN-NNN |
79 static const int VAR_USAGE = 401; // var(NNN-NNN [,default]) | 79 static const int VAR_USAGE = 401; // var(NNN-NNN [,default]) |
80 | 80 |
81 // Synthesized Tokens (no character associated with TOKEN). | 81 // Synthesized Tokens (no character associated with TOKEN). |
82 static const int STRING = 500; | 82 static const int STRING = 500; |
83 static const int STRING_PART = 501; | 83 static const int STRING_PART = 501; |
84 static const int NUMBER = 502; | 84 static const int NUMBER = 502; |
85 static const int HEX_NUMBER = 503; | 85 static const int HEX_NUMBER = 503; |
86 static const int HTML_COMMENT = 504; // <!-- | 86 static const int HTML_COMMENT = 504; // <!-- |
87 static const int IMPORTANT = 505; // !important | 87 static const int IMPORTANT = 505; // !important |
88 static const int CDATA_START = 506; // <![CDATA[ | 88 static const int CDATA_START = 506; // <![CDATA[ |
89 static const int CDATA_END = 507; // ]]> | 89 static const int CDATA_END = 507; // ]]> |
90 // U+uNumber[-U+uNumber] | 90 // U+uNumber[-U+uNumber] |
91 // uNumber = 0..10FFFF | ?[?]* | 91 // uNumber = 0..10FFFF | ?[?]* |
92 static const int UNICODE_RANGE = 508; | 92 static const int UNICODE_RANGE = 508; |
93 static const int HEX_RANGE = 509; // ? in the hex range | 93 static const int HEX_RANGE = 509; // ? in the hex range |
94 static const int IDENTIFIER = 511; | 94 static const int IDENTIFIER = 511; |
95 | 95 |
96 // Uniquely synthesized tokens for CSS. | 96 // Uniquely synthesized tokens for CSS. |
97 static const int SELECTOR_EXPRESSION = 512; | 97 static const int SELECTOR_EXPRESSION = 512; |
98 static const int COMBINATOR_NONE = 513; | 98 static const int COMBINATOR_NONE = 513; |
99 static const int COMBINATOR_DESCENDANT = 514; // Space combinator | 99 static const int COMBINATOR_DESCENDANT = 514; // Space combinator |
100 static const int COMBINATOR_PLUS = 515; // + combinator | 100 static const int COMBINATOR_PLUS = 515; // + combinator |
101 static const int COMBINATOR_GREATER = 516; // > combinator | 101 static const int COMBINATOR_GREATER = 516; // > combinator |
102 static const int COMBINATOR_TILDE = 517; // ~ combinator | 102 static const int COMBINATOR_TILDE = 517; // ~ combinator |
103 | 103 |
104 static const int UNARY_OP_NONE = 518; // No unary operator present. | 104 static const int UNARY_OP_NONE = 518; // No unary operator present. |
105 | 105 |
106 // Attribute match types: | 106 // Attribute match types: |
107 static const int INCLUDES = 530; // '~=' | 107 static const int INCLUDES = 530; // '~=' |
108 static const int DASH_MATCH = 531; // '|=' | 108 static const int DASH_MATCH = 531; // '|=' |
109 static const int PREFIX_MATCH = 532; // '^=' | 109 static const int PREFIX_MATCH = 532; // '^=' |
110 static const int SUFFIX_MATCH = 533; // '$=' | 110 static const int SUFFIX_MATCH = 533; // '$=' |
111 static const int SUBSTRING_MATCH = 534; // '*=' | 111 static const int SUBSTRING_MATCH = 534; // '*=' |
112 static const int NO_MATCH = 535; // No operator. | 112 static const int NO_MATCH = 535; // No operator. |
113 | 113 |
114 // Unit types: | 114 // Unit types: |
115 static const int UNIT_EM = 600; | 115 static const int UNIT_EM = 600; |
116 static const int UNIT_EX = 601; | 116 static const int UNIT_EX = 601; |
117 static const int UNIT_LENGTH_PX = 602; | 117 static const int UNIT_LENGTH_PX = 602; |
118 static const int UNIT_LENGTH_CM = 603; | 118 static const int UNIT_LENGTH_CM = 603; |
119 static const int UNIT_LENGTH_MM = 604; | 119 static const int UNIT_LENGTH_MM = 604; |
120 static const int UNIT_LENGTH_IN = 605; | 120 static const int UNIT_LENGTH_IN = 605; |
121 static const int UNIT_LENGTH_PT = 606; | 121 static const int UNIT_LENGTH_PT = 606; |
122 static const int UNIT_LENGTH_PC = 607; | 122 static const int UNIT_LENGTH_PC = 607; |
123 static const int UNIT_ANGLE_DEG = 608; | 123 static const int UNIT_ANGLE_DEG = 608; |
124 static const int UNIT_ANGLE_RAD = 609; | 124 static const int UNIT_ANGLE_RAD = 609; |
125 static const int UNIT_ANGLE_GRAD = 610; | 125 static const int UNIT_ANGLE_GRAD = 610; |
126 static const int UNIT_ANGLE_TURN = 611; | 126 static const int UNIT_ANGLE_TURN = 611; |
127 static const int UNIT_TIME_MS = 612; | 127 static const int UNIT_TIME_MS = 612; |
128 static const int UNIT_TIME_S = 613; | 128 static const int UNIT_TIME_S = 613; |
129 static const int UNIT_FREQ_HZ = 614; | 129 static const int UNIT_FREQ_HZ = 614; |
130 static const int UNIT_FREQ_KHZ = 615; | 130 static const int UNIT_FREQ_KHZ = 615; |
131 static const int UNIT_PERCENT = 616; | 131 static const int UNIT_PERCENT = 616; |
132 static const int UNIT_FRACTION = 617; | 132 static const int UNIT_FRACTION = 617; |
133 static const int UNIT_RESOLUTION_DPI = 618; | 133 static const int UNIT_RESOLUTION_DPI = 618; |
134 static const int UNIT_RESOLUTION_DPCM = 619; | 134 static const int UNIT_RESOLUTION_DPCM = 619; |
135 static const int UNIT_RESOLUTION_DPPX = 620; | 135 static const int UNIT_RESOLUTION_DPPX = 620; |
136 static const int UNIT_CH = 621; // Measure of "0" U+0030 glyph. | 136 static const int UNIT_CH = 621; // Measure of "0" U+0030 glyph. |
137 static const int UNIT_REM = 622; // computed value ‘font-size’ on root elem. | 137 static const int UNIT_REM = 622; // computed value ‘font-size’ on root elem. |
138 static const int UNIT_VIEWPORT_VW = 623; | 138 static const int UNIT_VIEWPORT_VW = 623; |
139 static const int UNIT_VIEWPORT_VH = 624; | 139 static const int UNIT_VIEWPORT_VH = 624; |
140 static const int UNIT_VIEWPORT_VMIN = 625; | 140 static const int UNIT_VIEWPORT_VMIN = 625; |
141 static const int UNIT_VIEWPORT_VMAX = 626; | 141 static const int UNIT_VIEWPORT_VMAX = 626; |
142 | 142 |
143 // Directives (@nnnn) | 143 // Directives (@nnnn) |
144 static const int DIRECTIVE_NONE = 640; | 144 static const int DIRECTIVE_NONE = 640; |
145 static const int DIRECTIVE_IMPORT = 641; | 145 static const int DIRECTIVE_IMPORT = 641; |
146 static const int DIRECTIVE_MEDIA = 642; | 146 static const int DIRECTIVE_MEDIA = 642; |
147 static const int DIRECTIVE_PAGE = 643; | 147 static const int DIRECTIVE_PAGE = 643; |
148 static const int DIRECTIVE_CHARSET = 644; | 148 static const int DIRECTIVE_CHARSET = 644; |
149 static const int DIRECTIVE_STYLET = 645; | 149 static const int DIRECTIVE_STYLET = 645; |
150 static const int DIRECTIVE_KEYFRAMES = 646; | 150 static const int DIRECTIVE_KEYFRAMES = 646; |
151 static const int DIRECTIVE_WEB_KIT_KEYFRAMES = 647; | 151 static const int DIRECTIVE_WEB_KIT_KEYFRAMES = 647; |
152 static const int DIRECTIVE_MOZ_KEYFRAMES = 648; | 152 static const int DIRECTIVE_MOZ_KEYFRAMES = 648; |
153 static const int DIRECTIVE_MS_KEYFRAMES = 649; | 153 static const int DIRECTIVE_MS_KEYFRAMES = 649; |
154 static const int DIRECTIVE_O_KEYFRAMES = 650; | 154 static const int DIRECTIVE_O_KEYFRAMES = 650; |
155 static const int DIRECTIVE_FONTFACE = 651; | 155 static const int DIRECTIVE_FONTFACE = 651; |
156 static const int DIRECTIVE_NAMESPACE = 652; | 156 static const int DIRECTIVE_NAMESPACE = 652; |
157 static const int DIRECTIVE_HOST = 653; | 157 static const int DIRECTIVE_HOST = 653; |
158 static const int DIRECTIVE_MIXIN = 654; | 158 static const int DIRECTIVE_MIXIN = 654; |
159 static const int DIRECTIVE_INCLUDE = 655; | 159 static const int DIRECTIVE_INCLUDE = 655; |
160 static const int DIRECTIVE_CONTENT = 656; | 160 static const int DIRECTIVE_CONTENT = 656; |
161 static const int DIRECTIVE_EXTEND = 657; | 161 static const int DIRECTIVE_EXTEND = 657; |
162 | 162 |
163 // Media query operators | 163 // Media query operators |
164 static const int MEDIA_OP_ONLY = 665; // Unary. | 164 static const int MEDIA_OP_ONLY = 665; // Unary. |
165 static const int MEDIA_OP_NOT = 666; // Unary. | 165 static const int MEDIA_OP_NOT = 666; // Unary. |
166 static const int MEDIA_OP_AND = 667; // Binary. | 166 static const int MEDIA_OP_AND = 667; // Binary. |
167 | 167 |
168 // Directives inside of a @page (margin sym). | 168 // Directives inside of a @page (margin sym). |
169 static const int MARGIN_DIRECTIVE_TOPLEFTCORNER = 670; | 169 static const int MARGIN_DIRECTIVE_TOPLEFTCORNER = 670; |
170 static const int MARGIN_DIRECTIVE_TOPLEFT = 671; | 170 static const int MARGIN_DIRECTIVE_TOPLEFT = 671; |
171 static const int MARGIN_DIRECTIVE_TOPCENTER = 672; | 171 static const int MARGIN_DIRECTIVE_TOPCENTER = 672; |
172 static const int MARGIN_DIRECTIVE_TOPRIGHT = 673; | 172 static const int MARGIN_DIRECTIVE_TOPRIGHT = 673; |
173 static const int MARGIN_DIRECTIVE_TOPRIGHTCORNER = 674; | 173 static const int MARGIN_DIRECTIVE_TOPRIGHTCORNER = 674; |
174 static const int MARGIN_DIRECTIVE_BOTTOMLEFTCORNER = 675; | 174 static const int MARGIN_DIRECTIVE_BOTTOMLEFTCORNER = 675; |
175 static const int MARGIN_DIRECTIVE_BOTTOMLEFT = 676; | 175 static const int MARGIN_DIRECTIVE_BOTTOMLEFT = 676; |
176 static const int MARGIN_DIRECTIVE_BOTTOMCENTER = 677; | 176 static const int MARGIN_DIRECTIVE_BOTTOMCENTER = 677; |
177 static const int MARGIN_DIRECTIVE_BOTTOMRIGHT = 678; | 177 static const int MARGIN_DIRECTIVE_BOTTOMRIGHT = 678; |
178 static const int MARGIN_DIRECTIVE_BOTTOMRIGHTCORNER = 679; | 178 static const int MARGIN_DIRECTIVE_BOTTOMRIGHTCORNER = 679; |
179 static const int MARGIN_DIRECTIVE_LEFTTOP = 680; | 179 static const int MARGIN_DIRECTIVE_LEFTTOP = 680; |
180 static const int MARGIN_DIRECTIVE_LEFTMIDDLE = 681; | 180 static const int MARGIN_DIRECTIVE_LEFTMIDDLE = 681; |
181 static const int MARGIN_DIRECTIVE_LEFTBOTTOM = 682; | 181 static const int MARGIN_DIRECTIVE_LEFTBOTTOM = 682; |
182 static const int MARGIN_DIRECTIVE_RIGHTTOP = 683; | 182 static const int MARGIN_DIRECTIVE_RIGHTTOP = 683; |
183 static const int MARGIN_DIRECTIVE_RIGHTMIDDLE = 684; | 183 static const int MARGIN_DIRECTIVE_RIGHTMIDDLE = 684; |
184 static const int MARGIN_DIRECTIVE_RIGHTBOTTOM = 685; | 184 static const int MARGIN_DIRECTIVE_RIGHTBOTTOM = 685; |
185 | 185 |
186 // Simple selector type. | 186 // Simple selector type. |
187 static const int CLASS_NAME = 700; // .class | 187 static const int CLASS_NAME = 700; // .class |
188 static const int ELEMENT_NAME = 701; // tagName | 188 static const int ELEMENT_NAME = 701; // tagName |
189 static const int HASH_NAME = 702; // #elementId | 189 static const int HASH_NAME = 702; // #elementId |
190 static const int ATTRIBUTE_NAME = 703; // [attrib] | 190 static const int ATTRIBUTE_NAME = 703; // [attrib] |
191 static const int PSEUDO_ELEMENT_NAME = 704; // ::pseudoElement | 191 static const int PSEUDO_ELEMENT_NAME = 704; // ::pseudoElement |
192 static const int PSEUDO_CLASS_NAME = 705; // :pseudoClass | 192 static const int PSEUDO_CLASS_NAME = 705; // :pseudoClass |
193 static const int NEGATION = 706; // NOT | 193 static const int NEGATION = 706; // NOT |
194 | 194 |
195 static const List<Map<int, String>> _DIRECTIVES = const [ | 195 static const List<Map<int, String>> _DIRECTIVES = const [ |
196 const {'type': TokenKind.DIRECTIVE_IMPORT, 'value' : 'import'}, | 196 const {'type': TokenKind.DIRECTIVE_IMPORT, 'value': 'import'}, |
197 const {'type': TokenKind.DIRECTIVE_MEDIA, 'value' : 'media'}, | 197 const {'type': TokenKind.DIRECTIVE_MEDIA, 'value': 'media'}, |
198 const {'type': TokenKind.DIRECTIVE_PAGE, 'value' : 'page'}, | 198 const {'type': TokenKind.DIRECTIVE_PAGE, 'value': 'page'}, |
199 const {'type': TokenKind.DIRECTIVE_CHARSET, 'value' : 'charset'}, | 199 const {'type': TokenKind.DIRECTIVE_CHARSET, 'value': 'charset'}, |
200 const {'type': TokenKind.DIRECTIVE_STYLET, 'value' : 'stylet'}, | 200 const {'type': TokenKind.DIRECTIVE_STYLET, 'value': 'stylet'}, |
201 const {'type': TokenKind.DIRECTIVE_KEYFRAMES, 'value' : 'keyframes'}, | 201 const {'type': TokenKind.DIRECTIVE_KEYFRAMES, 'value': 'keyframes'}, |
202 const {'type': TokenKind.DIRECTIVE_WEB_KIT_KEYFRAMES, | 202 const { |
203 'value' : '-webkit-keyframes'}, | 203 'type': TokenKind.DIRECTIVE_WEB_KIT_KEYFRAMES, |
204 const {'type': TokenKind.DIRECTIVE_MOZ_KEYFRAMES, | 204 'value': '-webkit-keyframes' |
205 'value' : '-moz-keyframes'}, | 205 }, |
206 const {'type': TokenKind.DIRECTIVE_MS_KEYFRAMES, 'value' : '-ms-keyframes'}, | 206 const { |
207 const {'type': TokenKind.DIRECTIVE_O_KEYFRAMES, 'value' : '-o-keyframes'}, | 207 'type': TokenKind.DIRECTIVE_MOZ_KEYFRAMES, |
208 const {'type': TokenKind.DIRECTIVE_FONTFACE, 'value' : 'font-face'}, | 208 'value': '-moz-keyframes' |
209 const {'type': TokenKind.DIRECTIVE_NAMESPACE, 'value' : 'namespace'}, | 209 }, |
210 const {'type': TokenKind.DIRECTIVE_HOST, 'value' : 'host'}, | 210 const {'type': TokenKind.DIRECTIVE_MS_KEYFRAMES, 'value': '-ms-keyframes'}, |
211 const {'type': TokenKind.DIRECTIVE_MIXIN, 'value' : 'mixin'}, | 211 const {'type': TokenKind.DIRECTIVE_O_KEYFRAMES, 'value': '-o-keyframes'}, |
212 const {'type': TokenKind.DIRECTIVE_INCLUDE, 'value' : 'include'}, | 212 const {'type': TokenKind.DIRECTIVE_FONTFACE, 'value': 'font-face'}, |
213 const {'type': TokenKind.DIRECTIVE_CONTENT, 'value' : 'content'}, | 213 const {'type': TokenKind.DIRECTIVE_NAMESPACE, 'value': 'namespace'}, |
214 const {'type': TokenKind.DIRECTIVE_EXTEND, 'value' : 'extend'}, | 214 const {'type': TokenKind.DIRECTIVE_HOST, 'value': 'host'}, |
| 215 const {'type': TokenKind.DIRECTIVE_MIXIN, 'value': 'mixin'}, |
| 216 const {'type': TokenKind.DIRECTIVE_INCLUDE, 'value': 'include'}, |
| 217 const {'type': TokenKind.DIRECTIVE_CONTENT, 'value': 'content'}, |
| 218 const {'type': TokenKind.DIRECTIVE_EXTEND, 'value': 'extend'}, |
215 ]; | 219 ]; |
216 | 220 |
217 static const List<Map<int, String>> MEDIA_OPERATORS = const [ | 221 static const List<Map<int, String>> MEDIA_OPERATORS = const [ |
218 const {'type': TokenKind.MEDIA_OP_ONLY, 'value' : 'only'}, | 222 const {'type': TokenKind.MEDIA_OP_ONLY, 'value': 'only'}, |
219 const {'type': TokenKind.MEDIA_OP_NOT, 'value' : 'not'}, | 223 const {'type': TokenKind.MEDIA_OP_NOT, 'value': 'not'}, |
220 const {'type': TokenKind.MEDIA_OP_AND, 'value' : 'and'}, | 224 const {'type': TokenKind.MEDIA_OP_AND, 'value': 'and'}, |
221 ]; | 225 ]; |
222 | 226 |
223 static const List<Map<int, String>> MARGIN_DIRECTIVES = const [ | 227 static const List<Map<int, String>> MARGIN_DIRECTIVES = const [ |
224 const {'type': TokenKind.MARGIN_DIRECTIVE_TOPLEFTCORNER, | 228 const { |
225 'value' : 'top-left-corner'}, | 229 'type': TokenKind.MARGIN_DIRECTIVE_TOPLEFTCORNER, |
226 const {'type': TokenKind.MARGIN_DIRECTIVE_TOPLEFT, | 230 'value': 'top-left-corner' |
227 'value' : 'top-left'}, | 231 }, |
228 const {'type': TokenKind.MARGIN_DIRECTIVE_TOPCENTER, | 232 const {'type': TokenKind.MARGIN_DIRECTIVE_TOPLEFT, 'value': 'top-left'}, |
229 'value' : 'top-center'}, | 233 const {'type': TokenKind.MARGIN_DIRECTIVE_TOPCENTER, 'value': 'top-center'}, |
230 const {'type': TokenKind.MARGIN_DIRECTIVE_TOPRIGHT, | 234 const {'type': TokenKind.MARGIN_DIRECTIVE_TOPRIGHT, 'value': 'top-right'}, |
231 'value' : 'top-right'}, | 235 const { |
232 const {'type': TokenKind.MARGIN_DIRECTIVE_TOPRIGHTCORNER, | 236 'type': TokenKind.MARGIN_DIRECTIVE_TOPRIGHTCORNER, |
233 'value' : 'top-right-corner'}, | 237 'value': 'top-right-corner' |
234 const {'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMLEFTCORNER, | 238 }, |
235 'value' : 'bottom-left-corner'}, | 239 const { |
236 const {'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMLEFT, | 240 'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMLEFTCORNER, |
237 'value' : 'bottom-left'}, | 241 'value': 'bottom-left-corner' |
238 const {'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMCENTER, | 242 }, |
239 'value' : 'bottom-center'}, | 243 const { |
240 const {'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMRIGHT, | 244 'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMLEFT, |
241 'value' : 'bottom-right'}, | 245 'value': 'bottom-left' |
242 const {'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMRIGHTCORNER, | 246 }, |
243 'value' : 'bottom-right-corner'}, | 247 const { |
244 const {'type': TokenKind.MARGIN_DIRECTIVE_LEFTTOP, | 248 'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMCENTER, |
245 'value' : 'left-top'}, | 249 'value': 'bottom-center' |
246 const {'type': TokenKind.MARGIN_DIRECTIVE_LEFTMIDDLE, | 250 }, |
247 'value' : 'left-middle'}, | 251 const { |
248 const {'type': TokenKind.MARGIN_DIRECTIVE_LEFTBOTTOM, | 252 'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMRIGHT, |
249 'value' : 'right-bottom'}, | 253 'value': 'bottom-right' |
250 const {'type': TokenKind.MARGIN_DIRECTIVE_RIGHTTOP, | 254 }, |
251 'value' : 'right-top'}, | 255 const { |
252 const {'type': TokenKind.MARGIN_DIRECTIVE_RIGHTMIDDLE, | 256 'type': TokenKind.MARGIN_DIRECTIVE_BOTTOMRIGHTCORNER, |
253 'value' : 'right-middle'}, | 257 'value': 'bottom-right-corner' |
254 const {'type': TokenKind.MARGIN_DIRECTIVE_RIGHTBOTTOM, | 258 }, |
255 'value' : 'right-bottom'}, | 259 const {'type': TokenKind.MARGIN_DIRECTIVE_LEFTTOP, 'value': 'left-top'}, |
| 260 const { |
| 261 'type': TokenKind.MARGIN_DIRECTIVE_LEFTMIDDLE, |
| 262 'value': 'left-middle' |
| 263 }, |
| 264 const { |
| 265 'type': TokenKind.MARGIN_DIRECTIVE_LEFTBOTTOM, |
| 266 'value': 'right-bottom' |
| 267 }, |
| 268 const {'type': TokenKind.MARGIN_DIRECTIVE_RIGHTTOP, 'value': 'right-top'}, |
| 269 const { |
| 270 'type': TokenKind.MARGIN_DIRECTIVE_RIGHTMIDDLE, |
| 271 'value': 'right-middle' |
| 272 }, |
| 273 const { |
| 274 'type': TokenKind.MARGIN_DIRECTIVE_RIGHTBOTTOM, |
| 275 'value': 'right-bottom' |
| 276 }, |
256 ]; | 277 ]; |
257 | 278 |
258 static const List<Map> _UNITS = const [ | 279 static const List<Map> _UNITS = const [ |
259 const {'unit': TokenKind.UNIT_EM, 'value' : 'em'}, | 280 const {'unit': TokenKind.UNIT_EM, 'value': 'em'}, |
260 const {'unit': TokenKind.UNIT_EX, 'value' : 'ex'}, | 281 const {'unit': TokenKind.UNIT_EX, 'value': 'ex'}, |
261 const {'unit': TokenKind.UNIT_LENGTH_PX, 'value' : 'px'}, | 282 const {'unit': TokenKind.UNIT_LENGTH_PX, 'value': 'px'}, |
262 const {'unit': TokenKind.UNIT_LENGTH_CM, 'value' : 'cm'}, | 283 const {'unit': TokenKind.UNIT_LENGTH_CM, 'value': 'cm'}, |
263 const {'unit': TokenKind.UNIT_LENGTH_MM, 'value' : 'mm'}, | 284 const {'unit': TokenKind.UNIT_LENGTH_MM, 'value': 'mm'}, |
264 const {'unit': TokenKind.UNIT_LENGTH_IN, 'value' : 'in'}, | 285 const {'unit': TokenKind.UNIT_LENGTH_IN, 'value': 'in'}, |
265 const {'unit': TokenKind.UNIT_LENGTH_PT, 'value' : 'pt'}, | 286 const {'unit': TokenKind.UNIT_LENGTH_PT, 'value': 'pt'}, |
266 const {'unit': TokenKind.UNIT_LENGTH_PC, 'value' : 'pc'}, | 287 const {'unit': TokenKind.UNIT_LENGTH_PC, 'value': 'pc'}, |
267 const {'unit': TokenKind.UNIT_ANGLE_DEG, 'value' : 'deg'}, | 288 const {'unit': TokenKind.UNIT_ANGLE_DEG, 'value': 'deg'}, |
268 const {'unit': TokenKind.UNIT_ANGLE_RAD, 'value' : 'rad'}, | 289 const {'unit': TokenKind.UNIT_ANGLE_RAD, 'value': 'rad'}, |
269 const {'unit': TokenKind.UNIT_ANGLE_GRAD, 'value' : 'grad'}, | 290 const {'unit': TokenKind.UNIT_ANGLE_GRAD, 'value': 'grad'}, |
270 const {'unit': TokenKind.UNIT_ANGLE_TURN, 'value' : 'turn'}, | 291 const {'unit': TokenKind.UNIT_ANGLE_TURN, 'value': 'turn'}, |
271 const {'unit': TokenKind.UNIT_TIME_MS, 'value' : 'ms'}, | 292 const {'unit': TokenKind.UNIT_TIME_MS, 'value': 'ms'}, |
272 const {'unit': TokenKind.UNIT_TIME_S, 'value' : 's'}, | 293 const {'unit': TokenKind.UNIT_TIME_S, 'value': 's'}, |
273 const {'unit': TokenKind.UNIT_FREQ_HZ, 'value' : 'hz'}, | 294 const {'unit': TokenKind.UNIT_FREQ_HZ, 'value': 'hz'}, |
274 const {'unit': TokenKind.UNIT_FREQ_KHZ, 'value' : 'khz'}, | 295 const {'unit': TokenKind.UNIT_FREQ_KHZ, 'value': 'khz'}, |
275 const {'unit': TokenKind.UNIT_FRACTION, 'value' : 'fr'}, | 296 const {'unit': TokenKind.UNIT_FRACTION, 'value': 'fr'}, |
276 const {'unit': TokenKind.UNIT_RESOLUTION_DPI, 'value' : 'dpi'}, | 297 const {'unit': TokenKind.UNIT_RESOLUTION_DPI, 'value': 'dpi'}, |
277 const {'unit': TokenKind.UNIT_RESOLUTION_DPCM, 'value' : 'dpcm'}, | 298 const {'unit': TokenKind.UNIT_RESOLUTION_DPCM, 'value': 'dpcm'}, |
278 const {'unit': TokenKind.UNIT_RESOLUTION_DPPX, 'value' : 'dppx'}, | 299 const {'unit': TokenKind.UNIT_RESOLUTION_DPPX, 'value': 'dppx'}, |
279 const {'unit': TokenKind.UNIT_CH, 'value' : 'ch'}, | 300 const {'unit': TokenKind.UNIT_CH, 'value': 'ch'}, |
280 const {'unit': TokenKind.UNIT_REM, 'value' : 'rem'}, | 301 const {'unit': TokenKind.UNIT_REM, 'value': 'rem'}, |
281 const {'unit': TokenKind.UNIT_VIEWPORT_VW, 'value' : 'vw'}, | 302 const {'unit': TokenKind.UNIT_VIEWPORT_VW, 'value': 'vw'}, |
282 const {'unit': TokenKind.UNIT_VIEWPORT_VH, 'value' : 'vh'}, | 303 const {'unit': TokenKind.UNIT_VIEWPORT_VH, 'value': 'vh'}, |
283 const {'unit': TokenKind.UNIT_VIEWPORT_VMIN, 'value' : 'vmin'}, | 304 const {'unit': TokenKind.UNIT_VIEWPORT_VMIN, 'value': 'vmin'}, |
284 const {'unit': TokenKind.UNIT_VIEWPORT_VMAX, 'value' : 'vmax'}, | 305 const {'unit': TokenKind.UNIT_VIEWPORT_VMAX, 'value': 'vmax'}, |
285 ]; | 306 ]; |
286 | 307 |
287 // Some more constants: | 308 // Some more constants: |
288 static const int ASCII_UPPER_A = 65; // ASCII value for uppercase A | 309 static const int ASCII_UPPER_A = 65; // ASCII value for uppercase A |
289 static const int ASCII_UPPER_Z = 90; // ASCII value for uppercase Z | 310 static const int ASCII_UPPER_Z = 90; // ASCII value for uppercase Z |
290 | 311 |
291 // Extended color keywords: | 312 // Extended color keywords: |
292 static const List<Map> _EXTENDED_COLOR_NAMES = const [ | 313 static const List<Map> _EXTENDED_COLOR_NAMES = const [ |
293 const {'name' : 'aliceblue', 'value' : 0xF08FF}, | 314 const {'name': 'aliceblue', 'value': 0xF08FF}, |
294 const {'name' : 'antiquewhite', 'value' : 0xFAEBD7}, | 315 const {'name': 'antiquewhite', 'value': 0xFAEBD7}, |
295 const {'name' : 'aqua', 'value' : 0x00FFFF}, | 316 const {'name': 'aqua', 'value': 0x00FFFF}, |
296 const {'name' : 'aquamarine', 'value' : 0x7FFFD4}, | 317 const {'name': 'aquamarine', 'value': 0x7FFFD4}, |
297 const {'name' : 'azure', 'value' : 0xF0FFFF}, | 318 const {'name': 'azure', 'value': 0xF0FFFF}, |
298 const {'name' : 'beige', 'value' : 0xF5F5DC}, | 319 const {'name': 'beige', 'value': 0xF5F5DC}, |
299 const {'name' : 'bisque', 'value' : 0xFFE4C4}, | 320 const {'name': 'bisque', 'value': 0xFFE4C4}, |
300 const {'name' : 'black', 'value' : 0x000000}, | 321 const {'name': 'black', 'value': 0x000000}, |
301 const {'name' : 'blanchedalmond', 'value' : 0xFFEBCD}, | 322 const {'name': 'blanchedalmond', 'value': 0xFFEBCD}, |
302 const {'name' : 'blue', 'value' : 0x0000FF}, | 323 const {'name': 'blue', 'value': 0x0000FF}, |
303 const {'name' : 'blueviolet', 'value' : 0x8A2BE2}, | 324 const {'name': 'blueviolet', 'value': 0x8A2BE2}, |
304 const {'name' : 'brown', 'value' : 0xA52A2A}, | 325 const {'name': 'brown', 'value': 0xA52A2A}, |
305 const {'name' : 'burlywood', 'value' : 0xDEB887}, | 326 const {'name': 'burlywood', 'value': 0xDEB887}, |
306 const {'name' : 'cadetblue', 'value' : 0x5F9EA0}, | 327 const {'name': 'cadetblue', 'value': 0x5F9EA0}, |
307 const {'name' : 'chartreuse', 'value' : 0x7FFF00}, | 328 const {'name': 'chartreuse', 'value': 0x7FFF00}, |
308 const {'name' : 'chocolate', 'value' : 0xD2691E}, | 329 const {'name': 'chocolate', 'value': 0xD2691E}, |
309 const {'name' : 'coral', 'value' : 0xFF7F50}, | 330 const {'name': 'coral', 'value': 0xFF7F50}, |
310 const {'name' : 'cornflowerblue', 'value' : 0x6495ED}, | 331 const {'name': 'cornflowerblue', 'value': 0x6495ED}, |
311 const {'name' : 'cornsilk', 'value' : 0xFFF8DC}, | 332 const {'name': 'cornsilk', 'value': 0xFFF8DC}, |
312 const {'name' : 'crimson', 'value' : 0xDC143C}, | 333 const {'name': 'crimson', 'value': 0xDC143C}, |
313 const {'name' : 'cyan', 'value' : 0x00FFFF}, | 334 const {'name': 'cyan', 'value': 0x00FFFF}, |
314 const {'name' : 'darkblue', 'value' : 0x00008B}, | 335 const {'name': 'darkblue', 'value': 0x00008B}, |
315 const {'name' : 'darkcyan', 'value' : 0x008B8B}, | 336 const {'name': 'darkcyan', 'value': 0x008B8B}, |
316 const {'name' : 'darkgoldenrod', 'value' : 0xB8860B}, | 337 const {'name': 'darkgoldenrod', 'value': 0xB8860B}, |
317 const {'name' : 'darkgray', 'value' : 0xA9A9A9}, | 338 const {'name': 'darkgray', 'value': 0xA9A9A9}, |
318 const {'name' : 'darkgreen', 'value' : 0x006400}, | 339 const {'name': 'darkgreen', 'value': 0x006400}, |
319 const {'name' : 'darkgrey', 'value' : 0xA9A9A9}, | 340 const {'name': 'darkgrey', 'value': 0xA9A9A9}, |
320 const {'name' : 'darkkhaki', 'value' : 0xBDB76B}, | 341 const {'name': 'darkkhaki', 'value': 0xBDB76B}, |
321 const {'name' : 'darkmagenta', 'value' : 0x8B008B}, | 342 const {'name': 'darkmagenta', 'value': 0x8B008B}, |
322 const {'name' : 'darkolivegreen', 'value' : 0x556B2F}, | 343 const {'name': 'darkolivegreen', 'value': 0x556B2F}, |
323 const {'name' : 'darkorange', 'value' : 0xFF8C00}, | 344 const {'name': 'darkorange', 'value': 0xFF8C00}, |
324 const {'name' : 'darkorchid', 'value' : 0x9932CC}, | 345 const {'name': 'darkorchid', 'value': 0x9932CC}, |
325 const {'name' : 'darkred', 'value' : 0x8B0000}, | 346 const {'name': 'darkred', 'value': 0x8B0000}, |
326 const {'name' : 'darksalmon', 'value' : 0xE9967A}, | 347 const {'name': 'darksalmon', 'value': 0xE9967A}, |
327 const {'name' : 'darkseagreen', 'value' : 0x8FBC8F}, | 348 const {'name': 'darkseagreen', 'value': 0x8FBC8F}, |
328 const {'name' : 'darkslateblue', 'value' : 0x483D8B}, | 349 const {'name': 'darkslateblue', 'value': 0x483D8B}, |
329 const {'name' : 'darkslategray', 'value' : 0x2F4F4F}, | 350 const {'name': 'darkslategray', 'value': 0x2F4F4F}, |
330 const {'name' : 'darkslategrey', 'value' : 0x2F4F4F}, | 351 const {'name': 'darkslategrey', 'value': 0x2F4F4F}, |
331 const {'name' : 'darkturquoise', 'value' : 0x00CED1}, | 352 const {'name': 'darkturquoise', 'value': 0x00CED1}, |
332 const {'name' : 'darkviolet', 'value' : 0x9400D3}, | 353 const {'name': 'darkviolet', 'value': 0x9400D3}, |
333 const {'name' : 'deeppink', 'value' : 0xFF1493}, | 354 const {'name': 'deeppink', 'value': 0xFF1493}, |
334 const {'name' : 'deepskyblue', 'value' : 0x00BFFF}, | 355 const {'name': 'deepskyblue', 'value': 0x00BFFF}, |
335 const {'name' : 'dimgray', 'value' : 0x696969}, | 356 const {'name': 'dimgray', 'value': 0x696969}, |
336 const {'name' : 'dimgrey', 'value' : 0x696969}, | 357 const {'name': 'dimgrey', 'value': 0x696969}, |
337 const {'name' : 'dodgerblue', 'value' : 0x1E90FF}, | 358 const {'name': 'dodgerblue', 'value': 0x1E90FF}, |
338 const {'name' : 'firebrick', 'value' : 0xB22222}, | 359 const {'name': 'firebrick', 'value': 0xB22222}, |
339 const {'name' : 'floralwhite', 'value' : 0xFFFAF0}, | 360 const {'name': 'floralwhite', 'value': 0xFFFAF0}, |
340 const {'name' : 'forestgreen', 'value' : 0x228B22}, | 361 const {'name': 'forestgreen', 'value': 0x228B22}, |
341 const {'name' : 'fuchsia', 'value' : 0xFF00FF}, | 362 const {'name': 'fuchsia', 'value': 0xFF00FF}, |
342 const {'name' : 'gainsboro', 'value' : 0xDCDCDC}, | 363 const {'name': 'gainsboro', 'value': 0xDCDCDC}, |
343 const {'name' : 'ghostwhite', 'value' : 0xF8F8FF}, | 364 const {'name': 'ghostwhite', 'value': 0xF8F8FF}, |
344 const {'name' : 'gold', 'value' : 0xFFD700}, | 365 const {'name': 'gold', 'value': 0xFFD700}, |
345 const {'name' : 'goldenrod', 'value' : 0xDAA520}, | 366 const {'name': 'goldenrod', 'value': 0xDAA520}, |
346 const {'name' : 'gray', 'value' : 0x808080}, | 367 const {'name': 'gray', 'value': 0x808080}, |
347 const {'name' : 'green', 'value' : 0x008000}, | 368 const {'name': 'green', 'value': 0x008000}, |
348 const {'name' : 'greenyellow', 'value' : 0xADFF2F}, | 369 const {'name': 'greenyellow', 'value': 0xADFF2F}, |
349 const {'name' : 'grey', 'value' : 0x808080}, | 370 const {'name': 'grey', 'value': 0x808080}, |
350 const {'name' : 'honeydew', 'value' : 0xF0FFF0}, | 371 const {'name': 'honeydew', 'value': 0xF0FFF0}, |
351 const {'name' : 'hotpink', 'value' : 0xFF69B4}, | 372 const {'name': 'hotpink', 'value': 0xFF69B4}, |
352 const {'name' : 'indianred', 'value' : 0xCD5C5C}, | 373 const {'name': 'indianred', 'value': 0xCD5C5C}, |
353 const {'name' : 'indigo', 'value' : 0x4B0082}, | 374 const {'name': 'indigo', 'value': 0x4B0082}, |
354 const {'name' : 'ivory', 'value' : 0xFFFFF0}, | 375 const {'name': 'ivory', 'value': 0xFFFFF0}, |
355 const {'name' : 'khaki', 'value' : 0xF0E68C}, | 376 const {'name': 'khaki', 'value': 0xF0E68C}, |
356 const {'name' : 'lavender', 'value' : 0xE6E6FA}, | 377 const {'name': 'lavender', 'value': 0xE6E6FA}, |
357 const {'name' : 'lavenderblush', 'value' : 0xFFF0F5}, | 378 const {'name': 'lavenderblush', 'value': 0xFFF0F5}, |
358 const {'name' : 'lawngreen', 'value' : 0x7CFC00}, | 379 const {'name': 'lawngreen', 'value': 0x7CFC00}, |
359 const {'name' : 'lemonchiffon', 'value' : 0xFFFACD}, | 380 const {'name': 'lemonchiffon', 'value': 0xFFFACD}, |
360 const {'name' : 'lightblue', 'value' : 0xADD8E6}, | 381 const {'name': 'lightblue', 'value': 0xADD8E6}, |
361 const {'name' : 'lightcoral', 'value' : 0xF08080}, | 382 const {'name': 'lightcoral', 'value': 0xF08080}, |
362 const {'name' : 'lightcyan', 'value' : 0xE0FFFF}, | 383 const {'name': 'lightcyan', 'value': 0xE0FFFF}, |
363 const {'name' : 'lightgoldenrodyellow', 'value' : 0xFAFAD2}, | 384 const {'name': 'lightgoldenrodyellow', 'value': 0xFAFAD2}, |
364 const {'name' : 'lightgray', 'value' : 0xD3D3D3}, | 385 const {'name': 'lightgray', 'value': 0xD3D3D3}, |
365 const {'name' : 'lightgreen', 'value' : 0x90EE90}, | 386 const {'name': 'lightgreen', 'value': 0x90EE90}, |
366 const {'name' : 'lightgrey', 'value' : 0xD3D3D3}, | 387 const {'name': 'lightgrey', 'value': 0xD3D3D3}, |
367 const {'name' : 'lightpink', 'value' : 0xFFB6C1}, | 388 const {'name': 'lightpink', 'value': 0xFFB6C1}, |
368 const {'name' : 'lightsalmon', 'value' : 0xFFA07A}, | 389 const {'name': 'lightsalmon', 'value': 0xFFA07A}, |
369 const {'name' : 'lightseagreen', 'value' : 0x20B2AA}, | 390 const {'name': 'lightseagreen', 'value': 0x20B2AA}, |
370 const {'name' : 'lightskyblue', 'value' : 0x87CEFA}, | 391 const {'name': 'lightskyblue', 'value': 0x87CEFA}, |
371 const {'name' : 'lightslategray', 'value' : 0x778899}, | 392 const {'name': 'lightslategray', 'value': 0x778899}, |
372 const {'name' : 'lightslategrey', 'value' : 0x778899}, | 393 const {'name': 'lightslategrey', 'value': 0x778899}, |
373 const {'name' : 'lightsteelblue', 'value' : 0xB0C4DE}, | 394 const {'name': 'lightsteelblue', 'value': 0xB0C4DE}, |
374 const {'name' : 'lightyellow', 'value' : 0xFFFFE0}, | 395 const {'name': 'lightyellow', 'value': 0xFFFFE0}, |
375 const {'name' : 'lime', 'value' : 0x00FF00}, | 396 const {'name': 'lime', 'value': 0x00FF00}, |
376 const {'name' : 'limegreen', 'value' : 0x32CD32}, | 397 const {'name': 'limegreen', 'value': 0x32CD32}, |
377 const {'name' : 'linen', 'value' : 0xFAF0E6}, | 398 const {'name': 'linen', 'value': 0xFAF0E6}, |
378 const {'name' : 'magenta', 'value' : 0xFF00FF}, | 399 const {'name': 'magenta', 'value': 0xFF00FF}, |
379 const {'name' : 'maroon', 'value' : 0x800000}, | 400 const {'name': 'maroon', 'value': 0x800000}, |
380 const {'name' : 'mediumaquamarine', 'value' : 0x66CDAA}, | 401 const {'name': 'mediumaquamarine', 'value': 0x66CDAA}, |
381 const {'name' : 'mediumblue', 'value' : 0x0000CD}, | 402 const {'name': 'mediumblue', 'value': 0x0000CD}, |
382 const {'name' : 'mediumorchid', 'value' : 0xBA55D3}, | 403 const {'name': 'mediumorchid', 'value': 0xBA55D3}, |
383 const {'name' : 'mediumpurple', 'value' : 0x9370DB}, | 404 const {'name': 'mediumpurple', 'value': 0x9370DB}, |
384 const {'name' : 'mediumseagreen', 'value' : 0x3CB371}, | 405 const {'name': 'mediumseagreen', 'value': 0x3CB371}, |
385 const {'name' : 'mediumslateblue', 'value' : 0x7B68EE}, | 406 const {'name': 'mediumslateblue', 'value': 0x7B68EE}, |
386 const {'name' : 'mediumspringgreen', 'value' : 0x00FA9A}, | 407 const {'name': 'mediumspringgreen', 'value': 0x00FA9A}, |
387 const {'name' : 'mediumturquoise', 'value' : 0x48D1CC}, | 408 const {'name': 'mediumturquoise', 'value': 0x48D1CC}, |
388 const {'name' : 'mediumvioletred', 'value' : 0xC71585}, | 409 const {'name': 'mediumvioletred', 'value': 0xC71585}, |
389 const {'name' : 'midnightblue', 'value' : 0x191970}, | 410 const {'name': 'midnightblue', 'value': 0x191970}, |
390 const {'name' : 'mintcream', 'value' : 0xF5FFFA}, | 411 const {'name': 'mintcream', 'value': 0xF5FFFA}, |
391 const {'name' : 'mistyrose', 'value' : 0xFFE4E1}, | 412 const {'name': 'mistyrose', 'value': 0xFFE4E1}, |
392 const {'name' : 'moccasin', 'value' : 0xFFE4B5}, | 413 const {'name': 'moccasin', 'value': 0xFFE4B5}, |
393 const {'name' : 'navajowhite', 'value' : 0xFFDEAD}, | 414 const {'name': 'navajowhite', 'value': 0xFFDEAD}, |
394 const {'name' : 'navy', 'value' : 0x000080}, | 415 const {'name': 'navy', 'value': 0x000080}, |
395 const {'name' : 'oldlace', 'value' : 0xFDF5E6}, | 416 const {'name': 'oldlace', 'value': 0xFDF5E6}, |
396 const {'name' : 'olive', 'value' : 0x808000}, | 417 const {'name': 'olive', 'value': 0x808000}, |
397 const {'name' : 'olivedrab', 'value' : 0x6B8E23}, | 418 const {'name': 'olivedrab', 'value': 0x6B8E23}, |
398 const {'name' : 'orange', 'value' : 0xFFA500}, | 419 const {'name': 'orange', 'value': 0xFFA500}, |
399 const {'name' : 'orangered', 'value' : 0xFF4500}, | 420 const {'name': 'orangered', 'value': 0xFF4500}, |
400 const {'name' : 'orchid', 'value' : 0xDA70D6}, | 421 const {'name': 'orchid', 'value': 0xDA70D6}, |
401 const {'name' : 'palegoldenrod', 'value' : 0xEEE8AA}, | 422 const {'name': 'palegoldenrod', 'value': 0xEEE8AA}, |
402 const {'name' : 'palegreen', 'value' : 0x98FB98}, | 423 const {'name': 'palegreen', 'value': 0x98FB98}, |
403 const {'name' : 'paleturquoise', 'value' : 0xAFEEEE}, | 424 const {'name': 'paleturquoise', 'value': 0xAFEEEE}, |
404 const {'name' : 'palevioletred', 'value' : 0xDB7093}, | 425 const {'name': 'palevioletred', 'value': 0xDB7093}, |
405 const {'name' : 'papayawhip', 'value' : 0xFFEFD5}, | 426 const {'name': 'papayawhip', 'value': 0xFFEFD5}, |
406 const {'name' : 'peachpuff', 'value' : 0xFFDAB9}, | 427 const {'name': 'peachpuff', 'value': 0xFFDAB9}, |
407 const {'name' : 'peru', 'value' : 0xCD853F}, | 428 const {'name': 'peru', 'value': 0xCD853F}, |
408 const {'name' : 'pink', 'value' : 0xFFC0CB}, | 429 const {'name': 'pink', 'value': 0xFFC0CB}, |
409 const {'name' : 'plum', 'value' : 0xDDA0DD}, | 430 const {'name': 'plum', 'value': 0xDDA0DD}, |
410 const {'name' : 'powderblue', 'value' : 0xB0E0E6}, | 431 const {'name': 'powderblue', 'value': 0xB0E0E6}, |
411 const {'name' : 'purple', 'value' : 0x800080}, | 432 const {'name': 'purple', 'value': 0x800080}, |
412 const {'name' : 'red', 'value' : 0xFF0000}, | 433 const {'name': 'red', 'value': 0xFF0000}, |
413 const {'name' : 'rosybrown', 'value' : 0xBC8F8F}, | 434 const {'name': 'rosybrown', 'value': 0xBC8F8F}, |
414 const {'name' : 'royalblue', 'value' : 0x4169E1}, | 435 const {'name': 'royalblue', 'value': 0x4169E1}, |
415 const {'name' : 'saddlebrown', 'value' : 0x8B4513}, | 436 const {'name': 'saddlebrown', 'value': 0x8B4513}, |
416 const {'name' : 'salmon', 'value' : 0xFA8072}, | 437 const {'name': 'salmon', 'value': 0xFA8072}, |
417 const {'name' : 'sandybrown', 'value' : 0xF4A460}, | 438 const {'name': 'sandybrown', 'value': 0xF4A460}, |
418 const {'name' : 'seagreen', 'value' : 0x2E8B57}, | 439 const {'name': 'seagreen', 'value': 0x2E8B57}, |
419 const {'name' : 'seashell', 'value' : 0xFFF5EE}, | 440 const {'name': 'seashell', 'value': 0xFFF5EE}, |
420 const {'name' : 'sienna', 'value' : 0xA0522D}, | 441 const {'name': 'sienna', 'value': 0xA0522D}, |
421 const {'name' : 'silver', 'value' : 0xC0C0C0}, | 442 const {'name': 'silver', 'value': 0xC0C0C0}, |
422 const {'name' : 'skyblue', 'value' : 0x87CEEB}, | 443 const {'name': 'skyblue', 'value': 0x87CEEB}, |
423 const {'name' : 'slateblue', 'value' : 0x6A5ACD}, | 444 const {'name': 'slateblue', 'value': 0x6A5ACD}, |
424 const {'name' : 'slategray', 'value' : 0x708090}, | 445 const {'name': 'slategray', 'value': 0x708090}, |
425 const {'name' : 'slategrey', 'value' : 0x708090}, | 446 const {'name': 'slategrey', 'value': 0x708090}, |
426 const {'name' : 'snow', 'value' : 0xFFFAFA}, | 447 const {'name': 'snow', 'value': 0xFFFAFA}, |
427 const {'name' : 'springgreen', 'value' : 0x00FF7F}, | 448 const {'name': 'springgreen', 'value': 0x00FF7F}, |
428 const {'name' : 'steelblue', 'value' : 0x4682B4}, | 449 const {'name': 'steelblue', 'value': 0x4682B4}, |
429 const {'name' : 'tan', 'value' : 0xD2B48C}, | 450 const {'name': 'tan', 'value': 0xD2B48C}, |
430 const {'name' : 'teal', 'value' : 0x008080}, | 451 const {'name': 'teal', 'value': 0x008080}, |
431 const {'name' : 'thistle', 'value' : 0xD8BFD8}, | 452 const {'name': 'thistle', 'value': 0xD8BFD8}, |
432 const {'name' : 'tomato', 'value' : 0xFF6347}, | 453 const {'name': 'tomato', 'value': 0xFF6347}, |
433 const {'name' : 'turquoise', 'value' : 0x40E0D0}, | 454 const {'name': 'turquoise', 'value': 0x40E0D0}, |
434 const {'name' : 'violet', 'value' : 0xEE82EE}, | 455 const {'name': 'violet', 'value': 0xEE82EE}, |
435 const {'name' : 'wheat', 'value' : 0xF5DEB3}, | 456 const {'name': 'wheat', 'value': 0xF5DEB3}, |
436 const {'name' : 'white', 'value' : 0xFFFFFF}, | 457 const {'name': 'white', 'value': 0xFFFFFF}, |
437 const {'name' : 'whitesmoke', 'value' : 0xF5F5F5}, | 458 const {'name': 'whitesmoke', 'value': 0xF5F5F5}, |
438 const {'name' : 'yellow', 'value' : 0xFFFF00}, | 459 const {'name': 'yellow', 'value': 0xFFFF00}, |
439 const {'name' : 'yellowgreen', 'value' : 0x9ACD32}, | 460 const {'name': 'yellowgreen', 'value': 0x9ACD32}, |
440 ]; | 461 ]; |
441 | 462 |
442 // TODO(terry): Should used Dart mirroring for parameter values and types | 463 // TODO(terry): Should used Dart mirroring for parameter values and types |
443 // especially for enumeration (e.g., counter's second parameter | 464 // especially for enumeration (e.g., counter's second parameter |
444 // is list-style-type which is an enumerated list for ordering | 465 // is list-style-type which is an enumerated list for ordering |
445 // of a list 'circle', 'decimal', 'lower-roman', 'square', etc. | 466 // of a list 'circle', 'decimal', 'lower-roman', 'square', etc. |
446 // see http://www.w3schools.com/cssref/pr_list-style-type.asp | 467 // see http://www.w3schools.com/cssref/pr_list-style-type.asp |
447 // for list of possible values. | 468 // for list of possible values. |
448 | 469 |
449 // List of valid CSS functions: | 470 // List of valid CSS functions: |
450 static const List<Map<String, Object>> _FUNCTIONS = const [ | 471 static const List<Map<String, Object>> _FUNCTIONS = const [ |
451 const {'name' : 'counter', 'info' : const {'params' : 2, 'expr' : false}}, | 472 const {'name': 'counter', 'info': const {'params': 2, 'expr': false}}, |
452 const {'name' : 'attr', 'info' : const {'params' : 1, 'expr' : false}}, | 473 const {'name': 'attr', 'info': const {'params': 1, 'expr': false}}, |
453 const {'name' : 'calc', 'info' : const {'params' : 1, 'expr' : true}}, | 474 const {'name': 'calc', 'info': const {'params': 1, 'expr': true}}, |
454 const {'name' : 'min', 'info' : const {'params' : 2, 'expr' : true}}, | 475 const {'name': 'min', 'info': const {'params': 2, 'expr': true}}, |
455 const {'name' : 'max', 'info' : const {'params' : 2, 'expr' : true}}, | 476 const {'name': 'max', 'info': const {'params': 2, 'expr': true}}, |
456 | 477 |
457 // 2D functions: | 478 // 2D functions: |
458 const {'name' : 'translateX', | 479 const {'name': 'translateX', 'info': const {'params': 1, 'expr': false}}, |
459 'info' : const {'params' : 1, 'expr' : false}}, | 480 const {'name': 'translateY', 'info': const {'params': 1, 'expr': false}}, |
460 const {'name' : 'translateY', | 481 const {'name': 'translate', 'info': const {'params': 2, 'expr': false}}, |
461 'info' : const {'params' : 1, 'expr' : false}}, | 482 const {'name': 'rotate', 'info': const {'params': 1, 'expr': false}}, |
462 const {'name' : 'translate', 'info' : const {'params' : 2, 'expr' : false}}, | 483 const {'name': 'scaleX', 'info': const {'params': 1, 'expr': false}}, |
463 const {'name' : 'rotate', 'info' : const {'params' : 1, 'expr' : false}}, | 484 const {'name': 'scaleY', 'info': const {'params': 1, 'expr': false}}, |
464 const {'name' : 'scaleX', 'info' : const {'params' : 1, 'expr' : false}}, | 485 const {'name': 'scale', 'info': const {'params': 2, 'expr': false}}, |
465 const {'name' : 'scaleY', 'info' : const {'params' : 1, 'expr' : false}}, | 486 const {'name': 'skewX', 'info': const {'params': 1, 'expr': false}}, |
466 const {'name' : 'scale', 'info' : const {'params' : 2, 'expr' : false}}, | 487 const {'name': 'skewY', 'info': const {'params': 1, 'expr': false}}, |
467 const {'name' : 'skewX', 'info' : const {'params' : 1, 'expr' : false}}, | 488 const {'name': 'skew', 'info': const {'params': 2, 'expr': false}}, |
468 const {'name' : 'skewY', 'info' : const {'params' : 1, 'expr' : false}}, | 489 const {'name': 'matrix', 'info': const {'params': 6, 'expr': false}}, |
469 const {'name' : 'skew', 'info' : const {'params' : 2, 'expr' : false}}, | |
470 const {'name' : 'matrix', 'info' : const {'params' : 6, 'expr' : false}}, | |
471 | 490 |
472 // 3D functions: | 491 // 3D functions: |
473 const {'name' : 'matrix3d', 'info' : const {'params' : 16, 'expr' : false}}, | 492 const {'name': 'matrix3d', 'info': const {'params': 16, 'expr': false}}, |
474 const {'name' : 'translate3d', | 493 const {'name': 'translate3d', 'info': const {'params': 3, 'expr': false}}, |
475 'info' : const {'params' : 3, 'expr' : false}}, | 494 const {'name': 'translateZ', 'info': const {'params': 1, 'expr': false}}, |
476 const {'name' : 'translateZ', | 495 const {'name': 'scale3d', 'info': const {'params': 3, 'expr': false}}, |
477 'info' : const {'params' : 1, 'expr' : false}}, | 496 const {'name': 'scaleZ', 'info': const {'params': 1, 'expr': false}}, |
478 const {'name' : 'scale3d', 'info' : const {'params' : 3, 'expr' : false}}, | 497 const {'name': 'rotate3d', 'info': const {'params': 3, 'expr': false}}, |
479 const {'name' : 'scaleZ', 'info' : const {'params' : 1, 'expr' : false}}, | 498 const {'name': 'rotateX', 'info': const {'params': 1, 'expr': false}}, |
480 const {'name' : 'rotate3d', 'info' : const {'params' : 3, 'expr' : false}}, | 499 const {'name': 'rotateY', 'info': const {'params': 1, 'expr': false}}, |
481 const {'name' : 'rotateX', 'info' : const {'params' : 1, 'expr' : false}}, | 500 const {'name': 'rotateZ', 'info': const {'params': 1, 'expr': false}}, |
482 const {'name' : 'rotateY', 'info' : const {'params' : 1, 'expr' : false}}, | 501 const {'name': 'perspective', 'info': const {'params': 1, 'expr': false}}, |
483 const {'name' : 'rotateZ', 'info' : const {'params' : 1, 'expr' : false}}, | |
484 const {'name' : 'perspective', | |
485 'info' : const {'params' : 1, 'expr' : false}}, | |
486 ]; | 502 ]; |
487 | 503 |
488 /** | 504 /** |
489 * Check if name is a pre-defined CSS name. Used by error handler to report | 505 * Check if name is a pre-defined CSS name. Used by error handler to report |
490 * if name is unknown or used improperly. | 506 * if name is unknown or used improperly. |
491 */ | 507 */ |
492 static bool isPredefinedName(String name) { | 508 static bool isPredefinedName(String name) { |
493 var nameLen = name.length; | 509 var nameLen = name.length; |
494 // TODO(terry): Add more pre-defined names (hidden, bolder, inherit, etc.). | 510 // TODO(terry): Add more pre-defined names (hidden, bolder, inherit, etc.). |
495 if (matchUnits(name, 0, nameLen) == -1 || | 511 if (matchUnits(name, 0, nameLen) == -1 || |
496 matchDirectives(name, 0, nameLen) == -1 || | 512 matchDirectives(name, 0, nameLen) == -1 || |
497 matchMarginDirectives(name, 0, nameLen) == -1 || | 513 matchMarginDirectives(name, 0, nameLen) == -1 || |
498 matchColorName(name) == null) { | 514 matchColorName(name) == null) { |
499 return false; | 515 return false; |
500 } | 516 } |
501 | 517 |
502 return true; | 518 return true; |
503 } | 519 } |
504 | 520 |
505 /** Return the token that matches the unit ident found. */ | 521 /** Return the token that matches the unit ident found. */ |
506 static int matchList(var identList, String tokenField, String text, | 522 static int matchList( |
507 int offset, int length) { | 523 var identList, String tokenField, String text, int offset, int length) { |
508 for (final entry in identList) { | 524 for (final entry in identList) { |
509 String ident = entry['value']; | 525 String ident = entry['value']; |
510 | 526 |
511 if (length == ident.length) { | 527 if (length == ident.length) { |
512 int idx = offset; | 528 int idx = offset; |
513 bool match = true; | 529 bool match = true; |
514 for (int i = 0; i < ident.length; i++) { | 530 for (int i = 0; i < ident.length; i++) { |
515 int identChar = ident.codeUnitAt(i); | 531 int identChar = ident.codeUnitAt(i); |
516 int char = text.codeUnitAt(idx++); | 532 int char = text.codeUnitAt(idx++); |
517 // Compare lowercase to lowercase then check if char is uppercase. | 533 // Compare lowercase to lowercase then check if char is uppercase. |
518 match = match && (char == identChar || | 534 match = match && |
519 ((char >= ASCII_UPPER_A && char <= ASCII_UPPER_Z) && | 535 (char == identChar || |
520 (char + 32) == identChar)); | 536 ((char >= ASCII_UPPER_A && char <= ASCII_UPPER_Z) && |
| 537 (char + 32) == identChar)); |
521 if (!match) { | 538 if (!match) { |
522 break; | 539 break; |
523 } | 540 } |
524 } | 541 } |
525 | 542 |
526 if (match) { | 543 if (match) { |
527 // Completely matched; return the token for this unit. | 544 // Completely matched; return the token for this unit. |
528 return entry[tokenField]; | 545 return entry[tokenField]; |
529 } | 546 } |
530 } | 547 } |
531 } | 548 } |
532 | 549 |
533 return -1; // Not a unit token. | 550 return -1; // Not a unit token. |
534 } | 551 } |
535 | 552 |
536 /** Return the token that matches the unit ident found. */ | 553 /** Return the token that matches the unit ident found. */ |
537 static int matchUnits(String text, int offset, int length) { | 554 static int matchUnits(String text, int offset, int length) { |
538 return matchList(_UNITS, 'unit', text, offset, length); | 555 return matchList(_UNITS, 'unit', text, offset, length); |
539 } | 556 } |
540 | 557 |
541 /** Return the token that matches the directive name found. */ | 558 /** Return the token that matches the directive name found. */ |
542 static int matchDirectives(String text, int offset, int length) { | 559 static int matchDirectives(String text, int offset, int length) { |
543 return matchList(_DIRECTIVES, 'type', text, offset, length); | 560 return matchList(_DIRECTIVES, 'type', text, offset, length); |
(...skipping 12 matching lines...) Expand all Loading... |
556 static String idToValue(var identList, int tokenId) { | 573 static String idToValue(var identList, int tokenId) { |
557 for (var entry in identList) { | 574 for (var entry in identList) { |
558 if (tokenId == entry['type']) { | 575 if (tokenId == entry['type']) { |
559 return entry['value']; | 576 return entry['value']; |
560 } | 577 } |
561 } | 578 } |
562 | 579 |
563 return null; | 580 return null; |
564 } | 581 } |
565 | 582 |
566 | |
567 /** Return the unit token as its pretty name. */ | 583 /** Return the unit token as its pretty name. */ |
568 static String unitToString(int unitTokenToFind) { | 584 static String unitToString(int unitTokenToFind) { |
569 if (unitTokenToFind == TokenKind.PERCENT) { | 585 if (unitTokenToFind == TokenKind.PERCENT) { |
570 return '%'; | 586 return '%'; |
571 } else { | 587 } else { |
572 for (final entry in _UNITS) { | 588 for (final entry in _UNITS) { |
573 int unit = entry['unit']; | 589 int unit = entry['unit']; |
574 if (unit == unitTokenToFind) { | 590 if (unit == unitTokenToFind) { |
575 return entry['value']; | 591 return entry['value']; |
576 } | 592 } |
577 } | 593 } |
578 } | 594 } |
579 | 595 |
580 return '<BAD UNIT>'; // Not a unit token. | 596 return '<BAD UNIT>'; // Not a unit token. |
581 } | 597 } |
582 | 598 |
583 /** | 599 /** |
584 * Match color name, case insensitive match and return the associated color | 600 * Match color name, case insensitive match and return the associated color |
585 * entry from _EXTENDED_COLOR_NAMES list, return [:null:] if not found. | 601 * entry from _EXTENDED_COLOR_NAMES list, return [:null:] if not found. |
586 */ | 602 */ |
587 static Map matchColorName(String text) { | 603 static Map matchColorName(String text) { |
588 var name = text.toLowerCase(); | 604 var name = text.toLowerCase(); |
589 return _EXTENDED_COLOR_NAMES. | 605 return _EXTENDED_COLOR_NAMES.firstWhere((e) => e['name'] == name, |
590 firstWhere((e) => e['name'] == name, orElse: () => null); | 606 orElse: () => null); |
591 } | 607 } |
592 | 608 |
593 /** Return RGB value as [int] from a color entry in _EXTENDED_COLOR_NAMES. */ | 609 /** Return RGB value as [int] from a color entry in _EXTENDED_COLOR_NAMES. */ |
594 static int colorValue(Map entry) { | 610 static int colorValue(Map entry) { |
595 assert(entry != null); | 611 assert(entry != null); |
596 return entry['value']; | 612 return entry['value']; |
597 } | 613 } |
598 | 614 |
599 static String hexToColorName(hexValue) { | 615 static String hexToColorName(hexValue) { |
600 for (final entry in _EXTENDED_COLOR_NAMES) { | 616 for (final entry in _EXTENDED_COLOR_NAMES) { |
(...skipping 25 matching lines...) Expand all Loading... |
626 invertResult.write('0'); | 642 invertResult.write('0'); |
627 } | 643 } |
628 for (int i = result.length - 1; i >= 0; i--) { | 644 for (int i = result.length - 1; i >= 0; i--) { |
629 invertResult.write(result[i]); | 645 invertResult.write(result[i]); |
630 } | 646 } |
631 | 647 |
632 return invertResult.toString(); | 648 return invertResult.toString(); |
633 } | 649 } |
634 | 650 |
635 static String kindToString(int kind) { | 651 static String kindToString(int kind) { |
636 switch(kind) { | 652 switch (kind) { |
637 case TokenKind.UNUSED: return "ERROR"; | 653 case TokenKind.UNUSED: |
638 case TokenKind.END_OF_FILE: return "end of file"; | 654 return "ERROR"; |
639 case TokenKind.LPAREN: return "("; | 655 case TokenKind.END_OF_FILE: |
640 case TokenKind.RPAREN: return ")"; | 656 return "end of file"; |
641 case TokenKind.LBRACK: return "["; | 657 case TokenKind.LPAREN: |
642 case TokenKind.RBRACK: return "]"; | 658 return "("; |
643 case TokenKind.LBRACE: return "{"; | 659 case TokenKind.RPAREN: |
644 case TokenKind.RBRACE: return "}"; | 660 return ")"; |
645 case TokenKind.DOT: return "."; | 661 case TokenKind.LBRACK: |
646 case TokenKind.SEMICOLON: return ";"; | 662 return "["; |
647 case TokenKind.AT: return "@"; | 663 case TokenKind.RBRACK: |
648 case TokenKind.HASH: return "#"; | 664 return "]"; |
649 case TokenKind.PLUS: return "+"; | 665 case TokenKind.LBRACE: |
650 case TokenKind.GREATER: return ">"; | 666 return "{"; |
651 case TokenKind.TILDE: return "~"; | 667 case TokenKind.RBRACE: |
652 case TokenKind.ASTERISK: return "*"; | 668 return "}"; |
653 case TokenKind.NAMESPACE: return "|"; | 669 case TokenKind.DOT: |
654 case TokenKind.COLON: return ":"; | 670 return "."; |
655 case TokenKind.PRIVATE_NAME: return "_"; | 671 case TokenKind.SEMICOLON: |
656 case TokenKind.COMMA: return ","; | 672 return ";"; |
657 case TokenKind.SPACE: return " "; | 673 case TokenKind.AT: |
658 case TokenKind.TAB: return "\t"; | 674 return "@"; |
659 case TokenKind.NEWLINE: return "\n"; | 675 case TokenKind.HASH: |
660 case TokenKind.RETURN: return "\r"; | 676 return "#"; |
661 case TokenKind.PERCENT: return "%"; | 677 case TokenKind.PLUS: |
662 case TokenKind.SINGLE_QUOTE: return "'"; | 678 return "+"; |
663 case TokenKind.DOUBLE_QUOTE: return "\""; | 679 case TokenKind.GREATER: |
664 case TokenKind.SLASH: return "/"; | 680 return ">"; |
665 case TokenKind.EQUALS: return '='; | 681 case TokenKind.TILDE: |
666 case TokenKind.CARET: return '^'; | 682 return "~"; |
667 case TokenKind.DOLLAR: return '\$'; | 683 case TokenKind.ASTERISK: |
668 case TokenKind.LESS: return '<'; | 684 return "*"; |
669 case TokenKind.BANG: return '!'; | 685 case TokenKind.NAMESPACE: |
670 case TokenKind.MINUS: return '-'; | 686 return "|"; |
671 case TokenKind.BACKSLASH: return '\\'; | 687 case TokenKind.COLON: |
| 688 return ":"; |
| 689 case TokenKind.PRIVATE_NAME: |
| 690 return "_"; |
| 691 case TokenKind.COMMA: |
| 692 return ","; |
| 693 case TokenKind.SPACE: |
| 694 return " "; |
| 695 case TokenKind.TAB: |
| 696 return "\t"; |
| 697 case TokenKind.NEWLINE: |
| 698 return "\n"; |
| 699 case TokenKind.RETURN: |
| 700 return "\r"; |
| 701 case TokenKind.PERCENT: |
| 702 return "%"; |
| 703 case TokenKind.SINGLE_QUOTE: |
| 704 return "'"; |
| 705 case TokenKind.DOUBLE_QUOTE: |
| 706 return "\""; |
| 707 case TokenKind.SLASH: |
| 708 return "/"; |
| 709 case TokenKind.EQUALS: |
| 710 return '='; |
| 711 case TokenKind.CARET: |
| 712 return '^'; |
| 713 case TokenKind.DOLLAR: |
| 714 return '\$'; |
| 715 case TokenKind.LESS: |
| 716 return '<'; |
| 717 case TokenKind.BANG: |
| 718 return '!'; |
| 719 case TokenKind.MINUS: |
| 720 return '-'; |
| 721 case TokenKind.BACKSLASH: |
| 722 return '\\'; |
672 default: | 723 default: |
673 throw "Unknown TOKEN"; | 724 throw "Unknown TOKEN"; |
674 } | 725 } |
675 } | 726 } |
676 | 727 |
677 static bool isKindIdentifier(int kind) { | 728 static bool isKindIdentifier(int kind) { |
678 switch(kind) { | 729 switch (kind) { |
679 // Synthesized tokens. | 730 // Synthesized tokens. |
680 case TokenKind.DIRECTIVE_IMPORT: | 731 case TokenKind.DIRECTIVE_IMPORT: |
681 case TokenKind.DIRECTIVE_MEDIA: | 732 case TokenKind.DIRECTIVE_MEDIA: |
682 case TokenKind.DIRECTIVE_PAGE: | 733 case TokenKind.DIRECTIVE_PAGE: |
683 case TokenKind.DIRECTIVE_CHARSET: | 734 case TokenKind.DIRECTIVE_CHARSET: |
684 case TokenKind.DIRECTIVE_STYLET: | 735 case TokenKind.DIRECTIVE_STYLET: |
685 case TokenKind.DIRECTIVE_KEYFRAMES: | 736 case TokenKind.DIRECTIVE_KEYFRAMES: |
686 case TokenKind.DIRECTIVE_WEB_KIT_KEYFRAMES: | 737 case TokenKind.DIRECTIVE_WEB_KIT_KEYFRAMES: |
687 case TokenKind.DIRECTIVE_MOZ_KEYFRAMES: | 738 case TokenKind.DIRECTIVE_MOZ_KEYFRAMES: |
688 case TokenKind.DIRECTIVE_MS_KEYFRAMES: | 739 case TokenKind.DIRECTIVE_MS_KEYFRAMES: |
(...skipping 20 matching lines...) Expand all Loading... |
709 case TokenKind.UNIT_FREQ_HZ: | 760 case TokenKind.UNIT_FREQ_HZ: |
710 case TokenKind.UNIT_FREQ_KHZ: | 761 case TokenKind.UNIT_FREQ_KHZ: |
711 case TokenKind.UNIT_FRACTION: | 762 case TokenKind.UNIT_FRACTION: |
712 return true; | 763 return true; |
713 default: | 764 default: |
714 return false; | 765 return false; |
715 } | 766 } |
716 } | 767 } |
717 | 768 |
718 static bool isIdentifier(int kind) { | 769 static bool isIdentifier(int kind) { |
719 return kind == IDENTIFIER ; | 770 return kind == IDENTIFIER; |
720 } | 771 } |
721 } | 772 } |
722 | 773 |
723 // Note: these names should match TokenKind names | 774 // Note: these names should match TokenKind names |
724 class TokenChar { | 775 class TokenChar { |
725 static const int UNUSED = -1; | 776 static const int UNUSED = -1; |
726 static const int END_OF_FILE = 0; | 777 static const int END_OF_FILE = 0; |
727 static const int LPAREN = 0x28; // "(".codeUnitAt(0) | 778 static const int LPAREN = 0x28; // "(".codeUnitAt(0) |
728 static const int RPAREN = 0x29; // ")".codeUnitAt(0) | 779 static const int RPAREN = 0x29; // ")".codeUnitAt(0) |
729 static const int LBRACK = 0x5b; // "[".codeUnitAt(0) | 780 static const int LBRACK = 0x5b; // "[".codeUnitAt(0) |
(...skipping 26 matching lines...) Expand all Loading... |
756 static const int EQUALS = 0x3d; // "=".codeUnitAt(0) | 807 static const int EQUALS = 0x3d; // "=".codeUnitAt(0) |
757 static const int OR = 0x7c; // "|".codeUnitAt(0) | 808 static const int OR = 0x7c; // "|".codeUnitAt(0) |
758 static const int CARET = 0x5e; // "^".codeUnitAt(0) | 809 static const int CARET = 0x5e; // "^".codeUnitAt(0) |
759 static const int DOLLAR = 0x24; // "\$".codeUnitAt(0) | 810 static const int DOLLAR = 0x24; // "\$".codeUnitAt(0) |
760 static const int LESS = 0x3c; // "<".codeUnitAt(0) | 811 static const int LESS = 0x3c; // "<".codeUnitAt(0) |
761 static const int BANG = 0x21; // "!".codeUnitAt(0) | 812 static const int BANG = 0x21; // "!".codeUnitAt(0) |
762 static const int MINUS = 0x2d; // "-".codeUnitAt(0) | 813 static const int MINUS = 0x2d; // "-".codeUnitAt(0) |
763 static const int BACKSLASH = 0x5c; // "\".codeUnitAt(0) | 814 static const int BACKSLASH = 0x5c; // "\".codeUnitAt(0) |
764 static const int AMPERSAND = 0x26; // "&".codeUnitAt(0) | 815 static const int AMPERSAND = 0x26; // "&".codeUnitAt(0) |
765 } | 816 } |
OLD | NEW |