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

Side by Side Diff: frog/parser.dart

Issue 8849001: frog: use type annotation in map and list literals (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: '' 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
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 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 } 1444 }
1445 } 1445 }
1446 return new MapExpression(isConst, type, items, _makeSpan(start)); 1446 return new MapExpression(isConst, type, items, _makeSpan(start));
1447 } 1447 }
1448 1448
1449 finishTypedLiteral(int start, bool isConst) { 1449 finishTypedLiteral(int start, bool isConst) {
1450 var span = _makeSpan(start); 1450 var span = _makeSpan(start);
1451 var typeToBeNamedLater = new NameTypeReference(false, null, null, span); 1451 var typeToBeNamedLater = new NameTypeReference(false, null, null, span);
1452 var genericType = addTypeArguments(typeToBeNamedLater, 0); 1452 var genericType = addTypeArguments(typeToBeNamedLater, 0);
1453 1453
1454 // TODO(jimhug): Fill in correct typeToBeNamedLater details...
1455 if (_peekKind(TokenKind.LBRACK) || _peekKind(TokenKind.INDEX)) { 1454 if (_peekKind(TokenKind.LBRACK) || _peekKind(TokenKind.INDEX)) {
1455 genericType.baseType = new TypeReference(span, world.listType);
1456 return finishListLiteral(start, isConst, genericType); 1456 return finishListLiteral(start, isConst, genericType);
1457 } else if (_peekKind(TokenKind.LBRACE)) { 1457 } else if (_peekKind(TokenKind.LBRACE)) {
1458 genericType.baseType = new TypeReference(span, world.mapType);
1459 if (genericType.typeArguments.length != 1) {
Jennifer Messerly 2011/12/08 02:13:26 probably worth pulling "genericType.typeArguments"
Siggi Cherem (dart-lang) 2011/12/08 23:02:15 Done.
1460 _error('a map literal takes one type argument specfying the value type',
Jennifer Messerly 2011/12/08 02:13:26 I hope we follow up with the spec here. This curre
Siggi Cherem (dart-lang) 2011/12/08 23:02:15 Added TODO. Good news is that the spec actually ha
1461 genericType.typeArguments.length == 0
1462 ? genericType.typeArguments.span
1463 : genericType.typeArguments[1].span);
1464 }
1465 genericType.typeArguments = [new TypeReference(span, world.stringType),
1466 genericType.typeArguments[0]];
1458 return finishMapLiteral(start, isConst, genericType); 1467 return finishMapLiteral(start, isConst, genericType);
1459 } else { 1468 } else {
1460 _errorExpected('array or map literal'); 1469 _errorExpected('array or map literal');
1461 } 1470 }
1462 } 1471 }
1463 1472
1464 /////////////////////////////////////////////////////////////////// 1473 ///////////////////////////////////////////////////////////////////
1465 // Some auxilary productions. 1474 // Some auxilary productions.
1466 /////////////////////////////////////////////////////////////////// 1475 ///////////////////////////////////////////////////////////////////
1467 _readModifiers() { 1476 _readModifiers() {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 int _pos = 0; 1751 int _pos = 0;
1743 next() { 1752 next() {
1744 var token = tokens[_pos]; 1753 var token = tokens[_pos];
1745 ++_pos; 1754 ++_pos;
1746 if (_pos == tokens.length) { 1755 if (_pos == tokens.length) {
1747 parser.tokenizer = previousTokenizer; 1756 parser.tokenizer = previousTokenizer;
1748 } 1757 }
1749 return token; 1758 return token;
1750 } 1759 }
1751 } 1760 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698