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

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

Issue 17932005: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Disable resolver tests Created 7 years, 5 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 library engine.scanner; 3 library engine.scanner;
4 import 'dart:collection'; 4 import 'dart:collection';
5 import 'java_core.dart'; 5 import 'java_core.dart';
6 import 'java_engine.dart'; 6 import 'java_engine.dart';
7 import 'source.dart'; 7 import 'source.dart';
8 import 'error.dart'; 8 import 'error.dart';
9 import 'instrumentation.dart'; 9 import 'instrumentation.dart';
10 /** 10 /**
11 * Instances of the abstract class `KeywordState` represent a state in a state m achine used to 11 * Instances of the abstract class `KeywordState` represent a state in a state m achine used to
12 * scan keywords. 12 * scan keywords.
13 *
13 * @coverage dart.engine.parser 14 * @coverage dart.engine.parser
14 */ 15 */
15 class KeywordState { 16 class KeywordState {
16 17
17 /** 18 /**
18 * An empty transition table used by leaf states. 19 * An empty transition table used by leaf states.
19 */ 20 */
20 static List<KeywordState> _EMPTY_TABLE = new List<KeywordState>(26); 21 static List<KeywordState> _EMPTY_TABLE = new List<KeywordState>(26);
21 22
22 /** 23 /**
23 * The initial state in the state machine. 24 * The initial state in the state machine.
24 */ 25 */
25 static KeywordState KEYWORD_STATE = createKeywordStateTable(); 26 static KeywordState KEYWORD_STATE = createKeywordStateTable();
26 27
27 /** 28 /**
28 * Create the next state in the state machine where we have already recognized the subset of 29 * Create the next state in the state machine where we have already recognized the subset of
29 * strings in the given array of strings starting at the given offset and havi ng the given length. 30 * strings in the given array of strings starting at the given offset and havi ng the given length.
30 * All of these strings have a common prefix and the next character is at the given start index. 31 * All of these strings have a common prefix and the next character is at the given start index.
32 *
31 * @param start the index of the character in the strings used to transition t o a new state 33 * @param start the index of the character in the strings used to transition t o a new state
32 * @param strings an array containing all of the strings that will be recogniz ed by the state 34 * @param strings an array containing all of the strings that will be recogniz ed by the state
33 * machine 35 * machine
34 * @param offset the offset of the first string in the array that has the pref ix that is assumed 36 * @param offset the offset of the first string in the array that has the pref ix that is assumed
35 * to have been recognized by the time we reach the state being built 37 * to have been recognized by the time we reach the state being built
36 * @param length the number of strings in the array that pass through the stat e being built 38 * @param length the number of strings in the array that pass through the stat e being built
37 * @return the state that was created 39 * @return the state that was created
38 */ 40 */
39 static KeywordState computeKeywordStateTable(int start, List<String> strings, int offset, int length2) { 41 static KeywordState computeKeywordStateTable(int start, List<String> strings, int offset, int length2) {
40 List<KeywordState> result = new List<KeywordState>(26); 42 List<KeywordState> result = new List<KeywordState>(26);
41 assert(length2 != 0); 43 assert(length2 != 0);
42 int chunk = 0x0; 44 int chunk = 0x0;
43 int chunkStart = -1; 45 int chunkStart = -1;
44 bool isLeaf = false; 46 bool isLeaf = false;
45 for (int i = offset; i < offset + length2; i++) { 47 for (int i = offset; i < offset + length2; i++) {
(...skipping 20 matching lines...) Expand all
66 } 68 }
67 if (isLeaf) { 69 if (isLeaf) {
68 return new KeywordState(result, strings[offset]); 70 return new KeywordState(result, strings[offset]);
69 } else { 71 } else {
70 return new KeywordState(result, null); 72 return new KeywordState(result, null);
71 } 73 }
72 } 74 }
73 75
74 /** 76 /**
75 * Create the initial state in the state machine. 77 * Create the initial state in the state machine.
78 *
76 * @return the state that was created 79 * @return the state that was created
77 */ 80 */
78 static KeywordState createKeywordStateTable() { 81 static KeywordState createKeywordStateTable() {
79 List<Keyword> values = Keyword.values; 82 List<Keyword> values = Keyword.values;
80 List<String> strings = new List<String>(values.length); 83 List<String> strings = new List<String>(values.length);
81 for (int i = 0; i < values.length; i++) { 84 for (int i = 0; i < values.length; i++) {
82 strings[i] = values[i].syntax; 85 strings[i] = values[i].syntax;
83 } 86 }
84 strings.sort(); 87 strings.sort();
85 return computeKeywordStateTable(0, strings, 0, strings.length); 88 return computeKeywordStateTable(0, strings, 0, strings.length);
86 } 89 }
87 90
88 /** 91 /**
89 * A table mapping characters to the states to which those characters will tra nsition. (The index 92 * A table mapping characters to the states to which those characters will tra nsition. (The index
90 * into the array is the offset from the character `'a'` to the transitioning character.) 93 * into the array is the offset from the character `'a'` to the transitioning character.)
91 */ 94 */
92 List<KeywordState> _table; 95 List<KeywordState> _table;
93 96
94 /** 97 /**
95 * The keyword that is recognized by this state, or `null` if this state is no t a terminal 98 * The keyword that is recognized by this state, or `null` if this state is no t a terminal
96 * state. 99 * state.
97 */ 100 */
98 Keyword _keyword2; 101 Keyword _keyword2;
99 102
100 /** 103 /**
101 * Initialize a newly created state to have the given transitions and to recog nize the keyword 104 * Initialize a newly created state to have the given transitions and to recog nize the keyword
102 * with the given syntax. 105 * with the given syntax.
106 *
103 * @param table a table mapping characters to the states to which those charac ters will transition 107 * @param table a table mapping characters to the states to which those charac ters will transition
104 * @param syntax the syntax of the keyword that is recognized by the state 108 * @param syntax the syntax of the keyword that is recognized by the state
105 */ 109 */
106 KeywordState(List<KeywordState> table, String syntax) { 110 KeywordState(List<KeywordState> table, String syntax) {
107 this._table = table; 111 this._table = table;
108 this._keyword2 = (syntax == null) ? null : Keyword.keywords[syntax]; 112 this._keyword2 = (syntax == null) ? null : Keyword.keywords[syntax];
109 } 113 }
110 114
111 /** 115 /**
112 * Return the keyword that was recognized by this state, or `null` if this sta te does not 116 * Return the keyword that was recognized by this state, or `null` if this sta te does not
113 * recognized a keyword. 117 * recognized a keyword.
118 *
114 * @return the keyword that was matched by reaching this state 119 * @return the keyword that was matched by reaching this state
115 */ 120 */
116 Keyword keyword() => _keyword2; 121 Keyword keyword() => _keyword2;
117 122
118 /** 123 /**
119 * Return the state that follows this state on a transition of the given chara cter, or`null` if there is no valid state reachable from this state with such a transition. 124 * Return the state that follows this state on a transition of the given chara cter, or
125 * `null` if there is no valid state reachable from this state with such a tra nsition.
126 *
120 * @param c the character used to transition from this state to another state 127 * @param c the character used to transition from this state to another state
121 * @return the state that follows this state on a transition of the given char acter 128 * @return the state that follows this state on a transition of the given char acter
122 */ 129 */
123 KeywordState next(int c) => _table[c - 0x61]; 130 KeywordState next(int c) => _table[c - 0x61];
124 } 131 }
125 /** 132 /**
126 * The enumeration `ScannerErrorCode` defines the error codes used for errors de tected by the 133 * The enumeration `ScannerErrorCode` defines the error codes used for errors de tected by the
127 * scanner. 134 * scanner.
135 *
128 * @coverage dart.engine.parser 136 * @coverage dart.engine.parser
129 */ 137 */
130 class ScannerErrorCode implements Comparable<ScannerErrorCode>, ErrorCode { 138 class ScannerErrorCode implements Comparable<ScannerErrorCode>, ErrorCode {
131 static final ScannerErrorCode ILLEGAL_CHARACTER = new ScannerErrorCode('ILLEGA L_CHARACTER', 0, "Illegal character %x"); 139 static final ScannerErrorCode ILLEGAL_CHARACTER = new ScannerErrorCode('ILLEGA L_CHARACTER', 0, "Illegal character %x");
132 static final ScannerErrorCode MISSING_DIGIT = new ScannerErrorCode('MISSING_DI GIT', 1, "Decimal digit expected"); 140 static final ScannerErrorCode MISSING_DIGIT = new ScannerErrorCode('MISSING_DI GIT', 1, "Decimal digit expected");
133 static final ScannerErrorCode MISSING_HEX_DIGIT = new ScannerErrorCode('MISSIN G_HEX_DIGIT', 2, "Hexidecimal digit expected"); 141 static final ScannerErrorCode MISSING_HEX_DIGIT = new ScannerErrorCode('MISSIN G_HEX_DIGIT', 2, "Hexidecimal digit expected");
134 static final ScannerErrorCode MISSING_QUOTE = new ScannerErrorCode('MISSING_QU OTE', 3, "Expected quote (' or \")"); 142 static final ScannerErrorCode MISSING_QUOTE = new ScannerErrorCode('MISSING_QU OTE', 3, "Expected quote (' or \")");
135 static final ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = new ScannerErr orCode('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line comment"); 143 static final ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = new ScannerErr orCode('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line comment");
136 static final ScannerErrorCode UNTERMINATED_STRING_LITERAL = new ScannerErrorCo de('UNTERMINATED_STRING_LITERAL', 5, "Unterminated string literal"); 144 static final ScannerErrorCode UNTERMINATED_STRING_LITERAL = new ScannerErrorCo de('UNTERMINATED_STRING_LITERAL', 5, "Unterminated 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]; 145 static final List<ScannerErrorCode> values = [ILLEGAL_CHARACTER, MISSING_DIGIT , MISSING_HEX_DIGIT, MISSING_QUOTE, UNTERMINATED_MULTI_LINE_COMMENT, UNTERMINATE D_STRING_LITERAL];
138 146
139 /// The name of this enum constant, as declared in the enum declaration. 147 /// The name of this enum constant, as declared in the enum declaration.
140 final String name; 148 final String name;
141 149
142 /// The position in the enum declaration. 150 /// The position in the enum declaration.
143 final int ordinal; 151 final int ordinal;
144 152
145 /** 153 /**
146 * The message template used to create the message to be displayed for this er ror. 154 * The message template used to create the message to be displayed for this er ror.
147 */ 155 */
148 String _message; 156 String _message;
149 157
150 /** 158 /**
151 * Initialize a newly created error code to have the given message. 159 * Initialize a newly created error code to have the given message.
160 *
152 * @param message the message template used to create the message to be displa yed for this error 161 * @param message the message template used to create the message to be displa yed for this error
153 */ 162 */
154 ScannerErrorCode(this.name, this.ordinal, String message) { 163 ScannerErrorCode(this.name, this.ordinal, String message) {
155 this._message = message; 164 this._message = message;
156 } 165 }
157 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; 166 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
158 String get message => _message; 167 String get message => _message;
159 ErrorType get type => ErrorType.SYNTACTIC_ERROR; 168 ErrorType get type => ErrorType.SYNTACTIC_ERROR;
160 int compareTo(ScannerErrorCode other) => ordinal - other.ordinal; 169 int compareTo(ScannerErrorCode other) => ordinal - other.ordinal;
161 int get hashCode => ordinal; 170 int get hashCode => ordinal;
162 String toString() => name; 171 String toString() => name;
163 } 172 }
164 /** 173 /**
165 * Instances of the class `TokenWithComment` represent a string token that is pr eceded by 174 * Instances of the class `TokenWithComment` represent a string token that is pr eceded by
166 * comments. 175 * comments.
176 *
167 * @coverage dart.engine.parser 177 * @coverage dart.engine.parser
168 */ 178 */
169 class StringTokenWithComment extends StringToken { 179 class StringTokenWithComment extends StringToken {
170 180
171 /** 181 /**
172 * The first comment in the list of comments that precede this token. 182 * The first comment in the list of comments that precede this token.
173 */ 183 */
174 Token _precedingComment; 184 Token _precedingComment;
175 185
176 /** 186 /**
177 * Initialize a newly created token to have the given type and offset and to b e preceded by the 187 * Initialize a newly created token to have the given type and offset and to b e preceded by the
178 * comments reachable from the given comment. 188 * comments reachable from the given comment.
189 *
179 * @param type the type of the token 190 * @param type the type of the token
180 * @param offset the offset from the beginning of the file to the first charac ter in the token 191 * @param offset the offset from the beginning of the file to the first charac ter in the token
181 * @param precedingComment the first comment in the list of comments that prec ede this token 192 * @param precedingComment the first comment in the list of comments that prec ede this token
182 */ 193 */
183 StringTokenWithComment(TokenType type, String value, int offset, Token precedi ngComment) : super(type, value, offset) { 194 StringTokenWithComment(TokenType type, String value, int offset, Token precedi ngComment) : super(type, value, offset) {
184 this._precedingComment = precedingComment; 195 this._precedingComment = precedingComment;
185 } 196 }
186 Token get precedingComments => _precedingComment; 197 Token get precedingComments => _precedingComment;
187 } 198 }
188 /** 199 /**
189 * The enumeration `Keyword` defines the keywords in the Dart programming langua ge. 200 * The enumeration `Keyword` defines the keywords in the Dart programming langua ge.
201 *
190 * @coverage dart.engine.parser 202 * @coverage dart.engine.parser
191 */ 203 */
192 class Keyword implements Comparable<Keyword> { 204 class Keyword implements Comparable<Keyword> {
193 static final Keyword ASSERT = new Keyword.con1('ASSERT', 0, "assert"); 205 static final Keyword ASSERT = new Keyword.con1('ASSERT', 0, "assert");
194 static final Keyword BREAK = new Keyword.con1('BREAK', 1, "break"); 206 static final Keyword BREAK = new Keyword.con1('BREAK', 1, "break");
195 static final Keyword CASE = new Keyword.con1('CASE', 2, "case"); 207 static final Keyword CASE = new Keyword.con1('CASE', 2, "case");
196 static final Keyword CATCH = new Keyword.con1('CATCH', 3, "catch"); 208 static final Keyword CATCH = new Keyword.con1('CATCH', 3, "catch");
197 static final Keyword CLASS = new Keyword.con1('CLASS', 4, "class"); 209 static final Keyword CLASS = new Keyword.con1('CLASS', 4, "class");
198 static final Keyword CONST = new Keyword.con1('CONST', 5, "const"); 210 static final Keyword CONST = new Keyword.con1('CONST', 5, "const");
199 static final Keyword CONTINUE = new Keyword.con1('CONTINUE', 6, "continue"); 211 static final Keyword CONTINUE = new Keyword.con1('CONTINUE', 6, "continue");
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 */ 269 */
258 bool _isPseudoKeyword2 = false; 270 bool _isPseudoKeyword2 = false;
259 271
260 /** 272 /**
261 * A table mapping the lexemes of keywords to the corresponding keyword. 273 * A table mapping the lexemes of keywords to the corresponding keyword.
262 */ 274 */
263 static Map<String, Keyword> keywords = createKeywordMap(); 275 static Map<String, Keyword> keywords = createKeywordMap();
264 276
265 /** 277 /**
266 * Create a table mapping the lexemes of keywords to the corresponding keyword . 278 * Create a table mapping the lexemes of keywords to the corresponding keyword .
279 *
267 * @return the table that was created 280 * @return the table that was created
268 */ 281 */
269 static Map<String, Keyword> createKeywordMap() { 282 static Map<String, Keyword> createKeywordMap() {
270 LinkedHashMap<String, Keyword> result = new LinkedHashMap<String, Keyword>() ; 283 LinkedHashMap<String, Keyword> result = new LinkedHashMap<String, Keyword>() ;
271 for (Keyword keyword in values) { 284 for (Keyword keyword in values) {
272 result[keyword._syntax] = keyword; 285 result[keyword._syntax] = keyword;
273 } 286 }
274 return result; 287 return result;
275 } 288 }
276 289
277 /** 290 /**
278 * Initialize a newly created keyword to have the given syntax. The keyword is not a 291 * Initialize a newly created keyword to have the given syntax. The keyword is not a
279 * pseudo-keyword. 292 * pseudo-keyword.
293 *
280 * @param syntax the lexeme for the keyword 294 * @param syntax the lexeme for the keyword
281 */ 295 */
282 Keyword.con1(this.name, this.ordinal, String syntax) { 296 Keyword.con1(this.name, this.ordinal, String syntax) {
283 _jtd_constructor_318_impl(syntax); 297 _jtd_constructor_318_impl(syntax);
284 } 298 }
285 _jtd_constructor_318_impl(String syntax) { 299 _jtd_constructor_318_impl(String syntax) {
286 _jtd_constructor_319_impl(syntax, false); 300 _jtd_constructor_319_impl(syntax, false);
287 } 301 }
288 302
289 /** 303 /**
290 * Initialize a newly created keyword to have the given syntax. The keyword is a pseudo-keyword if 304 * Initialize a newly created keyword to have the given syntax. The keyword is a pseudo-keyword if
291 * the given flag is `true`. 305 * the given flag is `true`.
306 *
292 * @param syntax the lexeme for the keyword 307 * @param syntax the lexeme for the keyword
293 * @param isPseudoKeyword `true` if this keyword is a pseudo-keyword 308 * @param isPseudoKeyword `true` if this keyword is a pseudo-keyword
294 */ 309 */
295 Keyword.con2(this.name, this.ordinal, String syntax2, bool isPseudoKeyword) { 310 Keyword.con2(this.name, this.ordinal, String syntax2, bool isPseudoKeyword) {
296 _jtd_constructor_319_impl(syntax2, isPseudoKeyword); 311 _jtd_constructor_319_impl(syntax2, isPseudoKeyword);
297 } 312 }
298 _jtd_constructor_319_impl(String syntax2, bool isPseudoKeyword) { 313 _jtd_constructor_319_impl(String syntax2, bool isPseudoKeyword) {
299 this._syntax = syntax2; 314 this._syntax = syntax2;
300 this._isPseudoKeyword2 = isPseudoKeyword; 315 this._isPseudoKeyword2 = isPseudoKeyword;
301 } 316 }
302 317
303 /** 318 /**
304 * Return the lexeme for the keyword. 319 * Return the lexeme for the keyword.
320 *
305 * @return the lexeme for the keyword 321 * @return the lexeme for the keyword
306 */ 322 */
307 String get syntax => _syntax; 323 String get syntax => _syntax;
308 324
309 /** 325 /**
310 * Return `true` if this keyword is a pseudo-keyword. Pseudo keywords can be u sed as 326 * Return `true` if this keyword is a pseudo-keyword. Pseudo keywords can be u sed as
311 * identifiers. 327 * identifiers.
328 *
312 * @return `true` if this keyword is a pseudo-keyword 329 * @return `true` if this keyword is a pseudo-keyword
313 */ 330 */
314 bool get isPseudoKeyword => _isPseudoKeyword2; 331 bool get isPseudoKeyword => _isPseudoKeyword2;
315 int compareTo(Keyword other) => ordinal - other.ordinal; 332 int compareTo(Keyword other) => ordinal - other.ordinal;
316 int get hashCode => ordinal; 333 int get hashCode => ordinal;
317 String toString() => name; 334 String toString() => name;
318 } 335 }
319 /** 336 /**
320 * The abstract class `AbstractScanner` implements a scanner for Dart code. Subc lasses are 337 * The abstract class `AbstractScanner` implements a scanner for Dart code. Subc lasses are
321 * required to implement the interface used to access the characters being scann ed. 338 * required to implement the interface used to access the characters being scann ed.
322 * 339 *
323 * The lexical structure of Dart is ambiguous without knowledge of the context i n which a token is 340 * The lexical structure of Dart is ambiguous without knowledge of the context i n which a token is
324 * being scanned. For example, without context we cannot determine whether sourc e of the form "<<" 341 * being scanned. For example, without context we cannot determine whether sourc e of the form "<<"
325 * should be scanned as a single left-shift operator or as two left angle bracke ts. This scanner 342 * should be scanned as a single left-shift operator or as two left angle bracke ts. This scanner
326 * does not have any context, so it always resolves such conflicts by scanning t he longest possible 343 * does not have any context, so it always resolves such conflicts by scanning t he longest possible
327 * token. 344 * token.
345 *
328 * @coverage dart.engine.parser 346 * @coverage dart.engine.parser
329 */ 347 */
330 abstract class AbstractScanner { 348 abstract class AbstractScanner {
331 349
332 /** 350 /**
333 * The source being scanned. 351 * The source being scanned.
334 */ 352 */
335 Source _source; 353 Source _source;
336 354
337 /** 355 /**
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 */ 398 */
381 bool _hasUnmatchedGroups2 = false; 399 bool _hasUnmatchedGroups2 = false;
382 400
383 /** 401 /**
384 * A non-breaking space, which is allowed by this scanner as a white-space cha racter. 402 * A non-breaking space, which is allowed by this scanner as a white-space cha racter.
385 */ 403 */
386 static int _$NBSP = 160; 404 static int _$NBSP = 160;
387 405
388 /** 406 /**
389 * Initialize a newly created scanner. 407 * Initialize a newly created scanner.
408 *
390 * @param source the source being scanned 409 * @param source the source being scanned
391 * @param errorListener the error listener that will be informed of any errors that are found 410 * @param errorListener the error listener that will be informed of any errors that are found
392 */ 411 */
393 AbstractScanner(Source source, AnalysisErrorListener errorListener) { 412 AbstractScanner(Source source, AnalysisErrorListener errorListener) {
394 this._source = source; 413 this._source = source;
395 this._errorListener = errorListener; 414 this._errorListener = errorListener;
396 _tokens = new Token(TokenType.EOF, -1); 415 _tokens = new Token(TokenType.EOF, -1);
397 _tokens.setNext(_tokens); 416 _tokens.setNext(_tokens);
398 _tail = _tokens; 417 _tail = _tokens;
399 _tokenStart = -1; 418 _tokenStart = -1;
400 _lineStarts.add(0); 419 _lineStarts.add(0);
401 } 420 }
402 421
403 /** 422 /**
404 * Return an array containing the offsets of the first character of each line in the source code. 423 * Return an array containing the offsets of the first character of each line in the source code.
424 *
405 * @return an array containing the offsets of the first character of each line in the source code 425 * @return an array containing the offsets of the first character of each line in the source code
406 */ 426 */
407 List<int> get lineStarts => _lineStarts; 427 List<int> get lineStarts => _lineStarts;
408 428
409 /** 429 /**
410 * Return the current offset relative to the beginning of the file. Return the initial offset if 430 * Return the current offset relative to the beginning of the file. Return the initial offset if
411 * the scanner has not yet scanned the source code, and one (1) past the end o f the source code if 431 * the scanner has not yet scanned the source code, and one (1) past the end o f the source code if
412 * the source code has been scanned. 432 * the source code has been scanned.
433 *
413 * @return the current offset of the scanner in the source 434 * @return the current offset of the scanner in the source
414 */ 435 */
415 int get offset; 436 int get offset;
416 437
417 /** 438 /**
418 * Return `true` if any unmatched groups were found during the parse. 439 * Return `true` if any unmatched groups were found during the parse.
440 *
419 * @return `true` if any unmatched groups were found during the parse 441 * @return `true` if any unmatched groups were found during the parse
420 */ 442 */
421 bool hasUnmatchedGroups() => _hasUnmatchedGroups2; 443 bool hasUnmatchedGroups() => _hasUnmatchedGroups2;
422 444
423 /** 445 /**
424 * Scan the source code to produce a list of tokens representing the source. 446 * Scan the source code to produce a list of tokens representing the source.
447 *
425 * @return the first token in the list of tokens that were produced 448 * @return the first token in the list of tokens that were produced
426 */ 449 */
427 Token tokenize() { 450 Token tokenize() {
428 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.AbstractScanner.tokenize"); 451 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.AbstractScanner.tokenize");
429 int tokenCounter = 0; 452 int tokenCounter = 0;
430 try { 453 try {
431 int next = advance(); 454 int next = advance();
432 while (next != -1) { 455 while (next != -1) {
433 tokenCounter++; 456 tokenCounter++;
434 next = bigSwitch(next); 457 next = bigSwitch(next);
435 } 458 }
436 appendEofToken(); 459 appendEofToken();
437 instrumentation.metric2("tokensCount", tokenCounter); 460 instrumentation.metric2("tokensCount", tokenCounter);
438 return firstToken(); 461 return firstToken();
439 } finally { 462 } finally {
440 instrumentation.log(); 463 instrumentation.log();
441 } 464 }
442 } 465 }
443 466
444 /** 467 /**
445 * Advance the current position and return the character at the new current po sition. 468 * Advance the current position and return the character at the new current po sition.
469 *
446 * @return the character at the new current position 470 * @return the character at the new current position
447 */ 471 */
448 int advance(); 472 int advance();
449 473
450 /** 474 /**
451 * Return the substring of the source code between the start offset and the mo dified current 475 * Return the substring of the source code between the start offset and the mo dified current
452 * position. The current position is modified by adding the end delta. 476 * position. The current position is modified by adding the end delta.
477 *
453 * @param start the offset to the beginning of the string, relative to the sta rt of the file 478 * @param start the offset to the beginning of the string, relative to the sta rt of the file
454 * @param endDelta the number of character after the current location to be in cluded in the 479 * @param endDelta the number of character after the current location to be in cluded in the
455 * string, or the number of characters before the current location to be exclu ded if the 480 * string, or the number of characters before the current location to be excluded if the
456 * offset is negative 481 * offset is negative
457 * @return the specified substring of the source code 482 * @return the specified substring of the source code
458 */ 483 */
459 String getString(int start, int endDelta); 484 String getString(int start, int endDelta);
460 485
461 /** 486 /**
462 * Return the character at the current position without changing the current p osition. 487 * Return the character at the current position without changing the current p osition.
488 *
463 * @return the character at the current position 489 * @return the character at the current position
464 */ 490 */
465 int peek(); 491 int peek();
466 492
467 /** 493 /**
468 * Record the fact that we are at the beginning of a new line in the source. 494 * Record the fact that we are at the beginning of a new line in the source.
469 */ 495 */
470 void recordStartOfLine() { 496 void recordStartOfLine() {
471 _lineStarts.add(offset); 497 _lineStarts.add(offset);
472 } 498 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 } 728 }
703 if (next == 0x30) { 729 if (next == 0x30) {
704 return tokenizeHexOrNumber(next); 730 return tokenizeHexOrNumber(next);
705 } 731 }
706 if (0x31 <= next && next <= 0x39) { 732 if (0x31 <= next && next <= 0x39) {
707 return tokenizeNumber(next); 733 return tokenizeNumber(next);
708 } 734 }
709 if (next == -1) { 735 if (next == -1) {
710 return -1; 736 return -1;
711 } 737 }
712 if (Character.isLetter(next)) {
713 return tokenizeIdentifier(next, offset, true);
714 }
715 if (next == _$NBSP) { 738 if (next == _$NBSP) {
716 return advance(); 739 return advance();
717 } 740 }
718 reportError(ScannerErrorCode.ILLEGAL_CHARACTER, [next]); 741 reportError(ScannerErrorCode.ILLEGAL_CHARACTER, [next]);
719 return advance(); 742 return advance();
720 } 743 }
721 744
722 /** 745 /**
723 * Return the beginning token corresponding to a closing brace that was found while scanning 746 * Return the beginning token corresponding to a closing brace that was found while scanning
724 * inside a string interpolation expression. Tokens that cannot be matched wit h the closing brace 747 * inside a string interpolation expression. Tokens that cannot be matched wit h the closing brace
725 * will be dropped from the stack. 748 * will be dropped from the stack.
749 *
726 * @return the token to be paired with the closing brace 750 * @return the token to be paired with the closing brace
727 */ 751 */
728 BeginToken findTokenMatchingClosingBraceInInterpolationExpression() { 752 BeginToken findTokenMatchingClosingBraceInInterpolationExpression() {
729 int last = _groupingStack.length - 1; 753 int last = _groupingStack.length - 1;
730 while (last >= 0) { 754 while (last >= 0) {
731 BeginToken begin = _groupingStack[last]; 755 BeginToken begin = _groupingStack[last];
732 if (identical(begin.type, TokenType.OPEN_CURLY_BRACKET) || identical(begin .type, TokenType.STRING_INTERPOLATION_EXPRESSION)) { 756 if (identical(begin.type, TokenType.OPEN_CURLY_BRACKET) || identical(begin .type, TokenType.STRING_INTERPOLATION_EXPRESSION)) {
733 return begin; 757 return begin;
734 } 758 }
735 _hasUnmatchedGroups2 = true; 759 _hasUnmatchedGroups2 = true;
736 _groupingStack.removeAt(last); 760 _groupingStack.removeAt(last);
737 last--; 761 last--;
738 } 762 }
739 return null; 763 return null;
740 } 764 }
741 Token firstToken() => _tokens.next; 765 Token firstToken() => _tokens.next;
742 766
743 /** 767 /**
744 * Return the source being scanned. 768 * Return the source being scanned.
769 *
745 * @return the source being scanned 770 * @return the source being scanned
746 */ 771 */
747 Source get source => _source; 772 Source get source => _source;
748 773
749 /** 774 /**
750 * Report an error at the current offset. 775 * Report an error at the current offset.
776 *
751 * @param errorCode the error code indicating the nature of the error 777 * @param errorCode the error code indicating the nature of the error
752 * @param arguments any arguments needed to complete the error message 778 * @param arguments any arguments needed to complete the error message
753 */ 779 */
754 void reportError(ScannerErrorCode errorCode, List<Object> arguments) { 780 void reportError(ScannerErrorCode errorCode, List<Object> arguments) {
755 _errorListener.onError(new AnalysisError.con2(source, offset, 1, errorCode, arguments)); 781 _errorListener.onError(new AnalysisError.con2(source, offset, 1, errorCode, arguments));
756 } 782 }
757 int select(int choice, TokenType yesType, TokenType noType) { 783 int select(int choice, TokenType yesType, TokenType noType) {
758 int next = advance(); 784 int next = advance();
759 if (next == choice) { 785 if (next == choice) {
760 appendToken(yesType); 786 appendToken(yesType);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 } 945 }
920 int tokenizeHexOrNumber(int next) { 946 int tokenizeHexOrNumber(int next) {
921 int x = peek(); 947 int x = peek();
922 if (x == 0x78 || x == 0x58) { 948 if (x == 0x78 || x == 0x58) {
923 advance(); 949 advance();
924 return tokenizeHex(x); 950 return tokenizeHex(x);
925 } 951 }
926 return tokenizeNumber(next); 952 return tokenizeNumber(next);
927 } 953 }
928 int tokenizeIdentifier(int next, int start, bool allowDollar) { 954 int tokenizeIdentifier(int next, int start, bool allowDollar) {
929 while ((0x61 <= next && next <= 0x7A) || (0x41 <= next && next <= 0x5A) || ( 0x30 <= next && next <= 0x39) || next == 0x5F || (next == 0x24 && allowDollar) | | Character.isLetterOrDigit(next)) { 955 while ((0x61 <= next && next <= 0x7A) || (0x41 <= next && next <= 0x5A) || ( 0x30 <= next && next <= 0x39) || next == 0x5F || (next == 0x24 && allowDollar)) {
930 next = advance(); 956 next = advance();
931 } 957 }
932 appendStringToken(TokenType.IDENTIFIER, getString(start, next < 0 ? 0 : -1)) ; 958 appendStringToken(TokenType.IDENTIFIER, getString(start, next < 0 ? 0 : -1)) ;
933 return next; 959 return next;
934 } 960 }
935 int tokenizeInterpolatedExpression(int next, int start) { 961 int tokenizeInterpolatedExpression(int next, int start) {
936 appendBeginToken(TokenType.STRING_INTERPOLATION_EXPRESSION); 962 appendBeginToken(TokenType.STRING_INTERPOLATION_EXPRESSION);
937 next = advance(); 963 next = advance();
938 while (next != -1) { 964 while (next != -1) {
939 if (next == 0x7D) { 965 if (next == 0x7D) {
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 return select(0x3D, TokenType.TILDE_SLASH_EQ, TokenType.TILDE_SLASH); 1293 return select(0x3D, TokenType.TILDE_SLASH_EQ, TokenType.TILDE_SLASH);
1268 } else { 1294 } else {
1269 appendToken(TokenType.TILDE); 1295 appendToken(TokenType.TILDE);
1270 return next; 1296 return next;
1271 } 1297 }
1272 } 1298 }
1273 } 1299 }
1274 /** 1300 /**
1275 * Instances of the class `StringToken` represent a token whose value is indepen dent of it's 1301 * Instances of the class `StringToken` represent a token whose value is indepen dent of it's
1276 * type. 1302 * type.
1303 *
1277 * @coverage dart.engine.parser 1304 * @coverage dart.engine.parser
1278 */ 1305 */
1279 class StringToken extends Token { 1306 class StringToken extends Token {
1280 1307
1281 /** 1308 /**
1282 * The lexeme represented by this token. 1309 * The lexeme represented by this token.
1283 */ 1310 */
1284 String _value2; 1311 String _value2;
1285 1312
1286 /** 1313 /**
1287 * Initialize a newly created token to represent a token of the given type wit h the given value. 1314 * Initialize a newly created token to represent a token of the given type wit h the given value.
1315 *
1288 * @param type the type of the token 1316 * @param type the type of the token
1289 * @param value the lexeme represented by this token 1317 * @param value the lexeme represented by this token
1290 * @param offset the offset from the beginning of the file to the first charac ter in the token 1318 * @param offset the offset from the beginning of the file to the first charac ter in the token
1291 */ 1319 */
1292 StringToken(TokenType type, String value, int offset) : super(type, offset) { 1320 StringToken(TokenType type, String value, int offset) : super(type, offset) {
1293 this._value2 = StringUtilities.intern(value); 1321 this._value2 = StringUtilities.intern(value);
1294 } 1322 }
1295 String get lexeme => _value2; 1323 String get lexeme => _value2;
1296 String value() => _value2; 1324 String value() => _value2;
1297 } 1325 }
1298 /** 1326 /**
1299 * Instances of the class `CharBufferScanner` implement a scanner that reads fro m a character 1327 * Instances of the class `CharBufferScanner` implement a scanner that reads fro m a character
1300 * buffer. The scanning logic is in the superclass. 1328 * buffer. The scanning logic is in the superclass.
1329 *
1301 * @coverage dart.engine.parser 1330 * @coverage dart.engine.parser
1302 */ 1331 */
1303 class CharBufferScanner extends AbstractScanner { 1332 class CharBufferScanner extends AbstractScanner {
1304 1333
1305 /** 1334 /**
1306 * The buffer from which characters will be read. 1335 * The buffer from which characters will be read.
1307 */ 1336 */
1308 CharBuffer _buffer; 1337 CharBuffer _buffer;
1309 1338
1310 /** 1339 /**
1311 * The number of characters in the buffer. 1340 * The number of characters in the buffer.
1312 */ 1341 */
1313 int _bufferLength = 0; 1342 int _bufferLength = 0;
1314 1343
1315 /** 1344 /**
1316 * The index of the last character that was read. 1345 * The index of the last character that was read.
1317 */ 1346 */
1318 int _charOffset = 0; 1347 int _charOffset = 0;
1319 1348
1320 /** 1349 /**
1321 * Initialize a newly created scanner to scan the characters in the given char acter buffer. 1350 * Initialize a newly created scanner to scan the characters in the given char acter buffer.
1351 *
1322 * @param source the source being scanned 1352 * @param source the source being scanned
1323 * @param buffer the buffer from which characters will be read 1353 * @param buffer the buffer from which characters will be read
1324 * @param errorListener the error listener that will be informed of any errors that are found 1354 * @param errorListener the error listener that will be informed of any errors that are found
1325 */ 1355 */
1326 CharBufferScanner(Source source, CharBuffer buffer, AnalysisErrorListener erro rListener) : super(source, errorListener) { 1356 CharBufferScanner(Source source, CharBuffer buffer, AnalysisErrorListener erro rListener) : super(source, errorListener) {
1327 this._buffer = buffer; 1357 this._buffer = buffer;
1328 this._bufferLength = buffer.length(); 1358 this._bufferLength = buffer.length();
1329 this._charOffset = -1; 1359 this._charOffset = -1;
1330 } 1360 }
1331 int get offset => _charOffset; 1361 int get offset => _charOffset;
1332 int advance() { 1362 int advance() {
1333 if (_charOffset + 1 >= _bufferLength) { 1363 if (_charOffset + 1 >= _bufferLength) {
1334 return -1; 1364 return -1;
1335 } 1365 }
1336 return _buffer.charAt(++_charOffset); 1366 return _buffer.charAt(++_charOffset);
1337 } 1367 }
1338 String getString(int start, int endDelta) => ((_buffer as CharSequence)).subSe quence(start, _charOffset + 1 + endDelta).toString(); 1368 String getString(int start, int endDelta) => ((_buffer as CharSequence)).subSe quence(start, _charOffset + 1 + endDelta).toString();
1339 int peek() { 1369 int peek() {
1340 if (_charOffset + 1 >= _buffer.length()) { 1370 if (_charOffset + 1 >= _buffer.length()) {
1341 return -1; 1371 return -1;
1342 } 1372 }
1343 return _buffer.charAt(_charOffset + 1); 1373 return _buffer.charAt(_charOffset + 1);
1344 } 1374 }
1345 } 1375 }
1346 /** 1376 /**
1347 * Instances of the class `TokenWithComment` represent a normal token that is pr eceded by 1377 * Instances of the class `TokenWithComment` represent a normal token that is pr eceded by
1348 * comments. 1378 * comments.
1379 *
1349 * @coverage dart.engine.parser 1380 * @coverage dart.engine.parser
1350 */ 1381 */
1351 class TokenWithComment extends Token { 1382 class TokenWithComment extends Token {
1352 1383
1353 /** 1384 /**
1354 * The first comment in the list of comments that precede this token. 1385 * The first comment in the list of comments that precede this token.
1355 */ 1386 */
1356 Token _precedingComment; 1387 Token _precedingComment;
1357 1388
1358 /** 1389 /**
1359 * Initialize a newly created token to have the given type and offset and to b e preceded by the 1390 * Initialize a newly created token to have the given type and offset and to b e preceded by the
1360 * comments reachable from the given comment. 1391 * comments reachable from the given comment.
1392 *
1361 * @param type the type of the token 1393 * @param type the type of the token
1362 * @param offset the offset from the beginning of the file to the first charac ter in the token 1394 * @param offset the offset from the beginning of the file to the first charac ter in the token
1363 * @param precedingComment the first comment in the list of comments that prec ede this token 1395 * @param precedingComment the first comment in the list of comments that prec ede this token
1364 */ 1396 */
1365 TokenWithComment(TokenType type, int offset, Token precedingComment) : super(t ype, offset) { 1397 TokenWithComment(TokenType type, int offset, Token precedingComment) : super(t ype, offset) {
1366 this._precedingComment = precedingComment; 1398 this._precedingComment = precedingComment;
1367 } 1399 }
1368 Token get precedingComments => _precedingComment; 1400 Token get precedingComments => _precedingComment;
1369 } 1401 }
1370 /** 1402 /**
1371 * Instances of the class `Token` represent a token that was scanned from the in put. Each 1403 * Instances of the class `Token` represent a token that was scanned from the in put. Each
1372 * token knows which token follows it, acting as the head of a linked list of to kens. 1404 * token knows which token follows it, acting as the head of a linked list of to kens.
1405 *
1373 * @coverage dart.engine.parser 1406 * @coverage dart.engine.parser
1374 */ 1407 */
1375 class Token { 1408 class Token {
1376 1409
1377 /** 1410 /**
1378 * The type of the token. 1411 * The type of the token.
1379 */ 1412 */
1380 TokenType _type; 1413 TokenType _type;
1381 1414
1382 /** 1415 /**
1383 * The offset from the beginning of the file to the first character in the tok en. 1416 * The offset from the beginning of the file to the first character in the tok en.
1384 */ 1417 */
1385 int _offset = 0; 1418 int _offset = 0;
1386 1419
1387 /** 1420 /**
1388 * The previous token in the token stream. 1421 * The previous token in the token stream.
1389 */ 1422 */
1390 Token _previous; 1423 Token _previous;
1391 1424
1392 /** 1425 /**
1393 * The next token in the token stream. 1426 * The next token in the token stream.
1394 */ 1427 */
1395 Token _next; 1428 Token _next;
1396 1429
1397 /** 1430 /**
1398 * Initialize a newly created token to have the given type and offset. 1431 * Initialize a newly created token to have the given type and offset.
1432 *
1399 * @param type the type of the token 1433 * @param type the type of the token
1400 * @param offset the offset from the beginning of the file to the first charac ter in the token 1434 * @param offset the offset from the beginning of the file to the first charac ter in the token
1401 */ 1435 */
1402 Token(TokenType type, int offset) { 1436 Token(TokenType type, int offset) {
1403 this._type = type; 1437 this._type = type;
1404 this._offset = offset; 1438 this._offset = offset;
1405 } 1439 }
1406 1440
1407 /** 1441 /**
1408 * Return the offset from the beginning of the file to the character after las t character of the 1442 * Return the offset from the beginning of the file to the character after las t character of the
1409 * token. 1443 * token.
1444 *
1410 * @return the offset from the beginning of the file to the first character af ter last character 1445 * @return the offset from the beginning of the file to the first character af ter last character
1411 * of the token 1446 * of the token
1412 */ 1447 */
1413 int get end => _offset + length; 1448 int get end => _offset + length;
1414 1449
1415 /** 1450 /**
1416 * Return the number of characters in the node's source range. 1451 * Return the number of characters in the node's source range.
1452 *
1417 * @return the number of characters in the node's source range 1453 * @return the number of characters in the node's source range
1418 */ 1454 */
1419 int get length => lexeme.length; 1455 int get length => lexeme.length;
1420 1456
1421 /** 1457 /**
1422 * Return the lexeme that represents this token. 1458 * Return the lexeme that represents this token.
1459 *
1423 * @return the lexeme that represents this token 1460 * @return the lexeme that represents this token
1424 */ 1461 */
1425 String get lexeme => _type.lexeme; 1462 String get lexeme => _type.lexeme;
1426 1463
1427 /** 1464 /**
1428 * Return the next token in the token stream. 1465 * Return the next token in the token stream.
1466 *
1429 * @return the next token in the token stream 1467 * @return the next token in the token stream
1430 */ 1468 */
1431 Token get next => _next; 1469 Token get next => _next;
1432 1470
1433 /** 1471 /**
1434 * Return the offset from the beginning of the file to the first character in the token. 1472 * Return the offset from the beginning of the file to the first character in the token.
1473 *
1435 * @return the offset from the beginning of the file to the first character in the token 1474 * @return the offset from the beginning of the file to the first character in the token
1436 */ 1475 */
1437 int get offset => _offset; 1476 int get offset => _offset;
1438 1477
1439 /** 1478 /**
1440 * Return the first comment in the list of comments that precede this token, o r `null` if 1479 * Return the first comment in the list of comments that precede this token, o r `null` if
1441 * there are no comments preceding this token. Additional comments can be reac hed by following the 1480 * there are no comments preceding this token. Additional comments can be reac hed by following the
1442 * token stream using [getNext] until `null` is returned. 1481 * token stream using [getNext] until `null` is returned.
1482 *
1443 * @return the first comment in the list of comments that precede this token 1483 * @return the first comment in the list of comments that precede this token
1444 */ 1484 */
1445 Token get precedingComments => null; 1485 Token get precedingComments => null;
1446 1486
1447 /** 1487 /**
1448 * Return the previous token in the token stream. 1488 * Return the previous token in the token stream.
1489 *
1449 * @return the previous token in the token stream 1490 * @return the previous token in the token stream
1450 */ 1491 */
1451 Token get previous => _previous; 1492 Token get previous => _previous;
1452 1493
1453 /** 1494 /**
1454 * Return the type of the token. 1495 * Return the type of the token.
1496 *
1455 * @return the type of the token 1497 * @return the type of the token
1456 */ 1498 */
1457 TokenType get type => _type; 1499 TokenType get type => _type;
1458 1500
1459 /** 1501 /**
1460 * Return `true` if this token represents an operator. 1502 * Return `true` if this token represents an operator.
1503 *
1461 * @return `true` if this token represents an operator 1504 * @return `true` if this token represents an operator
1462 */ 1505 */
1463 bool get isOperator => _type.isOperator; 1506 bool get isOperator => _type.isOperator;
1464 1507
1465 /** 1508 /**
1466 * Return `true` if this token is a synthetic token. A synthetic token is a to ken that was 1509 * Return `true` if this token is a synthetic token. A synthetic token is a to ken that was
1467 * introduced by the parser in order to recover from an error in the code. Syn thetic tokens always 1510 * introduced by the parser in order to recover from an error in the code. Syn thetic tokens always
1468 * have a length of zero (`0`). 1511 * have a length of zero (`0`).
1512 *
1469 * @return `true` if this token is a synthetic token 1513 * @return `true` if this token is a synthetic token
1470 */ 1514 */
1471 bool get isSynthetic => length == 0; 1515 bool get isSynthetic => length == 0;
1472 1516
1473 /** 1517 /**
1474 * Return `true` if this token represents an operator that can be defined by u sers. 1518 * Return `true` if this token represents an operator that can be defined by u sers.
1519 *
1475 * @return `true` if this token represents an operator that can be defined by users 1520 * @return `true` if this token represents an operator that can be defined by users
1476 */ 1521 */
1477 bool get isUserDefinableOperator => _type.isUserDefinableOperator; 1522 bool get isUserDefinableOperator => _type.isUserDefinableOperator;
1478 1523
1479 /** 1524 /**
1480 * Set the next token in the token stream to the given token. This has the sid e-effect of setting 1525 * Set the next token in the token stream to the given token. This has the sid e-effect of setting
1481 * this token to be the previous token for the given token. 1526 * this token to be the previous token for the given token.
1527 *
1482 * @param token the next token in the token stream 1528 * @param token the next token in the token stream
1483 * @return the token that was passed in 1529 * @return the token that was passed in
1484 */ 1530 */
1485 Token setNext(Token token) { 1531 Token setNext(Token token) {
1486 _next = token; 1532 _next = token;
1487 token.previous = this; 1533 token.previous = this;
1488 return token; 1534 return token;
1489 } 1535 }
1490 1536
1491 /** 1537 /**
1492 * Set the next token in the token stream to the given token without changing which token is the 1538 * Set the next token in the token stream to the given token without changing which token is the
1493 * previous token for the given token. 1539 * previous token for the given token.
1540 *
1494 * @param token the next token in the token stream 1541 * @param token the next token in the token stream
1495 * @return the token that was passed in 1542 * @return the token that was passed in
1496 */ 1543 */
1497 Token setNextWithoutSettingPrevious(Token token) { 1544 Token setNextWithoutSettingPrevious(Token token) {
1498 _next = token; 1545 _next = token;
1499 return token; 1546 return token;
1500 } 1547 }
1501 1548
1502 /** 1549 /**
1503 * Set the offset from the beginning of the file to the first character in the token to the given 1550 * Set the offset from the beginning of the file to the first character in the token to the given
1504 * offset. 1551 * offset.
1552 *
1505 * @param offset the offset from the beginning of the file to the first charac ter in the token 1553 * @param offset the offset from the beginning of the file to the first charac ter in the token
1506 */ 1554 */
1507 void set offset(int offset2) { 1555 void set offset(int offset2) {
1508 this._offset = offset2; 1556 this._offset = offset2;
1509 } 1557 }
1510 String toString() => lexeme; 1558 String toString() => lexeme;
1511 1559
1512 /** 1560 /**
1513 * Return the value of this token. For keyword tokens, this is the keyword ass ociated with the 1561 * Return the value of this token. For keyword tokens, this is the keyword ass ociated with the
1514 * token, for other tokens it is the lexeme associated with the token. 1562 * token, for other tokens it is the lexeme associated with the token.
1563 *
1515 * @return the value of this token 1564 * @return the value of this token
1516 */ 1565 */
1517 Object value() => _type.lexeme; 1566 Object value() => _type.lexeme;
1518 1567
1519 /** 1568 /**
1520 * Set the previous token in the token stream to the given token. 1569 * Set the previous token in the token stream to the given token.
1570 *
1521 * @param previous the previous token in the token stream 1571 * @param previous the previous token in the token stream
1522 */ 1572 */
1523 void set previous(Token previous2) { 1573 void set previous(Token previous2) {
1524 this._previous = previous2; 1574 this._previous = previous2;
1525 } 1575 }
1526 } 1576 }
1527 /** 1577 /**
1528 * Instances of the class `StringScanner` implement a scanner that reads from a string. The 1578 * Instances of the class `StringScanner` implement a scanner that reads from a string. The
1529 * scanning logic is in the superclass. 1579 * scanning logic is in the superclass.
1580 *
1530 * @coverage dart.engine.parser 1581 * @coverage dart.engine.parser
1531 */ 1582 */
1532 class StringScanner extends AbstractScanner { 1583 class StringScanner extends AbstractScanner {
1533 1584
1534 /** 1585 /**
1535 * The offset from the beginning of the file to the beginning of the source be ing scanned. 1586 * The offset from the beginning of the file to the beginning of the source be ing scanned.
1536 */ 1587 */
1537 int _offsetDelta = 0; 1588 int _offsetDelta = 0;
1538 1589
1539 /** 1590 /**
1540 * The string from which characters will be read. 1591 * The string from which characters will be read.
1541 */ 1592 */
1542 String _string; 1593 String _string;
1543 1594
1544 /** 1595 /**
1545 * The number of characters in the string. 1596 * The number of characters in the string.
1546 */ 1597 */
1547 int _stringLength = 0; 1598 int _stringLength = 0;
1548 1599
1549 /** 1600 /**
1550 * The index, relative to the string, of the last character that was read. 1601 * The index, relative to the string, of the last character that was read.
1551 */ 1602 */
1552 int _charOffset = 0; 1603 int _charOffset = 0;
1553 1604
1554 /** 1605 /**
1555 * Initialize a newly created scanner to scan the characters in the given stri ng. 1606 * Initialize a newly created scanner to scan the characters in the given stri ng.
1607 *
1556 * @param source the source being scanned 1608 * @param source the source being scanned
1557 * @param string the string from which characters will be read 1609 * @param string the string from which characters will be read
1558 * @param errorListener the error listener that will be informed of any errors that are found 1610 * @param errorListener the error listener that will be informed of any errors that are found
1559 */ 1611 */
1560 StringScanner(Source source, String string, AnalysisErrorListener errorListene r) : super(source, errorListener) { 1612 StringScanner(Source source, String string, AnalysisErrorListener errorListene r) : super(source, errorListener) {
1561 this._offsetDelta = 0; 1613 this._offsetDelta = 0;
1562 this._string = string; 1614 this._string = string;
1563 this._stringLength = string.length; 1615 this._stringLength = string.length;
1564 this._charOffset = -1; 1616 this._charOffset = -1;
1565 } 1617 }
1566 int get offset => _offsetDelta + _charOffset; 1618 int get offset => _offsetDelta + _charOffset;
1567 1619
1568 /** 1620 /**
1569 * Record that the source begins on the given line and column at the given off set. The line starts 1621 * Record that the source begins on the given line and column at the given off set. The line starts
1570 * for lines before the given line will not be correct. 1622 * for lines before the given line will not be correct.
1571 * 1623 *
1572 * This method must be invoked at most one time and must be invoked before sca nning begins. The 1624 * This method must be invoked at most one time and must be invoked before sca nning begins. The
1573 * values provided must be sensible. The results are undefined if these condit ions are violated. 1625 * values provided must be sensible. The results are undefined if these condit ions are violated.
1626 *
1574 * @param line the one-based index of the line containing the first character of the source 1627 * @param line the one-based index of the line containing the first character of the source
1575 * @param column the one-based index of the column in which the first characte r of the source 1628 * @param column the one-based index of the column in which the first characte r of the source
1576 * occurs 1629 * occurs
1577 * @param offset the zero-based offset from the beginning of the larger contex t to the first 1630 * @param offset the zero-based offset from the beginning of the larger contex t to the first
1578 * character of the source 1631 * character of the source
1579 */ 1632 */
1580 void setSourceStart(int line, int column, int offset) { 1633 void setSourceStart(int line, int column, int offset) {
1581 if (line < 1 || column < 1 || offset < 0 || (line + column - 2) >= offset) { 1634 if (line < 1 || column < 1 || offset < 0 || (line + column - 2) >= offset) {
1582 return; 1635 return;
1583 } 1636 }
1584 _offsetDelta = 1; 1637 _offsetDelta = 1;
1585 for (int i = 2; i < line; i++) { 1638 for (int i = 2; i < line; i++) {
1586 recordStartOfLine(); 1639 recordStartOfLine();
1587 } 1640 }
1588 _offsetDelta = offset - column + 1; 1641 _offsetDelta = offset - column + 1;
(...skipping 10 matching lines...) Expand all
1599 int peek() { 1652 int peek() {
1600 if (_charOffset + 1 >= _string.length) { 1653 if (_charOffset + 1 >= _string.length) {
1601 return -1; 1654 return -1;
1602 } 1655 }
1603 return _string.codeUnitAt(_charOffset + 1); 1656 return _string.codeUnitAt(_charOffset + 1);
1604 } 1657 }
1605 } 1658 }
1606 /** 1659 /**
1607 * Instances of the class `BeginTokenWithComment` represent a begin token that i s preceded by 1660 * Instances of the class `BeginTokenWithComment` represent a begin token that i s preceded by
1608 * comments. 1661 * comments.
1662 *
1609 * @coverage dart.engine.parser 1663 * @coverage dart.engine.parser
1610 */ 1664 */
1611 class BeginTokenWithComment extends BeginToken { 1665 class BeginTokenWithComment extends BeginToken {
1612 1666
1613 /** 1667 /**
1614 * The first comment in the list of comments that precede this token. 1668 * The first comment in the list of comments that precede this token.
1615 */ 1669 */
1616 Token _precedingComment; 1670 Token _precedingComment;
1617 1671
1618 /** 1672 /**
1619 * Initialize a newly created token to have the given type and offset and to b e preceded by the 1673 * Initialize a newly created token to have the given type and offset and to b e preceded by the
1620 * comments reachable from the given comment. 1674 * comments reachable from the given comment.
1675 *
1621 * @param type the type of the token 1676 * @param type the type of the token
1622 * @param offset the offset from the beginning of the file to the first charac ter in the token 1677 * @param offset the offset from the beginning of the file to the first charac ter in the token
1623 * @param precedingComment the first comment in the list of comments that prec ede this token 1678 * @param precedingComment the first comment in the list of comments that prec ede this token
1624 */ 1679 */
1625 BeginTokenWithComment(TokenType type, int offset, Token precedingComment) : su per(type, offset) { 1680 BeginTokenWithComment(TokenType type, int offset, Token precedingComment) : su per(type, offset) {
1626 this._precedingComment = precedingComment; 1681 this._precedingComment = precedingComment;
1627 } 1682 }
1628 Token get precedingComments => _precedingComment; 1683 Token get precedingComments => _precedingComment;
1629 } 1684 }
1630 /** 1685 /**
1631 * Instances of the class `KeywordToken` represent a keyword in the language. 1686 * Instances of the class `KeywordToken` represent a keyword in the language.
1687 *
1632 * @coverage dart.engine.parser 1688 * @coverage dart.engine.parser
1633 */ 1689 */
1634 class KeywordToken extends Token { 1690 class KeywordToken extends Token {
1635 1691
1636 /** 1692 /**
1637 * The keyword being represented by this token. 1693 * The keyword being represented by this token.
1638 */ 1694 */
1639 Keyword _keyword; 1695 Keyword _keyword;
1640 1696
1641 /** 1697 /**
1642 * Initialize a newly created token to represent the given keyword. 1698 * Initialize a newly created token to represent the given keyword.
1699 *
1643 * @param keyword the keyword being represented by this token 1700 * @param keyword the keyword being represented by this token
1644 * @param offset the offset from the beginning of the file to the first charac ter in the token 1701 * @param offset the offset from the beginning of the file to the first charac ter in the token
1645 */ 1702 */
1646 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) { 1703 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) {
1647 this._keyword = keyword; 1704 this._keyword = keyword;
1648 } 1705 }
1649 1706
1650 /** 1707 /**
1651 * Return the keyword being represented by this token. 1708 * Return the keyword being represented by this token.
1709 *
1652 * @return the keyword being represented by this token 1710 * @return the keyword being represented by this token
1653 */ 1711 */
1654 Keyword get keyword => _keyword; 1712 Keyword get keyword => _keyword;
1655 String get lexeme => _keyword.syntax; 1713 String get lexeme => _keyword.syntax;
1656 Keyword value() => _keyword; 1714 Keyword value() => _keyword;
1657 } 1715 }
1658 /** 1716 /**
1659 * Instances of the class `BeginToken` represent the opening half of a grouping pair of 1717 * Instances of the class `BeginToken` represent the opening half of a grouping pair of
1660 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square brackets ('\['). 1718 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square brackets ('[').
1719 *
1661 * @coverage dart.engine.parser 1720 * @coverage dart.engine.parser
1662 */ 1721 */
1663 class BeginToken extends Token { 1722 class BeginToken extends Token {
1664 1723
1665 /** 1724 /**
1666 * The token that corresponds to this token. 1725 * The token that corresponds to this token.
1667 */ 1726 */
1668 Token _endToken; 1727 Token _endToken;
1669 1728
1670 /** 1729 /**
1671 * Initialize a newly created token representing the opening half of a groupin g pair of tokens. 1730 * Initialize a newly created token representing the opening half of a groupin g pair of tokens.
1731 *
1672 * @param type the type of the token 1732 * @param type the type of the token
1673 * @param offset the offset from the beginning of the file to the first charac ter in the token 1733 * @param offset the offset from the beginning of the file to the first charac ter in the token
1674 */ 1734 */
1675 BeginToken(TokenType type, int offset) : super(type, offset) { 1735 BeginToken(TokenType type, int offset) : super(type, offset) {
1676 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))); 1736 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)));
1677 } 1737 }
1678 1738
1679 /** 1739 /**
1680 * Return the token that corresponds to this token. 1740 * Return the token that corresponds to this token.
1741 *
1681 * @return the token that corresponds to this token 1742 * @return the token that corresponds to this token
1682 */ 1743 */
1683 Token get endToken => _endToken; 1744 Token get endToken => _endToken;
1684 1745
1685 /** 1746 /**
1686 * Set the token that corresponds to this token to the given token. 1747 * Set the token that corresponds to this token to the given token.
1748 *
1687 * @param token the token that corresponds to this token 1749 * @param token the token that corresponds to this token
1688 */ 1750 */
1689 void set endToken(Token token) { 1751 void set endToken(Token token) {
1690 this._endToken = token; 1752 this._endToken = token;
1691 } 1753 }
1692 } 1754 }
1693 /** 1755 /**
1694 * The enumeration `TokenClass` represents classes (or groups) of tokens with a similar use. 1756 * The enumeration `TokenClass` represents classes (or groups) of tokens with a similar use.
1757 *
1695 * @coverage dart.engine.parser 1758 * @coverage dart.engine.parser
1696 */ 1759 */
1697 class TokenClass implements Comparable<TokenClass> { 1760 class TokenClass implements Comparable<TokenClass> {
1698 1761
1699 /** 1762 /**
1700 * A value used to indicate that the token type is not part of any specific cl ass of token. 1763 * A value used to indicate that the token type is not part of any specific cl ass of token.
1701 */ 1764 */
1702 static final TokenClass NO_CLASS = new TokenClass.con1('NO_CLASS', 0); 1765 static final TokenClass NO_CLASS = new TokenClass.con1('NO_CLASS', 0);
1703 1766
1704 /** 1767 /**
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1797 TokenClass.con2(this.name, this.ordinal, int precedence2) { 1860 TokenClass.con2(this.name, this.ordinal, int precedence2) {
1798 _jtd_constructor_329_impl(precedence2); 1861 _jtd_constructor_329_impl(precedence2);
1799 } 1862 }
1800 _jtd_constructor_329_impl(int precedence2) { 1863 _jtd_constructor_329_impl(int precedence2) {
1801 this._precedence = precedence2; 1864 this._precedence = precedence2;
1802 } 1865 }
1803 1866
1804 /** 1867 /**
1805 * Return the precedence of tokens of this class, or `0` if the such tokens do not represent 1868 * Return the precedence of tokens of this class, or `0` if the such tokens do not represent
1806 * an operator. 1869 * an operator.
1870 *
1807 * @return the precedence of tokens of this class 1871 * @return the precedence of tokens of this class
1808 */ 1872 */
1809 int get precedence => _precedence; 1873 int get precedence => _precedence;
1810 int compareTo(TokenClass other) => ordinal - other.ordinal; 1874 int compareTo(TokenClass other) => ordinal - other.ordinal;
1811 int get hashCode => ordinal; 1875 int get hashCode => ordinal;
1812 String toString() => name; 1876 String toString() => name;
1813 } 1877 }
1814 /** 1878 /**
1815 * Instances of the class `KeywordTokenWithComment` implement a keyword token th at is preceded 1879 * Instances of the class `KeywordTokenWithComment` implement a keyword token th at is preceded
1816 * by comments. 1880 * by comments.
1881 *
1817 * @coverage dart.engine.parser 1882 * @coverage dart.engine.parser
1818 */ 1883 */
1819 class KeywordTokenWithComment extends KeywordToken { 1884 class KeywordTokenWithComment extends KeywordToken {
1820 1885
1821 /** 1886 /**
1822 * The first comment in the list of comments that precede this token. 1887 * The first comment in the list of comments that precede this token.
1823 */ 1888 */
1824 Token _precedingComment; 1889 Token _precedingComment;
1825 1890
1826 /** 1891 /**
1827 * Initialize a newly created token to to represent the given keyword and to b e preceded by the 1892 * Initialize a newly created token to to represent the given keyword and to b e preceded by the
1828 * comments reachable from the given comment. 1893 * comments reachable from the given comment.
1894 *
1829 * @param keyword the keyword being represented by this token 1895 * @param keyword the keyword being represented by this token
1830 * @param offset the offset from the beginning of the file to the first charac ter in the token 1896 * @param offset the offset from the beginning of the file to the first charac ter in the token
1831 * @param precedingComment the first comment in the list of comments that prec ede this token 1897 * @param precedingComment the first comment in the list of comments that prec ede this token
1832 */ 1898 */
1833 KeywordTokenWithComment(Keyword keyword, int offset, Token precedingComment) : super(keyword, offset) { 1899 KeywordTokenWithComment(Keyword keyword, int offset, Token precedingComment) : super(keyword, offset) {
1834 this._precedingComment = precedingComment; 1900 this._precedingComment = precedingComment;
1835 } 1901 }
1836 Token get precedingComments => _precedingComment; 1902 Token get precedingComments => _precedingComment;
1837 } 1903 }
1838 /** 1904 /**
1839 * The enumeration `TokenType` defines the types of tokens that can be returned by the 1905 * The enumeration `TokenType` defines the types of tokens that can be returned by the
1840 * scanner. 1906 * scanner.
1907 *
1841 * @coverage dart.engine.parser 1908 * @coverage dart.engine.parser
1842 */ 1909 */
1843 class TokenType implements Comparable<TokenType> { 1910 class TokenType implements Comparable<TokenType> {
1844 1911
1845 /** 1912 /**
1846 * The type of the token that marks the end of the input. 1913 * The type of the token that marks the end of the input.
1847 */ 1914 */
1848 static final TokenType EOF = new TokenType_EOF('EOF', 0, null, ""); 1915 static final TokenType EOF = new TokenType_EOF('EOF', 0, null, "");
1849 static final TokenType DOUBLE = new TokenType.con1('DOUBLE', 1); 1916 static final TokenType DOUBLE = new TokenType.con1('DOUBLE', 1);
1850 static final TokenType HEXADECIMAL = new TokenType.con1('HEXADECIMAL', 2); 1917 static final TokenType HEXADECIMAL = new TokenType.con1('HEXADECIMAL', 2);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 _jtd_constructor_331_impl(tokenClass2, lexeme2); 2008 _jtd_constructor_331_impl(tokenClass2, lexeme2);
1942 } 2009 }
1943 _jtd_constructor_331_impl(TokenClass tokenClass2, String lexeme2) { 2010 _jtd_constructor_331_impl(TokenClass tokenClass2, String lexeme2) {
1944 this._tokenClass = tokenClass2 == null ? TokenClass.NO_CLASS : tokenClass2; 2011 this._tokenClass = tokenClass2 == null ? TokenClass.NO_CLASS : tokenClass2;
1945 this._lexeme = lexeme2; 2012 this._lexeme = lexeme2;
1946 } 2013 }
1947 2014
1948 /** 2015 /**
1949 * Return the lexeme that defines this type of token, or `null` if there is mo re than one 2016 * Return the lexeme that defines this type of token, or `null` if there is mo re than one
1950 * possible lexeme for this type of token. 2017 * possible lexeme for this type of token.
2018 *
1951 * @return the lexeme that defines this type of token 2019 * @return the lexeme that defines this type of token
1952 */ 2020 */
1953 String get lexeme => _lexeme; 2021 String get lexeme => _lexeme;
1954 2022
1955 /** 2023 /**
1956 * Return the precedence of the token, or `0` if the token does not represent an operator. 2024 * Return the precedence of the token, or `0` if the token does not represent an operator.
2025 *
1957 * @return the precedence of the token 2026 * @return the precedence of the token
1958 */ 2027 */
1959 int get precedence => _tokenClass.precedence; 2028 int get precedence => _tokenClass.precedence;
1960 2029
1961 /** 2030 /**
1962 * Return `true` if this type of token represents an additive operator. 2031 * Return `true` if this type of token represents an additive operator.
2032 *
1963 * @return `true` if this type of token represents an additive operator 2033 * @return `true` if this type of token represents an additive operator
1964 */ 2034 */
1965 bool get isAdditiveOperator => identical(_tokenClass, TokenClass.ADDITIVE_OPER ATOR); 2035 bool get isAdditiveOperator => identical(_tokenClass, TokenClass.ADDITIVE_OPER ATOR);
1966 2036
1967 /** 2037 /**
1968 * Return `true` if this type of token represents an assignment operator. 2038 * Return `true` if this type of token represents an assignment operator.
2039 *
1969 * @return `true` if this type of token represents an assignment operator 2040 * @return `true` if this type of token represents an assignment operator
1970 */ 2041 */
1971 bool get isAssignmentOperator => identical(_tokenClass, TokenClass.ASSIGNMENT_ OPERATOR); 2042 bool get isAssignmentOperator => identical(_tokenClass, TokenClass.ASSIGNMENT_ OPERATOR);
1972 2043
1973 /** 2044 /**
1974 * Return `true` if this type of token represents an associative operator. An associative 2045 * Return `true` if this type of token represents an associative operator. An associative
1975 * operator is an operator for which the following equality is true:`(a * b) * c == a * (b * c)`. In other words, if the result of applying the operator to 2046 * operator is an operator for which the following equality is true:
2047 * `(a * b) * c == a * (b * c)`. In other words, if the result of applying the operator to
1976 * multiple operands does not depend on the order in which those applications occur. 2048 * multiple operands does not depend on the order in which those applications occur.
1977 * 2049 *
1978 * Note: This method considers the logical-and and logical-or operators to be associative, even 2050 * Note: This method considers the logical-and and logical-or operators to be associative, even
1979 * though the order in which the application of those operators can have an ef fect because 2051 * though the order in which the application of those operators can have an ef fect because
1980 * evaluation of the right-hand operand is conditional. 2052 * evaluation of the right-hand operand is conditional.
2053 *
1981 * @return `true` if this type of token represents an associative operator 2054 * @return `true` if this type of token represents an associative operator
1982 */ 2055 */
1983 bool get isAssociativeOperator => identical(this, AMPERSAND) || identical(this , AMPERSAND_AMPERSAND) || identical(this, BAR) || identical(this, BAR_BAR) || id entical(this, CARET) || identical(this, PLUS) || identical(this, STAR); 2056 bool get isAssociativeOperator => identical(this, AMPERSAND) || identical(this , AMPERSAND_AMPERSAND) || identical(this, BAR) || identical(this, BAR_BAR) || id entical(this, CARET) || identical(this, PLUS) || identical(this, STAR);
1984 2057
1985 /** 2058 /**
1986 * Return `true` if this type of token represents an equality operator. 2059 * Return `true` if this type of token represents an equality operator.
2060 *
1987 * @return `true` if this type of token represents an equality operator 2061 * @return `true` if this type of token represents an equality operator
1988 */ 2062 */
1989 bool get isEqualityOperator => identical(_tokenClass, TokenClass.EQUALITY_OPER ATOR); 2063 bool get isEqualityOperator => identical(_tokenClass, TokenClass.EQUALITY_OPER ATOR);
1990 2064
1991 /** 2065 /**
1992 * Return `true` if this type of token represents an increment operator. 2066 * Return `true` if this type of token represents an increment operator.
2067 *
1993 * @return `true` if this type of token represents an increment operator 2068 * @return `true` if this type of token represents an increment operator
1994 */ 2069 */
1995 bool get isIncrementOperator => identical(_lexeme, "++") || identical(_lexeme, "--"); 2070 bool get isIncrementOperator => identical(_lexeme, "++") || identical(_lexeme, "--");
1996 2071
1997 /** 2072 /**
1998 * Return `true` if this type of token represents a multiplicative operator. 2073 * Return `true` if this type of token represents a multiplicative operator.
2074 *
1999 * @return `true` if this type of token represents a multiplicative operator 2075 * @return `true` if this type of token represents a multiplicative operator
2000 */ 2076 */
2001 bool get isMultiplicativeOperator => identical(_tokenClass, TokenClass.MULTIPL ICATIVE_OPERATOR); 2077 bool get isMultiplicativeOperator => identical(_tokenClass, TokenClass.MULTIPL ICATIVE_OPERATOR);
2002 2078
2003 /** 2079 /**
2004 * Return `true` if this token type represents an operator. 2080 * Return `true` if this token type represents an operator.
2081 *
2005 * @return `true` if this token type represents an operator 2082 * @return `true` if this token type represents an operator
2006 */ 2083 */
2007 bool get isOperator => _tokenClass != TokenClass.NO_CLASS && this != OPEN_PARE N && this != OPEN_SQUARE_BRACKET && this != PERIOD; 2084 bool get isOperator => _tokenClass != TokenClass.NO_CLASS && this != OPEN_PARE N && this != OPEN_SQUARE_BRACKET && this != PERIOD;
2008 2085
2009 /** 2086 /**
2010 * Return `true` if this type of token represents a relational operator. 2087 * Return `true` if this type of token represents a relational operator.
2088 *
2011 * @return `true` if this type of token represents a relational operator 2089 * @return `true` if this type of token represents a relational operator
2012 */ 2090 */
2013 bool get isRelationalOperator => identical(_tokenClass, TokenClass.RELATIONAL_ OPERATOR); 2091 bool get isRelationalOperator => identical(_tokenClass, TokenClass.RELATIONAL_ OPERATOR);
2014 2092
2015 /** 2093 /**
2016 * Return `true` if this type of token represents a shift operator. 2094 * Return `true` if this type of token represents a shift operator.
2095 *
2017 * @return `true` if this type of token represents a shift operator 2096 * @return `true` if this type of token represents a shift operator
2018 */ 2097 */
2019 bool get isShiftOperator => identical(_tokenClass, TokenClass.SHIFT_OPERATOR); 2098 bool get isShiftOperator => identical(_tokenClass, TokenClass.SHIFT_OPERATOR);
2020 2099
2021 /** 2100 /**
2022 * Return `true` if this type of token represents a unary postfix operator. 2101 * Return `true` if this type of token represents a unary postfix operator.
2102 *
2023 * @return `true` if this type of token represents a unary postfix operator 2103 * @return `true` if this type of token represents a unary postfix operator
2024 */ 2104 */
2025 bool get isUnaryPostfixOperator => identical(_tokenClass, TokenClass.UNARY_POS TFIX_OPERATOR); 2105 bool get isUnaryPostfixOperator => identical(_tokenClass, TokenClass.UNARY_POS TFIX_OPERATOR);
2026 2106
2027 /** 2107 /**
2028 * Return `true` if this type of token represents a unary prefix operator. 2108 * Return `true` if this type of token represents a unary prefix operator.
2109 *
2029 * @return `true` if this type of token represents a unary prefix operator 2110 * @return `true` if this type of token represents a unary prefix operator
2030 */ 2111 */
2031 bool get isUnaryPrefixOperator => identical(_tokenClass, TokenClass.UNARY_PREF IX_OPERATOR); 2112 bool get isUnaryPrefixOperator => identical(_tokenClass, TokenClass.UNARY_PREF IX_OPERATOR);
2032 2113
2033 /** 2114 /**
2034 * Return `true` if this token type represents an operator that can be defined by users. 2115 * Return `true` if this token type represents an operator that can be defined by users.
2116 *
2035 * @return `true` if this token type represents an operator that can be define d by users 2117 * @return `true` if this token type represents an operator that can be define d by users
2036 */ 2118 */
2037 bool get isUserDefinableOperator => identical(_lexeme, "==") || identical(_lex eme, "~") || identical(_lexeme, "[]") || identical(_lexeme, "[]=") || identical( _lexeme, "*") || identical(_lexeme, "/") || identical(_lexeme, "%") || identical (_lexeme, "~/") || identical(_lexeme, "+") || identical(_lexeme, "-") || identic al(_lexeme, "<<") || identical(_lexeme, ">>") || identical(_lexeme, ">=") || ide ntical(_lexeme, ">") || identical(_lexeme, "<=") || identical(_lexeme, "<") || i dentical(_lexeme, "&") || identical(_lexeme, "^") || identical(_lexeme, "|"); 2119 bool get isUserDefinableOperator => identical(_lexeme, "==") || identical(_lex eme, "~") || identical(_lexeme, "[]") || identical(_lexeme, "[]=") || identical( _lexeme, "*") || identical(_lexeme, "/") || identical(_lexeme, "%") || identical (_lexeme, "~/") || identical(_lexeme, "+") || identical(_lexeme, "-") || identic al(_lexeme, "<<") || identical(_lexeme, ">>") || identical(_lexeme, ">=") || ide ntical(_lexeme, ">") || identical(_lexeme, "<=") || identical(_lexeme, "<") || i dentical(_lexeme, "&") || identical(_lexeme, "^") || identical(_lexeme, "|");
2038 int compareTo(TokenType other) => ordinal - other.ordinal; 2120 int compareTo(TokenType other) => ordinal - other.ordinal;
2039 int get hashCode => ordinal; 2121 int get hashCode => ordinal;
2040 String toString() => name; 2122 String toString() => name;
2041 } 2123 }
2042 class TokenType_EOF extends TokenType { 2124 class TokenType_EOF extends TokenType {
2043 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super. con2(name, ordinal, arg0, arg1); 2125 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super. con2(name, ordinal, arg0, arg1);
2044 String toString() => "-eof-"; 2126 String toString() => "-eof-";
2045 } 2127 }
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