| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:charcode/ascii.dart'; | 5 import 'package:charcode/ascii.dart'; |
| 6 import 'package:front_end/src/scanner/errors.dart'; | 6 import 'package:front_end/src/scanner/errors.dart'; |
| 7 import 'package:front_end/src/scanner/reader.dart'; | 7 import 'package:front_end/src/scanner/reader.dart'; |
| 8 import 'package:front_end/src/scanner/string_utilities.dart'; | 8 import 'package:front_end/src/scanner/string_utilities.dart'; |
| 9 import 'package:front_end/src/scanner/token.dart'; | 9 import 'package:front_end/src/scanner/token.dart'; |
| 10 | 10 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 * A flag indicating whether the lazy compound assignment operators '&&=' and | 202 * A flag indicating whether the lazy compound assignment operators '&&=' and |
| 203 * '||=' are enabled. | 203 * '||=' are enabled. |
| 204 */ | 204 */ |
| 205 bool scanLazyAssignmentOperators = false; | 205 bool scanLazyAssignmentOperators = false; |
| 206 | 206 |
| 207 /** | 207 /** |
| 208 * Initialize a newly created scanner to scan characters from the given | 208 * Initialize a newly created scanner to scan characters from the given |
| 209 * character [_reader]. | 209 * character [_reader]. |
| 210 */ | 210 */ |
| 211 Scanner.create(this._reader) { | 211 Scanner.create(this._reader) { |
| 212 _tokens = new Token(TokenType.EOF, -1); | 212 _tokens = new Token.eof(-1); |
| 213 _tokens.setNext(_tokens); | |
| 214 _tail = _tokens; | 213 _tail = _tokens; |
| 215 _tokenStart = -1; | 214 _tokenStart = -1; |
| 216 _lineStarts.add(0); | 215 _lineStarts.add(0); |
| 217 } | 216 } |
| 218 | 217 |
| 219 /** | 218 /** |
| 220 * Return the first token in the token stream that was scanned. | 219 * Return the first token in the token stream that was scanned. |
| 221 */ | 220 */ |
| 222 Token get firstToken => _tokens.next; | 221 Token get firstToken => _tokens.next; |
| 223 | 222 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 if (begin.type == beginType) { | 537 if (begin.type == beginType) { |
| 539 begin.endToken = token; | 538 begin.endToken = token; |
| 540 _groupingStack.removeAt(_stackEnd--); | 539 _groupingStack.removeAt(_stackEnd--); |
| 541 } | 540 } |
| 542 } | 541 } |
| 543 } | 542 } |
| 544 | 543 |
| 545 void _appendEofToken() { | 544 void _appendEofToken() { |
| 546 Token eofToken; | 545 Token eofToken; |
| 547 if (_firstComment == null) { | 546 if (_firstComment == null) { |
| 548 eofToken = new Token(TokenType.EOF, _reader.offset + 1); | 547 eofToken = new Token.eof(_reader.offset + 1); |
| 549 } else { | 548 } else { |
| 550 eofToken = new TokenWithComment( | 549 eofToken = new Token.eof(_reader.offset + 1, _firstComment); |
| 551 TokenType.EOF, _reader.offset + 1, _firstComment); | |
| 552 _firstComment = null; | 550 _firstComment = null; |
| 553 _lastComment = null; | 551 _lastComment = null; |
| 554 } | 552 } |
| 555 // The EOF token points to itself so that there is always infinite | 553 // The EOF token points to itself so that there is always infinite |
| 556 // look-ahead. | 554 // look-ahead. |
| 557 eofToken.setNext(eofToken); | 555 eofToken.setNext(eofToken); |
| 558 _tail = _tail.setNext(eofToken); | 556 _tail = _tail.setNext(eofToken); |
| 559 if (_stackEnd >= 0) { | 557 if (_stackEnd >= 0) { |
| 560 _hasUnmatchedGroups = true; | 558 _hasUnmatchedGroups = true; |
| 561 // TODO(brianwilkerson) Fix the ungrouped tokens? | 559 // TODO(brianwilkerson) Fix the ungrouped tokens? |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 } | 1334 } |
| 1337 | 1335 |
| 1338 /** | 1336 /** |
| 1339 * Checks if [value] is a single-line or multi-line comment. | 1337 * Checks if [value] is a single-line or multi-line comment. |
| 1340 */ | 1338 */ |
| 1341 static bool _isDocumentationComment(String value) { | 1339 static bool _isDocumentationComment(String value) { |
| 1342 return StringUtilities.startsWith3(value, 0, $slash, $slash, $slash) || | 1340 return StringUtilities.startsWith3(value, 0, $slash, $slash, $slash) || |
| 1343 StringUtilities.startsWith3(value, 0, $slash, $asterisk, $asterisk); | 1341 StringUtilities.startsWith3(value, 0, $slash, $asterisk, $asterisk); |
| 1344 } | 1342 } |
| 1345 } | 1343 } |
| OLD | NEW |