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

Side by Side Diff: dart/frog/leg/scanner/string_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/scanner.dart ('k') | dart/frog/leg/scanner/token.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 String and creates tokens that points to 6 * Scanner that reads from a String and creates tokens that points to
7 * substrings. 7 * substrings.
8 */ 8 */
9 class StringScanner extends ArrayBasedScanner<SourceString> { 9 class StringScanner extends ArrayBasedScanner<SourceString> {
10 final String string; 10 final String string;
11 11
12 StringScanner(String this.string) : super(); 12 StringScanner(String this.string) : super();
13 13
14 int nextByte() => charAt(++byteOffset); 14 int nextByte() => charAt(++byteOffset);
15 15
16 int peek() => charAt(byteOffset + 1); 16 int peek() => charAt(byteOffset + 1);
17 17
18 int charAt(index) 18 int charAt(index)
19 => (string.length > index) ? string.charCodeAt(index) : $EOF; 19 => (string.length > index) ? string.charCodeAt(index) : $EOF;
20 20
21 SourceString asciiString(int start) { 21 SourceString asciiString(int start, int offset) {
22 return new SubstringWrapper(string, start, byteOffset); 22 return new SubstringWrapper(string, start, byteOffset + offset);
23 } 23 }
24 24
25 SourceString utf8String(int start, int offset) { 25 SourceString utf8String(int start, int offset) {
26 return new SubstringWrapper(string, start, byteOffset + offset + 1); 26 return new SubstringWrapper(string, start, byteOffset + offset + 1);
27 } 27 }
28 28
29 void appendByteStringToken(int kind, SourceString value) { 29 void appendByteStringToken(int kind, SourceString value) {
30 // assert(kind != $a || keywords.get(value) == null); 30 // assert(kind != $a || keywords.get(value) == null);
31 tail.next = new StringToken.fromSource(kind, value, tokenStart); 31 tail.next = new StringToken.fromSource(kind, value, tokenStart);
32 tail = tail.next; 32 tail = tail.next;
(...skipping 15 matching lines...) Expand all
48 } 48 }
49 49
50 void printOn(StringBuffer sb) { 50 void printOn(StringBuffer sb) {
51 sb.add(this); 51 sb.add(this);
52 } 52 }
53 53
54 String toString() => internalString.substring(begin, end); 54 String toString() => internalString.substring(begin, end);
55 55
56 String get stringValue() => toString(); 56 String get stringValue() => toString();
57 } 57 }
OLDNEW
« no previous file with comments | « dart/frog/leg/scanner/scanner.dart ('k') | dart/frog/leg/scanner/token.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698