| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of scanner; | 5 part of scanner; |
| 6 | 6 |
| 7 abstract class Scanner { | 7 abstract class Scanner { |
| 8 Token tokenize(); | 8 Token tokenize(); |
| 9 | 9 |
| 10 factory Scanner(SourceFile file, {bool includeComments: false}) { | 10 factory Scanner(SourceFile file, {bool includeComments: false}) { |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 323 } |
| 324 | 324 |
| 325 if (identical(next, $SEMICOLON)) { | 325 if (identical(next, $SEMICOLON)) { |
| 326 appendPrecedenceToken(SEMICOLON_INFO); | 326 appendPrecedenceToken(SEMICOLON_INFO); |
| 327 // Type parameters and arguments cannot contain semicolon. | 327 // Type parameters and arguments cannot contain semicolon. |
| 328 discardOpenLt(); | 328 discardOpenLt(); |
| 329 return advance(); | 329 return advance(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 if (identical(next, $QUESTION)) { | 332 if (identical(next, $QUESTION)) { |
| 333 appendPrecedenceToken(QUESTION_INFO); | 333 return tokenizeQuestion(next); |
| 334 return advance(); | |
| 335 } | 334 } |
| 336 | 335 |
| 337 if (identical(next, $CLOSE_SQUARE_BRACKET)) { | 336 if (identical(next, $CLOSE_SQUARE_BRACKET)) { |
| 338 return appendEndGroup(CLOSE_SQUARE_BRACKET_INFO, | 337 return appendEndGroup(CLOSE_SQUARE_BRACKET_INFO, |
| 339 OPEN_SQUARE_BRACKET_TOKEN); | 338 OPEN_SQUARE_BRACKET_TOKEN); |
| 340 } | 339 } |
| 341 | 340 |
| 342 if (identical(next, $BACKPING)) { | 341 if (identical(next, $BACKPING)) { |
| 343 appendPrecedenceToken(BACKPING_INFO); | 342 appendPrecedenceToken(BACKPING_INFO); |
| 344 return advance(); | 343 return advance(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 } | 442 } |
| 444 appendBeginGroup(OPEN_SQUARE_BRACKET_INFO); | 443 appendBeginGroup(OPEN_SQUARE_BRACKET_INFO); |
| 445 return next; | 444 return next; |
| 446 } | 445 } |
| 447 | 446 |
| 448 int tokenizeCaret(int next) { | 447 int tokenizeCaret(int next) { |
| 449 // ^ ^= | 448 // ^ ^= |
| 450 return select($EQ, CARET_EQ_INFO, CARET_INFO); | 449 return select($EQ, CARET_EQ_INFO, CARET_INFO); |
| 451 } | 450 } |
| 452 | 451 |
| 452 int tokenizeQuestion(int next) { |
| 453 // ? ?. ?? ??= |
| 454 next = advance(); |
| 455 if (identical(next, $QUESTION)) { |
| 456 return select($EQ, QUESTION_QUESTION_EQ_INFO, QUESTION_QUESTION_INFO); |
| 457 } else if (identical(next, $PERIOD)) { |
| 458 appendPrecedenceToken(QUESTION_PERIOD_INFO); |
| 459 return advance(); |
| 460 } else { |
| 461 appendPrecedenceToken(QUESTION_INFO); |
| 462 return next; |
| 463 } |
| 464 } |
| 465 |
| 453 int tokenizeBar(int next) { | 466 int tokenizeBar(int next) { |
| 454 // | || |= | 467 // | || |= |
| 455 next = advance(); | 468 next = advance(); |
| 456 if (identical(next, $BAR)) { | 469 if (identical(next, $BAR)) { |
| 457 appendPrecedenceToken(BAR_BAR_INFO); | 470 appendPrecedenceToken(BAR_BAR_INFO); |
| 458 return advance(); | 471 return advance(); |
| 459 } else if (identical(next, $EQ)) { | 472 } else if (identical(next, $EQ)) { |
| 460 appendPrecedenceToken(BAR_EQ_INFO); | 473 appendPrecedenceToken(BAR_EQ_INFO); |
| 461 return advance(); | 474 return advance(); |
| 462 } else { | 475 } else { |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 | 1160 |
| 1148 PrecedenceInfo closeBraceInfoFor(BeginGroupToken begin) { | 1161 PrecedenceInfo closeBraceInfoFor(BeginGroupToken begin) { |
| 1149 return const { | 1162 return const { |
| 1150 '(': CLOSE_PAREN_INFO, | 1163 '(': CLOSE_PAREN_INFO, |
| 1151 '[': CLOSE_SQUARE_BRACKET_INFO, | 1164 '[': CLOSE_SQUARE_BRACKET_INFO, |
| 1152 '{': CLOSE_CURLY_BRACKET_INFO, | 1165 '{': CLOSE_CURLY_BRACKET_INFO, |
| 1153 '<': GT_INFO, | 1166 '<': GT_INFO, |
| 1154 r'${': CLOSE_CURLY_BRACKET_INFO, | 1167 r'${': CLOSE_CURLY_BRACKET_INFO, |
| 1155 }[begin.value]; | 1168 }[begin.value]; |
| 1156 } | 1169 } |
| OLD | NEW |