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

Side by Side Diff: frog/parser.dart

Issue 8739002: Frog: Fix parsing of hex literals with >31 bits (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: put issue# in comment 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 | « frog/frogsh ('k') | tests/language/src/NumberConstantFolding1Test.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 // TODO(jimhug): Error recovery needs major work! 5 // TODO(jimhug): Error recovery needs major work!
6 /** 6 /**
7 * A simple recursive descent parser for the dart language. 7 * A simple recursive descent parser for the dart language.
8 * 8 *
9 * This parser is designed to be more permissive than the official 9 * This parser is designed to be more permissive than the official
10 * Dart grammar. It is expected that many grammar errors would be 10 * Dart grammar. It is expected that many grammar errors would be
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 } else if (c >= 65/*A*/ && c <= 70/*F*/) { 1327 } else if (c >= 65/*A*/ && c <= 70/*F*/) {
1328 return c - 55; 1328 return c - 55;
1329 } else { 1329 } else {
1330 return -1; 1330 return -1;
1331 } 1331 }
1332 } 1332 }
1333 1333
1334 static int parseHex(String hex) { 1334 static int parseHex(String hex) {
1335 var result = 0; 1335 var result = 0;
1336 1336
1337 for (int i=0; i < hex.length; i++) { 1337 for (int i = 0; i < hex.length; i++) {
1338 var digit = _hexDigit(hex.charCodeAt(i)); 1338 var digit = _hexDigit(hex.charCodeAt(i));
1339 assert(digit != -1); 1339 assert(digit != -1);
1340 result = (result << 4) + digit; 1340 // Multiply by 16 rather than shift by 4 since that will result in a
1341 // correct value for numbers that exceed the 32 bit precision of JS
1342 // 'integers'.
1343 // TODO: Figure out a better solution to integer truncation. Issue 638.
1344 result = (result * 16) + digit;
1341 } 1345 }
1342 1346
1343 return result; 1347 return result;
1344 } 1348 }
1345 1349
1346 finishNewExpression(int start, bool isConst) { 1350 finishNewExpression(int start, bool isConst) {
1347 var type = type(); 1351 var type = type();
1348 var name = null; 1352 var name = null;
1349 if (_maybeEat(TokenKind.DOT)) { 1353 if (_maybeEat(TokenKind.DOT)) {
1350 name = identifier(); 1354 name = identifier();
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 int _pos = 0; 1686 int _pos = 0;
1683 next() { 1687 next() {
1684 var token = tokens[_pos]; 1688 var token = tokens[_pos];
1685 ++_pos; 1689 ++_pos;
1686 if (_pos == tokens.length) { 1690 if (_pos == tokens.length) {
1687 parser.tokenizer = previousTokenizer; 1691 parser.tokenizer = previousTokenizer;
1688 } 1692 }
1689 return token; 1693 return token;
1690 } 1694 }
1691 } 1695 }
OLDNEW
« no previous file with comments | « frog/frogsh ('k') | tests/language/src/NumberConstantFolding1Test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698