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

Side by Side Diff: frog/parser.dart

Issue 8763001: Fix names with '$' to not conflict with operators or internal helpers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged again 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/member.dart ('k') | frog/scripts/token_info.py » ('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 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 break; 1264 break;
1265 case TokenKind.THIS: 1265 case TokenKind.THIS:
1266 _eat(TokenKind.THIS); 1266 _eat(TokenKind.THIS);
1267 _eat(TokenKind.DOT); 1267 _eat(TokenKind.DOT);
1268 name = 'this.${identifier().name}'; 1268 name = 'this.${identifier().name}';
1269 break; 1269 break;
1270 case TokenKind.GET: 1270 case TokenKind.GET:
1271 if (!includeOperators) return null; 1271 if (!includeOperators) return null;
1272 _eat(TokenKind.GET); 1272 _eat(TokenKind.GET);
1273 if (_peekIdentifier()) { 1273 if (_peekIdentifier()) {
1274 name = 'get\$${identifier().name}'; 1274 name = 'get:${identifier().name}';
1275 } else { 1275 } else {
1276 name = 'get'; 1276 name = 'get';
1277 } 1277 }
1278 break; 1278 break;
1279 case TokenKind.SET: 1279 case TokenKind.SET:
1280 if (!includeOperators) return null; 1280 if (!includeOperators) return null;
1281 _eat(TokenKind.SET); 1281 _eat(TokenKind.SET);
1282 if (_peekIdentifier()) { 1282 if (_peekIdentifier()) {
1283 name = 'set\$${identifier().name}'; 1283 name = 'set:${identifier().name}';
1284 } else { 1284 } else {
1285 name = 'set'; 1285 name = 'set';
1286 } 1286 }
1287 break; 1287 break;
1288 case TokenKind.OPERATOR: 1288 case TokenKind.OPERATOR:
1289 if (!includeOperators) return null; 1289 if (!includeOperators) return null;
1290 _eat(TokenKind.OPERATOR); 1290 _eat(TokenKind.OPERATOR);
1291 var kind = _peek(); 1291 var kind = _peek();
1292 if (kind == TokenKind.NEGATE) { 1292 if (kind == TokenKind.NEGATE) {
1293 name = '\$negate'; 1293 name = ':negate';
1294 _next(); 1294 _next();
1295 } else { 1295 } else {
1296 name = TokenKind.binaryMethodName(kind); 1296 name = TokenKind.binaryMethodName(kind);
1297 if (name == null) { 1297 if (name == null) {
1298 // TODO(jimhug): This is a very useful error, but we have to 1298 // TODO(jimhug): This is a very useful error, but we have to
1299 // lose it because operator is a pseudo-keyword... 1299 // lose it because operator is a pseudo-keyword...
1300 //_errorExpected('legal operator name, but found: ${tok}'); 1300 //_errorExpected('legal operator name, but found: ${tok}');
1301 name = 'operator'; 1301 name = 'operator';
1302 } else { 1302 } else {
1303 _next(); 1303 _next();
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 int _pos = 0; 1700 int _pos = 0;
1701 next() { 1701 next() {
1702 var token = tokens[_pos]; 1702 var token = tokens[_pos];
1703 ++_pos; 1703 ++_pos;
1704 if (_pos == tokens.length) { 1704 if (_pos == tokens.length) {
1705 parser.tokenizer = previousTokenizer; 1705 parser.tokenizer = previousTokenizer;
1706 } 1706 }
1707 return token; 1707 return token;
1708 } 1708 }
1709 } 1709 }
OLDNEW
« no previous file with comments | « frog/member.dart ('k') | frog/scripts/token_info.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698