Chromium Code Reviews| 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 // Generated by scripts/tokenizer_gen.py. | 4 // Generated by scripts/tokenizer_gen.py. |
| 5 | 5 |
| 6 | 6 |
| 7 /** A generated file that extends the hand coded methods in TokenizerBase. */ | 7 /** A generated file that extends the hand coded methods in TokenizerBase. */ |
| 8 class Tokenizer extends TokenizerBase { | 8 class Tokenizer extends TokenizerBase { |
| 9 | 9 |
| 10 Tokenizer(SourceFile source, bool skipWhitespace, [int index = 0]) | 10 Tokenizer(SourceFile source, bool skipWhitespace, [int index = 0]) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 return finishHashBang(); | 47 return finishHashBang(); |
| 48 } else { | 48 } else { |
| 49 return _finishToken(TokenKind.HASH); | 49 return _finishToken(TokenKind.HASH); |
| 50 } | 50 } |
| 51 case 36/*$*/: | 51 case 36/*$*/: |
| 52 if (_maybeEatChar(34/*"*/)) { | 52 if (_maybeEatChar(34/*"*/)) { |
| 53 return finishString(34/*"*/); | 53 return finishString(34/*"*/); |
| 54 } else if (_maybeEatChar(39/*'*/)) { | 54 } else if (_maybeEatChar(39/*'*/)) { |
| 55 return finishString(39/*'*/); | 55 return finishString(39/*'*/); |
| 56 } else { | 56 } else { |
| 57 return finishIdentifier(); | 57 return finishIdentifier(36/*$*/); |
| 58 } | 58 } |
| 59 case 37/*%*/: | 59 case 37/*%*/: |
| 60 if (_maybeEatChar(61/*=*/)) { | 60 if (_maybeEatChar(61/*=*/)) { |
| 61 return _finishToken(TokenKind.ASSIGN_MOD); | 61 return _finishToken(TokenKind.ASSIGN_MOD); |
| 62 } else { | 62 } else { |
| 63 return _finishToken(TokenKind.MOD); | 63 return _finishToken(TokenKind.MOD); |
| 64 } | 64 } |
| 65 case 38/*&*/: | 65 case 38/*&*/: |
| 66 if (_maybeEatChar(38/*&*/)) { | 66 if (_maybeEatChar(38/*&*/)) { |
| 67 return _finishToken(TokenKind.AND); | 67 return _finishToken(TokenKind.AND); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 if (_maybeEatChar(61/*=*/)) { | 219 if (_maybeEatChar(61/*=*/)) { |
| 220 return _finishToken(TokenKind.ASSIGN_TRUNCDIV); | 220 return _finishToken(TokenKind.ASSIGN_TRUNCDIV); |
| 221 } else { | 221 } else { |
| 222 return _finishToken(TokenKind.TRUNCDIV); | 222 return _finishToken(TokenKind.TRUNCDIV); |
| 223 } | 223 } |
| 224 } else { | 224 } else { |
| 225 return _finishToken(TokenKind.BIT_NOT); | 225 return _finishToken(TokenKind.BIT_NOT); |
| 226 } | 226 } |
| 227 default: | 227 default: |
| 228 if (isIdentifierStart(ch)) { | 228 if (isIdentifierStart(ch)) { |
| 229 return this.finishIdentifier(); | 229 return this.finishIdentifier(ch); |
| 230 } else if (isDigit(ch)) { | 230 } else if (isDigit(ch)) { |
| 231 return this.finishNumber(); | 231 return this.finishNumber(); |
| 232 } else { | 232 } else { |
| 233 return _errorToken(); | 233 return _errorToken(); |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 } | 237 } |
| 238 | 238 |
| 239 int getIdentifierKind() { | 239 int getIdentifierKind() { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 return TokenKind.IDENTIFIER; | 366 return TokenKind.IDENTIFIER; |
| 367 default: return TokenKind.IDENTIFIER; | 367 default: return TokenKind.IDENTIFIER; |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 | 370 |
| 371 } | 371 } |
| 372 | 372 |
| 373 /** Static helper methods. */ | 373 /** Static helper methods. */ |
| 374 class TokenizerHelpers { | 374 class TokenizerHelpers { |
| 375 | 375 |
| 376 static bool isIdentifierStart(int c) { | 376 static bool isIdentifierStart(int c) { |
|
jimhug
2011/11/18 17:05:29
This definition is now incorrect - if you want to
| |
| 377 return ((c >= 97/*a*/ && c <= 122/*z*/) || (c >= 65/*A*/ && c <= 90/*Z*/) || c == 95/*_*/); | 377 return ((c >= 97/*a*/ && c <= 122/*z*/) || (c >= 65/*A*/ && c <= 90/*Z*/) || c == 95/*_*/); |
| 378 } | 378 } |
| 379 | 379 |
| 380 static bool isDigit(int c) { | 380 static bool isDigit(int c) { |
| 381 return (c >= 48/*0*/ && c <= 57/*9*/); | 381 return (c >= 48/*0*/ && c <= 57/*9*/); |
| 382 } | 382 } |
| 383 | 383 |
| 384 static bool isHexDigit(int c) { | 384 static bool isHexDigit(int c) { |
| 385 return (isDigit(c) || (c >= 97/*a*/ && c <= 102/*f*/) || (c >= 65/*A*/ && c <= 70/*F*/)); | 385 return (isDigit(c) || (c >= 97/*a*/ && c <= 102/*f*/) || (c >= 65/*A*/ && c <= 70/*F*/)); |
| 386 } | 386 } |
| 387 | 387 |
| 388 static bool isWhitespace(int c) { | 388 static bool isWhitespace(int c) { |
| 389 return (c == 32/*' '*/ || c == 9/*'\t'*/ || c == 10/*'\n'*/ || c == 13/*'\r' */); | 389 return (c == 32/*' '*/ || c == 9/*'\t'*/ || c == 10/*'\n'*/ || c == 13/*'\r' */); |
| 390 } | 390 } |
| 391 | 391 |
| 392 static bool isIdentifierPart(int c) { | 392 static bool isIdentifierPart(int c) { |
| 393 return (isIdentifierStart(c) || isDigit(c) || c == 36/*$*/); | |
| 394 } | |
| 395 | |
| 396 static bool isInterpIdentifierPart(int c) { | |
|
jimhug
2011/11/18 17:05:29
FYI - I really hate this -but I can't fault you fo
| |
| 393 return (isIdentifierStart(c) || isDigit(c)); | 397 return (isIdentifierStart(c) || isDigit(c)); |
| 394 } | 398 } |
| 395 | 399 |
| 396 | 400 |
| 397 } | 401 } |
| OLD | NEW |