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

Side by Side Diff: compiler/java/com/google/dart/compiler/parser/DartParser.java

Issue 10005040: Using annotations to help with parser recovery (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed unrelated file Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 * : classDefinition 246 * : classDefinition
247 * | interfaceDefinition 247 * | interfaceDefinition
248 * | functionTypeAlias 248 * | functionTypeAlias
249 * | methodOrConstructorDeclaration functionStatementBody 249 * | methodOrConstructorDeclaration functionStatementBody
250 * | type? getOrSet identifier formalParameterList functionStatementBody 250 * | type? getOrSet identifier formalParameterList functionStatementBody
251 * | CONST type? staticConstDeclarationList ';' 251 * | CONST type? staticConstDeclarationList ';'
252 * | variableDeclaration ';' 252 * | variableDeclaration ';'
253 * ; 253 * ;
254 * </pre> 254 * </pre>
255 */ 255 */
256 @Terminals(tokens={Token.EOS, Token.CLASS})
256 public DartUnit parseUnit(DartSource source) { 257 public DartUnit parseUnit(DartSource source) {
257 beginCompilationUnit(); 258 beginCompilationUnit();
258 ctx.unitAboutToCompile(source, isDietParse); 259 ctx.unitAboutToCompile(source, isDietParse);
259 DartUnit unit = new DartUnit(source, isDietParse); 260 DartUnit unit = new DartUnit(source, isDietParse);
260 261
261 // parse any directives at the beginning of the source 262 // parse any directives at the beginning of the source
262 parseDirectives(unit); 263 parseDirectives(unit);
263 264
264 while (!EOS()) { 265 while (!EOS()) {
265 try { 266 try {
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 done(null); 1780 done(null);
1780 } 1781 }
1781 return result; 1782 return result;
1782 } 1783 }
1783 1784
1784 /** 1785 /**
1785 * expressionList 1786 * expressionList
1786 * : expression (',' expression)* 1787 * : expression (',' expression)*
1787 * ; 1788 * ;
1788 */ 1789 */
1790 @Terminals(tokens={Token.COMMA})
1789 private DartExpression parseExpressionList() { 1791 private DartExpression parseExpressionList() {
1790 beginExpressionList(); 1792 beginExpressionList();
1791 DartExpression result = parseExpression(); 1793 DartExpression result = parseExpression();
1792 while (optional(Token.COMMA)) { 1794 while (optional(Token.COMMA)) {
1793 result = new DartBinaryExpression(Token.COMMA, result, parseExpression()); 1795 result = new DartBinaryExpression(Token.COMMA, result, parseExpression());
1794 if (match(Token.COMMA)) { 1796 if (match(Token.COMMA)) {
1795 result = doneWithoutConsuming(result); 1797 result = doneWithoutConsuming(result);
1796 } 1798 }
1797 } 1799 }
1798 return done(result); 1800 return done(result);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 * | spreadArgument 1911 * | spreadArgument
1910 * ; 1912 * ;
1911 * 1913 *
1912 * spreadArgument 1914 * spreadArgument
1913 * : '...' expression 1915 * : '...' expression
1914 * ; 1916 * ;
1915 * </pre> 1917 * </pre>
1916 * 1918 *
1917 * @return a list of expressions containing the arguments to be passed 1919 * @return a list of expressions containing the arguments to be passed
1918 */ 1920 */
1919 private List<DartExpression> parseArguments() { 1921 @Terminals(tokens={Token.RPAREN, Token.COMMA})
1922 public List<DartExpression> parseArguments() {
1920 List<DartExpression> arguments = new ArrayList<DartExpression>(); 1923 List<DartExpression> arguments = new ArrayList<DartExpression>();
1921 expect(Token.LPAREN); 1924 expect(Token.LPAREN);
1922 // SEMICOLON is for error recovery 1925 // SEMICOLON is for error recovery
1923 boolean namedArgumentParsed = false; 1926 boolean namedArgumentParsed = false;
1924 while (!match(Token.RPAREN) && !match(Token.EOS) && !match(Token.SEMICOLON)) { 1927 while (!match(Token.RPAREN) && !match(Token.EOS) && !match(Token.SEMICOLON)) {
1925 beginParameter(); 1928 beginParameter();
1926 DartExpression expression; 1929 DartExpression expression;
1927 if (peek(1) == Token.COLON) { 1930 if (peek(1) == Token.COLON) {
1928 DartIdentifier name = parseIdentifier(); 1931 DartIdentifier name = parseIdentifier();
1929 expect(Token.COLON); 1932 expect(Token.COLON);
(...skipping 2226 matching lines...) Expand 10 before | Expand all | Expand 10 after
4156 } 4159 }
4157 4160
4158 private void reportError(DartNode node, ErrorCode errorCode, Object... argumen ts) { 4161 private void reportError(DartNode node, ErrorCode errorCode, Object... argumen ts) {
4159 reportError(new DartCompilationError(node, errorCode, arguments)); 4162 reportError(new DartCompilationError(node, errorCode, arguments));
4160 } 4163 }
4161 4164
4162 private boolean currentlyParsingToplevel() { 4165 private boolean currentlyParsingToplevel() {
4163 return !(isParsingInterface || isTopLevelAbstract || isParsingClass); 4166 return !(isParsingInterface || isTopLevelAbstract || isParsingClass);
4164 } 4167 }
4165 } 4168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698