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

Unified Diff: frog/parser.dart

Issue 9139062: fix pseudo keyword test failues (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « frog/minfrog ('k') | frog/scripts/token_info.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/parser.dart
diff --git a/frog/parser.dart b/frog/parser.dart
index 0a56b8b0f9bba0f7b5536664e667a04577ea5452..294d3d20458d6d9b29723f15127f722976c0e142 100644
--- a/frog/parser.dart
+++ b/frog/parser.dart
@@ -250,7 +250,7 @@ class Parser {
classDefinition(int kind) {
int start = _peekToken.start;
_eat(kind);
- var name = identifier();
+ var name = identifierForType();
var typeParams = null;
if (_peekKind(TokenKind.LT)) {
@@ -321,6 +321,7 @@ class Parser {
var formals = formalParameterList();
_eatSemicolon();
+ // TODO(jimhug): Validate that di.name is not a pseudo-keyword
var func = new FunctionDefinition(null, di.type, di.name, formals,
null, null, null, _makeSpan(start));
@@ -1616,6 +1617,18 @@ class Parser {
return formals;
}
+ // Type names are not allowed to use pseudo keywords
+ identifierForType() {
+ var tok = _next();
+ if (!_isIdentifier(tok.kind)) {
+ _error('expected identifier, but found $tok', tok.span);
+ }
+ if (tok.kind !== TokenKind.IDENTIFIER && tok.kind != TokenKind.NATIVE) {
+ _error('$tok may not be used as a type name', tok.span);
+ }
+ return new Identifier(tok.text, _makeSpan(tok.start));
+ }
+
identifier() {
var tok = _next();
if (!_isIdentifier(tok.kind)) {
« no previous file with comments | « frog/minfrog ('k') | frog/scripts/token_info.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698