| 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 library fasta.scanner.abstract_scanner; | 5 library fasta.scanner.abstract_scanner; |
| 6 | 6 |
| 7 import 'dart:collection' show | 7 import 'dart:collection' show |
| 8 ListMixin; | 8 ListMixin; |
| 9 | 9 |
| 10 import 'dart:typed_data' show | 10 import 'dart:typed_data' show |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 BeginGroupToken, | 30 BeginGroupToken, |
| 31 KeywordToken, | 31 KeywordToken, |
| 32 SymbolToken, | 32 SymbolToken, |
| 33 Token; | 33 Token; |
| 34 | 34 |
| 35 import 'token_constants.dart'; | 35 import 'token_constants.dart'; |
| 36 | 36 |
| 37 import 'characters.dart'; | 37 import 'characters.dart'; |
| 38 | 38 |
| 39 abstract class AbstractScanner implements Scanner { | 39 abstract class AbstractScanner implements Scanner { |
| 40 /// If true, include comments in the token stream. |
| 40 final bool includeComments; | 41 final bool includeComments; |
| 41 | 42 |
| 42 /** | 43 /** |
| 43 * The string offset for the next token that will be created. | 44 * The string offset for the next token that will be created. |
| 44 * | 45 * |
| 45 * Note that in the [Utf8BytesScanner], [stringOffset] and [scanOffset] values | 46 * Note that in the [Utf8BytesScanner], [stringOffset] and [scanOffset] values |
| 46 * are different. One string character can be encoded using multiple UTF-8 | 47 * are different. One string character can be encoded using multiple UTF-8 |
| 47 * bytes. | 48 * bytes. |
| 48 */ | 49 */ |
| 49 int tokenStart = -1; | 50 int tokenStart = -1; |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 if (next < 0x1f) { | 402 if (next < 0x1f) { |
| 402 return unexpected(next); | 403 return unexpected(next); |
| 403 } | 404 } |
| 404 | 405 |
| 405 next = currentAsUnicode(next); | 406 next = currentAsUnicode(next); |
| 406 | 407 |
| 407 return unexpected(next); | 408 return unexpected(next); |
| 408 } | 409 } |
| 409 | 410 |
| 410 int tokenizeTag(int next) { | 411 int tokenizeTag(int next) { |
| 411 // # or #!.*[\n\r] | 412 // #!.*[\n\r] |
| 412 if (scanOffset == 0) { | 413 if (scanOffset == 0 && identical(peek(), $BANG)) { |
| 413 if (identical(peek(), $BANG)) { | 414 tokenizeSingleLineComment(next, scanOffset); |
| 414 int start = scanOffset + 1; | |
| 415 bool asciiOnly = true; | |
| 416 do { | |
| 417 next = advance(); | |
| 418 if (next > 127) asciiOnly = false; | |
| 419 } while (!identical(next, $LF) && | |
| 420 !identical(next, $CR) && | |
| 421 !identical(next, $EOF)); | |
| 422 if (!asciiOnly) handleUnicode(start); | |
| 423 return next; | |
| 424 } | |
| 425 } | 415 } |
| 426 appendPrecedenceToken(HASH_INFO); | 416 appendPrecedenceToken(HASH_INFO); |
| 427 return advance(); | 417 return advance(); |
| 428 } | 418 } |
| 429 | 419 |
| 430 int tokenizeTilde(int next) { | 420 int tokenizeTilde(int next) { |
| 431 // ~ ~/ ~/= | 421 // ~ ~/ ~/= |
| 432 next = advance(); | 422 next = advance(); |
| 433 if (identical(next, $SLASH)) { | 423 if (identical(next, $SLASH)) { |
| 434 return select($EQ, TILDE_SLASH_EQ_INFO, TILDE_SLASH_INFO); | 424 return select($EQ, TILDE_SLASH_EQ_INFO, TILDE_SLASH_INFO); |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 switchToUint32(newLength); | 1242 switchToUint32(newLength); |
| 1253 } | 1243 } |
| 1254 } | 1244 } |
| 1255 | 1245 |
| 1256 void switchToUint32(int newLength) { | 1246 void switchToUint32(int newLength) { |
| 1257 final newArray = new Uint32List(newLength); | 1247 final newArray = new Uint32List(newLength); |
| 1258 newArray.setRange(0, arrayLength, array); | 1248 newArray.setRange(0, arrayLength, array); |
| 1259 array = newArray; | 1249 array = newArray; |
| 1260 } | 1250 } |
| 1261 } | 1251 } |
| OLD | NEW |