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

Side by Side 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, 11 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
« no previous file with comments | « frog/minfrog ('k') | tests/language/language.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Generated by scripts/tokenizer_gen.py. 4 // Generated by scripts/tokenizer_gen.py.
5 5
6 6
7 /**
8 */
9 interface TokenSource { 7 interface TokenSource {
10 Token next(); 8 Token next();
11 } 9 }
12 10
13 class InterpStack { 11 class InterpStack {
14 InterpStack next, previous; 12 InterpStack next, previous;
15 final int quote; 13 final int quote;
16 final bool isMultiline; 14 final bool isMultiline;
17 int depth; 15 int depth;
18 16
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (_skipWhitespace) { 150 if (_skipWhitespace) {
153 return next(); 151 return next();
154 } else { 152 } else {
155 return _finishToken(TokenKind.COMMENT); 153 return _finishToken(TokenKind.COMMENT);
156 } 154 }
157 } 155 }
158 } 156 }
159 } 157 }
160 158
161 Token finishMultiLineComment() { 159 Token finishMultiLineComment() {
162 while (true) { 160 int nesting = 1;
161 do {
163 int ch = _nextChar(); 162 int ch = _nextChar();
164 if (ch == 0) { 163 if (ch == 0) {
165 return _finishToken(TokenKind.INCOMPLETE_COMMENT); 164 return _finishToken(TokenKind.INCOMPLETE_COMMENT);
166 } else if (ch == 42/*'*'*/) { 165 } else if (ch == 42/*'*'*/) {
167 if (_maybeEatChar(47/*'/'*/)) { 166 if (_maybeEatChar(47/*'/'*/)) {
168 if (_skipWhitespace) { 167 nesting--;
169 return next(); 168 }
170 } else { 169 } else if (ch == 47/*'/'*/) {
171 return _finishToken(TokenKind.COMMENT); 170 if (_maybeEatChar(42/*'*'*/)) {
172 } 171 nesting++;
173 } 172 }
174 } 173 }
174 } while (nesting > 0);
175
176 if (_skipWhitespace) {
177 return next();
178 } else {
179 return _finishToken(TokenKind.COMMENT);
175 } 180 }
176 return _errorToken();
jimhug 2012/01/05 18:32:29 Nice to see this cleaned up as part of the change.
177 } 181 }
178 182
179 void eatDigits() { 183 void eatDigits() {
180 while (_index < _text.length) { 184 while (_index < _text.length) {
181 if (isDigit(_text.charCodeAt(_index))) { 185 if (isDigit(_text.charCodeAt(_index))) {
182 _index++; 186 _index++;
183 } else { 187 } else {
184 return; 188 return;
185 } 189 }
186 } 190 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 418 }
415 } 419 }
416 int kind = getIdentifierKind(); 420 int kind = getIdentifierKind();
417 if (kind == TokenKind.IDENTIFIER) { 421 if (kind == TokenKind.IDENTIFIER) {
418 return _finishToken(TokenKind.IDENTIFIER); 422 return _finishToken(TokenKind.IDENTIFIER);
419 } else { 423 } else {
420 return _finishToken(kind); 424 return _finishToken(kind);
421 } 425 }
422 } 426 }
423 } 427 }
OLDNEW
« 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