| 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. | |
| 41 final bool includeComments; | 40 final bool includeComments; |
| 42 | 41 |
| 43 /** | 42 /** |
| 44 * The string offset for the next token that will be created. | 43 * The string offset for the next token that will be created. |
| 45 * | 44 * |
| 46 * Note that in the [Utf8BytesScanner], [stringOffset] and [scanOffset] values | 45 * Note that in the [Utf8BytesScanner], [stringOffset] and [scanOffset] values |
| 47 * are different. One string character can be encoded using multiple UTF-8 | 46 * are different. One string character can be encoded using multiple UTF-8 |
| 48 * bytes. | 47 * bytes. |
| 49 */ | 48 */ |
| 50 int tokenStart = -1; | 49 int tokenStart = -1; |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 if (next < 0x1f) { | 401 if (next < 0x1f) { |
| 403 return unexpected(next); | 402 return unexpected(next); |
| 404 } | 403 } |
| 405 | 404 |
| 406 next = currentAsUnicode(next); | 405 next = currentAsUnicode(next); |
| 407 | 406 |
| 408 return unexpected(next); | 407 return unexpected(next); |
| 409 } | 408 } |
| 410 | 409 |
| 411 int tokenizeTag(int next) { | 410 int tokenizeTag(int next) { |
| 412 // #!.*[\n\r] | 411 // # or #!.*[\n\r] |
| 413 if (scanOffset == 0 && identical(peek(), $BANG)) { | 412 if (scanOffset == 0) { |
| 414 tokenizeSingleLineComment(next, scanOffset); | 413 if (identical(peek(), $BANG)) { |
| 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 } |
| 415 } | 425 } |
| 416 appendPrecedenceToken(HASH_INFO); | 426 appendPrecedenceToken(HASH_INFO); |
| 417 return advance(); | 427 return advance(); |
| 418 } | 428 } |
| 419 | 429 |
| 420 int tokenizeTilde(int next) { | 430 int tokenizeTilde(int next) { |
| 421 // ~ ~/ ~/= | 431 // ~ ~/ ~/= |
| 422 next = advance(); | 432 next = advance(); |
| 423 if (identical(next, $SLASH)) { | 433 if (identical(next, $SLASH)) { |
| 424 return select($EQ, TILDE_SLASH_EQ_INFO, TILDE_SLASH_INFO); | 434 return select($EQ, TILDE_SLASH_EQ_INFO, TILDE_SLASH_INFO); |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 switchToUint32(newLength); | 1252 switchToUint32(newLength); |
| 1243 } | 1253 } |
| 1244 } | 1254 } |
| 1245 | 1255 |
| 1246 void switchToUint32(int newLength) { | 1256 void switchToUint32(int newLength) { |
| 1247 final newArray = new Uint32List(newLength); | 1257 final newArray = new Uint32List(newLength); |
| 1248 newArray.setRange(0, arrayLength, array); | 1258 newArray.setRange(0, arrayLength, array); |
| 1249 array = newArray; | 1259 array = newArray; |
| 1250 } | 1260 } |
| 1251 } | 1261 } |
| OLD | NEW |