Chromium Code Reviews| 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(); |