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

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

Issue 9190038: Handle escapes in string literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 months 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
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 final int EOF_TOKEN = 0; 5 final int EOF_TOKEN = 0;
6 6
7 final int KEYWORD_TOKEN = $k; 7 final int KEYWORD_TOKEN = $k;
8 final int IDENTIFIER_TOKEN = $a; 8 final int IDENTIFIER_TOKEN = $a;
9 final int DOUBLE_TOKEN = $d; 9 final int DOUBLE_TOKEN = $d;
10 final int INT_TOKEN = $i; 10 final int INT_TOKEN = $i;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 String toString() => value.toString(); 122 String toString() => value.toString();
123 } 123 }
124 124
125 interface SourceString extends Hashable default StringWrapper { 125 interface SourceString extends Hashable default StringWrapper {
126 const SourceString(String string); 126 const SourceString(String string);
127 127
128 int get length(); 128 int get length();
129 129
130 void printOn(StringBuffer sb); 130 void printOn(StringBuffer sb);
131 void printSubstringOn(StringBuffer sb, int from, int to);
132
133 int charCodeAt(int i);
134 String operator[](int index);
131 135
132 String get stringValue(); 136 String get stringValue();
133 } 137 }
134 138
135 class StringWrapper implements SourceString { 139 class StringWrapper implements SourceString {
136 final String stringValue; 140 final String stringValue;
137 141
138 const StringWrapper(String this.stringValue); 142 const StringWrapper(String this.stringValue);
139 143
140 int hashCode() => stringValue.hashCode(); 144 int hashCode() => stringValue.hashCode();
141 145
142 bool operator ==(other) { 146 bool operator ==(other) {
143 return other is SourceString && toString() == other.toString(); 147 return other is SourceString && toString() == other.toString();
144 } 148 }
145 149
146 int get length() => stringValue.length; 150 int get length() => stringValue.length;
147 151
148 void printOn(StringBuffer sb) { 152 void printOn(StringBuffer sb) {
149 sb.add(stringValue); 153 sb.add(stringValue);
150 } 154 }
151 155
156 void printSubstringOn(StringBuffer sb, int from, int to) {
157 if (from >= to) return;
158 sb.add(stringValue.substring(from, to));
159 }
160
161 int charCodeAt(int index) => stringValue.charCodeAt(index);
162 String operator[](int index) => stringValue[index];
163
152 String toString() => stringValue; 164 String toString() => stringValue;
153 } 165 }
154 166
155 class BeginGroupToken extends StringToken { 167 class BeginGroupToken extends StringToken {
156 Token endGroup; 168 Token endGroup;
157 BeginGroupToken(PrecedenceInfo info, String value, int charOffset) 169 BeginGroupToken(PrecedenceInfo info, String value, int charOffset)
158 : super(info, value, charOffset); 170 : super(info, value, charOffset);
159 } 171 }
160 172
161 class PrecedenceInfo { 173 class PrecedenceInfo {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 367
356 final PrecedenceInfo DOUBLE_INFO = 368 final PrecedenceInfo DOUBLE_INFO =
357 const PrecedenceInfo(const SourceString('double'), 0, DOUBLE_TOKEN); 369 const PrecedenceInfo(const SourceString('double'), 0, DOUBLE_TOKEN);
358 370
359 final PrecedenceInfo STRING_INTERPOLATION_INFO = 371 final PrecedenceInfo STRING_INTERPOLATION_INFO =
360 const PrecedenceInfo(const SourceString('\${'), 0, 372 const PrecedenceInfo(const SourceString('\${'), 0,
361 STRING_INTERPOLATION_TOKEN); 373 STRING_INTERPOLATION_TOKEN);
362 374
363 final PrecedenceInfo HEXADECIMAL_INFO = 375 final PrecedenceInfo HEXADECIMAL_INFO =
364 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); 376 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698