| 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 87042360b6991d6f06e206768cb9d54efcae8ce7..48aabd68c8796944bde6868f02ab8a6207ad1062 100644
|
| --- a/compiler/java/com/google/dart/compiler/parser/DartParser.java
|
| +++ b/compiler/java/com/google/dart/compiler/parser/DartParser.java
|
| @@ -2245,6 +2245,7 @@ public class DartParser extends CompletionHooksParserBase {
|
| * <pre> mapLiteral : '{' (mapLiteralEntry (',' mapLiteralEntry)* ','?)? '}' ;
|
| * </pre>
|
| */
|
| + @Terminals(tokens={Token.RBRACE, Token.COMMA})
|
| private DartExpression parseMapLiteral(boolean isConst, List<DartTypeNode> typeArguments) {
|
| beginMapLiteral();
|
| expect(Token.LBRACE);
|
| @@ -2267,16 +2268,24 @@ public class DartParser extends CompletionHooksParserBase {
|
| if (entry != null) {
|
| entries.add(entry);
|
| }
|
| - switch (peek(0)) {
|
| + Token nextToken = peek(0);
|
| + switch (nextToken) {
|
| + // Must keep in sync with @Terminals above
|
| case COMMA:
|
| consume(Token.COMMA);
|
| break;
|
| + // Must keep in sync with @Terminals above
|
| case RBRACE:
|
| break;
|
| default:
|
| if (entry == null) {
|
| - // Ensure the parser makes progress.
|
| - ctx.advance();
|
| + Set<Token> terminals = collectTerminalAnnotations();
|
| + if (!terminals.contains(nextToken) && !looksLikeTopLevelKeyword()) {
|
| + if (entry == null) {
|
| + // Ensure the parser makes progress.
|
| + ctx.advance();
|
| + }
|
| + }
|
| }
|
| reportError(position(), ParserErrorCode.EXPECTED_COMMA_OR_RIGHT_BRACE);
|
| break;
|
| @@ -2298,6 +2307,7 @@ public class DartParser extends CompletionHooksParserBase {
|
| * ;
|
| * </pre>
|
| */
|
| + @Terminals(tokens={Token.RBRACK, Token.COMMA})
|
| private DartExpression parseArrayLiteral(boolean isConst, List<DartTypeNode> typeArguments) {
|
| beginArrayLiteral();
|
| expect(Token.LBRACK);
|
| @@ -2305,10 +2315,12 @@ public class DartParser extends CompletionHooksParserBase {
|
| List<DartExpression> exprs = new ArrayList<DartExpression>();
|
| while (!match(Token.RBRACK) && !EOS()) {
|
| exprs.add(parseExpression());
|
| + // Must keep in sync with @Terminals above
|
| if (!optional(Token.COMMA)) {
|
| break;
|
| }
|
| }
|
| + // Must keep in sync with @Terminals above
|
| expect(Token.RBRACK);
|
| setAllowFunctionExpression(save);
|
| return done(new DartArrayLiteral(isConst, typeArguments, exprs));
|
|
|