| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 package com.google.dart.compiler.parser; | 5 package com.google.dart.compiler.parser; |
| 6 | 6 |
| 7 import com.google.common.annotations.VisibleForTesting; | 7 import com.google.common.annotations.VisibleForTesting; |
| 8 import com.google.common.io.CharStreams; | 8 import com.google.common.io.CharStreams; |
| 9 import com.google.dart.compiler.DartCompilationError; | 9 import com.google.dart.compiler.DartCompilationError; |
| 10 import com.google.dart.compiler.DartCompilerListener; | 10 import com.google.dart.compiler.DartCompilerListener; |
| (...skipping 3579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3590 return new DartSyntheticErrorStatement(buf.toString()); | 3590 return new DartSyntheticErrorStatement(buf.toString()); |
| 3591 } | 3591 } |
| 3592 | 3592 |
| 3593 | 3593 |
| 3594 /** | 3594 /** |
| 3595 * Look for a statement terminator, giving error messages and consuming tokens | 3595 * Look for a statement terminator, giving error messages and consuming tokens |
| 3596 * for error recovery. | 3596 * for error recovery. |
| 3597 */ | 3597 */ |
| 3598 protected void expectStatmentTerminator() { | 3598 protected void expectStatmentTerminator() { |
| 3599 Token token = peek(0); | 3599 Token token = peek(0); |
| 3600 int braceCount = 1; | |
| 3601 if (expect(Token.SEMICOLON)) { | 3600 if (expect(Token.SEMICOLON)) { |
| 3602 return; | 3601 return; |
| 3603 } | 3602 } |
| 3604 Set<Token> terminals = collectTerminalAnnotations(); | 3603 Set<Token> terminals = collectTerminalAnnotations(); |
| 3605 assert(terminals.contains(Token.SEMICOLON)); | 3604 assert(terminals.contains(Token.SEMICOLON)); |
| 3606 | 3605 |
| 3607 switch (token) { | |
| 3608 case LBRACE: | |
| 3609 braceCount++; | |
| 3610 break; | |
| 3611 } | |
| 3612 if (peek(0) == token) { | 3606 if (peek(0) == token) { |
| 3613 reportErrorWithoutAdvancing(ParserErrorCode.EXPECTED_SEMICOLON); | 3607 reportErrorWithoutAdvancing(ParserErrorCode.EXPECTED_SEMICOLON); |
| 3614 } else { | 3608 } else { |
| 3615 reportError(position(), ParserErrorCode.EXPECTED_SEMICOLON); | 3609 reportError(position(), ParserErrorCode.EXPECTED_SEMICOLON); |
| 3616 token = peek(0); | 3610 token = peek(0); |
| 3617 } | 3611 } |
| 3618 | 3612 |
| 3619 // Consume tokens until we see something that could terminate or start a new
statement | 3613 // Consume tokens until we see something that could terminate or start a new
statement |
| 3620 while (token != Token.SEMICOLON) { | 3614 while (token != Token.SEMICOLON) { |
| 3621 if (looksLikeTopLevelKeyword() || terminals.contains(token)) { | 3615 if (looksLikeTopLevelKeyword() || terminals.contains(token)) { |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4203 } | 4197 } |
| 4204 | 4198 |
| 4205 private void reportError(DartNode node, ErrorCode errorCode, Object... argumen
ts) { | 4199 private void reportError(DartNode node, ErrorCode errorCode, Object... argumen
ts) { |
| 4206 reportError(new DartCompilationError(node, errorCode, arguments)); | 4200 reportError(new DartCompilationError(node, errorCode, arguments)); |
| 4207 } | 4201 } |
| 4208 | 4202 |
| 4209 private boolean currentlyParsingToplevel() { | 4203 private boolean currentlyParsingToplevel() { |
| 4210 return !(isParsingInterface || isTopLevelAbstract || isParsingClass); | 4204 return !(isParsingInterface || isTopLevelAbstract || isParsingClass); |
| 4211 } | 4205 } |
| 4212 } | 4206 } |
| OLD | NEW |