Index: pkg/analyzer/lib/src/dart/scanner/scanner.dart |
diff --git a/pkg/analyzer/lib/src/generated/scanner.dart b/pkg/analyzer/lib/src/dart/scanner/scanner.dart |
similarity index 89% |
copy from pkg/analyzer/lib/src/generated/scanner.dart |
copy to pkg/analyzer/lib/src/dart/scanner/scanner.dart |
index 1d2ffe8b85cddaaa9f5038ddeb55ccebbede2a43..7814eb7fde0bbd75eccaceaea41adc547f4981c8 100644 |
--- a/pkg/analyzer/lib/src/generated/scanner.dart |
+++ b/pkg/analyzer/lib/src/dart/scanner/scanner.dart |
@@ -2,167 +2,15 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-library analyzer.src.generated.scanner; |
+library analyzer.src.dart.scanner.scanner; |
import 'package:analyzer/dart/ast/token.dart'; |
import 'package:analyzer/src/dart/ast/token.dart'; |
+import 'package:analyzer/src/dart/scanner/reader.dart'; |
import 'package:analyzer/src/generated/error.dart'; |
import 'package:analyzer/src/generated/java_engine.dart'; |
import 'package:analyzer/src/generated/source.dart'; |
-export 'package:analyzer/dart/ast/token.dart'; |
-export 'package:analyzer/src/dart/ast/token.dart' hide SimpleToken; |
- |
-/** |
- * A [CharacterReader] that reads a range of characters from another character |
- * reader. |
- */ |
-class CharacterRangeReader extends CharacterReader { |
- /** |
- * The reader from which the characters are actually being read. |
- */ |
- final CharacterReader baseReader; |
- |
- /** |
- * The last character to be read. |
- */ |
- final int endIndex; |
- |
- /** |
- * Initialize a newly created reader to read the characters from the given |
- * [baseReader] between the [startIndex] inclusive to [endIndex] exclusive. |
- */ |
- CharacterRangeReader(this.baseReader, int startIndex, this.endIndex) { |
- baseReader.offset = startIndex - 1; |
- } |
- |
- @override |
- int get offset => baseReader.offset; |
- |
- @override |
- void set offset(int offset) { |
- baseReader.offset = offset; |
- } |
- |
- @override |
- int advance() { |
- if (baseReader.offset + 1 >= endIndex) { |
- return -1; |
- } |
- return baseReader.advance(); |
- } |
- |
- @override |
- String getString(int start, int endDelta) => |
- baseReader.getString(start, endDelta); |
- |
- @override |
- int peek() { |
- if (baseReader.offset + 1 >= endIndex) { |
- return -1; |
- } |
- return baseReader.peek(); |
- } |
-} |
- |
-/** |
- * An object used by the scanner to read the characters to be scanned. |
- */ |
-abstract class CharacterReader { |
- /** |
- * The current offset relative to the beginning of the source. Return the |
- * initial offset if the scanner has not yet scanned the source code, and one |
- * (1) past the end of the source code if the entire source code has been |
- * scanned. |
- */ |
- int get offset; |
- |
- /** |
- * Set the current offset relative to the beginning of the source to the given |
- * [offset]. The new offset must be between the initial offset and one (1) |
- * past the end of the source code. |
- */ |
- void set offset(int offset); |
- |
- /** |
- * Advance the current position and return the character at the new current |
- * position. |
- */ |
- int advance(); |
- |
- /** |
- * Return the substring of the source code between the [start] offset and the |
- * modified current position. The current position is modified by adding the |
- * [endDelta], which is the number of characters after the current location to |
- * be included in the string, or the number of characters before the current |
- * location to be excluded if the offset is negative. |
- */ |
- String getString(int start, int endDelta); |
- |
- /** |
- * Return the character at the current position without changing the current |
- * position. |
- */ |
- int peek(); |
-} |
- |
-/** |
- * A [CharacterReader] that reads characters from a character sequence. |
- */ |
-class CharSequenceReader implements CharacterReader { |
- /** |
- * The sequence from which characters will be read. |
- */ |
- final String _sequence; |
- |
- /** |
- * The number of characters in the string. |
- */ |
- int _stringLength = 0; |
- |
- /** |
- * The index, relative to the string, of the last character that was read. |
- */ |
- int _charOffset = 0; |
- |
- /** |
- * Initialize a newly created reader to read the characters in the given |
- * [_sequence]. |
- */ |
- CharSequenceReader(this._sequence) { |
- this._stringLength = _sequence.length; |
- this._charOffset = -1; |
- } |
- |
- @override |
- int get offset => _charOffset; |
- |
- @override |
- void set offset(int offset) { |
- _charOffset = offset; |
- } |
- |
- @override |
- int advance() { |
- if (_charOffset + 1 >= _stringLength) { |
- return -1; |
- } |
- return _sequence.codeUnitAt(++_charOffset); |
- } |
- |
- @override |
- String getString(int start, int endDelta) => |
- _sequence.substring(start, _charOffset + 1 + endDelta).toString(); |
- |
- @override |
- int peek() { |
- if (_charOffset + 1 >= _stringLength) { |
- return -1; |
- } |
- return _sequence.codeUnitAt(_charOffset + 1); |
- } |
-} |
- |
/** |
* A state in a state machine used to scan keywords. |
*/ |
@@ -1525,35 +1373,3 @@ class ScannerErrorCode extends ErrorCode { |
@override |
ErrorType get type => ErrorType.SYNTACTIC_ERROR; |
} |
- |
-/** |
- * A [CharacterReader] that reads characters from a character sequence, but adds |
- * a delta when reporting the current character offset so that the character |
- * sequence can be a subsequence from a larger sequence. |
- */ |
-class SubSequenceReader extends CharSequenceReader { |
- /** |
- * The offset from the beginning of the file to the beginning of the source |
- * being scanned. |
- */ |
- final int _offsetDelta; |
- |
- /** |
- * Initialize a newly created reader to read the characters in the given |
- * [sequence]. The [_offsetDelta] is the offset from the beginning of the file |
- * to the beginning of the source being scanned |
- */ |
- SubSequenceReader(String sequence, this._offsetDelta) : super(sequence); |
- |
- @override |
- int get offset => _offsetDelta + super.offset; |
- |
- @override |
- void set offset(int offset) { |
- super.offset = offset - _offsetDelta; |
- } |
- |
- @override |
- String getString(int start, int endDelta) => |
- super.getString(start - _offsetDelta, endDelta); |
-} |