| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 interface Scanner { | 5 interface Scanner { |
| 6 Token tokenize(); | 6 Token tokenize(); |
| 7 } | 7 } |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Common base class for a Dart scanner. | 10 * Common base class for a Dart scanner. |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 int tokenizeSingleLineComment(int next) { | 511 int tokenizeSingleLineComment(int next) { |
| 512 while (true) { | 512 while (true) { |
| 513 next = advance(); | 513 next = advance(); |
| 514 if ($LF === next || $CR === next || $EOF === next) { | 514 if ($LF === next || $CR === next || $EOF === next) { |
| 515 return next; | 515 return next; |
| 516 } | 516 } |
| 517 } | 517 } |
| 518 } | 518 } |
| 519 | 519 |
| 520 int tokenizeMultiLineComment(int next) { | 520 int tokenizeMultiLineComment(int next) { |
| 521 int nesting = 1; |
| 521 next = advance(); | 522 next = advance(); |
| 522 while (true) { | 523 while (true) { |
| 523 if ($EOF === next) { | 524 if ($EOF === next) { |
| 525 // TODO(ahe): Report error. |
| 524 return next; | 526 return next; |
| 525 } else if ($STAR === next) { | 527 } else if ($STAR === next) { |
| 526 next = advance(); | 528 next = advance(); |
| 527 if (next === $SLASH) { | 529 if ($SLASH === next) { |
| 528 return advance(); | 530 --nesting; |
| 529 } else if (next === $EOF) { | 531 if (0 === nesting) { |
| 530 return next; | 532 return advance(); |
| 533 } else { |
| 534 next = advance(); |
| 535 } |
| 536 } |
| 537 } else if ($SLASH === next) { |
| 538 next = advance(); |
| 539 if ($STAR === next) { |
| 540 next = advance(); |
| 541 ++nesting; |
| 531 } | 542 } |
| 532 } else { | 543 } else { |
| 533 next = advance(); | 544 next = advance(); |
| 534 } | 545 } |
| 535 } | 546 } |
| 536 } | 547 } |
| 537 | 548 |
| 538 int tokenizeKeywordOrIdentifier(int next, bool allowDollar) { | 549 int tokenizeKeywordOrIdentifier(int next, bool allowDollar) { |
| 539 KeywordState state = KeywordState.KEYWORD_STATE; | 550 KeywordState state = KeywordState.KEYWORD_STATE; |
| 540 int start = byteOffset; | 551 int start = byteOffset; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 } | 709 } |
| 699 return next; | 710 return next; |
| 700 } | 711 } |
| 701 } | 712 } |
| 702 | 713 |
| 703 class MalformedInputException { | 714 class MalformedInputException { |
| 704 final message; | 715 final message; |
| 705 MalformedInputException(this.message); | 716 MalformedInputException(this.message); |
| 706 toString() => message.toString(); | 717 toString() => message.toString(); |
| 707 } | 718 } |
| OLD | NEW |