Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: dart/frog/leg/scanner/byte_array_scanner.dart

Issue 8805008: Various scanner fixes: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased and update language.status Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/frog/leg/scanner/array_based_scanner.dart ('k') | dart/frog/leg/scanner/characters.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * Scanner that reads from a byte array and creates tokens that points 6 * Scanner that reads from a byte array and creates tokens that points
7 * to the same array. 7 * to the same array.
8 */ 8 */
9 class ByteArrayScanner extends ArrayBasedScanner<ByteString> { 9 class ByteArrayScanner extends ArrayBasedScanner<ByteString> {
10 final List<int> bytes; 10 final List<int> bytes;
11 11
12 ByteArrayScanner(List<int> this.bytes) : super(); 12 ByteArrayScanner(List<int> this.bytes) : super();
13 13
14 int nextByte() => byteAt(++byteOffset); 14 int nextByte() => byteAt(++byteOffset);
15 15
16 int peek() => byteAt(byteOffset + 1); 16 int peek() => byteAt(byteOffset + 1);
17 17
18 int byteAt(int index) => bytes[index]; 18 int byteAt(int index) => bytes[index];
19 19
20 AsciiString asciiString(int start) { 20 AsciiString asciiString(int start, int offset) {
21 return AsciiString.of(bytes, start, byteOffset - start); 21 return AsciiString.of(bytes, start, byteOffset - start + offset);
22 } 22 }
23 23
24 Utf8String utf8String(int start, int offset) { 24 Utf8String utf8String(int start, int offset) {
25 return Utf8String.of(bytes, start, byteOffset - start + offset + 1); 25 return Utf8String.of(bytes, start, byteOffset - start + offset + 1);
26 } 26 }
27 27
28 void appendByteStringToken(int kind, ByteString value) { 28 void appendByteStringToken(int kind, ByteString value) {
29 // assert(kind != $a || keywords.get(value) == null); 29 // assert(kind != $a || keywords.get(value) == null);
30 tail.next = new ByteStringToken(kind, value, tokenStart); 30 tail.next = new ByteStringToken(kind, value, tokenStart);
31 tail = tail.next; 31 tail = tail.next;
32 } 32 }
33 33
34 // This method should be equivalent to the one in super. However, 34 // This method should be equivalent to the one in super. However,
35 // this is a *HOT* method and Dart VM performs better if it is easy 35 // this is a *HOT* method and Dart VM performs better if it is easy
36 // to inline. 36 // to inline.
37 int advance() => bytes[++byteOffset]; 37 int advance() => bytes[++byteOffset];
38 } 38 }
OLDNEW
« no previous file with comments | « dart/frog/leg/scanner/array_based_scanner.dart ('k') | dart/frog/leg/scanner/characters.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698