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

Side by Side Diff: frog/tokenizer.dart

Issue 8457007: Better runtime type checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged, and fix typo in member name Created 9 years, 1 month 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 // Generated by scripts/tokenizer_gen.py. 4 // Generated by scripts/tokenizer_gen.py.
5 5
6 class InterpStack { 6 class InterpStack {
7 InterpStack next, previous; 7 InterpStack next, previous;
8 final int quote; 8 final int quote;
9 final bool isMultiline; 9 final bool isMultiline;
10 int depth; 10 int depth;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 bool maybeEatHexDigit() { 179 bool maybeEatHexDigit() {
180 if (_index < _text.length && isHexDigit(_text.charCodeAt(_index))) { 180 if (_index < _text.length && isHexDigit(_text.charCodeAt(_index))) {
181 _index++; 181 _index++;
182 return true; 182 return true;
183 } 183 }
184 return false; 184 return false;
185 } 185 }
186 186
187 Token finishHex() { 187 Token finishHex() {
188 eatHexDigits(); 188 eatHexDigits();
189 return _finishToken(TokenKind.HEX_NUMBER); 189 return _finishToken(TokenKind.HEX_INTEGER);
190 } 190 }
191 191
192 Token finishNumber() { 192 Token finishNumber() {
193 eatDigits(); 193 eatDigits();
194 194
195 if (_peekChar() == 46/*.*/) { 195 if (_peekChar() == 46/*.*/) {
196 // Handle the case of 1.toString(). 196 // Handle the case of 1.toString().
197 _nextChar(); 197 _nextChar();
198 if (isDigit(_peekChar())) { 198 if (isDigit(_peekChar())) {
199 eatDigits(); 199 eatDigits();
200 return finishNumberExtra(TokenKind.DOUBLE);
200 } else { 201 } else {
201 _index--; 202 _index--;
202 } 203 }
203 } 204 }
204 205
205 return finishNumberExtra(); 206 return finishNumberExtra(TokenKind.INTEGER);
206 } 207 }
207 208
208 Token finishNumberExtra() { 209 Token finishNumberExtra(int kind) {
209 if (_maybeEatChar(101/*e*/) || _maybeEatChar(69/*E*/)) { 210 if (_maybeEatChar(101/*e*/) || _maybeEatChar(69/*E*/)) {
211 kind = TokenKind.DOUBLE;
210 _maybeEatChar(45/*-*/); 212 _maybeEatChar(45/*-*/);
211 _maybeEatChar(43/*+*/); 213 _maybeEatChar(43/*+*/);
212 eatDigits(); 214 eatDigits();
213 } 215 }
214 if (_peekChar() != 0 && isIdentifierStart(_peekChar())) { 216 if (_peekChar() != 0 && isIdentifierStart(_peekChar())) {
215 _nextChar(); 217 _nextChar();
216 // numbers cannot contain identifiers 218 // numbers cannot contain identifiers
217 return _errorToken(); 219 return _errorToken();
218 } 220 }
219 221
220 return _finishToken(TokenKind.NUMBER); 222 return _finishToken(kind);
221 } 223 }
222 224
223 Token finishMultilineString(int quote) { 225 Token finishMultilineString(int quote) {
224 while (true) { 226 while (true) {
225 int ch = _nextChar(); 227 int ch = _nextChar();
226 if (ch == 0) { 228 if (ch == 0) {
227 final kind = quote == 34/*"*/ ? 229 final kind = quote == 34/*"*/ ?
228 TokenKind.INCOMPLETE_MULTILINE_STRING_DQ : 230 TokenKind.INCOMPLETE_MULTILINE_STRING_DQ :
229 TokenKind.INCOMPLETE_MULTILINE_STRING_SQ; 231 TokenKind.INCOMPLETE_MULTILINE_STRING_SQ;
230 return _finishToken(kind); 232 return _finishToken(kind);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // According to the Unicode standard the high and low surrogate halves 362 // According to the Unicode standard the high and low surrogate halves
361 // used by UTF-16 (U+D800 through U+DFFF) and values above U+10FFFF 363 // used by UTF-16 (U+D800 through U+DFFF) and values above U+10FFFF
362 // are not legal Unicode values. 364 // are not legal Unicode values.
363 num n = Parser.parseHex(hex); 365 num n = Parser.parseHex(hex);
364 return n < 0xD800 || n > 0xDFFF && n <= 0x10FFFF; 366 return n < 0xD800 || n > 0xDFFF && n <= 0x10FFFF;
365 } 367 }
366 368
367 Token finishDot() { 369 Token finishDot() {
368 if (isDigit(_peekChar())) { 370 if (isDigit(_peekChar())) {
369 eatDigits(); 371 eatDigits();
370 return finishNumberExtra(); 372 return finishNumberExtra(TokenKind.DOUBLE);
371 } else { 373 } else {
372 return _finishToken(TokenKind.DOT); 374 return _finishToken(TokenKind.DOT);
373 } 375 }
374 } 376 }
375 377
376 Token finishIdentifier() { 378 Token finishIdentifier() {
377 while (_index < _text.length) { 379 while (_index < _text.length) {
378 if (!isIdentifierPart(_text.charCodeAt(_index++))) { 380 if (!isIdentifierPart(_text.charCodeAt(_index++))) {
379 _index--; 381 _index--;
380 break; 382 break;
381 } 383 }
382 } 384 }
383 int kind = getIdentifierKind(); 385 int kind = getIdentifierKind();
384 if (_interpStack != null && _interpStack.depth == -1) { 386 if (_interpStack != null && _interpStack.depth == -1) {
385 _interpStack.depth = 0; 387 _interpStack.depth = 0;
386 } 388 }
387 if (kind == TokenKind.IDENTIFIER) { 389 if (kind == TokenKind.IDENTIFIER) {
388 return _finishToken(TokenKind.IDENTIFIER); 390 return _finishToken(TokenKind.IDENTIFIER);
389 } else { 391 } else {
390 return _finishToken(kind); 392 return _finishToken(kind);
391 } 393 }
392 } 394 }
393 } 395 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698