Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Side by Side Diff: pkg/analyzer_experimental/lib/src/generated/scanner.dart

Issue 16256021: Remove trailing spaces in analyzer_experimental (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3
4 library engine.scanner; 3 library engine.scanner;
5
6 import 'dart:collection'; 4 import 'dart:collection';
7 import 'java_core.dart'; 5 import 'java_core.dart';
8 import 'java_engine.dart'; 6 import 'java_engine.dart';
9 import 'source.dart'; 7 import 'source.dart';
10 import 'error.dart'; 8 import 'error.dart';
11 import 'instrumentation.dart'; 9 import 'instrumentation.dart';
12
13
14 /** 10 /**
15 * Instances of the abstract class {@code KeywordState} represent a state in a s tate machine used to 11 * Instances of the abstract class {@code KeywordState} represent a state in a s tate machine used to
16 * scan keywords. 12 * scan keywords.
17 * @coverage dart.engine.parser 13 * @coverage dart.engine.parser
18 */ 14 */
19 class KeywordState { 15 class KeywordState {
20 16
21 /** 17 /**
22 * An empty transition table used by leaf states. 18 * An empty transition table used by leaf states.
23 */ 19 */
24 static List<KeywordState> _EMPTY_TABLE = new List<KeywordState>(26); 20 static List<KeywordState> _EMPTY_TABLE = new List<KeywordState>(26);
25 21
26 /** 22 /**
27 * The initial state in the state machine. 23 * The initial state in the state machine.
28 */ 24 */
29 static KeywordState KEYWORD_STATE = createKeywordStateTable(); 25 static KeywordState KEYWORD_STATE = createKeywordStateTable();
30 26
31 /** 27 /**
32 * Create the next state in the state machine where we have already recognized the subset of 28 * Create the next state in the state machine where we have already recognized the subset of
33 * strings in the given array of strings starting at the given offset and havi ng the given length. 29 * strings in the given array of strings starting at the given offset and havi ng the given length.
34 * All of these strings have a common prefix and the next character is at the given start index. 30 * All of these strings have a common prefix and the next character is at the given start index.
35 * @param start the index of the character in the strings used to transition t o a new state 31 * @param start the index of the character in the strings used to transition t o a new state
36 * @param strings an array containing all of the strings that will be recogniz ed by the state 32 * @param strings an array containing all of the strings that will be recogniz ed by the state
37 * machine 33 * machine
38 * @param offset the offset of the first string in the array that has the pref ix that is assumed 34 * @param offset the offset of the first string in the array that has the pref ix that is assumed
39 * to have been recognized by the time we reach the state being built 35 * to have been recognized by the time we reach the state being built
40 * @param length the number of strings in the array that pass through the stat e being built 36 * @param length the number of strings in the array that pass through the stat e being built
(...skipping 26 matching lines...) Expand all
67 } else { 63 } else {
68 assert(length2 == 1); 64 assert(length2 == 1);
69 return new KeywordState(_EMPTY_TABLE, strings[offset]); 65 return new KeywordState(_EMPTY_TABLE, strings[offset]);
70 } 66 }
71 if (isLeaf) { 67 if (isLeaf) {
72 return new KeywordState(result, strings[offset]); 68 return new KeywordState(result, strings[offset]);
73 } else { 69 } else {
74 return new KeywordState(result, null); 70 return new KeywordState(result, null);
75 } 71 }
76 } 72 }
77 73
78 /** 74 /**
79 * Create the initial state in the state machine. 75 * Create the initial state in the state machine.
80 * @return the state that was created 76 * @return the state that was created
81 */ 77 */
82 static KeywordState createKeywordStateTable() { 78 static KeywordState createKeywordStateTable() {
83 List<Keyword> values2 = Keyword.values; 79 List<Keyword> values2 = Keyword.values;
84 List<String> strings = new List<String>(values2.length); 80 List<String> strings = new List<String>(values2.length);
85 for (int i = 0; i < values2.length; i++) { 81 for (int i = 0; i < values2.length; i++) {
86 strings[i] = values2[i].syntax; 82 strings[i] = values2[i].syntax;
87 } 83 }
88 strings.sort(); 84 strings.sort();
89 return computeKeywordStateTable(0, strings, 0, strings.length); 85 return computeKeywordStateTable(0, strings, 0, strings.length);
90 } 86 }
91 87
92 /** 88 /**
93 * A table mapping characters to the states to which those characters will tra nsition. (The index 89 * A table mapping characters to the states to which those characters will tra nsition. (The index
94 * into the array is the offset from the character {@code 'a'} to the transiti oning character.) 90 * into the array is the offset from the character {@code 'a'} to the transiti oning character.)
95 */ 91 */
96 List<KeywordState> _table; 92 List<KeywordState> _table;
97 93
98 /** 94 /**
99 * The keyword that is recognized by this state, or {@code null} if this state is not a terminal 95 * The keyword that is recognized by this state, or {@code null} if this state is not a terminal
100 * state. 96 * state.
101 */ 97 */
102 Keyword _keyword2; 98 Keyword _keyword2;
103 99
104 /** 100 /**
105 * Initialize a newly created state to have the given transitions and to recog nize the keyword 101 * Initialize a newly created state to have the given transitions and to recog nize the keyword
106 * with the given syntax. 102 * with the given syntax.
107 * @param table a table mapping characters to the states to which those charac ters will transition 103 * @param table a table mapping characters to the states to which those charac ters will transition
108 * @param syntax the syntax of the keyword that is recognized by the state 104 * @param syntax the syntax of the keyword that is recognized by the state
109 */ 105 */
110 KeywordState(List<KeywordState> table, String syntax) { 106 KeywordState(List<KeywordState> table, String syntax) {
111 this._table = table; 107 this._table = table;
112 this._keyword2 = (syntax == null) ? null : Keyword.keywords[syntax]; 108 this._keyword2 = (syntax == null) ? null : Keyword.keywords[syntax];
113 } 109 }
114 110
115 /** 111 /**
116 * Return the keyword that was recognized by this state, or {@code null} if th is state does not 112 * Return the keyword that was recognized by this state, or {@code null} if th is state does not
117 * recognized a keyword. 113 * recognized a keyword.
118 * @return the keyword that was matched by reaching this state 114 * @return the keyword that was matched by reaching this state
119 */ 115 */
120 Keyword keyword() => _keyword2; 116 Keyword keyword() => _keyword2;
121 117
122 /** 118 /**
123 * Return the state that follows this state on a transition of the given chara cter, or{@code null} if there is no valid state reachable from this state with s uch a transition. 119 * Return the state that follows this state on a transition of the given chara cter, or{@code null} if there is no valid state reachable from this state with s uch a transition.
124 * @param c the character used to transition from this state to another state 120 * @param c the character used to transition from this state to another state
125 * @return the state that follows this state on a transition of the given char acter 121 * @return the state that follows this state on a transition of the given char acter
126 */ 122 */
127 KeywordState next(int c) => _table[c - 0x61]; 123 KeywordState next(int c) => _table[c - 0x61];
128 } 124 }
129
130 /** 125 /**
131 * The enumeration {@code ScannerErrorCode} defines the error codes used for err ors detected by the 126 * The enumeration {@code ScannerErrorCode} defines the error codes used for err ors detected by the
132 * scanner. 127 * scanner.
133 * @coverage dart.engine.parser 128 * @coverage dart.engine.parser
134 */ 129 */
135 class ScannerErrorCode implements Comparable<ScannerErrorCode>, ErrorCode { 130 class ScannerErrorCode implements Comparable<ScannerErrorCode>, ErrorCode {
136 static final ScannerErrorCode ILLEGAL_CHARACTER = new ScannerErrorCode('ILLEGA L_CHARACTER', 0, "Illegal character %x"); 131 static final ScannerErrorCode ILLEGAL_CHARACTER = new ScannerErrorCode('ILLEGA L_CHARACTER', 0, "Illegal character %x");
137 static final ScannerErrorCode MISSING_DIGIT = new ScannerErrorCode('MISSING_DI GIT', 1, "Decimal digit expected"); 132 static final ScannerErrorCode MISSING_DIGIT = new ScannerErrorCode('MISSING_DI GIT', 1, "Decimal digit expected");
138 static final ScannerErrorCode MISSING_HEX_DIGIT = new ScannerErrorCode('MISSIN G_HEX_DIGIT', 2, "Hexidecimal digit expected"); 133 static final ScannerErrorCode MISSING_HEX_DIGIT = new ScannerErrorCode('MISSIN G_HEX_DIGIT', 2, "Hexidecimal digit expected");
139 static final ScannerErrorCode MISSING_QUOTE = new ScannerErrorCode('MISSING_QU OTE', 3, "Expected quote (' or \")"); 134 static final ScannerErrorCode MISSING_QUOTE = new ScannerErrorCode('MISSING_QU OTE', 3, "Expected quote (' or \")");
140 static final ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = new ScannerErr orCode('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line comment"); 135 static final ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = new ScannerErr orCode('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line comment");
141 static final ScannerErrorCode UNTERMINATED_STRING_LITERAL = new ScannerErrorCo de('UNTERMINATED_STRING_LITERAL', 5, "Unterminated string literal"); 136 static final ScannerErrorCode UNTERMINATED_STRING_LITERAL = new ScannerErrorCo de('UNTERMINATED_STRING_LITERAL', 5, "Unterminated string literal");
142 static final List<ScannerErrorCode> values = [ILLEGAL_CHARACTER, MISSING_DIGIT , MISSING_HEX_DIGIT, MISSING_QUOTE, UNTERMINATED_MULTI_LINE_COMMENT, UNTERMINATE D_STRING_LITERAL]; 137 static final List<ScannerErrorCode> values = [ILLEGAL_CHARACTER, MISSING_DIGIT , MISSING_HEX_DIGIT, MISSING_QUOTE, UNTERMINATED_MULTI_LINE_COMMENT, UNTERMINATE D_STRING_LITERAL];
143 138
144 /// The name of this enum constant, as declared in the enum declaration. 139 /// The name of this enum constant, as declared in the enum declaration.
145 final String name; 140 final String name;
146 141
147 /// The position in the enum declaration. 142 /// The position in the enum declaration.
148 final int ordinal; 143 final int ordinal;
149 144
150 /** 145 /**
151 * The message template used to create the message to be displayed for this er ror. 146 * The message template used to create the message to be displayed for this er ror.
152 */ 147 */
153 String _message; 148 String _message;
154 149
155 /** 150 /**
156 * Initialize a newly created error code to have the given message. 151 * Initialize a newly created error code to have the given message.
157 * @param message the message template used to create the message to be displa yed for this error 152 * @param message the message template used to create the message to be displa yed for this error
158 */ 153 */
159 ScannerErrorCode(this.name, this.ordinal, String message) { 154 ScannerErrorCode(this.name, this.ordinal, String message) {
160 this._message = message; 155 this._message = message;
161 } 156 }
162 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; 157 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
163 String get message => _message; 158 String get message => _message;
164 ErrorType get type => ErrorType.SYNTACTIC_ERROR; 159 ErrorType get type => ErrorType.SYNTACTIC_ERROR;
165 int compareTo(ScannerErrorCode other) => ordinal - other.ordinal; 160 int compareTo(ScannerErrorCode other) => ordinal - other.ordinal;
166 String toString() => name; 161 String toString() => name;
167 } 162 }
168
169 /** 163 /**
170 * Instances of the class {@code TokenWithComment} represent a string token that is preceded by 164 * Instances of the class {@code TokenWithComment} represent a string token that is preceded by
171 * comments. 165 * comments.
172 * @coverage dart.engine.parser 166 * @coverage dart.engine.parser
173 */ 167 */
174 class StringTokenWithComment extends StringToken { 168 class StringTokenWithComment extends StringToken {
175 169
176 /** 170 /**
177 * The first comment in the list of comments that precede this token. 171 * The first comment in the list of comments that precede this token.
178 */ 172 */
179 Token _precedingComment; 173 Token _precedingComment;
180 174
181 /** 175 /**
182 * Initialize a newly created token to have the given type and offset and to b e preceded by the 176 * Initialize a newly created token to have the given type and offset and to b e preceded by the
183 * comments reachable from the given comment. 177 * comments reachable from the given comment.
184 * @param type the type of the token 178 * @param type the type of the token
185 * @param offset the offset from the beginning of the file to the first charac ter in the token 179 * @param offset the offset from the beginning of the file to the first charac ter in the token
186 * @param precedingComment the first comment in the list of comments that prec ede this token 180 * @param precedingComment the first comment in the list of comments that prec ede this token
187 */ 181 */
188 StringTokenWithComment(TokenType type, String value, int offset, Token precedi ngComment) : super(type, value, offset) { 182 StringTokenWithComment(TokenType type, String value, int offset, Token precedi ngComment) : super(type, value, offset) {
189 this._precedingComment = precedingComment; 183 this._precedingComment = precedingComment;
190 } 184 }
191 Token get precedingComments => _precedingComment; 185 Token get precedingComments => _precedingComment;
192 } 186 }
193
194 /** 187 /**
195 * The enumeration {@code Keyword} defines the keywords in the Dart programming language. 188 * The enumeration {@code Keyword} defines the keywords in the Dart programming language.
196 * @coverage dart.engine.parser 189 * @coverage dart.engine.parser
197 */ 190 */
198 class Keyword implements Comparable<Keyword> { 191 class Keyword implements Comparable<Keyword> {
199 static final Keyword ASSERT = new Keyword.con1('ASSERT', 0, "assert"); 192 static final Keyword ASSERT = new Keyword.con1('ASSERT', 0, "assert");
200 static final Keyword BREAK = new Keyword.con1('BREAK', 1, "break"); 193 static final Keyword BREAK = new Keyword.con1('BREAK', 1, "break");
201 static final Keyword CASE = new Keyword.con1('CASE', 2, "case"); 194 static final Keyword CASE = new Keyword.con1('CASE', 2, "case");
202 static final Keyword CATCH = new Keyword.con1('CATCH', 3, "catch"); 195 static final Keyword CATCH = new Keyword.con1('CATCH', 3, "catch");
203 static final Keyword CLASS = new Keyword.con1('CLASS', 4, "class"); 196 static final Keyword CLASS = new Keyword.con1('CLASS', 4, "class");
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 static final Keyword GET = new Keyword.con2('GET', 39, "get", true); 231 static final Keyword GET = new Keyword.con2('GET', 39, "get", true);
239 static final Keyword IMPLEMENTS = new Keyword.con2('IMPLEMENTS', 40, "implemen ts", true); 232 static final Keyword IMPLEMENTS = new Keyword.con2('IMPLEMENTS', 40, "implemen ts", true);
240 static final Keyword IMPORT = new Keyword.con2('IMPORT', 41, "import", true); 233 static final Keyword IMPORT = new Keyword.con2('IMPORT', 41, "import", true);
241 static final Keyword LIBRARY = new Keyword.con2('LIBRARY', 42, "library", true ); 234 static final Keyword LIBRARY = new Keyword.con2('LIBRARY', 42, "library", true );
242 static final Keyword OPERATOR = new Keyword.con2('OPERATOR', 43, "operator", t rue); 235 static final Keyword OPERATOR = new Keyword.con2('OPERATOR', 43, "operator", t rue);
243 static final Keyword PART = new Keyword.con2('PART', 44, "part", true); 236 static final Keyword PART = new Keyword.con2('PART', 44, "part", true);
244 static final Keyword SET = new Keyword.con2('SET', 45, "set", true); 237 static final Keyword SET = new Keyword.con2('SET', 45, "set", true);
245 static final Keyword STATIC = new Keyword.con2('STATIC', 46, "static", true); 238 static final Keyword STATIC = new Keyword.con2('STATIC', 46, "static", true);
246 static final Keyword TYPEDEF = new Keyword.con2('TYPEDEF', 47, "typedef", true ); 239 static final Keyword TYPEDEF = new Keyword.con2('TYPEDEF', 47, "typedef", true );
247 static final List<Keyword> values = [ASSERT, BREAK, CASE, CATCH, CLASS, CONST, CONTINUE, DEFAULT, DO, ELSE, ENUM, EXTENDS, FALSE, FINAL, FINALLY, FOR, IF, IN, IS, NEW, NULL, RETHROW, RETURN, SUPER, SWITCH, THIS, THROW, TRUE, TRY, VAR, VOI D, WHILE, WITH, ABSTRACT, AS, DYNAMIC, EXPORT, EXTERNAL, FACTORY, GET, IMPLEMENT S, IMPORT, LIBRARY, OPERATOR, PART, SET, STATIC, TYPEDEF]; 240 static final List<Keyword> values = [ASSERT, BREAK, CASE, CATCH, CLASS, CONST, CONTINUE, DEFAULT, DO, ELSE, ENUM, EXTENDS, FALSE, FINAL, FINALLY, FOR, IF, IN, IS, NEW, NULL, RETHROW, RETURN, SUPER, SWITCH, THIS, THROW, TRUE, TRY, VAR, VOI D, WHILE, WITH, ABSTRACT, AS, DYNAMIC, EXPORT, EXTERNAL, FACTORY, GET, IMPLEMENT S, IMPORT, LIBRARY, OPERATOR, PART, SET, STATIC, TYPEDEF];
248 241
249 /// The name of this enum constant, as declared in the enum declaration. 242 /// The name of this enum constant, as declared in the enum declaration.
250 final String name; 243 final String name;
251 244
252 /// The position in the enum declaration. 245 /// The position in the enum declaration.
253 final int ordinal; 246 final int ordinal;
254 247
255 /** 248 /**
256 * The lexeme for the keyword. 249 * The lexeme for the keyword.
257 */ 250 */
258 String _syntax; 251 String _syntax;
259 252
260 /** 253 /**
261 * A flag indicating whether the keyword is a pseudo-keyword. Pseudo keywords can be used as 254 * A flag indicating whether the keyword is a pseudo-keyword. Pseudo keywords can be used as
262 * identifiers. 255 * identifiers.
263 */ 256 */
264 bool _isPseudoKeyword2 = false; 257 bool _isPseudoKeyword2 = false;
265 258
266 /** 259 /**
267 * A table mapping the lexemes of keywords to the corresponding keyword. 260 * A table mapping the lexemes of keywords to the corresponding keyword.
268 */ 261 */
269 static Map<String, Keyword> keywords = createKeywordMap(); 262 static Map<String, Keyword> keywords = createKeywordMap();
270 263
271 /** 264 /**
272 * Create a table mapping the lexemes of keywords to the corresponding keyword . 265 * Create a table mapping the lexemes of keywords to the corresponding keyword .
273 * @return the table that was created 266 * @return the table that was created
274 */ 267 */
275 static Map<String, Keyword> createKeywordMap() { 268 static Map<String, Keyword> createKeywordMap() {
276 LinkedHashMap<String, Keyword> result = new LinkedHashMap<String, Keyword>() ; 269 LinkedHashMap<String, Keyword> result = new LinkedHashMap<String, Keyword>() ;
277 for (Keyword keyword in values) { 270 for (Keyword keyword in values) {
278 result[keyword._syntax] = keyword; 271 result[keyword._syntax] = keyword;
279 } 272 }
280 return result; 273 return result;
281 } 274 }
282 275
283 /** 276 /**
284 * Initialize a newly created keyword to have the given syntax. The keyword is not a 277 * Initialize a newly created keyword to have the given syntax. The keyword is not a
285 * pseudo-keyword. 278 * pseudo-keyword.
286 * @param syntax the lexeme for the keyword 279 * @param syntax the lexeme for the keyword
287 */ 280 */
288 Keyword.con1(this.name, this.ordinal, String syntax) { 281 Keyword.con1(this.name, this.ordinal, String syntax) {
289 _jtd_constructor_316_impl(syntax); 282 _jtd_constructor_318_impl(syntax);
290 } 283 }
291 _jtd_constructor_316_impl(String syntax) { 284 _jtd_constructor_318_impl(String syntax) {
292 _jtd_constructor_317_impl(syntax, false); 285 _jtd_constructor_319_impl(syntax, false);
293 } 286 }
294 287
295 /** 288 /**
296 * Initialize a newly created keyword to have the given syntax. The keyword is a pseudo-keyword if 289 * Initialize a newly created keyword to have the given syntax. The keyword is a pseudo-keyword if
297 * the given flag is {@code true}. 290 * the given flag is {@code true}.
298 * @param syntax the lexeme for the keyword 291 * @param syntax the lexeme for the keyword
299 * @param isPseudoKeyword {@code true} if this keyword is a pseudo-keyword 292 * @param isPseudoKeyword {@code true} if this keyword is a pseudo-keyword
300 */ 293 */
301 Keyword.con2(this.name, this.ordinal, String syntax2, bool isPseudoKeyword) { 294 Keyword.con2(this.name, this.ordinal, String syntax2, bool isPseudoKeyword) {
302 _jtd_constructor_317_impl(syntax2, isPseudoKeyword); 295 _jtd_constructor_319_impl(syntax2, isPseudoKeyword);
303 } 296 }
304 _jtd_constructor_317_impl(String syntax2, bool isPseudoKeyword) { 297 _jtd_constructor_319_impl(String syntax2, bool isPseudoKeyword) {
305 this._syntax = syntax2; 298 this._syntax = syntax2;
306 this._isPseudoKeyword2 = isPseudoKeyword; 299 this._isPseudoKeyword2 = isPseudoKeyword;
307 } 300 }
308 301
309 /** 302 /**
310 * Return the lexeme for the keyword. 303 * Return the lexeme for the keyword.
311 * @return the lexeme for the keyword 304 * @return the lexeme for the keyword
312 */ 305 */
313 String get syntax => _syntax; 306 String get syntax => _syntax;
314 307
315 /** 308 /**
316 * Return {@code true} if this keyword is a pseudo-keyword. Pseudo keywords ca n be used as 309 * Return {@code true} if this keyword is a pseudo-keyword. Pseudo keywords ca n be used as
317 * identifiers. 310 * identifiers.
318 * @return {@code true} if this keyword is a pseudo-keyword 311 * @return {@code true} if this keyword is a pseudo-keyword
319 */ 312 */
320 bool isPseudoKeyword() => _isPseudoKeyword2; 313 bool isPseudoKeyword() => _isPseudoKeyword2;
321 int compareTo(Keyword other) => ordinal - other.ordinal; 314 int compareTo(Keyword other) => ordinal - other.ordinal;
322 String toString() => name; 315 String toString() => name;
323 } 316 }
324
325 /** 317 /**
326 * The abstract class {@code AbstractScanner} implements a scanner for Dart code . Subclasses are 318 * The abstract class {@code AbstractScanner} implements a scanner for Dart code . Subclasses are
327 * required to implement the interface used to access the characters being scann ed. 319 * required to implement the interface used to access the characters being scann ed.
328 * <p> 320 * <p>
329 * The lexical structure of Dart is ambiguous without knowledge of the context i n which a token is 321 * The lexical structure of Dart is ambiguous without knowledge of the context i n which a token is
330 * being scanned. For example, without context we cannot determine whether sourc e of the form "<<" 322 * being scanned. For example, without context we cannot determine whether sourc e of the form "<<"
331 * should be scanned as a single left-shift operator or as two left angle bracke ts. This scanner 323 * should be scanned as a single left-shift operator or as two left angle bracke ts. This scanner
332 * does not have any context, so it always resolves such conflicts by scanning t he longest possible 324 * does not have any context, so it always resolves such conflicts by scanning t he longest possible
333 * token. 325 * token.
334 * @coverage dart.engine.parser 326 * @coverage dart.engine.parser
335 */ 327 */
336 abstract class AbstractScanner { 328 abstract class AbstractScanner {
337 329
338 /** 330 /**
339 * The source being scanned. 331 * The source being scanned.
340 */ 332 */
341 Source _source; 333 Source _source;
342 334
343 /** 335 /**
344 * The error listener that will be informed of any errors that are found durin g the scan. 336 * The error listener that will be informed of any errors that are found durin g the scan.
345 */ 337 */
346 AnalysisErrorListener _errorListener; 338 AnalysisErrorListener _errorListener;
347 339
348 /** 340 /**
349 * The token pointing to the head of the linked list of tokens. 341 * The token pointing to the head of the linked list of tokens.
350 */ 342 */
351 Token _tokens; 343 Token _tokens;
352 344
353 /** 345 /**
354 * The last token that was scanned. 346 * The last token that was scanned.
355 */ 347 */
356 Token _tail; 348 Token _tail;
357 349
358 /** 350 /**
359 * The first token in the list of comment tokens found since the last non-comm ent token. 351 * The first token in the list of comment tokens found since the last non-comm ent token.
360 */ 352 */
361 Token _firstComment; 353 Token _firstComment;
362 354
363 /** 355 /**
364 * The last token in the list of comment tokens found since the last non-comme nt token. 356 * The last token in the list of comment tokens found since the last non-comme nt token.
365 */ 357 */
366 Token _lastComment; 358 Token _lastComment;
367 359
368 /** 360 /**
369 * The index of the first character of the current token. 361 * The index of the first character of the current token.
370 */ 362 */
371 int _tokenStart = 0; 363 int _tokenStart = 0;
372 364
373 /** 365 /**
374 * A list containing the offsets of the first character of each line in the so urce code. 366 * A list containing the offsets of the first character of each line in the so urce code.
375 */ 367 */
376 List<int> _lineStarts = new List<int>(); 368 List<int> _lineStarts = new List<int>();
377 369
378 /** 370 /**
379 * A list, treated something like a stack, of tokens representing the beginnin g of a matched pair. 371 * A list, treated something like a stack, of tokens representing the beginnin g of a matched pair.
380 * It is used to pair the end tokens with the begin tokens. 372 * It is used to pair the end tokens with the begin tokens.
381 */ 373 */
382 List<BeginToken> _groupingStack = new List<BeginToken>(); 374 List<BeginToken> _groupingStack = new List<BeginToken>();
383 375
384 /** 376 /**
385 * A flag indicating whether any unmatched groups were found during the parse. 377 * A flag indicating whether any unmatched groups were found during the parse.
386 */ 378 */
387 bool _hasUnmatchedGroups2 = false; 379 bool _hasUnmatchedGroups2 = false;
388 380
389 /** 381 /**
390 * A non-breaking space, which is allowed by this scanner as a white-space cha racter. 382 * A non-breaking space, which is allowed by this scanner as a white-space cha racter.
391 */ 383 */
392 static int _$NBSP = 160; 384 static int _$NBSP = 160;
393 385
394 /** 386 /**
395 * Initialize a newly created scanner. 387 * Initialize a newly created scanner.
396 * @param source the source being scanned 388 * @param source the source being scanned
397 * @param errorListener the error listener that will be informed of any errors that are found 389 * @param errorListener the error listener that will be informed of any errors that are found
398 */ 390 */
399 AbstractScanner(Source source, AnalysisErrorListener errorListener) { 391 AbstractScanner(Source source, AnalysisErrorListener errorListener) {
400 this._source = source; 392 this._source = source;
401 this._errorListener = errorListener; 393 this._errorListener = errorListener;
402 _tokens = new Token(TokenType.EOF, -1); 394 _tokens = new Token(TokenType.EOF, -1);
403 _tokens.setNext(_tokens); 395 _tokens.setNext(_tokens);
404 _tail = _tokens; 396 _tail = _tokens;
405 _tokenStart = -1; 397 _tokenStart = -1;
406 _lineStarts.add(0); 398 _lineStarts.add(0);
407 } 399 }
408 400
409 /** 401 /**
410 * Return an array containing the offsets of the first character of each line in the source code. 402 * Return an array containing the offsets of the first character of each line in the source code.
411 * @return an array containing the offsets of the first character of each line in the source code 403 * @return an array containing the offsets of the first character of each line in the source code
412 */ 404 */
413 List<int> get lineStarts => _lineStarts; 405 List<int> get lineStarts => _lineStarts;
414 406
415 /** 407 /**
416 * Return the current offset relative to the beginning of the file. Return the initial offset if 408 * Return the current offset relative to the beginning of the file. Return the initial offset if
417 * the scanner has not yet scanned the source code, and one (1) past the end o f the source code if 409 * the scanner has not yet scanned the source code, and one (1) past the end o f the source code if
418 * the source code has been scanned. 410 * the source code has been scanned.
419 * @return the current offset of the scanner in the source 411 * @return the current offset of the scanner in the source
420 */ 412 */
421 int get offset; 413 int get offset;
422 414
423 /** 415 /**
424 * Return {@code true} if any unmatched groups were found during the parse. 416 * Return {@code true} if any unmatched groups were found during the parse.
425 * @return {@code true} if any unmatched groups were found during the parse 417 * @return {@code true} if any unmatched groups were found during the parse
426 */ 418 */
427 bool hasUnmatchedGroups() => _hasUnmatchedGroups2; 419 bool hasUnmatchedGroups() => _hasUnmatchedGroups2;
428 420
429 /** 421 /**
430 * Scan the source code to produce a list of tokens representing the source. 422 * Scan the source code to produce a list of tokens representing the source.
431 * @return the first token in the list of tokens that were produced 423 * @return the first token in the list of tokens that were produced
432 */ 424 */
433 Token tokenize() { 425 Token tokenize() {
434 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.AbstractScanner.tokenize"); 426 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.AbstractScanner.tokenize");
435 int tokenCounter = 0; 427 int tokenCounter = 0;
436 try { 428 try {
437 int next = advance(); 429 int next = advance();
438 while (next != -1) { 430 while (next != -1) {
439 tokenCounter++; 431 tokenCounter++;
440 next = bigSwitch(next); 432 next = bigSwitch(next);
441 } 433 }
442 appendEofToken(); 434 appendEofToken();
443 instrumentation.metric2("tokensCount", tokenCounter); 435 instrumentation.metric2("tokensCount", tokenCounter);
444 return firstToken(); 436 return firstToken();
445 } finally { 437 } finally {
446 instrumentation.log(); 438 instrumentation.log();
447 } 439 }
448 } 440 }
449 441
450 /** 442 /**
451 * Advance the current position and return the character at the new current po sition. 443 * Advance the current position and return the character at the new current po sition.
452 * @return the character at the new current position 444 * @return the character at the new current position
453 */ 445 */
454 int advance(); 446 int advance();
455 447
456 /** 448 /**
457 * Return the substring of the source code between the start offset and the mo dified current 449 * Return the substring of the source code between the start offset and the mo dified current
458 * position. The current position is modified by adding the end delta. 450 * position. The current position is modified by adding the end delta.
459 * @param start the offset to the beginning of the string, relative to the sta rt of the file 451 * @param start the offset to the beginning of the string, relative to the sta rt of the file
460 * @param endDelta the number of character after the current location to be in cluded in the 452 * @param endDelta the number of character after the current location to be in cluded in the
461 * string, or the number of characters before the current location to be exclu ded if the 453 * string, or the number of characters before the current location to be exclu ded if the
462 * offset is negative 454 * offset is negative
463 * @return the specified substring of the source code 455 * @return the specified substring of the source code
464 */ 456 */
465 String getString(int start, int endDelta); 457 String getString(int start, int endDelta);
466 458
467 /** 459 /**
468 * Return the character at the current position without changing the current p osition. 460 * Return the character at the current position without changing the current p osition.
469 * @return the character at the current position 461 * @return the character at the current position
470 */ 462 */
471 int peek(); 463 int peek();
472 464
473 /** 465 /**
474 * Record the fact that we are at the beginning of a new line in the source. 466 * Record the fact that we are at the beginning of a new line in the source.
475 */ 467 */
476 void recordStartOfLine() { 468 void recordStartOfLine() {
477 _lineStarts.add(offset); 469 _lineStarts.add(offset);
478 } 470 }
479 void appendBeginToken(TokenType type) { 471 void appendBeginToken(TokenType type) {
480 BeginToken token; 472 BeginToken token;
481 if (_firstComment == null) { 473 if (_firstComment == null) {
482 token = new BeginToken(type, _tokenStart); 474 token = new BeginToken(type, _tokenStart);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 } 709 }
718 if (Character.isLetter(next)) { 710 if (Character.isLetter(next)) {
719 return tokenizeIdentifier(next, offset, true); 711 return tokenizeIdentifier(next, offset, true);
720 } 712 }
721 if (next == _$NBSP) { 713 if (next == _$NBSP) {
722 return advance(); 714 return advance();
723 } 715 }
724 reportError(ScannerErrorCode.ILLEGAL_CHARACTER, [next]); 716 reportError(ScannerErrorCode.ILLEGAL_CHARACTER, [next]);
725 return advance(); 717 return advance();
726 } 718 }
727 719
728 /** 720 /**
729 * Return the beginning token corresponding to a closing brace that was found while scanning 721 * Return the beginning token corresponding to a closing brace that was found while scanning
730 * inside a string interpolation expression. Tokens that cannot be matched wit h the closing brace 722 * inside a string interpolation expression. Tokens that cannot be matched wit h the closing brace
731 * will be dropped from the stack. 723 * will be dropped from the stack.
732 * @return the token to be paired with the closing brace 724 * @return the token to be paired with the closing brace
733 */ 725 */
734 BeginToken findTokenMatchingClosingBraceInInterpolationExpression() { 726 BeginToken findTokenMatchingClosingBraceInInterpolationExpression() {
735 int last = _groupingStack.length - 1; 727 int last = _groupingStack.length - 1;
736 while (last >= 0) { 728 while (last >= 0) {
737 BeginToken begin = _groupingStack[last]; 729 BeginToken begin = _groupingStack[last];
738 if (identical(begin.type, TokenType.OPEN_CURLY_BRACKET) || identical(begin .type, TokenType.STRING_INTERPOLATION_EXPRESSION)) { 730 if (identical(begin.type, TokenType.OPEN_CURLY_BRACKET) || identical(begin .type, TokenType.STRING_INTERPOLATION_EXPRESSION)) {
739 return begin; 731 return begin;
740 } 732 }
741 _hasUnmatchedGroups2 = true; 733 _hasUnmatchedGroups2 = true;
742 _groupingStack.removeAt(last); 734 _groupingStack.removeAt(last);
743 last--; 735 last--;
744 } 736 }
745 return null; 737 return null;
746 } 738 }
747 Token firstToken() => _tokens.next; 739 Token firstToken() => _tokens.next;
748 740
749 /** 741 /**
750 * Return the source being scanned. 742 * Return the source being scanned.
751 * @return the source being scanned 743 * @return the source being scanned
752 */ 744 */
753 Source get source => _source; 745 Source get source => _source;
754 746
755 /** 747 /**
756 * Report an error at the current offset. 748 * Report an error at the current offset.
757 * @param errorCode the error code indicating the nature of the error 749 * @param errorCode the error code indicating the nature of the error
758 * @param arguments any arguments needed to complete the error message 750 * @param arguments any arguments needed to complete the error message
759 */ 751 */
760 void reportError(ScannerErrorCode errorCode, List<Object> arguments) { 752 void reportError(ScannerErrorCode errorCode, List<Object> arguments) {
761 _errorListener.onError(new AnalysisError.con2(source, offset, 1, errorCode, arguments)); 753 _errorListener.onError(new AnalysisError.con2(source, offset, 1, errorCode, arguments));
762 } 754 }
763 int select(int choice, TokenType yesType, TokenType noType) { 755 int select(int choice, TokenType yesType, TokenType noType) {
764 int next = advance(); 756 int next = advance();
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 int tokenizeTilde(int next) { 1262 int tokenizeTilde(int next) {
1271 next = advance(); 1263 next = advance();
1272 if (next == 0x2F) { 1264 if (next == 0x2F) {
1273 return select(0x3D, TokenType.TILDE_SLASH_EQ, TokenType.TILDE_SLASH); 1265 return select(0x3D, TokenType.TILDE_SLASH_EQ, TokenType.TILDE_SLASH);
1274 } else { 1266 } else {
1275 appendToken(TokenType.TILDE); 1267 appendToken(TokenType.TILDE);
1276 return next; 1268 return next;
1277 } 1269 }
1278 } 1270 }
1279 } 1271 }
1280
1281 /** 1272 /**
1282 * Instances of the class {@code StringToken} represent a token whose value is i ndependent of it's 1273 * Instances of the class {@code StringToken} represent a token whose value is i ndependent of it's
1283 * type. 1274 * type.
1284 * @coverage dart.engine.parser 1275 * @coverage dart.engine.parser
1285 */ 1276 */
1286 class StringToken extends Token { 1277 class StringToken extends Token {
1287 1278
1288 /** 1279 /**
1289 * The lexeme represented by this token. 1280 * The lexeme represented by this token.
1290 */ 1281 */
1291 String _value2; 1282 String _value2;
1292 1283
1293 /** 1284 /**
1294 * Initialize a newly created token to represent a token of the given type wit h the given value. 1285 * Initialize a newly created token to represent a token of the given type wit h the given value.
1295 * @param type the type of the token 1286 * @param type the type of the token
1296 * @param value the lexeme represented by this token 1287 * @param value the lexeme represented by this token
1297 * @param offset the offset from the beginning of the file to the first charac ter in the token 1288 * @param offset the offset from the beginning of the file to the first charac ter in the token
1298 */ 1289 */
1299 StringToken(TokenType type, String value, int offset) : super(type, offset) { 1290 StringToken(TokenType type, String value, int offset) : super(type, offset) {
1300 this._value2 = StringUtilities.intern(value); 1291 this._value2 = StringUtilities.intern(value);
1301 } 1292 }
1302 String get lexeme => _value2; 1293 String get lexeme => _value2;
1303 String value() => _value2; 1294 String value() => _value2;
1304 } 1295 }
1305
1306 /** 1296 /**
1307 * Instances of the class {@code CharBufferScanner} implement a scanner that rea ds from a character 1297 * Instances of the class {@code CharBufferScanner} implement a scanner that rea ds from a character
1308 * buffer. The scanning logic is in the superclass. 1298 * buffer. The scanning logic is in the superclass.
1309 * @coverage dart.engine.parser 1299 * @coverage dart.engine.parser
1310 */ 1300 */
1311 class CharBufferScanner extends AbstractScanner { 1301 class CharBufferScanner extends AbstractScanner {
1312 1302
1313 /** 1303 /**
1314 * The buffer from which characters will be read. 1304 * The buffer from which characters will be read.
1315 */ 1305 */
1316 CharBuffer _buffer; 1306 CharBuffer _buffer;
1317 1307
1318 /** 1308 /**
1319 * The number of characters in the buffer. 1309 * The number of characters in the buffer.
1320 */ 1310 */
1321 int _bufferLength = 0; 1311 int _bufferLength = 0;
1322 1312
1323 /** 1313 /**
1324 * The index of the last character that was read. 1314 * The index of the last character that was read.
1325 */ 1315 */
1326 int _charOffset = 0; 1316 int _charOffset = 0;
1327 1317
1328 /** 1318 /**
1329 * Initialize a newly created scanner to scan the characters in the given char acter buffer. 1319 * Initialize a newly created scanner to scan the characters in the given char acter buffer.
1330 * @param source the source being scanned 1320 * @param source the source being scanned
1331 * @param buffer the buffer from which characters will be read 1321 * @param buffer the buffer from which characters will be read
1332 * @param errorListener the error listener that will be informed of any errors that are found 1322 * @param errorListener the error listener that will be informed of any errors that are found
1333 */ 1323 */
1334 CharBufferScanner(Source source, CharBuffer buffer, AnalysisErrorListener erro rListener) : super(source, errorListener) { 1324 CharBufferScanner(Source source, CharBuffer buffer, AnalysisErrorListener erro rListener) : super(source, errorListener) {
1335 this._buffer = buffer; 1325 this._buffer = buffer;
1336 this._bufferLength = buffer.length(); 1326 this._bufferLength = buffer.length();
1337 this._charOffset = -1; 1327 this._charOffset = -1;
1338 } 1328 }
1339 int get offset => _charOffset; 1329 int get offset => _charOffset;
1340 int advance() { 1330 int advance() {
1341 if (_charOffset + 1 >= _bufferLength) { 1331 if (_charOffset + 1 >= _bufferLength) {
1342 return -1; 1332 return -1;
1343 } 1333 }
1344 return _buffer.charAt(++_charOffset); 1334 return _buffer.charAt(++_charOffset);
1345 } 1335 }
1346 String getString(int start, int endDelta) => ((_buffer as CharSequence)).subSe quence(start, _charOffset + 1 + endDelta).toString(); 1336 String getString(int start, int endDelta) => ((_buffer as CharSequence)).subSe quence(start, _charOffset + 1 + endDelta).toString();
1347 int peek() { 1337 int peek() {
1348 if (_charOffset + 1 >= _buffer.length()) { 1338 if (_charOffset + 1 >= _buffer.length()) {
1349 return -1; 1339 return -1;
1350 } 1340 }
1351 return _buffer.charAt(_charOffset + 1); 1341 return _buffer.charAt(_charOffset + 1);
1352 } 1342 }
1353 } 1343 }
1354
1355 /** 1344 /**
1356 * Instances of the class {@code TokenWithComment} represent a normal token that is preceded by 1345 * Instances of the class {@code TokenWithComment} represent a normal token that is preceded by
1357 * comments. 1346 * comments.
1358 * @coverage dart.engine.parser 1347 * @coverage dart.engine.parser
1359 */ 1348 */
1360 class TokenWithComment extends Token { 1349 class TokenWithComment extends Token {
1361 1350
1362 /** 1351 /**
1363 * The first comment in the list of comments that precede this token. 1352 * The first comment in the list of comments that precede this token.
1364 */ 1353 */
1365 Token _precedingComment; 1354 Token _precedingComment;
1366 1355
1367 /** 1356 /**
1368 * Initialize a newly created token to have the given type and offset and to b e preceded by the 1357 * Initialize a newly created token to have the given type and offset and to b e preceded by the
1369 * comments reachable from the given comment. 1358 * comments reachable from the given comment.
1370 * @param type the type of the token 1359 * @param type the type of the token
1371 * @param offset the offset from the beginning of the file to the first charac ter in the token 1360 * @param offset the offset from the beginning of the file to the first charac ter in the token
1372 * @param precedingComment the first comment in the list of comments that prec ede this token 1361 * @param precedingComment the first comment in the list of comments that prec ede this token
1373 */ 1362 */
1374 TokenWithComment(TokenType type, int offset, Token precedingComment) : super(t ype, offset) { 1363 TokenWithComment(TokenType type, int offset, Token precedingComment) : super(t ype, offset) {
1375 this._precedingComment = precedingComment; 1364 this._precedingComment = precedingComment;
1376 } 1365 }
1377 Token get precedingComments => _precedingComment; 1366 Token get precedingComments => _precedingComment;
1378 } 1367 }
1379
1380 /** 1368 /**
1381 * Instances of the class {@code Token} represent a token that was scanned from the input. Each 1369 * Instances of the class {@code Token} represent a token that was scanned from the input. Each
1382 * token knows which token follows it, acting as the head of a linked list of to kens. 1370 * token knows which token follows it, acting as the head of a linked list of to kens.
1383 * @coverage dart.engine.parser 1371 * @coverage dart.engine.parser
1384 */ 1372 */
1385 class Token { 1373 class Token {
1386 1374
1387 /** 1375 /**
1388 * The type of the token. 1376 * The type of the token.
1389 */ 1377 */
1390 TokenType _type; 1378 TokenType _type;
1391 1379
1392 /** 1380 /**
1393 * The offset from the beginning of the file to the first character in the tok en. 1381 * The offset from the beginning of the file to the first character in the tok en.
1394 */ 1382 */
1395 int _offset = 0; 1383 int _offset = 0;
1396 1384
1397 /** 1385 /**
1398 * The previous token in the token stream. 1386 * The previous token in the token stream.
1399 */ 1387 */
1400 Token _previous; 1388 Token _previous;
1401 1389
1402 /** 1390 /**
1403 * The next token in the token stream. 1391 * The next token in the token stream.
1404 */ 1392 */
1405 Token _next; 1393 Token _next;
1406 1394
1407 /** 1395 /**
1408 * Initialize a newly created token to have the given type and offset. 1396 * Initialize a newly created token to have the given type and offset.
1409 * @param type the type of the token 1397 * @param type the type of the token
1410 * @param offset the offset from the beginning of the file to the first charac ter in the token 1398 * @param offset the offset from the beginning of the file to the first charac ter in the token
1411 */ 1399 */
1412 Token(TokenType type, int offset) { 1400 Token(TokenType type, int offset) {
1413 this._type = type; 1401 this._type = type;
1414 this._offset = offset; 1402 this._offset = offset;
1415 } 1403 }
1416 1404
1417 /** 1405 /**
1418 * Return the offset from the beginning of the file to the character after las t character of the 1406 * Return the offset from the beginning of the file to the character after las t character of the
1419 * token. 1407 * token.
1420 * @return the offset from the beginning of the file to the first character af ter last character 1408 * @return the offset from the beginning of the file to the first character af ter last character
1421 * of the token 1409 * of the token
1422 */ 1410 */
1423 int get end => _offset + length; 1411 int get end => _offset + length;
1424 1412
1425 /** 1413 /**
1426 * Return the number of characters in the node's source range. 1414 * Return the number of characters in the node's source range.
1427 * @return the number of characters in the node's source range 1415 * @return the number of characters in the node's source range
1428 */ 1416 */
1429 int get length => lexeme.length; 1417 int get length => lexeme.length;
1430 1418
1431 /** 1419 /**
1432 * Return the lexeme that represents this token. 1420 * Return the lexeme that represents this token.
1433 * @return the lexeme that represents this token 1421 * @return the lexeme that represents this token
1434 */ 1422 */
1435 String get lexeme => _type.lexeme; 1423 String get lexeme => _type.lexeme;
1436 1424
1437 /** 1425 /**
1438 * Return the next token in the token stream. 1426 * Return the next token in the token stream.
1439 * @return the next token in the token stream 1427 * @return the next token in the token stream
1440 */ 1428 */
1441 Token get next => _next; 1429 Token get next => _next;
1442 1430
1443 /** 1431 /**
1444 * Return the offset from the beginning of the file to the first character in the token. 1432 * Return the offset from the beginning of the file to the first character in the token.
1445 * @return the offset from the beginning of the file to the first character in the token 1433 * @return the offset from the beginning of the file to the first character in the token
1446 */ 1434 */
1447 int get offset => _offset; 1435 int get offset => _offset;
1448 1436
1449 /** 1437 /**
1450 * Return the first comment in the list of comments that precede this token, o r {@code null} if 1438 * Return the first comment in the list of comments that precede this token, o r {@code null} if
1451 * there are no comments preceding this token. Additional comments can be reac hed by following the 1439 * there are no comments preceding this token. Additional comments can be reac hed by following the
1452 * token stream using {@link #getNext()} until {@code null} is returned. 1440 * token stream using {@link #getNext()} until {@code null} is returned.
1453 * @return the first comment in the list of comments that precede this token 1441 * @return the first comment in the list of comments that precede this token
1454 */ 1442 */
1455 Token get precedingComments => null; 1443 Token get precedingComments => null;
1456 1444
1457 /** 1445 /**
1458 * Return the previous token in the token stream. 1446 * Return the previous token in the token stream.
1459 * @return the previous token in the token stream 1447 * @return the previous token in the token stream
1460 */ 1448 */
1461 Token get previous => _previous; 1449 Token get previous => _previous;
1462 1450
1463 /** 1451 /**
1464 * Return the type of the token. 1452 * Return the type of the token.
1465 * @return the type of the token 1453 * @return the type of the token
1466 */ 1454 */
1467 TokenType get type => _type; 1455 TokenType get type => _type;
1468 1456
1469 /** 1457 /**
1470 * Return {@code true} if this token represents an operator. 1458 * Return {@code true} if this token represents an operator.
1471 * @return {@code true} if this token represents an operator 1459 * @return {@code true} if this token represents an operator
1472 */ 1460 */
1473 bool isOperator() => _type.isOperator(); 1461 bool isOperator() => _type.isOperator();
1474 1462
1475 /** 1463 /**
1476 * Return {@code true} if this token is a synthetic token. A synthetic token i s a token that was 1464 * Return {@code true} if this token is a synthetic token. A synthetic token i s a token that was
1477 * introduced by the parser in order to recover from an error in the code. Syn thetic tokens always 1465 * introduced by the parser in order to recover from an error in the code. Syn thetic tokens always
1478 * have a length of zero ({@code 0}). 1466 * have a length of zero ({@code 0}).
1479 * @return {@code true} if this token is a synthetic token 1467 * @return {@code true} if this token is a synthetic token
1480 */ 1468 */
1481 bool isSynthetic() => length == 0; 1469 bool isSynthetic() => length == 0;
1482 1470
1483 /** 1471 /**
1484 * Return {@code true} if this token represents an operator that can be define d by users. 1472 * Return {@code true} if this token represents an operator that can be define d by users.
1485 * @return {@code true} if this token represents an operator that can be defin ed by users 1473 * @return {@code true} if this token represents an operator that can be defin ed by users
1486 */ 1474 */
1487 bool isUserDefinableOperator() => _type.isUserDefinableOperator(); 1475 bool isUserDefinableOperator() => _type.isUserDefinableOperator();
1488 1476
1489 /** 1477 /**
1490 * Set the next token in the token stream to the given token. This has the sid e-effect of setting 1478 * Set the next token in the token stream to the given token. This has the sid e-effect of setting
1491 * this token to be the previous token for the given token. 1479 * this token to be the previous token for the given token.
1492 * @param token the next token in the token stream 1480 * @param token the next token in the token stream
1493 * @return the token that was passed in 1481 * @return the token that was passed in
1494 */ 1482 */
1495 Token setNext(Token token) { 1483 Token setNext(Token token) {
1496 _next = token; 1484 _next = token;
1497 token.previous = this; 1485 token.previous = this;
1498 return token; 1486 return token;
1499 } 1487 }
1500 1488
1501 /** 1489 /**
1502 * Set the next token in the token stream to the given token without changing which token is the 1490 * Set the next token in the token stream to the given token without changing which token is the
1503 * previous token for the given token. 1491 * previous token for the given token.
1504 * @param token the next token in the token stream 1492 * @param token the next token in the token stream
1505 * @return the token that was passed in 1493 * @return the token that was passed in
1506 */ 1494 */
1507 Token setNextWithoutSettingPrevious(Token token) { 1495 Token setNextWithoutSettingPrevious(Token token) {
1508 _next = token; 1496 _next = token;
1509 return token; 1497 return token;
1510 } 1498 }
1511 1499
1512 /** 1500 /**
1513 * Set the offset from the beginning of the file to the first character in the token to the given 1501 * Set the offset from the beginning of the file to the first character in the token to the given
1514 * offset. 1502 * offset.
1515 * @param offset the offset from the beginning of the file to the first charac ter in the token 1503 * @param offset the offset from the beginning of the file to the first charac ter in the token
1516 */ 1504 */
1517 void set offset(int offset2) { 1505 void set offset(int offset2) {
1518 this._offset = offset2; 1506 this._offset = offset2;
1519 } 1507 }
1520 String toString() => lexeme; 1508 String toString() => lexeme;
1521 1509
1522 /** 1510 /**
1523 * Return the value of this token. For keyword tokens, this is the keyword ass ociated with the 1511 * Return the value of this token. For keyword tokens, this is the keyword ass ociated with the
1524 * token, for other tokens it is the lexeme associated with the token. 1512 * token, for other tokens it is the lexeme associated with the token.
1525 * @return the value of this token 1513 * @return the value of this token
1526 */ 1514 */
1527 Object value() => _type.lexeme; 1515 Object value() => _type.lexeme;
1528 1516
1529 /** 1517 /**
1530 * Set the previous token in the token stream to the given token. 1518 * Set the previous token in the token stream to the given token.
1531 * @param previous the previous token in the token stream 1519 * @param previous the previous token in the token stream
1532 */ 1520 */
1533 void set previous(Token previous2) { 1521 void set previous(Token previous2) {
1534 this._previous = previous2; 1522 this._previous = previous2;
1535 } 1523 }
1536 } 1524 }
1537
1538 /** 1525 /**
1539 * Instances of the class {@code StringScanner} implement a scanner that reads f rom a string. The 1526 * Instances of the class {@code StringScanner} implement a scanner that reads f rom a string. The
1540 * scanning logic is in the superclass. 1527 * scanning logic is in the superclass.
1541 * @coverage dart.engine.parser 1528 * @coverage dart.engine.parser
1542 */ 1529 */
1543 class StringScanner extends AbstractScanner { 1530 class StringScanner extends AbstractScanner {
1544 1531
1545 /** 1532 /**
1546 * The offset from the beginning of the file to the beginning of the source be ing scanned. 1533 * The offset from the beginning of the file to the beginning of the source be ing scanned.
1547 */ 1534 */
1548 int _offsetDelta = 0; 1535 int _offsetDelta = 0;
1549 1536
1550 /** 1537 /**
1551 * The string from which characters will be read. 1538 * The string from which characters will be read.
1552 */ 1539 */
1553 String _string; 1540 String _string;
1554 1541
1555 /** 1542 /**
1556 * The number of characters in the string. 1543 * The number of characters in the string.
1557 */ 1544 */
1558 int _stringLength = 0; 1545 int _stringLength = 0;
1559 1546
1560 /** 1547 /**
1561 * The index, relative to the string, of the last character that was read. 1548 * The index, relative to the string, of the last character that was read.
1562 */ 1549 */
1563 int _charOffset = 0; 1550 int _charOffset = 0;
1564 1551
1565 /** 1552 /**
1566 * Initialize a newly created scanner to scan the characters in the given stri ng. 1553 * Initialize a newly created scanner to scan the characters in the given stri ng.
1567 * @param source the source being scanned 1554 * @param source the source being scanned
1568 * @param string the string from which characters will be read 1555 * @param string the string from which characters will be read
1569 * @param errorListener the error listener that will be informed of any errors that are found 1556 * @param errorListener the error listener that will be informed of any errors that are found
1570 */ 1557 */
1571 StringScanner(Source source, String string, AnalysisErrorListener errorListene r) : super(source, errorListener) { 1558 StringScanner(Source source, String string, AnalysisErrorListener errorListene r) : super(source, errorListener) {
1572 this._offsetDelta = 0; 1559 this._offsetDelta = 0;
1573 this._string = string; 1560 this._string = string;
1574 this._stringLength = string.length; 1561 this._stringLength = string.length;
1575 this._charOffset = -1; 1562 this._charOffset = -1;
1576 } 1563 }
1577 int get offset => _offsetDelta + _charOffset; 1564 int get offset => _offsetDelta + _charOffset;
1578 1565
1579 /** 1566 /**
1580 * Record that the source begins on the given line and column at the given off set. The line starts 1567 * Record that the source begins on the given line and column at the given off set. The line starts
1581 * for lines before the given line will not be correct. 1568 * for lines before the given line will not be correct.
1582 * <p> 1569 * <p>
1583 * This method must be invoked at most one time and must be invoked before sca nning begins. The 1570 * This method must be invoked at most one time and must be invoked before sca nning begins. The
1584 * values provided must be sensible. The results are undefined if these condit ions are violated. 1571 * values provided must be sensible. The results are undefined if these condit ions are violated.
1585 * @param line the one-based index of the line containing the first character of the source 1572 * @param line the one-based index of the line containing the first character of the source
1586 * @param column the one-based index of the column in which the first characte r of the source 1573 * @param column the one-based index of the column in which the first characte r of the source
1587 * occurs 1574 * occurs
1588 * @param offset the zero-based offset from the beginning of the larger contex t to the first 1575 * @param offset the zero-based offset from the beginning of the larger contex t to the first
(...skipping 18 matching lines...) Expand all
1607 return _string.codeUnitAt(++_charOffset); 1594 return _string.codeUnitAt(++_charOffset);
1608 } 1595 }
1609 String getString(int start, int endDelta) => _string.substring(start - _offset Delta, _charOffset + 1 + endDelta); 1596 String getString(int start, int endDelta) => _string.substring(start - _offset Delta, _charOffset + 1 + endDelta);
1610 int peek() { 1597 int peek() {
1611 if (_charOffset + 1 >= _string.length) { 1598 if (_charOffset + 1 >= _string.length) {
1612 return -1; 1599 return -1;
1613 } 1600 }
1614 return _string.codeUnitAt(_charOffset + 1); 1601 return _string.codeUnitAt(_charOffset + 1);
1615 } 1602 }
1616 } 1603 }
1617
1618 /** 1604 /**
1619 * Instances of the class {@code BeginTokenWithComment} represent a begin token that is preceded by 1605 * Instances of the class {@code BeginTokenWithComment} represent a begin token that is preceded by
1620 * comments. 1606 * comments.
1621 * @coverage dart.engine.parser 1607 * @coverage dart.engine.parser
1622 */ 1608 */
1623 class BeginTokenWithComment extends BeginToken { 1609 class BeginTokenWithComment extends BeginToken {
1624 1610
1625 /** 1611 /**
1626 * The first comment in the list of comments that precede this token. 1612 * The first comment in the list of comments that precede this token.
1627 */ 1613 */
1628 Token _precedingComment; 1614 Token _precedingComment;
1629 1615
1630 /** 1616 /**
1631 * Initialize a newly created token to have the given type and offset and to b e preceded by the 1617 * Initialize a newly created token to have the given type and offset and to b e preceded by the
1632 * comments reachable from the given comment. 1618 * comments reachable from the given comment.
1633 * @param type the type of the token 1619 * @param type the type of the token
1634 * @param offset the offset from the beginning of the file to the first charac ter in the token 1620 * @param offset the offset from the beginning of the file to the first charac ter in the token
1635 * @param precedingComment the first comment in the list of comments that prec ede this token 1621 * @param precedingComment the first comment in the list of comments that prec ede this token
1636 */ 1622 */
1637 BeginTokenWithComment(TokenType type, int offset, Token precedingComment) : su per(type, offset) { 1623 BeginTokenWithComment(TokenType type, int offset, Token precedingComment) : su per(type, offset) {
1638 this._precedingComment = precedingComment; 1624 this._precedingComment = precedingComment;
1639 } 1625 }
1640 Token get precedingComments => _precedingComment; 1626 Token get precedingComments => _precedingComment;
1641 } 1627 }
1642
1643 /** 1628 /**
1644 * Instances of the class {@code KeywordToken} represent a keyword in the langua ge. 1629 * Instances of the class {@code KeywordToken} represent a keyword in the langua ge.
1645 * @coverage dart.engine.parser 1630 * @coverage dart.engine.parser
1646 */ 1631 */
1647 class KeywordToken extends Token { 1632 class KeywordToken extends Token {
1648 1633
1649 /** 1634 /**
1650 * The keyword being represented by this token. 1635 * The keyword being represented by this token.
1651 */ 1636 */
1652 Keyword _keyword; 1637 Keyword _keyword;
1653 1638
1654 /** 1639 /**
1655 * Initialize a newly created token to represent the given keyword. 1640 * Initialize a newly created token to represent the given keyword.
1656 * @param keyword the keyword being represented by this token 1641 * @param keyword the keyword being represented by this token
1657 * @param offset the offset from the beginning of the file to the first charac ter in the token 1642 * @param offset the offset from the beginning of the file to the first charac ter in the token
1658 */ 1643 */
1659 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) { 1644 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) {
1660 this._keyword = keyword; 1645 this._keyword = keyword;
1661 } 1646 }
1662 1647
1663 /** 1648 /**
1664 * Return the keyword being represented by this token. 1649 * Return the keyword being represented by this token.
1665 * @return the keyword being represented by this token 1650 * @return the keyword being represented by this token
1666 */ 1651 */
1667 Keyword get keyword => _keyword; 1652 Keyword get keyword => _keyword;
1668 String get lexeme => _keyword.syntax; 1653 String get lexeme => _keyword.syntax;
1669 Keyword value() => _keyword; 1654 Keyword value() => _keyword;
1670 } 1655 }
1671
1672 /** 1656 /**
1673 * Instances of the class {@code BeginToken} represent the opening half of a gro uping pair of 1657 * Instances of the class {@code BeginToken} represent the opening half of a gro uping pair of
1674 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square brackets ('\['). 1658 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square brackets ('\[').
1675 * @coverage dart.engine.parser 1659 * @coverage dart.engine.parser
1676 */ 1660 */
1677 class BeginToken extends Token { 1661 class BeginToken extends Token {
1678 1662
1679 /** 1663 /**
1680 * The token that corresponds to this token. 1664 * The token that corresponds to this token.
1681 */ 1665 */
1682 Token _endToken; 1666 Token _endToken;
1683 1667
1684 /** 1668 /**
1685 * Initialize a newly created token representing the opening half of a groupin g pair of tokens. 1669 * Initialize a newly created token representing the opening half of a groupin g pair of tokens.
1686 * @param type the type of the token 1670 * @param type the type of the token
1687 * @param offset the offset from the beginning of the file to the first charac ter in the token 1671 * @param offset the offset from the beginning of the file to the first charac ter in the token
1688 */ 1672 */
1689 BeginToken(TokenType type, int offset) : super(type, offset) { 1673 BeginToken(TokenType type, int offset) : super(type, offset) {
1690 assert((identical(type, TokenType.OPEN_CURLY_BRACKET) || identical(type, Tok enType.OPEN_PAREN) || identical(type, TokenType.OPEN_SQUARE_BRACKET) || identica l(type, TokenType.STRING_INTERPOLATION_EXPRESSION))); 1674 assert((identical(type, TokenType.OPEN_CURLY_BRACKET) || identical(type, Tok enType.OPEN_PAREN) || identical(type, TokenType.OPEN_SQUARE_BRACKET) || identica l(type, TokenType.STRING_INTERPOLATION_EXPRESSION)));
1691 } 1675 }
1692 1676
1693 /** 1677 /**
1694 * Return the token that corresponds to this token. 1678 * Return the token that corresponds to this token.
1695 * @return the token that corresponds to this token 1679 * @return the token that corresponds to this token
1696 */ 1680 */
1697 Token get endToken => _endToken; 1681 Token get endToken => _endToken;
1698 1682
1699 /** 1683 /**
1700 * Set the token that corresponds to this token to the given token. 1684 * Set the token that corresponds to this token to the given token.
1701 * @param token the token that corresponds to this token 1685 * @param token the token that corresponds to this token
1702 */ 1686 */
1703 void set endToken(Token token) { 1687 void set endToken(Token token) {
1704 this._endToken = token; 1688 this._endToken = token;
1705 } 1689 }
1706 } 1690 }
1707
1708 /** 1691 /**
1709 * The enumeration {@code TokenClass} represents classes (or groups) of tokens w ith a similar use. 1692 * The enumeration {@code TokenClass} represents classes (or groups) of tokens w ith a similar use.
1710 * @coverage dart.engine.parser 1693 * @coverage dart.engine.parser
1711 */ 1694 */
1712 class TokenClass implements Comparable<TokenClass> { 1695 class TokenClass implements Comparable<TokenClass> {
1713 1696
1714 /** 1697 /**
1715 * A value used to indicate that the token type is not part of any specific cl ass of token. 1698 * A value used to indicate that the token type is not part of any specific cl ass of token.
1716 */ 1699 */
1717 static final TokenClass NO_CLASS = new TokenClass.con1('NO_CLASS', 0); 1700 static final TokenClass NO_CLASS = new TokenClass.con1('NO_CLASS', 0);
1718 1701
1719 /** 1702 /**
1720 * A value used to indicate that the token type is an additive operator. 1703 * A value used to indicate that the token type is an additive operator.
1721 */ 1704 */
1722 static final TokenClass ADDITIVE_OPERATOR = new TokenClass.con2('ADDITIVE_OPER ATOR', 1, 12); 1705 static final TokenClass ADDITIVE_OPERATOR = new TokenClass.con2('ADDITIVE_OPER ATOR', 1, 12);
1723 1706
1724 /** 1707 /**
1725 * A value used to indicate that the token type is an assignment operator. 1708 * A value used to indicate that the token type is an assignment operator.
1726 */ 1709 */
1727 static final TokenClass ASSIGNMENT_OPERATOR = new TokenClass.con2('ASSIGNMENT_ OPERATOR', 2, 1); 1710 static final TokenClass ASSIGNMENT_OPERATOR = new TokenClass.con2('ASSIGNMENT_ OPERATOR', 2, 1);
1728 1711
1729 /** 1712 /**
1730 * A value used to indicate that the token type is a bitwise-and operator. 1713 * A value used to indicate that the token type is a bitwise-and operator.
1731 */ 1714 */
1732 static final TokenClass BITWISE_AND_OPERATOR = new TokenClass.con2('BITWISE_AN D_OPERATOR', 3, 8); 1715 static final TokenClass BITWISE_AND_OPERATOR = new TokenClass.con2('BITWISE_AN D_OPERATOR', 3, 8);
1733 1716
1734 /** 1717 /**
1735 * A value used to indicate that the token type is a bitwise-or operator. 1718 * A value used to indicate that the token type is a bitwise-or operator.
1736 */ 1719 */
1737 static final TokenClass BITWISE_OR_OPERATOR = new TokenClass.con2('BITWISE_OR_ OPERATOR', 4, 6); 1720 static final TokenClass BITWISE_OR_OPERATOR = new TokenClass.con2('BITWISE_OR_ OPERATOR', 4, 6);
1738 1721
1739 /** 1722 /**
1740 * A value used to indicate that the token type is a bitwise-xor operator. 1723 * A value used to indicate that the token type is a bitwise-xor operator.
1741 */ 1724 */
1742 static final TokenClass BITWISE_XOR_OPERATOR = new TokenClass.con2('BITWISE_XO R_OPERATOR', 5, 7); 1725 static final TokenClass BITWISE_XOR_OPERATOR = new TokenClass.con2('BITWISE_XO R_OPERATOR', 5, 7);
1743 1726
1744 /** 1727 /**
1745 * A value used to indicate that the token type is a cascade operator. 1728 * A value used to indicate that the token type is a cascade operator.
1746 */ 1729 */
1747 static final TokenClass CASCADE_OPERATOR = new TokenClass.con2('CASCADE_OPERAT OR', 6, 2); 1730 static final TokenClass CASCADE_OPERATOR = new TokenClass.con2('CASCADE_OPERAT OR', 6, 2);
1748 1731
1749 /** 1732 /**
1750 * A value used to indicate that the token type is a conditional operator. 1733 * A value used to indicate that the token type is a conditional operator.
1751 */ 1734 */
1752 static final TokenClass CONDITIONAL_OPERATOR = new TokenClass.con2('CONDITIONA L_OPERATOR', 7, 3); 1735 static final TokenClass CONDITIONAL_OPERATOR = new TokenClass.con2('CONDITIONA L_OPERATOR', 7, 3);
1753 1736
1754 /** 1737 /**
1755 * A value used to indicate that the token type is an equality operator. 1738 * A value used to indicate that the token type is an equality operator.
1756 */ 1739 */
1757 static final TokenClass EQUALITY_OPERATOR = new TokenClass.con2('EQUALITY_OPER ATOR', 8, 9); 1740 static final TokenClass EQUALITY_OPERATOR = new TokenClass.con2('EQUALITY_OPER ATOR', 8, 9);
1758 1741
1759 /** 1742 /**
1760 * A value used to indicate that the token type is a logical-and operator. 1743 * A value used to indicate that the token type is a logical-and operator.
1761 */ 1744 */
1762 static final TokenClass LOGICAL_AND_OPERATOR = new TokenClass.con2('LOGICAL_AN D_OPERATOR', 9, 5); 1745 static final TokenClass LOGICAL_AND_OPERATOR = new TokenClass.con2('LOGICAL_AN D_OPERATOR', 9, 5);
1763 1746
1764 /** 1747 /**
1765 * A value used to indicate that the token type is a logical-or operator. 1748 * A value used to indicate that the token type is a logical-or operator.
1766 */ 1749 */
1767 static final TokenClass LOGICAL_OR_OPERATOR = new TokenClass.con2('LOGICAL_OR_ OPERATOR', 10, 4); 1750 static final TokenClass LOGICAL_OR_OPERATOR = new TokenClass.con2('LOGICAL_OR_ OPERATOR', 10, 4);
1768 1751
1769 /** 1752 /**
1770 * A value used to indicate that the token type is a multiplicative operator. 1753 * A value used to indicate that the token type is a multiplicative operator.
1771 */ 1754 */
1772 static final TokenClass MULTIPLICATIVE_OPERATOR = new TokenClass.con2('MULTIPL ICATIVE_OPERATOR', 11, 13); 1755 static final TokenClass MULTIPLICATIVE_OPERATOR = new TokenClass.con2('MULTIPL ICATIVE_OPERATOR', 11, 13);
1773 1756
1774 /** 1757 /**
1775 * A value used to indicate that the token type is a relational operator. 1758 * A value used to indicate that the token type is a relational operator.
1776 */ 1759 */
1777 static final TokenClass RELATIONAL_OPERATOR = new TokenClass.con2('RELATIONAL_ OPERATOR', 12, 10); 1760 static final TokenClass RELATIONAL_OPERATOR = new TokenClass.con2('RELATIONAL_ OPERATOR', 12, 10);
1778 1761
1779 /** 1762 /**
1780 * A value used to indicate that the token type is a shift operator. 1763 * A value used to indicate that the token type is a shift operator.
1781 */ 1764 */
1782 static final TokenClass SHIFT_OPERATOR = new TokenClass.con2('SHIFT_OPERATOR', 13, 11); 1765 static final TokenClass SHIFT_OPERATOR = new TokenClass.con2('SHIFT_OPERATOR', 13, 11);
1783 1766
1784 /** 1767 /**
1785 * A value used to indicate that the token type is a unary operator. 1768 * A value used to indicate that the token type is a unary operator.
1786 */ 1769 */
1787 static final TokenClass UNARY_POSTFIX_OPERATOR = new TokenClass.con2('UNARY_PO STFIX_OPERATOR', 14, 15); 1770 static final TokenClass UNARY_POSTFIX_OPERATOR = new TokenClass.con2('UNARY_PO STFIX_OPERATOR', 14, 15);
1788 1771
1789 /** 1772 /**
1790 * A value used to indicate that the token type is a unary operator. 1773 * A value used to indicate that the token type is a unary operator.
1791 */ 1774 */
1792 static final TokenClass UNARY_PREFIX_OPERATOR = new TokenClass.con2('UNARY_PRE FIX_OPERATOR', 15, 14); 1775 static final TokenClass UNARY_PREFIX_OPERATOR = new TokenClass.con2('UNARY_PRE FIX_OPERATOR', 15, 14);
1793 static final List<TokenClass> values = [NO_CLASS, ADDITIVE_OPERATOR, ASSIGNMEN T_OPERATOR, BITWISE_AND_OPERATOR, BITWISE_OR_OPERATOR, BITWISE_XOR_OPERATOR, CAS CADE_OPERATOR, CONDITIONAL_OPERATOR, EQUALITY_OPERATOR, LOGICAL_AND_OPERATOR, LO GICAL_OR_OPERATOR, MULTIPLICATIVE_OPERATOR, RELATIONAL_OPERATOR, SHIFT_OPERATOR, UNARY_POSTFIX_OPERATOR, UNARY_PREFIX_OPERATOR]; 1776 static final List<TokenClass> values = [NO_CLASS, ADDITIVE_OPERATOR, ASSIGNMEN T_OPERATOR, BITWISE_AND_OPERATOR, BITWISE_OR_OPERATOR, BITWISE_XOR_OPERATOR, CAS CADE_OPERATOR, CONDITIONAL_OPERATOR, EQUALITY_OPERATOR, LOGICAL_AND_OPERATOR, LO GICAL_OR_OPERATOR, MULTIPLICATIVE_OPERATOR, RELATIONAL_OPERATOR, SHIFT_OPERATOR, UNARY_POSTFIX_OPERATOR, UNARY_PREFIX_OPERATOR];
1794 1777
1795 /// The name of this enum constant, as declared in the enum declaration. 1778 /// The name of this enum constant, as declared in the enum declaration.
1796 final String name; 1779 final String name;
1797 1780
1798 /// The position in the enum declaration. 1781 /// The position in the enum declaration.
1799 final int ordinal; 1782 final int ordinal;
1800 1783
1801 /** 1784 /**
1802 * The precedence of tokens of this class, or {@code 0} if the such tokens do not represent an 1785 * The precedence of tokens of this class, or {@code 0} if the such tokens do not represent an
1803 * operator. 1786 * operator.
1804 */ 1787 */
1805 int _precedence = 0; 1788 int _precedence = 0;
1806 TokenClass.con1(this.name, this.ordinal) { 1789 TokenClass.con1(this.name, this.ordinal) {
1807 _jtd_constructor_326_impl(); 1790 _jtd_constructor_328_impl();
1808 } 1791 }
1809 _jtd_constructor_326_impl() { 1792 _jtd_constructor_328_impl() {
1810 _jtd_constructor_327_impl(0); 1793 _jtd_constructor_329_impl(0);
1811 } 1794 }
1812 TokenClass.con2(this.name, this.ordinal, int precedence2) { 1795 TokenClass.con2(this.name, this.ordinal, int precedence2) {
1813 _jtd_constructor_327_impl(precedence2); 1796 _jtd_constructor_329_impl(precedence2);
1814 } 1797 }
1815 _jtd_constructor_327_impl(int precedence2) { 1798 _jtd_constructor_329_impl(int precedence2) {
1816 this._precedence = precedence2; 1799 this._precedence = precedence2;
1817 } 1800 }
1818 1801
1819 /** 1802 /**
1820 * Return the precedence of tokens of this class, or {@code 0} if the such tok ens do not represent 1803 * Return the precedence of tokens of this class, or {@code 0} if the such tok ens do not represent
1821 * an operator. 1804 * an operator.
1822 * @return the precedence of tokens of this class 1805 * @return the precedence of tokens of this class
1823 */ 1806 */
1824 int get precedence => _precedence; 1807 int get precedence => _precedence;
1825 int compareTo(TokenClass other) => ordinal - other.ordinal; 1808 int compareTo(TokenClass other) => ordinal - other.ordinal;
1826 String toString() => name; 1809 String toString() => name;
1827 } 1810 }
1828
1829 /** 1811 /**
1830 * Instances of the class {@code KeywordTokenWithComment} implement a keyword to ken that is preceded 1812 * Instances of the class {@code KeywordTokenWithComment} implement a keyword to ken that is preceded
1831 * by comments. 1813 * by comments.
1832 * @coverage dart.engine.parser 1814 * @coverage dart.engine.parser
1833 */ 1815 */
1834 class KeywordTokenWithComment extends KeywordToken { 1816 class KeywordTokenWithComment extends KeywordToken {
1835 1817
1836 /** 1818 /**
1837 * The first comment in the list of comments that precede this token. 1819 * The first comment in the list of comments that precede this token.
1838 */ 1820 */
1839 Token _precedingComment; 1821 Token _precedingComment;
1840 1822
1841 /** 1823 /**
1842 * Initialize a newly created token to to represent the given keyword and to b e preceded by the 1824 * Initialize a newly created token to to represent the given keyword and to b e preceded by the
1843 * comments reachable from the given comment. 1825 * comments reachable from the given comment.
1844 * @param keyword the keyword being represented by this token 1826 * @param keyword the keyword being represented by this token
1845 * @param offset the offset from the beginning of the file to the first charac ter in the token 1827 * @param offset the offset from the beginning of the file to the first charac ter in the token
1846 * @param precedingComment the first comment in the list of comments that prec ede this token 1828 * @param precedingComment the first comment in the list of comments that prec ede this token
1847 */ 1829 */
1848 KeywordTokenWithComment(Keyword keyword, int offset, Token precedingComment) : super(keyword, offset) { 1830 KeywordTokenWithComment(Keyword keyword, int offset, Token precedingComment) : super(keyword, offset) {
1849 this._precedingComment = precedingComment; 1831 this._precedingComment = precedingComment;
1850 } 1832 }
1851 Token get precedingComments => _precedingComment; 1833 Token get precedingComments => _precedingComment;
1852 } 1834 }
1853
1854 /** 1835 /**
1855 * The enumeration {@code TokenType} defines the types of tokens that can be ret urned by the 1836 * The enumeration {@code TokenType} defines the types of tokens that can be ret urned by the
1856 * scanner. 1837 * scanner.
1857 * @coverage dart.engine.parser 1838 * @coverage dart.engine.parser
1858 */ 1839 */
1859 class TokenType implements Comparable<TokenType> { 1840 class TokenType implements Comparable<TokenType> {
1860 1841
1861 /** 1842 /**
1862 * The type of the token that marks the end of the input. 1843 * The type of the token that marks the end of the input.
1863 */ 1844 */
1864 static final TokenType EOF = new TokenType_EOF('EOF', 0, null, ""); 1845 static final TokenType EOF = new TokenType_EOF('EOF', 0, null, "");
1865 static final TokenType DOUBLE = new TokenType.con1('DOUBLE', 1); 1846 static final TokenType DOUBLE = new TokenType.con1('DOUBLE', 1);
1866 static final TokenType HEXADECIMAL = new TokenType.con1('HEXADECIMAL', 2); 1847 static final TokenType HEXADECIMAL = new TokenType.con1('HEXADECIMAL', 2);
1867 static final TokenType IDENTIFIER = new TokenType.con1('IDENTIFIER', 3); 1848 static final TokenType IDENTIFIER = new TokenType.con1('IDENTIFIER', 3);
1868 static final TokenType INT = new TokenType.con1('INT', 4); 1849 static final TokenType INT = new TokenType.con1('INT', 4);
1869 static final TokenType KEYWORD = new TokenType.con1('KEYWORD', 5); 1850 static final TokenType KEYWORD = new TokenType.con1('KEYWORD', 5);
1870 static final TokenType MULTI_LINE_COMMENT = new TokenType.con1('MULTI_LINE_COM MENT', 6); 1851 static final TokenType MULTI_LINE_COMMENT = new TokenType.con1('MULTI_LINE_COM MENT', 6);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 static final TokenType STAR_EQ = new TokenType.con2('STAR_EQ', 59, TokenClass. ASSIGNMENT_OPERATOR, "*="); 1904 static final TokenType STAR_EQ = new TokenType.con2('STAR_EQ', 59, TokenClass. ASSIGNMENT_OPERATOR, "*=");
1924 static final TokenType STRING_INTERPOLATION_EXPRESSION = new TokenType.con2('S TRING_INTERPOLATION_EXPRESSION', 60, null, "\${"); 1905 static final TokenType STRING_INTERPOLATION_EXPRESSION = new TokenType.con2('S TRING_INTERPOLATION_EXPRESSION', 60, null, "\${");
1925 static final TokenType STRING_INTERPOLATION_IDENTIFIER = new TokenType.con2('S TRING_INTERPOLATION_IDENTIFIER', 61, null, "\$"); 1906 static final TokenType STRING_INTERPOLATION_IDENTIFIER = new TokenType.con2('S TRING_INTERPOLATION_IDENTIFIER', 61, null, "\$");
1926 static final TokenType TILDE = new TokenType.con2('TILDE', 62, TokenClass.UNAR Y_PREFIX_OPERATOR, "~"); 1907 static final TokenType TILDE = new TokenType.con2('TILDE', 62, TokenClass.UNAR Y_PREFIX_OPERATOR, "~");
1927 static final TokenType TILDE_SLASH = new TokenType.con2('TILDE_SLASH', 63, Tok enClass.MULTIPLICATIVE_OPERATOR, "~/"); 1908 static final TokenType TILDE_SLASH = new TokenType.con2('TILDE_SLASH', 63, Tok enClass.MULTIPLICATIVE_OPERATOR, "~/");
1928 static final TokenType TILDE_SLASH_EQ = new TokenType.con2('TILDE_SLASH_EQ', 6 4, TokenClass.ASSIGNMENT_OPERATOR, "~/="); 1909 static final TokenType TILDE_SLASH_EQ = new TokenType.con2('TILDE_SLASH_EQ', 6 4, TokenClass.ASSIGNMENT_OPERATOR, "~/=");
1929 static final TokenType BACKPING = new TokenType.con2('BACKPING', 65, null, "`" ); 1910 static final TokenType BACKPING = new TokenType.con2('BACKPING', 65, null, "`" );
1930 static final TokenType BACKSLASH = new TokenType.con2('BACKSLASH', 66, null, " \\"); 1911 static final TokenType BACKSLASH = new TokenType.con2('BACKSLASH', 66, null, " \\");
1931 static final TokenType PERIOD_PERIOD_PERIOD = new TokenType.con2('PERIOD_PERIO D_PERIOD', 67, null, "..."); 1912 static final TokenType PERIOD_PERIOD_PERIOD = new TokenType.con2('PERIOD_PERIO D_PERIOD', 67, null, "...");
1932 static final List<TokenType> values = [EOF, DOUBLE, HEXADECIMAL, IDENTIFIER, I NT, KEYWORD, MULTI_LINE_COMMENT, SCRIPT_TAG, SINGLE_LINE_COMMENT, STRING, AMPERS AND, AMPERSAND_AMPERSAND, AMPERSAND_EQ, AT, BANG, BANG_EQ, BAR, BAR_BAR, BAR_EQ, COLON, COMMA, CARET, CARET_EQ, CLOSE_CURLY_BRACKET, CLOSE_PAREN, CLOSE_SQUARE_B RACKET, EQ, EQ_EQ, FUNCTION, GT, GT_EQ, GT_GT, GT_GT_EQ, HASH, INDEX, INDEX_EQ, IS, LT, LT_EQ, LT_LT, LT_LT_EQ, MINUS, MINUS_EQ, MINUS_MINUS, OPEN_CURLY_BRACKET , OPEN_PAREN, OPEN_SQUARE_BRACKET, PERCENT, PERCENT_EQ, PERIOD, PERIOD_PERIOD, P LUS, PLUS_EQ, PLUS_PLUS, QUESTION, SEMICOLON, SLASH, SLASH_EQ, STAR, STAR_EQ, ST RING_INTERPOLATION_EXPRESSION, STRING_INTERPOLATION_IDENTIFIER, TILDE, TILDE_SLA SH, TILDE_SLASH_EQ, BACKPING, BACKSLASH, PERIOD_PERIOD_PERIOD]; 1913 static final List<TokenType> values = [EOF, DOUBLE, HEXADECIMAL, IDENTIFIER, I NT, KEYWORD, MULTI_LINE_COMMENT, SCRIPT_TAG, SINGLE_LINE_COMMENT, STRING, AMPERS AND, AMPERSAND_AMPERSAND, AMPERSAND_EQ, AT, BANG, BANG_EQ, BAR, BAR_BAR, BAR_EQ, COLON, COMMA, CARET, CARET_EQ, CLOSE_CURLY_BRACKET, CLOSE_PAREN, CLOSE_SQUARE_B RACKET, EQ, EQ_EQ, FUNCTION, GT, GT_EQ, GT_GT, GT_GT_EQ, HASH, INDEX, INDEX_EQ, IS, LT, LT_EQ, LT_LT, LT_LT_EQ, MINUS, MINUS_EQ, MINUS_MINUS, OPEN_CURLY_BRACKET , OPEN_PAREN, OPEN_SQUARE_BRACKET, PERCENT, PERCENT_EQ, PERIOD, PERIOD_PERIOD, P LUS, PLUS_EQ, PLUS_PLUS, QUESTION, SEMICOLON, SLASH, SLASH_EQ, STAR, STAR_EQ, ST RING_INTERPOLATION_EXPRESSION, STRING_INTERPOLATION_IDENTIFIER, TILDE, TILDE_SLA SH, TILDE_SLASH_EQ, BACKPING, BACKSLASH, PERIOD_PERIOD_PERIOD];
1933 1914
1934 /// The name of this enum constant, as declared in the enum declaration. 1915 /// The name of this enum constant, as declared in the enum declaration.
1935 final String name; 1916 final String name;
1936 1917
1937 /// The position in the enum declaration. 1918 /// The position in the enum declaration.
1938 final int ordinal; 1919 final int ordinal;
1939 1920
1940 /** 1921 /**
1941 * The class of the token. 1922 * The class of the token.
1942 */ 1923 */
1943 TokenClass _tokenClass; 1924 TokenClass _tokenClass;
1944 1925
1945 /** 1926 /**
1946 * The lexeme that defines this type of token, or {@code null} if there is mor e than one possible 1927 * The lexeme that defines this type of token, or {@code null} if there is mor e than one possible
1947 * lexeme for this type of token. 1928 * lexeme for this type of token.
1948 */ 1929 */
1949 String _lexeme; 1930 String _lexeme;
1950 TokenType.con1(this.name, this.ordinal) { 1931 TokenType.con1(this.name, this.ordinal) {
1951 _jtd_constructor_328_impl(); 1932 _jtd_constructor_330_impl();
1952 } 1933 }
1953 _jtd_constructor_328_impl() { 1934 _jtd_constructor_330_impl() {
1954 _jtd_constructor_329_impl(TokenClass.NO_CLASS, null); 1935 _jtd_constructor_331_impl(TokenClass.NO_CLASS, null);
1955 } 1936 }
1956 TokenType.con2(this.name, this.ordinal, TokenClass tokenClass2, String lexeme2 ) { 1937 TokenType.con2(this.name, this.ordinal, TokenClass tokenClass2, String lexeme2 ) {
1957 _jtd_constructor_329_impl(tokenClass2, lexeme2); 1938 _jtd_constructor_331_impl(tokenClass2, lexeme2);
1958 } 1939 }
1959 _jtd_constructor_329_impl(TokenClass tokenClass2, String lexeme2) { 1940 _jtd_constructor_331_impl(TokenClass tokenClass2, String lexeme2) {
1960 this._tokenClass = tokenClass2 == null ? TokenClass.NO_CLASS : tokenClass2; 1941 this._tokenClass = tokenClass2 == null ? TokenClass.NO_CLASS : tokenClass2;
1961 this._lexeme = lexeme2; 1942 this._lexeme = lexeme2;
1962 } 1943 }
1963 1944
1964 /** 1945 /**
1965 * Return the lexeme that defines this type of token, or {@code null} if there is more than one 1946 * Return the lexeme that defines this type of token, or {@code null} if there is more than one
1966 * possible lexeme for this type of token. 1947 * possible lexeme for this type of token.
1967 * @return the lexeme that defines this type of token 1948 * @return the lexeme that defines this type of token
1968 */ 1949 */
1969 String get lexeme => _lexeme; 1950 String get lexeme => _lexeme;
1970 1951
1971 /** 1952 /**
1972 * Return the precedence of the token, or {@code 0} if the token does not repr esent an operator. 1953 * Return the precedence of the token, or {@code 0} if the token does not repr esent an operator.
1973 * @return the precedence of the token 1954 * @return the precedence of the token
1974 */ 1955 */
1975 int get precedence => _tokenClass.precedence; 1956 int get precedence => _tokenClass.precedence;
1976 1957
1977 /** 1958 /**
1978 * Return {@code true} if this type of token represents an additive operator. 1959 * Return {@code true} if this type of token represents an additive operator.
1979 * @return {@code true} if this type of token represents an additive operator 1960 * @return {@code true} if this type of token represents an additive operator
1980 */ 1961 */
1981 bool isAdditiveOperator() => identical(_tokenClass, TokenClass.ADDITIVE_OPERAT OR); 1962 bool isAdditiveOperator() => identical(_tokenClass, TokenClass.ADDITIVE_OPERAT OR);
1982 1963
1983 /** 1964 /**
1984 * Return {@code true} if this type of token represents an assignment operator . 1965 * Return {@code true} if this type of token represents an assignment operator .
1985 * @return {@code true} if this type of token represents an assignment operato r 1966 * @return {@code true} if this type of token represents an assignment operato r
1986 */ 1967 */
1987 bool isAssignmentOperator() => identical(_tokenClass, TokenClass.ASSIGNMENT_OP ERATOR); 1968 bool isAssignmentOperator() => identical(_tokenClass, TokenClass.ASSIGNMENT_OP ERATOR);
1988 1969
1989 /** 1970 /**
1990 * Return {@code true} if this type of token represents an associative operato r. An associative 1971 * Return {@code true} if this type of token represents an associative operato r. An associative
1991 * operator is an operator for which the following equality is true:{@code (a * b) * c == a * (b * c)}. In other words, if the result of applying the operator to 1972 * operator is an operator for which the following equality is true:{@code (a * b) * c == a * (b * c)}. In other words, if the result of applying the operator to
1992 * multiple operands does not depend on the order in which those applications occur. 1973 * multiple operands does not depend on the order in which those applications occur.
1993 * <p> 1974 * <p>
1994 * Note: This method considers the logical-and and logical-or operators to be associative, even 1975 * Note: This method considers the logical-and and logical-or operators to be associative, even
1995 * though the order in which the application of those operators can have an ef fect because 1976 * though the order in which the application of those operators can have an ef fect because
1996 * evaluation of the right-hand operand is conditional. 1977 * evaluation of the right-hand operand is conditional.
1997 * @return {@code true} if this type of token represents an associative operat or 1978 * @return {@code true} if this type of token represents an associative operat or
1998 */ 1979 */
1999 bool isAssociativeOperator() => identical(this, AMPERSAND) || identical(this, AMPERSAND_AMPERSAND) || identical(this, BAR) || identical(this, BAR_BAR) || iden tical(this, CARET) || identical(this, PLUS) || identical(this, STAR); 1980 bool isAssociativeOperator() => identical(this, AMPERSAND) || identical(this, AMPERSAND_AMPERSAND) || identical(this, BAR) || identical(this, BAR_BAR) || iden tical(this, CARET) || identical(this, PLUS) || identical(this, STAR);
2000 1981
2001 /** 1982 /**
2002 * Return {@code true} if this type of token represents an equality operator. 1983 * Return {@code true} if this type of token represents an equality operator.
2003 * @return {@code true} if this type of token represents an equality operator 1984 * @return {@code true} if this type of token represents an equality operator
2004 */ 1985 */
2005 bool isEqualityOperator() => identical(_tokenClass, TokenClass.EQUALITY_OPERAT OR); 1986 bool isEqualityOperator() => identical(_tokenClass, TokenClass.EQUALITY_OPERAT OR);
2006 1987
2007 /** 1988 /**
2008 * Return {@code true} if this type of token represents an increment operator. 1989 * Return {@code true} if this type of token represents an increment operator.
2009 * @return {@code true} if this type of token represents an increment operator 1990 * @return {@code true} if this type of token represents an increment operator
2010 */ 1991 */
2011 bool isIncrementOperator() => identical(_lexeme, "++") || identical(_lexeme, " --"); 1992 bool isIncrementOperator() => identical(_lexeme, "++") || identical(_lexeme, " --");
2012 1993
2013 /** 1994 /**
2014 * Return {@code true} if this type of token represents a multiplicative opera tor. 1995 * Return {@code true} if this type of token represents a multiplicative opera tor.
2015 * @return {@code true} if this type of token represents a multiplicative oper ator 1996 * @return {@code true} if this type of token represents a multiplicative oper ator
2016 */ 1997 */
2017 bool isMultiplicativeOperator() => identical(_tokenClass, TokenClass.MULTIPLIC ATIVE_OPERATOR); 1998 bool isMultiplicativeOperator() => identical(_tokenClass, TokenClass.MULTIPLIC ATIVE_OPERATOR);
2018 1999
2019 /** 2000 /**
2020 * Return {@code true} if this token type represents an operator. 2001 * Return {@code true} if this token type represents an operator.
2021 * @return {@code true} if this token type represents an operator 2002 * @return {@code true} if this token type represents an operator
2022 */ 2003 */
2023 bool isOperator() => _tokenClass != TokenClass.NO_CLASS && this != OPEN_PAREN && this != OPEN_SQUARE_BRACKET && this != PERIOD; 2004 bool isOperator() => _tokenClass != TokenClass.NO_CLASS && this != OPEN_PAREN && this != OPEN_SQUARE_BRACKET && this != PERIOD;
2024 2005
2025 /** 2006 /**
2026 * Return {@code true} if this type of token represents a relational operator. 2007 * Return {@code true} if this type of token represents a relational operator.
2027 * @return {@code true} if this type of token represents a relational operator 2008 * @return {@code true} if this type of token represents a relational operator
2028 */ 2009 */
2029 bool isRelationalOperator() => identical(_tokenClass, TokenClass.RELATIONAL_OP ERATOR); 2010 bool isRelationalOperator() => identical(_tokenClass, TokenClass.RELATIONAL_OP ERATOR);
2030 2011
2031 /** 2012 /**
2032 * Return {@code true} if this type of token represents a shift operator. 2013 * Return {@code true} if this type of token represents a shift operator.
2033 * @return {@code true} if this type of token represents a shift operator 2014 * @return {@code true} if this type of token represents a shift operator
2034 */ 2015 */
2035 bool isShiftOperator() => identical(_tokenClass, TokenClass.SHIFT_OPERATOR); 2016 bool isShiftOperator() => identical(_tokenClass, TokenClass.SHIFT_OPERATOR);
2036 2017
2037 /** 2018 /**
2038 * Return {@code true} if this type of token represents a unary postfix operat or. 2019 * Return {@code true} if this type of token represents a unary postfix operat or.
2039 * @return {@code true} if this type of token represents a unary postfix opera tor 2020 * @return {@code true} if this type of token represents a unary postfix opera tor
2040 */ 2021 */
2041 bool isUnaryPostfixOperator() => identical(_tokenClass, TokenClass.UNARY_POSTF IX_OPERATOR); 2022 bool isUnaryPostfixOperator() => identical(_tokenClass, TokenClass.UNARY_POSTF IX_OPERATOR);
2042 2023
2043 /** 2024 /**
2044 * Return {@code true} if this type of token represents a unary prefix operato r. 2025 * Return {@code true} if this type of token represents a unary prefix operato r.
2045 * @return {@code true} if this type of token represents a unary prefix operat or 2026 * @return {@code true} if this type of token represents a unary prefix operat or
2046 */ 2027 */
2047 bool isUnaryPrefixOperator() => identical(_tokenClass, TokenClass.UNARY_PREFIX _OPERATOR); 2028 bool isUnaryPrefixOperator() => identical(_tokenClass, TokenClass.UNARY_PREFIX _OPERATOR);
2048 2029
2049 /** 2030 /**
2050 * Return {@code true} if this token type represents an operator that can be d efined by users. 2031 * Return {@code true} if this token type represents an operator that can be d efined by users.
2051 * @return {@code true} if this token type represents an operator that can be defined by users 2032 * @return {@code true} if this token type represents an operator that can be defined by users
2052 */ 2033 */
2053 bool isUserDefinableOperator() => identical(_lexeme, "==") || identical(_lexem e, "~") || identical(_lexeme, "[]") || identical(_lexeme, "[]=") || identical(_l exeme, "*") || identical(_lexeme, "/") || identical(_lexeme, "%") || identical(_ lexeme, "~/") || identical(_lexeme, "+") || identical(_lexeme, "-") || identical (_lexeme, "<<") || identical(_lexeme, ">>") || identical(_lexeme, ">=") || ident ical(_lexeme, ">") || identical(_lexeme, "<=") || identical(_lexeme, "<") || ide ntical(_lexeme, "&") || identical(_lexeme, "^") || identical(_lexeme, "|"); 2034 bool isUserDefinableOperator() => identical(_lexeme, "==") || identical(_lexem e, "~") || identical(_lexeme, "[]") || identical(_lexeme, "[]=") || identical(_l exeme, "*") || identical(_lexeme, "/") || identical(_lexeme, "%") || identical(_ lexeme, "~/") || identical(_lexeme, "+") || identical(_lexeme, "-") || identical (_lexeme, "<<") || identical(_lexeme, ">>") || identical(_lexeme, ">=") || ident ical(_lexeme, ">") || identical(_lexeme, "<=") || identical(_lexeme, "<") || ide ntical(_lexeme, "&") || identical(_lexeme, "^") || identical(_lexeme, "|");
2054 int compareTo(TokenType other) => ordinal - other.ordinal; 2035 int compareTo(TokenType other) => ordinal - other.ordinal;
2055 String toString() => name; 2036 String toString() => name;
2056 } 2037 }
2057 class TokenType_EOF extends TokenType { 2038 class TokenType_EOF extends TokenType {
2058 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super. con2(name, ordinal, arg0, arg1); 2039 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super. con2(name, ordinal, arg0, arg1);
2059 String toString() => "-eof-"; 2040 String toString() => "-eof-";
2060 } 2041 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/generated/resolver.dart ('k') | pkg/analyzer_experimental/lib/src/generated/sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698