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

Unified Diff: compiler/java/com/google/dart/compiler/parser/DartParser.java

Issue 8441001: Prefix string literal must be identifier (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 2 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
Index: compiler/java/com/google/dart/compiler/parser/DartParser.java
diff --git a/compiler/java/com/google/dart/compiler/parser/DartParser.java b/compiler/java/com/google/dart/compiler/parser/DartParser.java
index 9b42acb205fb4d9c924235cae9499006a872964b..ddb850625e21994d3a2edefe96fece5bfd6fa14b 100644
--- a/compiler/java/com/google/dart/compiler/parser/DartParser.java
+++ b/compiler/java/com/google/dart/compiler/parser/DartParser.java
@@ -362,6 +362,16 @@ public class DartParser extends CompletionHooksParserBase {
return new DartLibraryDirective(libname);
}
+ private boolean VerifyStringIdentifier(String id) {
mmendez 2011/11/02 13:45:58 Nit: VerifyString... -> verifyString... Please ad
codefu 2011/11/02 14:32:57 Done.
+ boolean pass = false;
+ if(id.charAt(0) == '$') {
+ pass = id.matches("[_$a-zA-Z]([_$A-Za-z0-9]*)");
+ } else {
+ pass = id.matches("[_a-zA-Z]([_A-Za-z0-9]*)");
+ }
+ return pass;
+ }
+
private DartImportDirective parseImportDirective() {
expect(Token.IMPORT);
expect(Token.LPAREN);
@@ -376,6 +386,9 @@ public class DartParser extends CompletionHooksParserBase {
expect(Token.COLON);
beginLiteral();
expect(Token.STRING);
+ if (!VerifyStringIdentifier(ctx.getTokenString())){
+ reportError(position(), ParserErrorCode.EXPECTED_PREFIX_IDENTIFIER);
+ }
prefix = done(DartStringLiteral.get(ctx.getTokenString()));
}
expectCloseParen();

Powered by Google App Engine
This is Rietveld 408576698