dc099c4a00
Review URL: https://chromiumcodereview.appspot.com//9873021 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5926 260f80e4-7a28-3924-810f-c04153c831b5
38 lines
1.2 KiB
Dart
38 lines
1.2 KiB
Dart
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
// 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.
|
|
|
|
/**
|
|
* Scanner that reads from a byte array and creates tokens that points
|
|
* to the same array.
|
|
*/
|
|
class ByteArrayScanner extends ArrayBasedScanner<ByteString> {
|
|
final List<int> bytes;
|
|
|
|
ByteArrayScanner(List<int> this.bytes) : super();
|
|
|
|
int nextByte() => byteAt(++byteOffset);
|
|
|
|
int peek() => byteAt(byteOffset + 1);
|
|
|
|
int byteAt(int index) => bytes[index];
|
|
|
|
AsciiString asciiString(int start, int offset) {
|
|
return AsciiString.of(bytes, start, byteOffset - start + offset);
|
|
}
|
|
|
|
Utf8String utf8String(int start, int offset) {
|
|
return Utf8String.of(bytes, start, byteOffset - start + offset + 1);
|
|
}
|
|
|
|
void appendByteStringToken(PrecedenceInfo info, ByteString value) {
|
|
tail.next = new ByteStringToken(info, value, tokenStart);
|
|
tail = tail.next;
|
|
}
|
|
|
|
// This method should be equivalent to the one in super. However,
|
|
// this is a *HOT* method and Dart VM performs better if it is easy
|
|
// to inline.
|
|
int advance() => bytes[++byteOffset];
|
|
}
|