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

Unified Diff: frog/tokenizer.dart

Issue 9111019: Support for nested comments (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « frog/minfrog ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/tokenizer.dart
diff --git a/frog/tokenizer.dart b/frog/tokenizer.dart
index 1fb86e1a455fcf28a85d986b0268d5739833aa1d..a944cf93b5bcd870ded107dd2d417c6e071950cf 100644
--- a/frog/tokenizer.dart
+++ b/frog/tokenizer.dart
@@ -4,8 +4,6 @@
// Generated by scripts/tokenizer_gen.py.
-/**
- */
interface TokenSource {
Token next();
}
@@ -159,21 +157,27 @@ class TokenizerBase extends TokenizerHelpers implements TokenSource {
}
Token finishMultiLineComment() {
- while (true) {
+ int nesting = 1;
+ do {
int ch = _nextChar();
if (ch == 0) {
return _finishToken(TokenKind.INCOMPLETE_COMMENT);
} else if (ch == 42/*'*'*/) {
if (_maybeEatChar(47/*'/'*/)) {
- if (_skipWhitespace) {
- return next();
- } else {
- return _finishToken(TokenKind.COMMENT);
- }
+ nesting--;
+ }
+ } else if (ch == 47/*'/'*/) {
+ if (_maybeEatChar(42/*'*'*/)) {
+ nesting++;
}
}
+ } while (nesting > 0);
+
+ if (_skipWhitespace) {
+ return next();
+ } else {
+ return _finishToken(TokenKind.COMMENT);
}
- return _errorToken();
jimhug 2012/01/05 18:32:29 Nice to see this cleaned up as part of the change.
}
void eatDigits() {
« no previous file with comments | « frog/minfrog ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698