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

Side by Side Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java

Issue 14811004: Improve error recovery when using 'var' as a type (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/ParserErrorCode.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012, the Dart project authors. 2 * Copyright (c) 2012, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
(...skipping 4806 matching lines...) Expand 10 before | Expand all | Expand 10 after
4817 * Parse a type name. 4817 * Parse a type name.
4818 * 4818 *
4819 * <pre> 4819 * <pre>
4820 * type ::= 4820 * type ::=
4821 * qualified typeArguments? 4821 * qualified typeArguments?
4822 * </pre> 4822 * </pre>
4823 * 4823 *
4824 * @return the type name that was parsed 4824 * @return the type name that was parsed
4825 */ 4825 */
4826 private TypeName parseTypeName() { 4826 private TypeName parseTypeName() {
4827 Identifier typeName = parsePrefixedIdentifier(); 4827 Identifier typeName;
4828 if (matches(Keyword.VAR)) {
4829 reportError(ParserErrorCode.VAR_AS_TYPE_NAME);
4830 typeName = new SimpleIdentifier(getAndAdvance());
4831 } else if (matchesIdentifier()) {
4832 typeName = parsePrefixedIdentifier();
4833 } else {
4834 typeName = createSyntheticIdentifier();
4835 reportError(ParserErrorCode.EXPECTED_TYPE_NAME);
4836 }
4828 TypeArgumentList typeArguments = null; 4837 TypeArgumentList typeArguments = null;
4829 if (matches(TokenType.LT)) { 4838 if (matches(TokenType.LT)) {
4830 typeArguments = parseTypeArgumentList(); 4839 typeArguments = parseTypeArgumentList();
4831 } 4840 }
4832 return new TypeName(typeName, typeArguments); 4841 return new TypeName(typeName, typeArguments);
4833 } 4842 }
4834 4843
4835 /** 4844 /**
4836 * Parse a type parameter. 4845 * Parse a type parameter.
4837 * 4846 *
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
6007 reportError(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.getExternalKeyword ()); 6016 reportError(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.getExternalKeyword ());
6008 } 6017 }
6009 if (modifiers.getFinalKeyword() != null) { 6018 if (modifiers.getFinalKeyword() != null) {
6010 reportError(ParserErrorCode.FINAL_TYPEDEF, modifiers.getFinalKeyword()); 6019 reportError(ParserErrorCode.FINAL_TYPEDEF, modifiers.getFinalKeyword());
6011 } 6020 }
6012 if (modifiers.getVarKeyword() != null) { 6021 if (modifiers.getVarKeyword() != null) {
6013 reportError(ParserErrorCode.VAR_TYPEDEF, modifiers.getVarKeyword()); 6022 reportError(ParserErrorCode.VAR_TYPEDEF, modifiers.getVarKeyword());
6014 } 6023 }
6015 } 6024 }
6016 } 6025 }
OLDNEW
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/ParserErrorCode.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698