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

Side by Side Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 975453004: Reformat (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.parser; 8 library engine.parser;
9 9
10 import "dart:math" as math; 10 import "dart:math" as math;
11 import 'dart:collection'; 11 import 'dart:collection';
12 12
13 import 'ast.dart'; 13 import 'ast.dart';
14 import 'engine.dart' show AnalysisEngine, AnalysisOptionsImpl; 14 import 'engine.dart' show AnalysisEngine, AnalysisOptionsImpl;
15 import 'error.dart'; 15 import 'error.dart';
16 import 'java_core.dart'; 16 import 'java_core.dart';
17 import 'java_engine.dart'; 17 import 'java_engine.dart';
18 import 'scanner.dart'; 18 import 'scanner.dart';
19 import 'source.dart'; 19 import 'source.dart';
20 import 'utilities_collection.dart' show TokenMap; 20 import 'utilities_collection.dart' show TokenMap;
21 import 'utilities_dart.dart'; 21 import 'utilities_dart.dart';
22 22
23 Map<String, MethodTrampoline> methodTable_Parser = <String, MethodTrampoline>{ 23 Map<String, MethodTrampoline> methodTable_Parser = <String, MethodTrampoline>{
24 'parseCompilationUnit_1': new MethodTrampoline( 24 'parseCompilationUnit_1': new MethodTrampoline(
25 1, 25 1, (Parser target, arg0) => target.parseCompilationUnit(arg0)),
26 (Parser target, arg0) => target.parseCompilationUnit(arg0)),
27 'parseDirectives_1': new MethodTrampoline( 26 'parseDirectives_1': new MethodTrampoline(
28 1, 27 1, (Parser target, arg0) => target.parseDirectives(arg0)),
29 (Parser target, arg0) => target.parseDirectives(arg0)),
30 'parseExpression_1': new MethodTrampoline( 28 'parseExpression_1': new MethodTrampoline(
31 1, 29 1, (Parser target, arg0) => target.parseExpression(arg0)),
32 (Parser target, arg0) => target.parseExpression(arg0)),
33 'parseStatement_1': new MethodTrampoline( 30 'parseStatement_1': new MethodTrampoline(
34 1, 31 1, (Parser target, arg0) => target.parseStatement(arg0)),
35 (Parser target, arg0) => target.parseStatement(arg0)),
36 'parseStatements_1': new MethodTrampoline( 32 'parseStatements_1': new MethodTrampoline(
37 1, 33 1, (Parser target, arg0) => target.parseStatements(arg0)),
38 (Parser target, arg0) => target.parseStatements(arg0)), 34 'parseAnnotation_0':
39 'parseAnnotation_0': new MethodTrampoline( 35 new MethodTrampoline(0, (Parser target) => target.parseAnnotation()),
40 0, 36 'parseArgument_0':
41 (Parser target) => target.parseAnnotation()), 37 new MethodTrampoline(0, (Parser target) => target.parseArgument()),
42 'parseArgument_0': new MethodTrampoline( 38 'parseArgumentList_0':
43 0, 39 new MethodTrampoline(0, (Parser target) => target.parseArgumentList()),
44 (Parser target) => target.parseArgument()),
45 'parseArgumentList_0': new MethodTrampoline(
46 0,
47 (Parser target) => target.parseArgumentList()),
48 'parseBitwiseOrExpression_0': new MethodTrampoline( 40 'parseBitwiseOrExpression_0': new MethodTrampoline(
49 0, 41 0, (Parser target) => target.parseBitwiseOrExpression()),
50 (Parser target) => target.parseBitwiseOrExpression()), 42 'parseBlock_0':
51 'parseBlock_0': new MethodTrampoline( 43 new MethodTrampoline(0, (Parser target) => target.parseBlock()),
52 0,
53 (Parser target) => target.parseBlock()),
54 'parseClassMember_1': new MethodTrampoline( 44 'parseClassMember_1': new MethodTrampoline(
55 1, 45 1, (Parser target, arg0) => target.parseClassMember(arg0)),
56 (Parser target, arg0) => target.parseClassMember(arg0)),
57 'parseCompilationUnit_0': new MethodTrampoline( 46 'parseCompilationUnit_0': new MethodTrampoline(
58 0, 47 0, (Parser target) => target.parseCompilationUnit2()),
59 (Parser target) => target.parseCompilationUnit2()),
60 'parseConditionalExpression_0': new MethodTrampoline( 48 'parseConditionalExpression_0': new MethodTrampoline(
61 0, 49 0, (Parser target) => target.parseConditionalExpression()),
62 (Parser target) => target.parseConditionalExpression()), 50 'parseConstructorName_0':
63 'parseConstructorName_0': new MethodTrampoline( 51 new MethodTrampoline(0, (Parser target) => target.parseConstructorName()),
64 0, 52 'parseExpression_0':
65 (Parser target) => target.parseConstructorName()), 53 new MethodTrampoline(0, (Parser target) => target.parseExpression2()),
66 'parseExpression_0': new MethodTrampoline(
67 0,
68 (Parser target) => target.parseExpression2()),
69 'parseExpressionWithoutCascade_0': new MethodTrampoline( 54 'parseExpressionWithoutCascade_0': new MethodTrampoline(
70 0, 55 0, (Parser target) => target.parseExpressionWithoutCascade()),
71 (Parser target) => target.parseExpressionWithoutCascade()), 56 'parseExtendsClause_0':
72 'parseExtendsClause_0': new MethodTrampoline( 57 new MethodTrampoline(0, (Parser target) => target.parseExtendsClause()),
73 0,
74 (Parser target) => target.parseExtendsClause()),
75 'parseFormalParameterList_0': new MethodTrampoline( 58 'parseFormalParameterList_0': new MethodTrampoline(
76 0, 59 0, (Parser target) => target.parseFormalParameterList()),
77 (Parser target) => target.parseFormalParameterList()),
78 'parseFunctionExpression_0': new MethodTrampoline( 60 'parseFunctionExpression_0': new MethodTrampoline(
79 0, 61 0, (Parser target) => target.parseFunctionExpression()),
80 (Parser target) => target.parseFunctionExpression()),
81 'parseImplementsClause_0': new MethodTrampoline( 62 'parseImplementsClause_0': new MethodTrampoline(
82 0, 63 0, (Parser target) => target.parseImplementsClause()),
83 (Parser target) => target.parseImplementsClause()), 64 'parseLabel_0':
84 'parseLabel_0': new MethodTrampoline( 65 new MethodTrampoline(0, (Parser target) => target.parseLabel()),
85 0,
86 (Parser target) => target.parseLabel()),
87 'parseLibraryIdentifier_0': new MethodTrampoline( 66 'parseLibraryIdentifier_0': new MethodTrampoline(
88 0, 67 0, (Parser target) => target.parseLibraryIdentifier()),
89 (Parser target) => target.parseLibraryIdentifier()),
90 'parseLogicalOrExpression_0': new MethodTrampoline( 68 'parseLogicalOrExpression_0': new MethodTrampoline(
91 0, 69 0, (Parser target) => target.parseLogicalOrExpression()),
92 (Parser target) => target.parseLogicalOrExpression()), 70 'parseMapLiteralEntry_0':
93 'parseMapLiteralEntry_0': new MethodTrampoline( 71 new MethodTrampoline(0, (Parser target) => target.parseMapLiteralEntry()),
94 0,
95 (Parser target) => target.parseMapLiteralEntry()),
96 'parseNormalFormalParameter_0': new MethodTrampoline( 72 'parseNormalFormalParameter_0': new MethodTrampoline(
97 0, 73 0, (Parser target) => target.parseNormalFormalParameter()),
98 (Parser target) => target.parseNormalFormalParameter()),
99 'parsePrefixedIdentifier_0': new MethodTrampoline( 74 'parsePrefixedIdentifier_0': new MethodTrampoline(
100 0, 75 0, (Parser target) => target.parsePrefixedIdentifier()),
101 (Parser target) => target.parsePrefixedIdentifier()), 76 'parseReturnType_0':
102 'parseReturnType_0': new MethodTrampoline( 77 new MethodTrampoline(0, (Parser target) => target.parseReturnType()),
103 0,
104 (Parser target) => target.parseReturnType()),
105 'parseSimpleIdentifier_0': new MethodTrampoline( 78 'parseSimpleIdentifier_0': new MethodTrampoline(
106 0, 79 0, (Parser target) => target.parseSimpleIdentifier()),
107 (Parser target) => target.parseSimpleIdentifier()), 80 'parseStatement_0':
108 'parseStatement_0': new MethodTrampoline( 81 new MethodTrampoline(0, (Parser target) => target.parseStatement2()),
109 0, 82 'parseStringLiteral_0':
110 (Parser target) => target.parseStatement2()), 83 new MethodTrampoline(0, (Parser target) => target.parseStringLiteral()),
111 'parseStringLiteral_0': new MethodTrampoline(
112 0,
113 (Parser target) => target.parseStringLiteral()),
114 'parseTypeArgumentList_0': new MethodTrampoline( 84 'parseTypeArgumentList_0': new MethodTrampoline(
115 0, 85 0, (Parser target) => target.parseTypeArgumentList()),
116 (Parser target) => target.parseTypeArgumentList()), 86 'parseTypeName_0':
117 'parseTypeName_0': new MethodTrampoline( 87 new MethodTrampoline(0, (Parser target) => target.parseTypeName()),
118 0, 88 'parseTypeParameter_0':
119 (Parser target) => target.parseTypeName()), 89 new MethodTrampoline(0, (Parser target) => target.parseTypeParameter()),
120 'parseTypeParameter_0': new MethodTrampoline(
121 0,
122 (Parser target) => target.parseTypeParameter()),
123 'parseTypeParameterList_0': new MethodTrampoline( 90 'parseTypeParameterList_0': new MethodTrampoline(
124 0, 91 0, (Parser target) => target.parseTypeParameterList()),
125 (Parser target) => target.parseTypeParameterList()), 92 'parseWithClause_0':
126 'parseWithClause_0': new MethodTrampoline( 93 new MethodTrampoline(0, (Parser target) => target.parseWithClause()),
127 0,
128 (Parser target) => target.parseWithClause()),
129 'advance_0': new MethodTrampoline(0, (Parser target) => target._advance()), 94 'advance_0': new MethodTrampoline(0, (Parser target) => target._advance()),
130 'appendScalarValue_5': new MethodTrampoline( 95 'appendScalarValue_5': new MethodTrampoline(5, (Parser target, arg0, arg1,
131 5, 96 arg2, arg3,
132 (Parser target, arg0, arg1, arg2, arg3, arg4) => 97 arg4) => target._appendScalarValue(arg0, arg1, arg2, arg3, arg4)),
133 target._appendScalarValue(arg0, arg1, arg2, arg3, arg4)), 98 'computeStringValue_3': new MethodTrampoline(3, (Parser target, arg0, arg1,
134 'computeStringValue_3': new MethodTrampoline( 99 arg2) => target._computeStringValue(arg0, arg1, arg2)),
135 3,
136 (Parser target, arg0, arg1, arg2) =>
137 target._computeStringValue(arg0, arg1, arg2)),
138 'convertToFunctionDeclaration_1': new MethodTrampoline( 100 'convertToFunctionDeclaration_1': new MethodTrampoline(
139 1, 101 1, (Parser target, arg0) => target._convertToFunctionDeclaration(arg0)),
140 (Parser target, arg0) => target._convertToFunctionDeclaration(arg0)),
141 'couldBeStartOfCompilationUnitMember_0': new MethodTrampoline( 102 'couldBeStartOfCompilationUnitMember_0': new MethodTrampoline(
142 0, 103 0, (Parser target) => target._couldBeStartOfCompilationUnitMember()),
143 (Parser target) => target._couldBeStartOfCompilationUnitMember()),
144 'createSyntheticIdentifier_0': new MethodTrampoline( 104 'createSyntheticIdentifier_0': new MethodTrampoline(
145 0, 105 0, (Parser target) => target._createSyntheticIdentifier()),
146 (Parser target) => target._createSyntheticIdentifier()),
147 'createSyntheticKeyword_1': new MethodTrampoline( 106 'createSyntheticKeyword_1': new MethodTrampoline(
148 1, 107 1, (Parser target, arg0) => target._createSyntheticKeyword(arg0)),
149 (Parser target, arg0) => target._createSyntheticKeyword(arg0)),
150 'createSyntheticStringLiteral_0': new MethodTrampoline( 108 'createSyntheticStringLiteral_0': new MethodTrampoline(
151 0, 109 0, (Parser target) => target._createSyntheticStringLiteral()),
152 (Parser target) => target._createSyntheticStringLiteral()),
153 'createSyntheticToken_1': new MethodTrampoline( 110 'createSyntheticToken_1': new MethodTrampoline(
154 1, 111 1, (Parser target, arg0) => target._createSyntheticToken(arg0)),
155 (Parser target, arg0) => target._createSyntheticToken(arg0)),
156 'ensureAssignable_1': new MethodTrampoline( 112 'ensureAssignable_1': new MethodTrampoline(
157 1, 113 1, (Parser target, arg0) => target._ensureAssignable(arg0)),
158 (Parser target, arg0) => target._ensureAssignable(arg0)), 114 'expect_1':
159 'expect_1': new MethodTrampoline( 115 new MethodTrampoline(1, (Parser target, arg0) => target._expect(arg0)),
160 1,
161 (Parser target, arg0) => target._expect(arg0)),
162 'expectGt_0': new MethodTrampoline(0, (Parser target) => target._expectGt()), 116 'expectGt_0': new MethodTrampoline(0, (Parser target) => target._expectGt()),
163 'expectKeyword_1': new MethodTrampoline( 117 'expectKeyword_1': new MethodTrampoline(
164 1, 118 1, (Parser target, arg0) => target._expectKeyword(arg0)),
165 (Parser target, arg0) => target._expectKeyword(arg0)), 119 'expectSemicolon_0':
166 'expectSemicolon_0': new MethodTrampoline( 120 new MethodTrampoline(0, (Parser target) => target._expectSemicolon()),
167 0,
168 (Parser target) => target._expectSemicolon()),
169 'findRange_2': new MethodTrampoline( 121 'findRange_2': new MethodTrampoline(
170 2, 122 2, (Parser target, arg0, arg1) => target._findRange(arg0, arg1)),
171 (Parser target, arg0, arg1) => target._findRange(arg0, arg1)),
172 'getCodeBlockRanges_1': new MethodTrampoline( 123 'getCodeBlockRanges_1': new MethodTrampoline(
173 1, 124 1, (Parser target, arg0) => target._getCodeBlockRanges(arg0)),
174 (Parser target, arg0) => target._getCodeBlockRanges(arg0)),
175 'getEndToken_1': new MethodTrampoline( 125 'getEndToken_1': new MethodTrampoline(
176 1, 126 1, (Parser target, arg0) => target._getEndToken(arg0)),
177 (Parser target, arg0) => target._getEndToken(arg0)),
178 'injectToken_1': new MethodTrampoline( 127 'injectToken_1': new MethodTrampoline(
179 1, 128 1, (Parser target, arg0) => target._injectToken(arg0)),
180 (Parser target, arg0) => target._injectToken(arg0)),
181 'isFunctionDeclaration_0': new MethodTrampoline( 129 'isFunctionDeclaration_0': new MethodTrampoline(
182 0, 130 0, (Parser target) => target._isFunctionDeclaration()),
183 (Parser target) => target._isFunctionDeclaration()),
184 'isFunctionExpression_1': new MethodTrampoline( 131 'isFunctionExpression_1': new MethodTrampoline(
185 1, 132 1, (Parser target, arg0) => target._isFunctionExpression(arg0)),
186 (Parser target, arg0) => target._isFunctionExpression(arg0)),
187 'isHexDigit_1': new MethodTrampoline( 133 'isHexDigit_1': new MethodTrampoline(
188 1, 134 1, (Parser target, arg0) => target._isHexDigit(arg0)),
189 (Parser target, arg0) => target._isHexDigit(arg0)),
190 'isInitializedVariableDeclaration_0': new MethodTrampoline( 135 'isInitializedVariableDeclaration_0': new MethodTrampoline(
191 0, 136 0, (Parser target) => target._isInitializedVariableDeclaration()),
192 (Parser target) => target._isInitializedVariableDeclaration()),
193 'isLinkText_2': new MethodTrampoline( 137 'isLinkText_2': new MethodTrampoline(
194 2, 138 2, (Parser target, arg0, arg1) => target._isLinkText(arg0, arg1)),
195 (Parser target, arg0, arg1) => target._isLinkText(arg0, arg1)),
196 'isOperator_1': new MethodTrampoline( 139 'isOperator_1': new MethodTrampoline(
197 1, 140 1, (Parser target, arg0) => target._isOperator(arg0)),
198 (Parser target, arg0) => target._isOperator(arg0)), 141 'isSwitchMember_0':
199 'isSwitchMember_0': new MethodTrampoline( 142 new MethodTrampoline(0, (Parser target) => target._isSwitchMember()),
200 0,
201 (Parser target) => target._isSwitchMember()),
202 'isTypedIdentifier_1': new MethodTrampoline( 143 'isTypedIdentifier_1': new MethodTrampoline(
203 1, 144 1, (Parser target, arg0) => target._isTypedIdentifier(arg0)),
204 (Parser target, arg0) => target._isTypedIdentifier(arg0)), 145 'lockErrorListener_0':
205 'lockErrorListener_0': new MethodTrampoline( 146 new MethodTrampoline(0, (Parser target) => target._lockErrorListener()),
206 0, 147 'matches_1':
207 (Parser target) => target._lockErrorListener()), 148 new MethodTrampoline(1, (Parser target, arg0) => target._matches(arg0)),
208 'matches_1': new MethodTrampoline( 149 'matchesGt_0':
209 1, 150 new MethodTrampoline(0, (Parser target) => target._matchesGt()),
210 (Parser target, arg0) => target._matches(arg0)), 151 'matchesIdentifier_0':
211 'matchesGt_0': new MethodTrampoline( 152 new MethodTrampoline(0, (Parser target) => target._matchesIdentifier()),
212 0,
213 (Parser target) => target._matchesGt()),
214 'matchesIdentifier_0': new MethodTrampoline(
215 0,
216 (Parser target) => target._matchesIdentifier()),
217 'matchesKeyword_1': new MethodTrampoline( 153 'matchesKeyword_1': new MethodTrampoline(
218 1, 154 1, (Parser target, arg0) => target._matchesKeyword(arg0)),
219 (Parser target, arg0) => target._matchesKeyword(arg0)),
220 'matchesString_1': new MethodTrampoline( 155 'matchesString_1': new MethodTrampoline(
221 1, 156 1, (Parser target, arg0) => target._matchesString(arg0)),
222 (Parser target, arg0) => target._matchesString(arg0)), 157 'optional_1':
223 'optional_1': new MethodTrampoline( 158 new MethodTrampoline(1, (Parser target, arg0) => target._optional(arg0)),
224 1,
225 (Parser target, arg0) => target._optional(arg0)),
226 'parseAdditiveExpression_0': new MethodTrampoline( 159 'parseAdditiveExpression_0': new MethodTrampoline(
227 0, 160 0, (Parser target) => target._parseAdditiveExpression()),
228 (Parser target) => target._parseAdditiveExpression()),
229 'parseAssertStatement_0': new MethodTrampoline( 161 'parseAssertStatement_0': new MethodTrampoline(
230 0, 162 0, (Parser target) => target._parseAssertStatement()),
231 (Parser target) => target._parseAssertStatement()),
232 'parseAssignableExpression_1': new MethodTrampoline( 163 'parseAssignableExpression_1': new MethodTrampoline(
233 1, 164 1, (Parser target, arg0) => target._parseAssignableExpression(arg0)),
234 (Parser target, arg0) => target._parseAssignableExpression(arg0)), 165 'parseAssignableSelector_2': new MethodTrampoline(2, (Parser target, arg0,
235 'parseAssignableSelector_2': new MethodTrampoline( 166 arg1) => target._parseAssignableSelector(arg0, arg1)),
236 2,
237 (Parser target, arg0, arg1) => target._parseAssignableSelector(arg0, arg1) ),
238 'parseAwaitExpression_0': new MethodTrampoline( 167 'parseAwaitExpression_0': new MethodTrampoline(
239 0, 168 0, (Parser target) => target._parseAwaitExpression()),
240 (Parser target) => target._parseAwaitExpression()),
241 'parseBitwiseAndExpression_0': new MethodTrampoline( 169 'parseBitwiseAndExpression_0': new MethodTrampoline(
242 0, 170 0, (Parser target) => target._parseBitwiseAndExpression()),
243 (Parser target) => target._parseBitwiseAndExpression()),
244 'parseBitwiseXorExpression_0': new MethodTrampoline( 171 'parseBitwiseXorExpression_0': new MethodTrampoline(
245 0, 172 0, (Parser target) => target._parseBitwiseXorExpression()),
246 (Parser target) => target._parseBitwiseXorExpression()), 173 'parseBreakStatement_0':
247 'parseBreakStatement_0': new MethodTrampoline( 174 new MethodTrampoline(0, (Parser target) => target._parseBreakStatement()),
248 0, 175 'parseCascadeSection_0':
249 (Parser target) => target._parseBreakStatement()), 176 new MethodTrampoline(0, (Parser target) => target._parseCascadeSection()),
250 'parseCascadeSection_0': new MethodTrampoline( 177 'parseClassDeclaration_2': new MethodTrampoline(2,
251 0,
252 (Parser target) => target._parseCascadeSection()),
253 'parseClassDeclaration_2': new MethodTrampoline(
254 2,
255 (Parser target, arg0, arg1) => target._parseClassDeclaration(arg0, arg1)), 178 (Parser target, arg0, arg1) => target._parseClassDeclaration(arg0, arg1)),
256 'parseClassMembers_2': new MethodTrampoline( 179 'parseClassMembers_2': new MethodTrampoline(
257 2, 180 2, (Parser target, arg0, arg1) => target._parseClassMembers(arg0, arg1)),
258 (Parser target, arg0, arg1) => target._parseClassMembers(arg0, arg1)), 181 'parseClassTypeAlias_3': new MethodTrampoline(3, (Parser target, arg0, arg1,
259 'parseClassTypeAlias_3': new MethodTrampoline( 182 arg2) => target._parseClassTypeAlias(arg0, arg1, arg2)),
260 3, 183 'parseCombinator_0':
261 (Parser target, arg0, arg1, arg2) => 184 new MethodTrampoline(0, (Parser target) => target.parseCombinator()),
262 target._parseClassTypeAlias(arg0, arg1, arg2)), 185 'parseCombinators_0':
263 'parseCombinator_0': new MethodTrampoline( 186 new MethodTrampoline(0, (Parser target) => target._parseCombinators()),
264 0,
265 (Parser target) => target.parseCombinator()),
266 'parseCombinators_0': new MethodTrampoline(
267 0,
268 (Parser target) => target._parseCombinators()),
269 'parseCommentAndMetadata_0': new MethodTrampoline( 187 'parseCommentAndMetadata_0': new MethodTrampoline(
270 0, 188 0, (Parser target) => target._parseCommentAndMetadata()),
271 (Parser target) => target._parseCommentAndMetadata()), 189 'parseCommentReference_2': new MethodTrampoline(2,
272 'parseCommentReference_2': new MethodTrampoline(
273 2,
274 (Parser target, arg0, arg1) => target._parseCommentReference(arg0, arg1)), 190 (Parser target, arg0, arg1) => target._parseCommentReference(arg0, arg1)),
275 'parseCommentReferences_1': new MethodTrampoline( 191 'parseCommentReferences_1': new MethodTrampoline(
276 1, 192 1, (Parser target, arg0) => target._parseCommentReferences(arg0)),
277 (Parser target, arg0) => target._parseCommentReferences(arg0)),
278 'parseCompilationUnitMember_1': new MethodTrampoline( 193 'parseCompilationUnitMember_1': new MethodTrampoline(
279 1, 194 1, (Parser target, arg0) => target._parseCompilationUnitMember(arg0)),
280 (Parser target, arg0) => target._parseCompilationUnitMember(arg0)),
281 'parseConstExpression_0': new MethodTrampoline( 195 'parseConstExpression_0': new MethodTrampoline(
282 0, 196 0, (Parser target) => target._parseConstExpression()),
283 (Parser target) => target._parseConstExpression()), 197 'parseConstructor_8': new MethodTrampoline(8, (Parser target, arg0, arg1,
284 'parseConstructor_8': new MethodTrampoline( 198 arg2, arg3, arg4, arg5, arg6, arg7) =>
285 8, 199 target._parseConstructor(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)),
286 (Parser target, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) =>
287 target._parseConstructor(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg 7)),
288 'parseConstructorFieldInitializer_0': new MethodTrampoline( 200 'parseConstructorFieldInitializer_0': new MethodTrampoline(
289 0, 201 0, (Parser target) => target._parseConstructorFieldInitializer()),
290 (Parser target) => target._parseConstructorFieldInitializer()),
291 'parseContinueStatement_0': new MethodTrampoline( 202 'parseContinueStatement_0': new MethodTrampoline(
292 0, 203 0, (Parser target) => target._parseContinueStatement()),
293 (Parser target) => target._parseContinueStatement()),
294 'parseDirective_1': new MethodTrampoline( 204 'parseDirective_1': new MethodTrampoline(
295 1, 205 1, (Parser target, arg0) => target._parseDirective(arg0)),
296 (Parser target, arg0) => target._parseDirective(arg0)), 206 'parseDirectives_0':
297 'parseDirectives_0': new MethodTrampoline( 207 new MethodTrampoline(0, (Parser target) => target._parseDirectives()),
298 0,
299 (Parser target) => target._parseDirectives()),
300 'parseDocumentationComment_0': new MethodTrampoline( 208 'parseDocumentationComment_0': new MethodTrampoline(
301 0, 209 0, (Parser target) => target._parseDocumentationComment()),
302 (Parser target) => target._parseDocumentationComment()), 210 'parseDoStatement_0':
303 'parseDoStatement_0': new MethodTrampoline( 211 new MethodTrampoline(0, (Parser target) => target._parseDoStatement()),
304 0, 212 'parseEmptyStatement_0':
305 (Parser target) => target._parseDoStatement()), 213 new MethodTrampoline(0, (Parser target) => target._parseEmptyStatement()),
306 'parseEmptyStatement_0': new MethodTrampoline(
307 0,
308 (Parser target) => target._parseEmptyStatement()),
309 'parseEnumConstantDeclaration_0': new MethodTrampoline( 214 'parseEnumConstantDeclaration_0': new MethodTrampoline(
310 0, 215 0, (Parser target) => target._parseEnumConstantDeclaration()),
311 (Parser target) => target._parseEnumConstantDeclaration()),
312 'parseEnumDeclaration_1': new MethodTrampoline( 216 'parseEnumDeclaration_1': new MethodTrampoline(
313 1, 217 1, (Parser target, arg0) => target._parseEnumDeclaration(arg0)),
314 (Parser target, arg0) => target._parseEnumDeclaration(arg0)),
315 'parseEqualityExpression_0': new MethodTrampoline( 218 'parseEqualityExpression_0': new MethodTrampoline(
316 0, 219 0, (Parser target) => target._parseEqualityExpression()),
317 (Parser target) => target._parseEqualityExpression()),
318 'parseExportDirective_1': new MethodTrampoline( 220 'parseExportDirective_1': new MethodTrampoline(
319 1, 221 1, (Parser target, arg0) => target._parseExportDirective(arg0)),
320 (Parser target, arg0) => target._parseExportDirective(arg0)), 222 'parseExpressionList_0':
321 'parseExpressionList_0': new MethodTrampoline( 223 new MethodTrampoline(0, (Parser target) => target._parseExpressionList()),
322 0,
323 (Parser target) => target._parseExpressionList()),
324 'parseFinalConstVarOrType_1': new MethodTrampoline( 224 'parseFinalConstVarOrType_1': new MethodTrampoline(
325 1, 225 1, (Parser target, arg0) => target._parseFinalConstVarOrType(arg0)),
326 (Parser target, arg0) => target._parseFinalConstVarOrType(arg0)),
327 'parseFormalParameter_1': new MethodTrampoline( 226 'parseFormalParameter_1': new MethodTrampoline(
328 1, 227 1, (Parser target, arg0) => target._parseFormalParameter(arg0)),
329 (Parser target, arg0) => target._parseFormalParameter(arg0)), 228 'parseForStatement_0':
330 'parseForStatement_0': new MethodTrampoline( 229 new MethodTrampoline(0, (Parser target) => target._parseForStatement()),
331 0, 230 'parseFunctionBody_3': new MethodTrampoline(3, (Parser target, arg0, arg1,
332 (Parser target) => target._parseForStatement()), 231 arg2) => target._parseFunctionBody(arg0, arg1, arg2)),
333 'parseFunctionBody_3': new MethodTrampoline( 232 'parseFunctionDeclaration_3': new MethodTrampoline(3, (Parser target, arg0,
334 3, 233 arg1, arg2) => target._parseFunctionDeclaration(arg0, arg1, arg2)),
335 (Parser target, arg0, arg1, arg2) =>
336 target._parseFunctionBody(arg0, arg1, arg2)),
337 'parseFunctionDeclaration_3': new MethodTrampoline(
338 3,
339 (Parser target, arg0, arg1, arg2) =>
340 target._parseFunctionDeclaration(arg0, arg1, arg2)),
341 'parseFunctionDeclarationStatement_0': new MethodTrampoline( 234 'parseFunctionDeclarationStatement_0': new MethodTrampoline(
342 0, 235 0, (Parser target) => target._parseFunctionDeclarationStatement()),
343 (Parser target) => target._parseFunctionDeclarationStatement()), 236 'parseFunctionDeclarationStatementAfterReturnType_2': new MethodTrampoline(2,
344 'parseFunctionDeclarationStatementAfterReturnType_2': new MethodTrampoline(
345 2,
346 (Parser target, arg0, arg1) => 237 (Parser target, arg0, arg1) =>
347 target._parseFunctionDeclarationStatementAfterReturnType(arg0, arg1)), 238 target._parseFunctionDeclarationStatementAfterReturnType(arg0, arg1)),
348 'parseFunctionTypeAlias_2': new MethodTrampoline( 239 'parseFunctionTypeAlias_2': new MethodTrampoline(2, (Parser target, arg0,
349 2, 240 arg1) => target._parseFunctionTypeAlias(arg0, arg1)),
350 (Parser target, arg0, arg1) => target._parseFunctionTypeAlias(arg0, arg1)) , 241 'parseGetter_4': new MethodTrampoline(4, (Parser target, arg0, arg1, arg2,
351 'parseGetter_4': new MethodTrampoline( 242 arg3) => target._parseGetter(arg0, arg1, arg2, arg3)),
352 4, 243 'parseIdentifierList_0':
353 (Parser target, arg0, arg1, arg2, arg3) => 244 new MethodTrampoline(0, (Parser target) => target._parseIdentifierList()),
354 target._parseGetter(arg0, arg1, arg2, arg3)), 245 'parseIfStatement_0':
355 'parseIdentifierList_0': new MethodTrampoline( 246 new MethodTrampoline(0, (Parser target) => target._parseIfStatement()),
356 0,
357 (Parser target) => target._parseIdentifierList()),
358 'parseIfStatement_0': new MethodTrampoline(
359 0,
360 (Parser target) => target._parseIfStatement()),
361 'parseImportDirective_1': new MethodTrampoline( 247 'parseImportDirective_1': new MethodTrampoline(
362 1, 248 1, (Parser target, arg0) => target._parseImportDirective(arg0)),
363 (Parser target, arg0) => target._parseImportDirective(arg0)), 249 'parseInitializedIdentifierList_4': new MethodTrampoline(4,
364 'parseInitializedIdentifierList_4': new MethodTrampoline(
365 4,
366 (Parser target, arg0, arg1, arg2, arg3) => 250 (Parser target, arg0, arg1, arg2, arg3) =>
367 target._parseInitializedIdentifierList(arg0, arg1, arg2, arg3)), 251 target._parseInitializedIdentifierList(arg0, arg1, arg2, arg3)),
368 'parseInstanceCreationExpression_1': new MethodTrampoline( 252 'parseInstanceCreationExpression_1': new MethodTrampoline(1,
369 1,
370 (Parser target, arg0) => target._parseInstanceCreationExpression(arg0)), 253 (Parser target, arg0) => target._parseInstanceCreationExpression(arg0)),
371 'parseLibraryDirective_1': new MethodTrampoline( 254 'parseLibraryDirective_1': new MethodTrampoline(
372 1, 255 1, (Parser target, arg0) => target._parseLibraryDirective(arg0)),
373 (Parser target, arg0) => target._parseLibraryDirective(arg0)),
374 'parseLibraryName_2': new MethodTrampoline( 256 'parseLibraryName_2': new MethodTrampoline(
375 2, 257 2, (Parser target, arg0, arg1) => target._parseLibraryName(arg0, arg1)),
376 (Parser target, arg0, arg1) => target._parseLibraryName(arg0, arg1)),
377 'parseListLiteral_2': new MethodTrampoline( 258 'parseListLiteral_2': new MethodTrampoline(
378 2, 259 2, (Parser target, arg0, arg1) => target._parseListLiteral(arg0, arg1)),
379 (Parser target, arg0, arg1) => target._parseListLiteral(arg0, arg1)),
380 'parseListOrMapLiteral_1': new MethodTrampoline( 260 'parseListOrMapLiteral_1': new MethodTrampoline(
381 1, 261 1, (Parser target, arg0) => target._parseListOrMapLiteral(arg0)),
382 (Parser target, arg0) => target._parseListOrMapLiteral(arg0)),
383 'parseLogicalAndExpression_0': new MethodTrampoline( 262 'parseLogicalAndExpression_0': new MethodTrampoline(
384 0, 263 0, (Parser target) => target._parseLogicalAndExpression()),
385 (Parser target) => target._parseLogicalAndExpression()),
386 'parseMapLiteral_2': new MethodTrampoline( 264 'parseMapLiteral_2': new MethodTrampoline(
387 2, 265 2, (Parser target, arg0, arg1) => target._parseMapLiteral(arg0, arg1)),
388 (Parser target, arg0, arg1) => target._parseMapLiteral(arg0, arg1)), 266 'parseMethodDeclarationAfterParameters_6': new MethodTrampoline(6,
389 'parseMethodDeclarationAfterParameters_6': new MethodTrampoline( 267 (Parser target, arg0, arg1, arg2, arg3, arg4, arg5) => target
390 6, 268 ._parseMethodDeclarationAfterParameters(
391 (Parser target, arg0, arg1, arg2, arg3, arg4, arg5) => 269 arg0, arg1, arg2, arg3, arg4, arg5)),
392 target._parseMethodDeclarationAfterParameters( 270 'parseMethodDeclarationAfterReturnType_4': new MethodTrampoline(4,
393 arg0, 271 (Parser target, arg0, arg1, arg2, arg3) => target
394 arg1, 272 ._parseMethodDeclarationAfterReturnType(arg0, arg1, arg2, arg3)),
395 arg2, 273 'parseModifiers_0':
396 arg3, 274 new MethodTrampoline(0, (Parser target) => target._parseModifiers()),
397 arg4,
398 arg5)),
399 'parseMethodDeclarationAfterReturnType_4': new MethodTrampoline(
400 4,
401 (Parser target, arg0, arg1, arg2, arg3) =>
402 target._parseMethodDeclarationAfterReturnType(arg0, arg1, arg2, arg3)) ,
403 'parseModifiers_0': new MethodTrampoline(
404 0,
405 (Parser target) => target._parseModifiers()),
406 'parseMultiplicativeExpression_0': new MethodTrampoline( 275 'parseMultiplicativeExpression_0': new MethodTrampoline(
407 0, 276 0, (Parser target) => target._parseMultiplicativeExpression()),
408 (Parser target) => target._parseMultiplicativeExpression()), 277 'parseNativeClause_0':
409 'parseNativeClause_0': new MethodTrampoline( 278 new MethodTrampoline(0, (Parser target) => target._parseNativeClause()),
410 0, 279 'parseNewExpression_0':
411 (Parser target) => target._parseNativeClause()), 280 new MethodTrampoline(0, (Parser target) => target._parseNewExpression()),
412 'parseNewExpression_0': new MethodTrampoline(
413 0,
414 (Parser target) => target._parseNewExpression()),
415 'parseNonLabeledStatement_0': new MethodTrampoline( 281 'parseNonLabeledStatement_0': new MethodTrampoline(
416 0, 282 0, (Parser target) => target._parseNonLabeledStatement()),
417 (Parser target) => target._parseNonLabeledStatement()), 283 'parseOperator_3': new MethodTrampoline(3, (Parser target, arg0, arg1,
418 'parseOperator_3': new MethodTrampoline( 284 arg2) => target._parseOperator(arg0, arg1, arg2)),
419 3,
420 (Parser target, arg0, arg1, arg2) => target._parseOperator(arg0, arg1, arg 2)),
421 'parseOptionalReturnType_0': new MethodTrampoline( 285 'parseOptionalReturnType_0': new MethodTrampoline(
422 0, 286 0, (Parser target) => target._parseOptionalReturnType()),
423 (Parser target) => target._parseOptionalReturnType()),
424 'parsePartDirective_1': new MethodTrampoline( 287 'parsePartDirective_1': new MethodTrampoline(
425 1, 288 1, (Parser target, arg0) => target._parsePartDirective(arg0)),
426 (Parser target, arg0) => target._parsePartDirective(arg0)),
427 'parsePostfixExpression_0': new MethodTrampoline( 289 'parsePostfixExpression_0': new MethodTrampoline(
428 0, 290 0, (Parser target) => target._parsePostfixExpression()),
429 (Parser target) => target._parsePostfixExpression()),
430 'parsePrimaryExpression_0': new MethodTrampoline( 291 'parsePrimaryExpression_0': new MethodTrampoline(
431 0, 292 0, (Parser target) => target._parsePrimaryExpression()),
432 (Parser target) => target._parsePrimaryExpression()),
433 'parseRedirectingConstructorInvocation_0': new MethodTrampoline( 293 'parseRedirectingConstructorInvocation_0': new MethodTrampoline(
434 0, 294 0, (Parser target) => target._parseRedirectingConstructorInvocation()),
435 (Parser target) => target._parseRedirectingConstructorInvocation()),
436 'parseRelationalExpression_0': new MethodTrampoline( 295 'parseRelationalExpression_0': new MethodTrampoline(
437 0, 296 0, (Parser target) => target._parseRelationalExpression()),
438 (Parser target) => target._parseRelationalExpression()),
439 'parseRethrowExpression_0': new MethodTrampoline( 297 'parseRethrowExpression_0': new MethodTrampoline(
440 0, 298 0, (Parser target) => target._parseRethrowExpression()),
441 (Parser target) => target._parseRethrowExpression()),
442 'parseReturnStatement_0': new MethodTrampoline( 299 'parseReturnStatement_0': new MethodTrampoline(
443 0, 300 0, (Parser target) => target._parseReturnStatement()),
444 (Parser target) => target._parseReturnStatement()), 301 'parseSetter_4': new MethodTrampoline(4, (Parser target, arg0, arg1, arg2,
445 'parseSetter_4': new MethodTrampoline( 302 arg3) => target._parseSetter(arg0, arg1, arg2, arg3)),
446 4,
447 (Parser target, arg0, arg1, arg2, arg3) =>
448 target._parseSetter(arg0, arg1, arg2, arg3)),
449 'parseShiftExpression_0': new MethodTrampoline( 303 'parseShiftExpression_0': new MethodTrampoline(
450 0, 304 0, (Parser target) => target._parseShiftExpression()),
451 (Parser target) => target._parseShiftExpression()), 305 'parseStatementList_0':
452 'parseStatementList_0': new MethodTrampoline( 306 new MethodTrampoline(0, (Parser target) => target._parseStatementList()),
453 0,
454 (Parser target) => target._parseStatementList()),
455 'parseStringInterpolation_1': new MethodTrampoline( 307 'parseStringInterpolation_1': new MethodTrampoline(
456 1, 308 1, (Parser target, arg0) => target._parseStringInterpolation(arg0)),
457 (Parser target, arg0) => target._parseStringInterpolation(arg0)),
458 'parseSuperConstructorInvocation_0': new MethodTrampoline( 309 'parseSuperConstructorInvocation_0': new MethodTrampoline(
459 0, 310 0, (Parser target) => target._parseSuperConstructorInvocation()),
460 (Parser target) => target._parseSuperConstructorInvocation()),
461 'parseSwitchStatement_0': new MethodTrampoline( 311 'parseSwitchStatement_0': new MethodTrampoline(
462 0, 312 0, (Parser target) => target._parseSwitchStatement()),
463 (Parser target) => target._parseSwitchStatement()), 313 'parseSymbolLiteral_0':
464 'parseSymbolLiteral_0': new MethodTrampoline( 314 new MethodTrampoline(0, (Parser target) => target._parseSymbolLiteral()),
465 0,
466 (Parser target) => target._parseSymbolLiteral()),
467 'parseThrowExpression_0': new MethodTrampoline( 315 'parseThrowExpression_0': new MethodTrampoline(
468 0, 316 0, (Parser target) => target._parseThrowExpression()),
469 (Parser target) => target._parseThrowExpression()),
470 'parseThrowExpressionWithoutCascade_0': new MethodTrampoline( 317 'parseThrowExpressionWithoutCascade_0': new MethodTrampoline(
471 0, 318 0, (Parser target) => target._parseThrowExpressionWithoutCascade()),
472 (Parser target) => target._parseThrowExpressionWithoutCascade()), 319 'parseTryStatement_0':
473 'parseTryStatement_0': new MethodTrampoline( 320 new MethodTrampoline(0, (Parser target) => target._parseTryStatement()),
474 0,
475 (Parser target) => target._parseTryStatement()),
476 'parseTypeAlias_1': new MethodTrampoline( 321 'parseTypeAlias_1': new MethodTrampoline(
477 1, 322 1, (Parser target, arg0) => target._parseTypeAlias(arg0)),
478 (Parser target, arg0) => target._parseTypeAlias(arg0)),
479 'parseUnaryExpression_0': new MethodTrampoline( 323 'parseUnaryExpression_0': new MethodTrampoline(
480 0, 324 0, (Parser target) => target._parseUnaryExpression()),
481 (Parser target) => target._parseUnaryExpression()),
482 'parseVariableDeclaration_0': new MethodTrampoline( 325 'parseVariableDeclaration_0': new MethodTrampoline(
483 0, 326 0, (Parser target) => target._parseVariableDeclaration()),
484 (Parser target) => target._parseVariableDeclaration()), 327 'parseVariableDeclarationListAfterMetadata_1': new MethodTrampoline(1,
485 'parseVariableDeclarationListAfterMetadata_1': new MethodTrampoline(
486 1,
487 (Parser target, arg0) => 328 (Parser target, arg0) =>
488 target._parseVariableDeclarationListAfterMetadata(arg0)), 329 target._parseVariableDeclarationListAfterMetadata(arg0)),
489 'parseVariableDeclarationListAfterType_3': new MethodTrampoline( 330 'parseVariableDeclarationListAfterType_3': new MethodTrampoline(3,
490 3,
491 (Parser target, arg0, arg1, arg2) => 331 (Parser target, arg0, arg1, arg2) =>
492 target._parseVariableDeclarationListAfterType(arg0, arg1, arg2)), 332 target._parseVariableDeclarationListAfterType(arg0, arg1, arg2)),
493 'parseVariableDeclarationStatementAfterMetadata_1': new MethodTrampoline( 333 'parseVariableDeclarationStatementAfterMetadata_1': new MethodTrampoline(1,
494 1,
495 (Parser target, arg0) => 334 (Parser target, arg0) =>
496 target._parseVariableDeclarationStatementAfterMetadata(arg0)), 335 target._parseVariableDeclarationStatementAfterMetadata(arg0)),
497 'parseVariableDeclarationStatementAfterType_3': new MethodTrampoline( 336 'parseVariableDeclarationStatementAfterType_3': new MethodTrampoline(3,
498 3,
499 (Parser target, arg0, arg1, arg2) => 337 (Parser target, arg0, arg1, arg2) =>
500 target._parseVariableDeclarationStatementAfterType(arg0, arg1, arg2)), 338 target._parseVariableDeclarationStatementAfterType(arg0, arg1, arg2)),
501 'parseWhileStatement_0': new MethodTrampoline( 339 'parseWhileStatement_0':
502 0, 340 new MethodTrampoline(0, (Parser target) => target._parseWhileStatement()),
503 (Parser target) => target._parseWhileStatement()), 341 'parseYieldStatement_0':
504 'parseYieldStatement_0': new MethodTrampoline( 342 new MethodTrampoline(0, (Parser target) => target._parseYieldStatement()),
505 0,
506 (Parser target) => target._parseYieldStatement()),
507 'peek_0': new MethodTrampoline(0, (Parser target) => target._peek()), 343 'peek_0': new MethodTrampoline(0, (Parser target) => target._peek()),
508 'peekAt_1': new MethodTrampoline( 344 'peekAt_1':
509 1, 345 new MethodTrampoline(1, (Parser target, arg0) => target._peekAt(arg0)),
510 (Parser target, arg0) => target._peekAt(arg0)),
511 'reportError_1': new MethodTrampoline( 346 'reportError_1': new MethodTrampoline(
512 1, 347 1, (Parser target, arg0) => target._reportError(arg0)),
513 (Parser target, arg0) => target._reportError(arg0)), 348 'reportErrorForCurrentToken_2': new MethodTrampoline(2, (Parser target, arg0,
514 'reportErrorForCurrentToken_2': new MethodTrampoline( 349 arg1) => target._reportErrorForCurrentToken(arg0, arg1)),
515 2, 350 'reportErrorForNode_3': new MethodTrampoline(3, (Parser target, arg0, arg1,
516 (Parser target, arg0, arg1) => target._reportErrorForCurrentToken(arg0, ar g1)), 351 arg2) => target._reportErrorForNode(arg0, arg1, arg2)),
517 'reportErrorForNode_3': new MethodTrampoline( 352 'reportErrorForToken_3': new MethodTrampoline(3, (Parser target, arg0, arg1,
518 3, 353 arg2) => target._reportErrorForToken(arg0, arg1, arg2)),
519 (Parser target, arg0, arg1, arg2) => 354 'skipBlock_0':
520 target._reportErrorForNode(arg0, arg1, arg2)), 355 new MethodTrampoline(0, (Parser target) => target._skipBlock()),
521 'reportErrorForToken_3': new MethodTrampoline(
522 3,
523 (Parser target, arg0, arg1, arg2) =>
524 target._reportErrorForToken(arg0, arg1, arg2)),
525 'skipBlock_0': new MethodTrampoline(
526 0,
527 (Parser target) => target._skipBlock()),
528 'skipFinalConstVarOrType_1': new MethodTrampoline( 356 'skipFinalConstVarOrType_1': new MethodTrampoline(
529 1, 357 1, (Parser target, arg0) => target._skipFinalConstVarOrType(arg0)),
530 (Parser target, arg0) => target._skipFinalConstVarOrType(arg0)),
531 'skipFormalParameterList_1': new MethodTrampoline( 358 'skipFormalParameterList_1': new MethodTrampoline(
532 1, 359 1, (Parser target, arg0) => target._skipFormalParameterList(arg0)),
533 (Parser target, arg0) => target._skipFormalParameterList(arg0)),
534 'skipPastMatchingToken_1': new MethodTrampoline( 360 'skipPastMatchingToken_1': new MethodTrampoline(
535 1, 361 1, (Parser target, arg0) => target._skipPastMatchingToken(arg0)),
536 (Parser target, arg0) => target._skipPastMatchingToken(arg0)),
537 'skipPrefixedIdentifier_1': new MethodTrampoline( 362 'skipPrefixedIdentifier_1': new MethodTrampoline(
538 1, 363 1, (Parser target, arg0) => target._skipPrefixedIdentifier(arg0)),
539 (Parser target, arg0) => target._skipPrefixedIdentifier(arg0)),
540 'skipReturnType_1': new MethodTrampoline( 364 'skipReturnType_1': new MethodTrampoline(
541 1, 365 1, (Parser target, arg0) => target._skipReturnType(arg0)),
542 (Parser target, arg0) => target._skipReturnType(arg0)),
543 'skipSimpleIdentifier_1': new MethodTrampoline( 366 'skipSimpleIdentifier_1': new MethodTrampoline(
544 1, 367 1, (Parser target, arg0) => target._skipSimpleIdentifier(arg0)),
545 (Parser target, arg0) => target._skipSimpleIdentifier(arg0)),
546 'skipStringInterpolation_1': new MethodTrampoline( 368 'skipStringInterpolation_1': new MethodTrampoline(
547 1, 369 1, (Parser target, arg0) => target._skipStringInterpolation(arg0)),
548 (Parser target, arg0) => target._skipStringInterpolation(arg0)),
549 'skipStringLiteral_1': new MethodTrampoline( 370 'skipStringLiteral_1': new MethodTrampoline(
550 1, 371 1, (Parser target, arg0) => target._skipStringLiteral(arg0)),
551 (Parser target, arg0) => target._skipStringLiteral(arg0)),
552 'skipTypeArgumentList_1': new MethodTrampoline( 372 'skipTypeArgumentList_1': new MethodTrampoline(
553 1, 373 1, (Parser target, arg0) => target._skipTypeArgumentList(arg0)),
554 (Parser target, arg0) => target._skipTypeArgumentList(arg0)),
555 'skipTypeName_1': new MethodTrampoline( 374 'skipTypeName_1': new MethodTrampoline(
556 1, 375 1, (Parser target, arg0) => target._skipTypeName(arg0)),
557 (Parser target, arg0) => target._skipTypeName(arg0)),
558 'skipTypeParameterList_1': new MethodTrampoline( 376 'skipTypeParameterList_1': new MethodTrampoline(
559 1, 377 1, (Parser target, arg0) => target._skipTypeParameterList(arg0)),
560 (Parser target, arg0) => target._skipTypeParameterList(arg0)),
561 'tokenMatches_2': new MethodTrampoline( 378 'tokenMatches_2': new MethodTrampoline(
562 2, 379 2, (Parser target, arg0, arg1) => target._tokenMatches(arg0, arg1)),
563 (Parser target, arg0, arg1) => target._tokenMatches(arg0, arg1)),
564 'tokenMatchesIdentifier_1': new MethodTrampoline( 380 'tokenMatchesIdentifier_1': new MethodTrampoline(
565 1, 381 1, (Parser target, arg0) => target._tokenMatchesIdentifier(arg0)),
566 (Parser target, arg0) => target._tokenMatchesIdentifier(arg0)), 382 'tokenMatchesKeyword_2': new MethodTrampoline(2,
567 'tokenMatchesKeyword_2': new MethodTrampoline(
568 2,
569 (Parser target, arg0, arg1) => target._tokenMatchesKeyword(arg0, arg1)), 383 (Parser target, arg0, arg1) => target._tokenMatchesKeyword(arg0, arg1)),
570 'tokenMatchesString_2': new MethodTrampoline( 384 'tokenMatchesString_2': new MethodTrampoline(
571 2, 385 2, (Parser target, arg0, arg1) => target._tokenMatchesString(arg0, arg1)),
572 (Parser target, arg0, arg1) => target._tokenMatchesString(arg0, arg1)), 386 'translateCharacter_3': new MethodTrampoline(3, (Parser target, arg0, arg1,
573 'translateCharacter_3': new MethodTrampoline( 387 arg2) => target._translateCharacter(arg0, arg1, arg2)),
574 3, 388 'unlockErrorListener_0':
575 (Parser target, arg0, arg1, arg2) => 389 new MethodTrampoline(0, (Parser target) => target._unlockErrorListener()),
576 target._translateCharacter(arg0, arg1, arg2)),
577 'unlockErrorListener_0': new MethodTrampoline(
578 0,
579 (Parser target) => target._unlockErrorListener()),
580 'validateFormalParameterList_1': new MethodTrampoline( 390 'validateFormalParameterList_1': new MethodTrampoline(
581 1, 391 1, (Parser target, arg0) => target._validateFormalParameterList(arg0)),
582 (Parser target, arg0) => target._validateFormalParameterList(arg0)),
583 'validateModifiersForClass_1': new MethodTrampoline( 392 'validateModifiersForClass_1': new MethodTrampoline(
584 1, 393 1, (Parser target, arg0) => target._validateModifiersForClass(arg0)),
585 (Parser target, arg0) => target._validateModifiersForClass(arg0)), 394 'validateModifiersForConstructor_1': new MethodTrampoline(1,
586 'validateModifiersForConstructor_1': new MethodTrampoline(
587 1,
588 (Parser target, arg0) => target._validateModifiersForConstructor(arg0)), 395 (Parser target, arg0) => target._validateModifiersForConstructor(arg0)),
589 'validateModifiersForEnum_1': new MethodTrampoline( 396 'validateModifiersForEnum_1': new MethodTrampoline(
590 1, 397 1, (Parser target, arg0) => target._validateModifiersForEnum(arg0)),
591 (Parser target, arg0) => target._validateModifiersForEnum(arg0)),
592 'validateModifiersForField_1': new MethodTrampoline( 398 'validateModifiersForField_1': new MethodTrampoline(
593 1, 399 1, (Parser target, arg0) => target._validateModifiersForField(arg0)),
594 (Parser target, arg0) => target._validateModifiersForField(arg0)), 400 'validateModifiersForFunctionDeclarationStatement_1': new MethodTrampoline(1,
595 'validateModifiersForFunctionDeclarationStatement_1': new MethodTrampoline(
596 1,
597 (Parser target, arg0) => 401 (Parser target, arg0) =>
598 target._validateModifiersForFunctionDeclarationStatement(arg0)), 402 target._validateModifiersForFunctionDeclarationStatement(arg0)),
599 'validateModifiersForGetterOrSetterOrMethod_1': new MethodTrampoline( 403 'validateModifiersForGetterOrSetterOrMethod_1': new MethodTrampoline(1,
600 1,
601 (Parser target, arg0) => 404 (Parser target, arg0) =>
602 target._validateModifiersForGetterOrSetterOrMethod(arg0)), 405 target._validateModifiersForGetterOrSetterOrMethod(arg0)),
603 'validateModifiersForOperator_1': new MethodTrampoline( 406 'validateModifiersForOperator_1': new MethodTrampoline(
604 1, 407 1, (Parser target, arg0) => target._validateModifiersForOperator(arg0)),
605 (Parser target, arg0) => target._validateModifiersForOperator(arg0)), 408 'validateModifiersForTopLevelDeclaration_1': new MethodTrampoline(1,
606 'validateModifiersForTopLevelDeclaration_1': new MethodTrampoline( 409 (Parser target, arg0) =>
607 1, 410 target._validateModifiersForTopLevelDeclaration(arg0)),
608 (Parser target, arg0) => target._validateModifiersForTopLevelDeclaration(a rg0)), 411 'validateModifiersForTopLevelFunction_1': new MethodTrampoline(1,
609 'validateModifiersForTopLevelFunction_1': new MethodTrampoline( 412 (Parser target, arg0) =>
610 1, 413 target._validateModifiersForTopLevelFunction(arg0)),
611 (Parser target, arg0) => target._validateModifiersForTopLevelFunction(arg0 )), 414 'validateModifiersForTopLevelVariable_1': new MethodTrampoline(1,
612 'validateModifiersForTopLevelVariable_1': new MethodTrampoline( 415 (Parser target, arg0) =>
613 1, 416 target._validateModifiersForTopLevelVariable(arg0)),
614 (Parser target, arg0) => target._validateModifiersForTopLevelVariable(arg0 )),
615 'validateModifiersForTypedef_1': new MethodTrampoline( 417 'validateModifiersForTypedef_1': new MethodTrampoline(
616 1, 418 1, (Parser target, arg0) => target._validateModifiersForTypedef(arg0)),
617 (Parser target, arg0) => target._validateModifiersForTypedef(arg0)),
618 }; 419 };
619 420
620 Object invokeParserMethodImpl(Parser parser, String methodName, 421 Object invokeParserMethodImpl(
621 List<Object> objects, Token tokenStream) { 422 Parser parser, String methodName, List<Object> objects, Token tokenStream) {
622 parser.currentToken = tokenStream; 423 parser.currentToken = tokenStream;
623 MethodTrampoline method = 424 MethodTrampoline method =
624 methodTable_Parser['${methodName}_${objects.length}']; 425 methodTable_Parser['${methodName}_${objects.length}'];
625 return method.invoke(parser, objects); 426 return method.invoke(parser, objects);
626 } 427 }
627 428
628 /** 429 /**
629 * Instances of the class `CommentAndMetadata` implement a simple data-holder fo r a method 430 * Instances of the class `CommentAndMetadata` implement a simple data-holder fo r a method
630 * that needs to return multiple values. 431 * that needs to return multiple values.
631 */ 432 */
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 AstNode visitPropertyAccess(PropertyAccess node) { 1304 AstNode visitPropertyAccess(PropertyAccess node) {
1504 if (identical(_oldNode, node.target)) { 1305 if (identical(_oldNode, node.target)) {
1505 throw new InsufficientContextException(); 1306 throw new InsufficientContextException();
1506 } else if (identical(_oldNode, node.propertyName)) { 1307 } else if (identical(_oldNode, node.propertyName)) {
1507 return _parser.parseSimpleIdentifier(); 1308 return _parser.parseSimpleIdentifier();
1508 } 1309 }
1509 return _notAChild(node); 1310 return _notAChild(node);
1510 } 1311 }
1511 1312
1512 @override 1313 @override
1513 AstNode 1314 AstNode visitRedirectingConstructorInvocation(
1514 visitRedirectingConstructorInvocation(RedirectingConstructorInvocation nod e) { 1315 RedirectingConstructorInvocation node) {
1515 if (identical(_oldNode, node.constructorName)) { 1316 if (identical(_oldNode, node.constructorName)) {
1516 return _parser.parseSimpleIdentifier(); 1317 return _parser.parseSimpleIdentifier();
1517 } else if (identical(_oldNode, node.argumentList)) { 1318 } else if (identical(_oldNode, node.argumentList)) {
1518 return _parser.parseArgumentList(); 1319 return _parser.parseArgumentList();
1519 } 1320 }
1520 return _notAChild(node); 1321 return _notAChild(node);
1521 } 1322 }
1522 1323
1523 @override 1324 @override
1524 AstNode visitRethrowExpression(RethrowExpression node) => _notAChild(node); 1325 AstNode visitRethrowExpression(RethrowExpression node) => _notAChild(node);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 firstToken = leftToken; 1694 firstToken = leftToken;
1894 } 1695 }
1895 // 1696 //
1896 // Find the smallest AST node that encompasses the range of re-scanned 1697 // Find the smallest AST node that encompasses the range of re-scanned
1897 // tokens. 1698 // tokens.
1898 // 1699 //
1899 if (originalEnd < originalStart) { 1700 if (originalEnd < originalStart) {
1900 oldNode = 1701 oldNode =
1901 new NodeLocator.con1(originalStart).searchWithin(originalStructure); 1702 new NodeLocator.con1(originalStart).searchWithin(originalStructure);
1902 } else { 1703 } else {
1903 oldNode = new NodeLocator.con2( 1704 oldNode = new NodeLocator.con2(originalStart, originalEnd)
1904 originalStart, 1705 .searchWithin(originalStructure);
1905 originalEnd).searchWithin(originalStructure);
1906 } 1706 }
1907 // 1707 //
1908 // Find the token at which parsing is to begin. 1708 // Find the token at which parsing is to begin.
1909 // 1709 //
1910 int originalOffset = oldNode.offset; 1710 int originalOffset = oldNode.offset;
1911 Token parseToken = _findTokenAt(firstToken, originalOffset); 1711 Token parseToken = _findTokenAt(firstToken, originalOffset);
1912 if (parseToken == null) { 1712 if (parseToken == null) {
1913 return null; 1713 return null;
1914 } 1714 }
1915 // 1715 //
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 case 0: 1937 case 0:
2138 return trampoline(target); 1938 return trampoline(target);
2139 case 1: 1939 case 1:
2140 return trampoline(target, arguments[0]); 1940 return trampoline(target, arguments[0]);
2141 case 2: 1941 case 2:
2142 return trampoline(target, arguments[0], arguments[1]); 1942 return trampoline(target, arguments[0], arguments[1]);
2143 case 3: 1943 case 3:
2144 return trampoline(target, arguments[0], arguments[1], arguments[2]); 1944 return trampoline(target, arguments[0], arguments[1], arguments[2]);
2145 case 4: 1945 case 4:
2146 return trampoline( 1946 return trampoline(
2147 target, 1947 target, arguments[0], arguments[1], arguments[2], arguments[3]);
2148 arguments[0],
2149 arguments[1],
2150 arguments[2],
2151 arguments[3]);
2152 default: 1948 default:
2153 throw new IllegalArgumentException("Not implemented for > 4 arguments"); 1949 throw new IllegalArgumentException("Not implemented for > 4 arguments");
2154 } 1950 }
2155 } 1951 }
2156 } 1952 }
2157 1953
2158 /** 1954 /**
2159 * Instances of the class `Modifiers` implement a simple data-holder for a metho d that needs 1955 * Instances of the class `Modifiers` implement a simple data-holder for a metho d that needs
2160 * to return multiple values. 1956 * to return multiple values.
2161 */ 1957 */
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
2458 _inInitializer = false; 2254 _inInitializer = false;
2459 try { 2255 try {
2460 Expression argument = parseArgument(); 2256 Expression argument = parseArgument();
2461 arguments.add(argument); 2257 arguments.add(argument);
2462 bool foundNamedArgument = argument is NamedExpression; 2258 bool foundNamedArgument = argument is NamedExpression;
2463 bool generatedError = false; 2259 bool generatedError = false;
2464 while (_optional(TokenType.COMMA)) { 2260 while (_optional(TokenType.COMMA)) {
2465 argument = parseArgument(); 2261 argument = parseArgument();
2466 arguments.add(argument); 2262 arguments.add(argument);
2467 if (foundNamedArgument) { 2263 if (foundNamedArgument) {
2468 bool blankArgument = 2264 bool blankArgument = argument is SimpleIdentifier &&
2469 argument is SimpleIdentifier &&
2470 (argument as SimpleIdentifier).name.isEmpty; 2265 (argument as SimpleIdentifier).name.isEmpty;
2471 if (!generatedError && 2266 if (!generatedError &&
2472 !(argument is NamedExpression && !blankArgument)) { 2267 !(argument is NamedExpression && !blankArgument)) {
2473 // Report the error, once, but allow the arguments to be in any 2268 // Report the error, once, but allow the arguments to be in any
2474 // order in the AST. 2269 // order in the AST.
2475 _reportErrorForCurrentToken( 2270 _reportErrorForCurrentToken(
2476 ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT); 2271 ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT);
2477 generatedError = true; 2272 generatedError = true;
2478 } 2273 }
2479 } else if (argument is NamedExpression) { 2274 } else if (argument is NamedExpression) {
(...skipping 24 matching lines...) Expand all
2504 Expression parseBitwiseOrExpression() { 2299 Expression parseBitwiseOrExpression() {
2505 Expression expression; 2300 Expression expression;
2506 if (_matchesKeyword(Keyword.SUPER) && 2301 if (_matchesKeyword(Keyword.SUPER) &&
2507 _tokenMatches(_peek(), TokenType.BAR)) { 2302 _tokenMatches(_peek(), TokenType.BAR)) {
2508 expression = new SuperExpression(getAndAdvance()); 2303 expression = new SuperExpression(getAndAdvance());
2509 } else { 2304 } else {
2510 expression = _parseBitwiseXorExpression(); 2305 expression = _parseBitwiseXorExpression();
2511 } 2306 }
2512 while (_matches(TokenType.BAR)) { 2307 while (_matches(TokenType.BAR)) {
2513 Token operator = getAndAdvance(); 2308 Token operator = getAndAdvance();
2514 expression = 2309 expression = new BinaryExpression(
2515 new BinaryExpression(expression, operator, _parseBitwiseXorExpression( )); 2310 expression, operator, _parseBitwiseXorExpression());
2516 } 2311 }
2517 return expression; 2312 return expression;
2518 } 2313 }
2519 2314
2520 /** 2315 /**
2521 * Parse a block. 2316 * Parse a block.
2522 * 2317 *
2523 * <pre> 2318 * <pre>
2524 * block ::= 2319 * block ::=
2525 * '{' statements '}' 2320 * '{' statements '}'
2526 * </pre> 2321 * </pre>
2527 * 2322 *
2528 * @return the block that was parsed 2323 * @return the block that was parsed
2529 */ 2324 */
2530 Block parseBlock() { 2325 Block parseBlock() {
2531 Token leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET); 2326 Token leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET);
2532 List<Statement> statements = new List<Statement>(); 2327 List<Statement> statements = new List<Statement>();
2533 Token statementStart = _currentToken; 2328 Token statementStart = _currentToken;
2534 while (!_matches(TokenType.EOF) && 2329 while (
2535 !_matches(TokenType.CLOSE_CURLY_BRACKET)) { 2330 !_matches(TokenType.EOF) && !_matches(TokenType.CLOSE_CURLY_BRACKET)) {
2536 Statement statement = parseStatement2(); 2331 Statement statement = parseStatement2();
2537 if (statement != null) { 2332 if (statement != null) {
2538 statements.add(statement); 2333 statements.add(statement);
2539 } 2334 }
2540 if (identical(_currentToken, statementStart)) { 2335 if (identical(_currentToken, statementStart)) {
2541 // Ensure that we are making progress and report an error if we're not. 2336 // Ensure that we are making progress and report an error if we're not.
2542 _reportErrorForToken( 2337 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken,
2543 ParserErrorCode.UNEXPECTED_TOKEN,
2544 _currentToken,
2545 [_currentToken.lexeme]); 2338 [_currentToken.lexeme]);
2546 _advance(); 2339 _advance();
2547 } 2340 }
2548 statementStart = _currentToken; 2341 statementStart = _currentToken;
2549 } 2342 }
2550 Token rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); 2343 Token rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET);
2551 return new Block(leftBracket, statements, rightBracket); 2344 return new Block(leftBracket, statements, rightBracket);
2552 } 2345 }
2553 2346
2554 /** 2347 /**
2555 * Parse a class member. 2348 * Parse a class member.
2556 * 2349 *
2557 * <pre> 2350 * <pre>
2558 * classMemberDefinition ::= 2351 * classMemberDefinition ::=
2559 * declaration ';' 2352 * declaration ';'
2560 * | methodSignature functionBody 2353 * | methodSignature functionBody
2561 * </pre> 2354 * </pre>
2562 * 2355 *
2563 * @param className the name of the class containing the member being parsed 2356 * @param className the name of the class containing the member being parsed
2564 * @return the class member that was parsed, or `null` if what was found was n ot a valid 2357 * @return the class member that was parsed, or `null` if what was found was n ot a valid
2565 * class member 2358 * class member
2566 */ 2359 */
2567 ClassMember parseClassMember(String className) { 2360 ClassMember parseClassMember(String className) {
2568 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); 2361 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata();
2569 Modifiers modifiers = _parseModifiers(); 2362 Modifiers modifiers = _parseModifiers();
2570 if (_matchesKeyword(Keyword.VOID)) { 2363 if (_matchesKeyword(Keyword.VOID)) {
2571 TypeName returnType = parseReturnType(); 2364 TypeName returnType = parseReturnType();
2572 if (_matchesKeyword(Keyword.GET) && _tokenMatchesIdentifier(_peek())) { 2365 if (_matchesKeyword(Keyword.GET) && _tokenMatchesIdentifier(_peek())) {
2573 _validateModifiersForGetterOrSetterOrMethod(modifiers); 2366 _validateModifiersForGetterOrSetterOrMethod(modifiers);
2574 return _parseGetter( 2367 return _parseGetter(commentAndMetadata, modifiers.externalKeyword,
2575 commentAndMetadata, 2368 modifiers.staticKeyword, returnType);
2576 modifiers.externalKeyword,
2577 modifiers.staticKeyword,
2578 returnType);
2579 } else if (_matchesKeyword(Keyword.SET) && 2369 } else if (_matchesKeyword(Keyword.SET) &&
2580 _tokenMatchesIdentifier(_peek())) { 2370 _tokenMatchesIdentifier(_peek())) {
2581 _validateModifiersForGetterOrSetterOrMethod(modifiers); 2371 _validateModifiersForGetterOrSetterOrMethod(modifiers);
2582 return _parseSetter( 2372 return _parseSetter(commentAndMetadata, modifiers.externalKeyword,
2583 commentAndMetadata, 2373 modifiers.staticKeyword, returnType);
2584 modifiers.externalKeyword,
2585 modifiers.staticKeyword,
2586 returnType);
2587 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { 2374 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) {
2588 _validateModifiersForOperator(modifiers); 2375 _validateModifiersForOperator(modifiers);
2589 return _parseOperator( 2376 return _parseOperator(
2590 commentAndMetadata, 2377 commentAndMetadata, modifiers.externalKeyword, returnType);
2591 modifiers.externalKeyword,
2592 returnType);
2593 } else if (_matchesIdentifier() && 2378 } else if (_matchesIdentifier() &&
2594 _peek().matchesAny( 2379 _peek().matchesAny([
2595 [TokenType.OPEN_PAREN, TokenType.OPEN_CURLY_BRACKET, TokenType.FUN CTION])) { 2380 TokenType.OPEN_PAREN,
2381 TokenType.OPEN_CURLY_BRACKET,
2382 TokenType.FUNCTION
2383 ])) {
2596 _validateModifiersForGetterOrSetterOrMethod(modifiers); 2384 _validateModifiersForGetterOrSetterOrMethod(modifiers);
2597 return _parseMethodDeclarationAfterReturnType( 2385 return _parseMethodDeclarationAfterReturnType(commentAndMetadata,
2598 commentAndMetadata, 2386 modifiers.externalKeyword, modifiers.staticKeyword, returnType);
2599 modifiers.externalKeyword,
2600 modifiers.staticKeyword,
2601 returnType);
2602 } else { 2387 } else {
2603 // 2388 //
2604 // We have found an error of some kind. Try to recover. 2389 // We have found an error of some kind. Try to recover.
2605 // 2390 //
2606 if (_matchesIdentifier()) { 2391 if (_matchesIdentifier()) {
2607 if (_peek().matchesAny( 2392 if (_peek().matchesAny(
2608 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { 2393 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) {
2609 // 2394 //
2610 // We appear to have a variable declaration with a type of "void". 2395 // We appear to have a variable declaration with a type of "void".
2611 // 2396 //
2612 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType); 2397 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType);
2613 return _parseInitializedIdentifierList( 2398 return _parseInitializedIdentifierList(commentAndMetadata,
2614 commentAndMetadata, 2399 modifiers.staticKeyword, _validateModifiersForField(modifiers),
2615 modifiers.staticKeyword,
2616 _validateModifiersForField(modifiers),
2617 returnType); 2400 returnType);
2618 } 2401 }
2619 } 2402 }
2620 if (_isOperator(_currentToken)) { 2403 if (_isOperator(_currentToken)) {
2621 // 2404 //
2622 // We appear to have found an operator declaration without the 2405 // We appear to have found an operator declaration without the
2623 // 'operator' keyword. 2406 // 'operator' keyword.
2624 // 2407 //
2625 _validateModifiersForOperator(modifiers); 2408 _validateModifiersForOperator(modifiers);
2626 return _parseOperator( 2409 return _parseOperator(
2627 commentAndMetadata, 2410 commentAndMetadata, modifiers.externalKeyword, returnType);
2628 modifiers.externalKeyword,
2629 returnType);
2630 } 2411 }
2631 _reportErrorForToken( 2412 _reportErrorForToken(
2632 ParserErrorCode.EXPECTED_EXECUTABLE, 2413 ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken);
2633 _currentToken);
2634 return null; 2414 return null;
2635 } 2415 }
2636 } else if (_matchesKeyword(Keyword.GET) && 2416 } else if (_matchesKeyword(Keyword.GET) &&
2637 _tokenMatchesIdentifier(_peek())) { 2417 _tokenMatchesIdentifier(_peek())) {
2638 _validateModifiersForGetterOrSetterOrMethod(modifiers); 2418 _validateModifiersForGetterOrSetterOrMethod(modifiers);
2639 return _parseGetter( 2419 return _parseGetter(commentAndMetadata, modifiers.externalKeyword,
2640 commentAndMetadata, 2420 modifiers.staticKeyword, null);
2641 modifiers.externalKeyword,
2642 modifiers.staticKeyword,
2643 null);
2644 } else if (_matchesKeyword(Keyword.SET) && 2421 } else if (_matchesKeyword(Keyword.SET) &&
2645 _tokenMatchesIdentifier(_peek())) { 2422 _tokenMatchesIdentifier(_peek())) {
2646 _validateModifiersForGetterOrSetterOrMethod(modifiers); 2423 _validateModifiersForGetterOrSetterOrMethod(modifiers);
2647 return _parseSetter( 2424 return _parseSetter(commentAndMetadata, modifiers.externalKeyword,
2648 commentAndMetadata, 2425 modifiers.staticKeyword, null);
2649 modifiers.externalKeyword,
2650 modifiers.staticKeyword,
2651 null);
2652 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { 2426 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) {
2653 _validateModifiersForOperator(modifiers); 2427 _validateModifiersForOperator(modifiers);
2654 return _parseOperator( 2428 return _parseOperator(
2655 commentAndMetadata, 2429 commentAndMetadata, modifiers.externalKeyword, null);
2656 modifiers.externalKeyword,
2657 null);
2658 } else if (!_matchesIdentifier()) { 2430 } else if (!_matchesIdentifier()) {
2659 // 2431 //
2660 // Recover from an error. 2432 // Recover from an error.
2661 // 2433 //
2662 if (_matchesKeyword(Keyword.CLASS)) { 2434 if (_matchesKeyword(Keyword.CLASS)) {
2663 _reportErrorForCurrentToken(ParserErrorCode.CLASS_IN_CLASS); 2435 _reportErrorForCurrentToken(ParserErrorCode.CLASS_IN_CLASS);
2664 // TODO(brianwilkerson) We don't currently have any way to capture the 2436 // TODO(brianwilkerson) We don't currently have any way to capture the
2665 // class that was parsed. 2437 // class that was parsed.
2666 _parseClassDeclaration(commentAndMetadata, null); 2438 _parseClassDeclaration(commentAndMetadata, null);
2667 return null; 2439 return null;
2668 } else if (_matchesKeyword(Keyword.ABSTRACT) && 2440 } else if (_matchesKeyword(Keyword.ABSTRACT) &&
2669 _tokenMatchesKeyword(_peek(), Keyword.CLASS)) { 2441 _tokenMatchesKeyword(_peek(), Keyword.CLASS)) {
2670 _reportErrorForToken(ParserErrorCode.CLASS_IN_CLASS, _peek()); 2442 _reportErrorForToken(ParserErrorCode.CLASS_IN_CLASS, _peek());
2671 // TODO(brianwilkerson) We don't currently have any way to capture the 2443 // TODO(brianwilkerson) We don't currently have any way to capture the
2672 // class that was parsed. 2444 // class that was parsed.
2673 _parseClassDeclaration(commentAndMetadata, getAndAdvance()); 2445 _parseClassDeclaration(commentAndMetadata, getAndAdvance());
2674 return null; 2446 return null;
2675 } else if (_isOperator(_currentToken)) { 2447 } else if (_isOperator(_currentToken)) {
2676 // 2448 //
2677 // We appear to have found an operator declaration without the 2449 // We appear to have found an operator declaration without the
2678 // 'operator' keyword. 2450 // 'operator' keyword.
2679 // 2451 //
2680 _validateModifiersForOperator(modifiers); 2452 _validateModifiersForOperator(modifiers);
2681 return _parseOperator( 2453 return _parseOperator(
2682 commentAndMetadata, 2454 commentAndMetadata, modifiers.externalKeyword, null);
2683 modifiers.externalKeyword,
2684 null);
2685 } 2455 }
2686 Token keyword = modifiers.varKeyword; 2456 Token keyword = modifiers.varKeyword;
2687 if (keyword == null) { 2457 if (keyword == null) {
2688 keyword = modifiers.finalKeyword; 2458 keyword = modifiers.finalKeyword;
2689 } 2459 }
2690 if (keyword == null) { 2460 if (keyword == null) {
2691 keyword = modifiers.constKeyword; 2461 keyword = modifiers.constKeyword;
2692 } 2462 }
2693 if (keyword != null) { 2463 if (keyword != null) {
2694 // 2464 //
2695 // We appear to have found an incomplete field declaration. 2465 // We appear to have found an incomplete field declaration.
2696 // 2466 //
2697 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER); 2467 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER);
2698 List<VariableDeclaration> variables = new List<VariableDeclaration>(); 2468 List<VariableDeclaration> variables = new List<VariableDeclaration>();
2699 variables.add( 2469 variables.add(new VariableDeclaration(
2700 new VariableDeclaration(null, null, _createSyntheticIdentifier(), nu ll, null)); 2470 null, null, _createSyntheticIdentifier(), null, null));
2701 return new FieldDeclaration( 2471 return new FieldDeclaration(commentAndMetadata.comment,
2702 commentAndMetadata.comment, 2472 commentAndMetadata.metadata, null,
2703 commentAndMetadata.metadata,
2704 null,
2705 new VariableDeclarationList(null, null, keyword, null, variables), 2473 new VariableDeclarationList(null, null, keyword, null, variables),
2706 _expectSemicolon()); 2474 _expectSemicolon());
2707 } 2475 }
2708 _reportErrorForToken( 2476 _reportErrorForToken(
2709 ParserErrorCode.EXPECTED_CLASS_MEMBER, 2477 ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken);
2710 _currentToken);
2711 if (commentAndMetadata.comment != null || 2478 if (commentAndMetadata.comment != null ||
2712 !commentAndMetadata.metadata.isEmpty) { 2479 !commentAndMetadata.metadata.isEmpty) {
2713 // 2480 //
2714 // We appear to have found an incomplete declaration at the end of the 2481 // We appear to have found an incomplete declaration at the end of the
2715 // class. At this point it consists of a metadata, which we don't want 2482 // class. At this point it consists of a metadata, which we don't want
2716 // to loose, so we'll treat it as a method declaration with a missing 2483 // to loose, so we'll treat it as a method declaration with a missing
2717 // name, parameters and empty body. 2484 // name, parameters and empty body.
2718 // 2485 //
2719 return new MethodDeclaration( 2486 return new MethodDeclaration(commentAndMetadata.comment,
2720 commentAndMetadata.comment, 2487 commentAndMetadata.metadata, null, null, null, null, null,
2721 commentAndMetadata.metadata, 2488 _createSyntheticIdentifier(), new FormalParameterList(
2722 null, 2489 null, new List<FormalParameter>(), null, null, null),
2723 null,
2724 null,
2725 null,
2726 null,
2727 _createSyntheticIdentifier(),
2728 new FormalParameterList(null, new List<FormalParameter>(), null, nul l, null),
2729 new EmptyFunctionBody(_createSyntheticToken(TokenType.SEMICOLON))); 2490 new EmptyFunctionBody(_createSyntheticToken(TokenType.SEMICOLON)));
2730 } 2491 }
2731 return null; 2492 return null;
2732 } else if (_tokenMatches(_peek(), TokenType.PERIOD) && 2493 } else if (_tokenMatches(_peek(), TokenType.PERIOD) &&
2733 _tokenMatchesIdentifier(_peekAt(2)) && 2494 _tokenMatchesIdentifier(_peekAt(2)) &&
2734 _tokenMatches(_peekAt(3), TokenType.OPEN_PAREN)) { 2495 _tokenMatches(_peekAt(3), TokenType.OPEN_PAREN)) {
2735 return _parseConstructor( 2496 return _parseConstructor(commentAndMetadata, modifiers.externalKeyword,
2736 commentAndMetadata, 2497 _validateModifiersForConstructor(modifiers), modifiers.factoryKeyword,
2737 modifiers.externalKeyword, 2498 parseSimpleIdentifier(), getAndAdvance(), parseSimpleIdentifier(),
2738 _validateModifiersForConstructor(modifiers),
2739 modifiers.factoryKeyword,
2740 parseSimpleIdentifier(),
2741 getAndAdvance(),
2742 parseSimpleIdentifier(),
2743 parseFormalParameterList()); 2499 parseFormalParameterList());
2744 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { 2500 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) {
2745 SimpleIdentifier methodName = parseSimpleIdentifier(); 2501 SimpleIdentifier methodName = parseSimpleIdentifier();
2746 FormalParameterList parameters = parseFormalParameterList(); 2502 FormalParameterList parameters = parseFormalParameterList();
2747 if (_matches(TokenType.COLON) || 2503 if (_matches(TokenType.COLON) ||
2748 modifiers.factoryKeyword != null || 2504 modifiers.factoryKeyword != null ||
2749 methodName.name == className) { 2505 methodName.name == className) {
2750 return _parseConstructor( 2506 return _parseConstructor(commentAndMetadata, modifiers.externalKeyword,
2751 commentAndMetadata,
2752 modifiers.externalKeyword,
2753 _validateModifiersForConstructor(modifiers), 2507 _validateModifiersForConstructor(modifiers),
2754 modifiers.factoryKeyword, 2508 modifiers.factoryKeyword, methodName, null, null, parameters);
2755 methodName,
2756 null,
2757 null,
2758 parameters);
2759 } 2509 }
2760 _validateModifiersForGetterOrSetterOrMethod(modifiers); 2510 _validateModifiersForGetterOrSetterOrMethod(modifiers);
2761 _validateFormalParameterList(parameters); 2511 _validateFormalParameterList(parameters);
2762 return _parseMethodDeclarationAfterParameters( 2512 return _parseMethodDeclarationAfterParameters(commentAndMetadata,
2763 commentAndMetadata, 2513 modifiers.externalKeyword, modifiers.staticKeyword, null, methodName,
2764 modifiers.externalKeyword,
2765 modifiers.staticKeyword,
2766 null,
2767 methodName,
2768 parameters); 2514 parameters);
2769 } else if (_peek().matchesAny( 2515 } else if (_peek()
2770 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { 2516 .matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) {
2771 if (modifiers.constKeyword == null && 2517 if (modifiers.constKeyword == null &&
2772 modifiers.finalKeyword == null && 2518 modifiers.finalKeyword == null &&
2773 modifiers.varKeyword == null) { 2519 modifiers.varKeyword == null) {
2774 _reportErrorForCurrentToken( 2520 _reportErrorForCurrentToken(
2775 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE); 2521 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE);
2776 } 2522 }
2777 return _parseInitializedIdentifierList( 2523 return _parseInitializedIdentifierList(commentAndMetadata,
2778 commentAndMetadata, 2524 modifiers.staticKeyword, _validateModifiersForField(modifiers), null);
2779 modifiers.staticKeyword,
2780 _validateModifiersForField(modifiers),
2781 null);
2782 } else if (_matchesKeyword(Keyword.TYPEDEF)) { 2525 } else if (_matchesKeyword(Keyword.TYPEDEF)) {
2783 _reportErrorForCurrentToken(ParserErrorCode.TYPEDEF_IN_CLASS); 2526 _reportErrorForCurrentToken(ParserErrorCode.TYPEDEF_IN_CLASS);
2784 // TODO(brianwilkerson) We don't currently have any way to capture the 2527 // TODO(brianwilkerson) We don't currently have any way to capture the
2785 // function type alias that was parsed. 2528 // function type alias that was parsed.
2786 _parseFunctionTypeAlias(commentAndMetadata, getAndAdvance()); 2529 _parseFunctionTypeAlias(commentAndMetadata, getAndAdvance());
2787 return null; 2530 return null;
2788 } 2531 }
2789 TypeName type = parseTypeName(); 2532 TypeName type = parseTypeName();
2790 if (_matchesKeyword(Keyword.GET) && _tokenMatchesIdentifier(_peek())) { 2533 if (_matchesKeyword(Keyword.GET) && _tokenMatchesIdentifier(_peek())) {
2791 _validateModifiersForGetterOrSetterOrMethod(modifiers); 2534 _validateModifiersForGetterOrSetterOrMethod(modifiers);
2792 return _parseGetter( 2535 return _parseGetter(commentAndMetadata, modifiers.externalKeyword,
2793 commentAndMetadata, 2536 modifiers.staticKeyword, type);
2794 modifiers.externalKeyword,
2795 modifiers.staticKeyword,
2796 type);
2797 } else if (_matchesKeyword(Keyword.SET) && 2537 } else if (_matchesKeyword(Keyword.SET) &&
2798 _tokenMatchesIdentifier(_peek())) { 2538 _tokenMatchesIdentifier(_peek())) {
2799 _validateModifiersForGetterOrSetterOrMethod(modifiers); 2539 _validateModifiersForGetterOrSetterOrMethod(modifiers);
2800 return _parseSetter( 2540 return _parseSetter(commentAndMetadata, modifiers.externalKeyword,
2801 commentAndMetadata, 2541 modifiers.staticKeyword, type);
2802 modifiers.externalKeyword,
2803 modifiers.staticKeyword,
2804 type);
2805 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { 2542 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) {
2806 _validateModifiersForOperator(modifiers); 2543 _validateModifiersForOperator(modifiers);
2807 return _parseOperator( 2544 return _parseOperator(
2808 commentAndMetadata, 2545 commentAndMetadata, modifiers.externalKeyword, type);
2809 modifiers.externalKeyword,
2810 type);
2811 } else if (!_matchesIdentifier()) { 2546 } else if (!_matchesIdentifier()) {
2812 if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { 2547 if (_matches(TokenType.CLOSE_CURLY_BRACKET)) {
2813 // 2548 //
2814 // We appear to have found an incomplete declaration at the end of the 2549 // We appear to have found an incomplete declaration at the end of the
2815 // class. At this point it consists of a type name, so we'll treat it as 2550 // class. At this point it consists of a type name, so we'll treat it as
2816 // a field declaration with a missing field name and semicolon. 2551 // a field declaration with a missing field name and semicolon.
2817 // 2552 //
2818 return _parseInitializedIdentifierList( 2553 return _parseInitializedIdentifierList(commentAndMetadata,
2819 commentAndMetadata, 2554 modifiers.staticKeyword, _validateModifiersForField(modifiers),
2820 modifiers.staticKeyword,
2821 _validateModifiersForField(modifiers),
2822 type); 2555 type);
2823 } 2556 }
2824 if (_isOperator(_currentToken)) { 2557 if (_isOperator(_currentToken)) {
2825 // 2558 //
2826 // We appear to have found an operator declaration without the 2559 // We appear to have found an operator declaration without the
2827 // 'operator' keyword. 2560 // 'operator' keyword.
2828 // 2561 //
2829 _validateModifiersForOperator(modifiers); 2562 _validateModifiersForOperator(modifiers);
2830 return _parseOperator( 2563 return _parseOperator(
2831 commentAndMetadata, 2564 commentAndMetadata, modifiers.externalKeyword, type);
2832 modifiers.externalKeyword,
2833 type);
2834 } 2565 }
2835 // 2566 //
2836 // We appear to have found an incomplete declaration before another 2567 // We appear to have found an incomplete declaration before another
2837 // declaration. At this point it consists of a type name, so we'll treat 2568 // declaration. At this point it consists of a type name, so we'll treat
2838 // it as a field declaration with a missing field name and semicolon. 2569 // it as a field declaration with a missing field name and semicolon.
2839 // 2570 //
2840 _reportErrorForToken( 2571 _reportErrorForToken(
2841 ParserErrorCode.EXPECTED_CLASS_MEMBER, 2572 ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken);
2842 _currentToken);
2843 try { 2573 try {
2844 _lockErrorListener(); 2574 _lockErrorListener();
2845 return _parseInitializedIdentifierList( 2575 return _parseInitializedIdentifierList(commentAndMetadata,
2846 commentAndMetadata, 2576 modifiers.staticKeyword, _validateModifiersForField(modifiers),
2847 modifiers.staticKeyword,
2848 _validateModifiersForField(modifiers),
2849 type); 2577 type);
2850 } finally { 2578 } finally {
2851 _unlockErrorListener(); 2579 _unlockErrorListener();
2852 } 2580 }
2853 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { 2581 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) {
2854 SimpleIdentifier methodName = parseSimpleIdentifier(); 2582 SimpleIdentifier methodName = parseSimpleIdentifier();
2855 FormalParameterList parameters = parseFormalParameterList(); 2583 FormalParameterList parameters = parseFormalParameterList();
2856 if (methodName.name == className) { 2584 if (methodName.name == className) {
2857 _reportErrorForNode(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, type); 2585 _reportErrorForNode(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, type);
2858 return _parseConstructor( 2586 return _parseConstructor(commentAndMetadata, modifiers.externalKeyword,
2859 commentAndMetadata,
2860 modifiers.externalKeyword,
2861 _validateModifiersForConstructor(modifiers), 2587 _validateModifiersForConstructor(modifiers),
2862 modifiers.factoryKeyword, 2588 modifiers.factoryKeyword, methodName, null, null, parameters);
2863 methodName,
2864 null,
2865 null,
2866 parameters);
2867 } 2589 }
2868 _validateModifiersForGetterOrSetterOrMethod(modifiers); 2590 _validateModifiersForGetterOrSetterOrMethod(modifiers);
2869 _validateFormalParameterList(parameters); 2591 _validateFormalParameterList(parameters);
2870 return _parseMethodDeclarationAfterParameters( 2592 return _parseMethodDeclarationAfterParameters(commentAndMetadata,
2871 commentAndMetadata, 2593 modifiers.externalKeyword, modifiers.staticKeyword, type, methodName,
2872 modifiers.externalKeyword,
2873 modifiers.staticKeyword,
2874 type,
2875 methodName,
2876 parameters); 2594 parameters);
2877 } else if (_tokenMatches(_peek(), TokenType.OPEN_CURLY_BRACKET)) { 2595 } else if (_tokenMatches(_peek(), TokenType.OPEN_CURLY_BRACKET)) {
2878 // We have found "TypeName identifier {", and are guessing that this is a 2596 // We have found "TypeName identifier {", and are guessing that this is a
2879 // getter without the keyword 'get'. 2597 // getter without the keyword 'get'.
2880 _validateModifiersForGetterOrSetterOrMethod(modifiers); 2598 _validateModifiersForGetterOrSetterOrMethod(modifiers);
2881 _reportErrorForCurrentToken(ParserErrorCode.MISSING_GET); 2599 _reportErrorForCurrentToken(ParserErrorCode.MISSING_GET);
2882 _currentToken = _injectToken( 2600 _currentToken = _injectToken(
2883 new Parser_SyntheticKeywordToken(Keyword.GET, _currentToken.offset)); 2601 new Parser_SyntheticKeywordToken(Keyword.GET, _currentToken.offset));
2884 return _parseGetter( 2602 return _parseGetter(commentAndMetadata, modifiers.externalKeyword,
2885 commentAndMetadata, 2603 modifiers.staticKeyword, type);
2886 modifiers.externalKeyword,
2887 modifiers.staticKeyword,
2888 type);
2889 } 2604 }
2890 return _parseInitializedIdentifierList( 2605 return _parseInitializedIdentifierList(commentAndMetadata,
2891 commentAndMetadata, 2606 modifiers.staticKeyword, _validateModifiersForField(modifiers), type);
2892 modifiers.staticKeyword,
2893 _validateModifiersForField(modifiers),
2894 type);
2895 } 2607 }
2896 2608
2897 /** 2609 /**
2898 * Parse a single import combinator. If no combinator is found, return 2610 * Parse a single import combinator. If no combinator is found, return
2899 * `null`. 2611 * `null`.
2900 * 2612 *
2901 * <pre> 2613 * <pre>
2902 * combinator ::= 2614 * combinator ::=
2903 * 'show' identifier (',' identifier)* 2615 * 'show' identifier (',' identifier)*
2904 * | 'hide' identifier (',' identifier)* 2616 * | 'hide' identifier (',' identifier)*
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2965 bool partOfDirectiveFound = false; 2677 bool partOfDirectiveFound = false;
2966 bool partDirectiveFound = false; 2678 bool partDirectiveFound = false;
2967 bool directiveFoundAfterDeclaration = false; 2679 bool directiveFoundAfterDeclaration = false;
2968 List<Directive> directives = new List<Directive>(); 2680 List<Directive> directives = new List<Directive>();
2969 List<CompilationUnitMember> declarations = 2681 List<CompilationUnitMember> declarations =
2970 new List<CompilationUnitMember>(); 2682 new List<CompilationUnitMember>();
2971 Token memberStart = _currentToken; 2683 Token memberStart = _currentToken;
2972 while (!_matches(TokenType.EOF)) { 2684 while (!_matches(TokenType.EOF)) {
2973 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); 2685 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata();
2974 if ((_matchesKeyword(Keyword.IMPORT) || 2686 if ((_matchesKeyword(Keyword.IMPORT) ||
2975 _matchesKeyword(Keyword.EXPORT) || 2687 _matchesKeyword(Keyword.EXPORT) ||
2976 _matchesKeyword(Keyword.LIBRARY) || 2688 _matchesKeyword(Keyword.LIBRARY) ||
2977 _matchesKeyword(Keyword.PART)) && 2689 _matchesKeyword(Keyword.PART)) &&
2978 !_tokenMatches(_peek(), TokenType.PERIOD) && 2690 !_tokenMatches(_peek(), TokenType.PERIOD) &&
2979 !_tokenMatches(_peek(), TokenType.LT) && 2691 !_tokenMatches(_peek(), TokenType.LT) &&
2980 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { 2692 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) {
2981 Directive directive = _parseDirective(commentAndMetadata); 2693 Directive directive = _parseDirective(commentAndMetadata);
2982 if (declarations.length > 0 && !directiveFoundAfterDeclaration) { 2694 if (declarations.length > 0 && !directiveFoundAfterDeclaration) {
2983 _reportErrorForCurrentToken( 2695 _reportErrorForCurrentToken(
2984 ParserErrorCode.DIRECTIVE_AFTER_DECLARATION); 2696 ParserErrorCode.DIRECTIVE_AFTER_DECLARATION);
2985 directiveFoundAfterDeclaration = true; 2697 directiveFoundAfterDeclaration = true;
2986 } 2698 }
2987 if (directive is LibraryDirective) { 2699 if (directive is LibraryDirective) {
2988 if (libraryDirectiveFound) { 2700 if (libraryDirectiveFound) {
2989 _reportErrorForCurrentToken( 2701 _reportErrorForCurrentToken(
2990 ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES); 2702 ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES);
2991 } else { 2703 } else {
2992 if (directives.length > 0) { 2704 if (directives.length > 0) {
2993 _reportErrorForToken( 2705 _reportErrorForToken(ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST,
2994 ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST,
2995 directive.libraryKeyword); 2706 directive.libraryKeyword);
2996 } 2707 }
2997 libraryDirectiveFound = true; 2708 libraryDirectiveFound = true;
2998 } 2709 }
2999 } else if (directive is PartDirective) { 2710 } else if (directive is PartDirective) {
3000 partDirectiveFound = true; 2711 partDirectiveFound = true;
3001 } else if (partDirectiveFound) { 2712 } else if (partDirectiveFound) {
3002 if (directive is ExportDirective) { 2713 if (directive is ExportDirective) {
3003 _reportErrorForToken( 2714 _reportErrorForToken(
3004 ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, 2715 ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE,
(...skipping 12 matching lines...) Expand all
3017 int directiveCount = directives.length; 2728 int directiveCount = directives.length;
3018 for (int i = 0; i < directiveCount; i++) { 2729 for (int i = 0; i < directiveCount; i++) {
3019 _reportErrorForToken( 2730 _reportErrorForToken(
3020 ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, 2731 ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART,
3021 directives[i].keyword); 2732 directives[i].keyword);
3022 } 2733 }
3023 partOfDirectiveFound = true; 2734 partOfDirectiveFound = true;
3024 } 2735 }
3025 } else { 2736 } else {
3026 if (partOfDirectiveFound) { 2737 if (partOfDirectiveFound) {
3027 _reportErrorForToken( 2738 _reportErrorForToken(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART,
3028 ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART,
3029 directive.keyword); 2739 directive.keyword);
3030 } 2740 }
3031 } 2741 }
3032 directives.add(directive); 2742 directives.add(directive);
3033 } else if (_matches(TokenType.SEMICOLON)) { 2743 } else if (_matches(TokenType.SEMICOLON)) {
3034 _reportErrorForToken( 2744 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [
3035 ParserErrorCode.UNEXPECTED_TOKEN, 2745 _currentToken.lexeme
3036 _currentToken, 2746 ]);
3037 [_currentToken.lexeme]);
3038 _advance(); 2747 _advance();
3039 } else { 2748 } else {
3040 CompilationUnitMember member = 2749 CompilationUnitMember member =
3041 _parseCompilationUnitMember(commentAndMetadata); 2750 _parseCompilationUnitMember(commentAndMetadata);
3042 if (member != null) { 2751 if (member != null) {
3043 declarations.add(member); 2752 declarations.add(member);
3044 } 2753 }
3045 } 2754 }
3046 if (identical(_currentToken, memberStart)) { 2755 if (identical(_currentToken, memberStart)) {
3047 _reportErrorForToken( 2756 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [
3048 ParserErrorCode.UNEXPECTED_TOKEN, 2757 _currentToken.lexeme
3049 _currentToken, 2758 ]);
3050 [_currentToken.lexeme]);
3051 _advance(); 2759 _advance();
3052 while (!_matches(TokenType.EOF) && 2760 while (!_matches(TokenType.EOF) &&
3053 !_couldBeStartOfCompilationUnitMember()) { 2761 !_couldBeStartOfCompilationUnitMember()) {
3054 _advance(); 2762 _advance();
3055 } 2763 }
3056 } 2764 }
3057 memberStart = _currentToken; 2765 memberStart = _currentToken;
3058 } 2766 }
3059 return new CompilationUnit( 2767 return new CompilationUnit(
3060 firstToken, 2768 firstToken, scriptTag, directives, declarations, _currentToken);
3061 scriptTag,
3062 directives,
3063 declarations,
3064 _currentToken);
3065 } 2769 }
3066 2770
3067 /** 2771 /**
3068 * Parse a conditional expression. 2772 * Parse a conditional expression.
3069 * 2773 *
3070 * <pre> 2774 * <pre>
3071 * conditionalExpression ::= 2775 * conditionalExpression ::=
3072 * logicalOrExpression ('?' expressionWithoutCascade ':' expressionWithout Cascade)? 2776 * logicalOrExpression ('?' expressionWithoutCascade ':' expressionWithout Cascade)?
3073 * </pre> 2777 * </pre>
3074 * 2778 *
3075 * @return the conditional expression that was parsed 2779 * @return the conditional expression that was parsed
3076 */ 2780 */
3077 Expression parseConditionalExpression() { 2781 Expression parseConditionalExpression() {
3078 Expression condition = parseLogicalOrExpression(); 2782 Expression condition = parseLogicalOrExpression();
3079 if (!_matches(TokenType.QUESTION)) { 2783 if (!_matches(TokenType.QUESTION)) {
3080 return condition; 2784 return condition;
3081 } 2785 }
3082 Token question = getAndAdvance(); 2786 Token question = getAndAdvance();
3083 Expression thenExpression = parseExpressionWithoutCascade(); 2787 Expression thenExpression = parseExpressionWithoutCascade();
3084 Token colon = _expect(TokenType.COLON); 2788 Token colon = _expect(TokenType.COLON);
3085 Expression elseExpression = parseExpressionWithoutCascade(); 2789 Expression elseExpression = parseExpressionWithoutCascade();
3086 return new ConditionalExpression( 2790 return new ConditionalExpression(
3087 condition, 2791 condition, question, thenExpression, colon, elseExpression);
3088 question,
3089 thenExpression,
3090 colon,
3091 elseExpression);
3092 } 2792 }
3093 2793
3094 /** 2794 /**
3095 * Parse the name of a constructor. 2795 * Parse the name of a constructor.
3096 * 2796 *
3097 * <pre> 2797 * <pre>
3098 * constructorName: 2798 * constructorName:
3099 * type ('.' identifier)? 2799 * type ('.' identifier)?
3100 * </pre> 2800 * </pre>
3101 * 2801 *
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
3204 // assignableExpression is a subset of conditionalExpression, so we can 2904 // assignableExpression is a subset of conditionalExpression, so we can
3205 // parse a conditional expression and then determine whether it is followed 2905 // parse a conditional expression and then determine whether it is followed
3206 // by an assignmentOperator, checking for conformance to the restricted 2906 // by an assignmentOperator, checking for conformance to the restricted
3207 // grammar after making that determination. 2907 // grammar after making that determination.
3208 // 2908 //
3209 Expression expression = parseConditionalExpression(); 2909 Expression expression = parseConditionalExpression();
3210 if (_currentToken.type.isAssignmentOperator) { 2910 if (_currentToken.type.isAssignmentOperator) {
3211 Token operator = getAndAdvance(); 2911 Token operator = getAndAdvance();
3212 _ensureAssignable(expression); 2912 _ensureAssignable(expression);
3213 expression = new AssignmentExpression( 2913 expression = new AssignmentExpression(
3214 expression, 2914 expression, operator, parseExpressionWithoutCascade());
3215 operator,
3216 parseExpressionWithoutCascade());
3217 } 2915 }
3218 return expression; 2916 return expression;
3219 } 2917 }
3220 2918
3221 /** 2919 /**
3222 * Parse a class extends clause. 2920 * Parse a class extends clause.
3223 * 2921 *
3224 * <pre> 2922 * <pre>
3225 * classExtendsClause ::= 2923 * classExtendsClause ::=
3226 * 'extends' type 2924 * 'extends' type
(...skipping 29 matching lines...) Expand all
3256 * namedFormalParameters ::= 2954 * namedFormalParameters ::=
3257 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}' 2955 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}'
3258 * </pre> 2956 * </pre>
3259 * 2957 *
3260 * @return the formal parameters that were parsed 2958 * @return the formal parameters that were parsed
3261 */ 2959 */
3262 FormalParameterList parseFormalParameterList() { 2960 FormalParameterList parseFormalParameterList() {
3263 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); 2961 Token leftParenthesis = _expect(TokenType.OPEN_PAREN);
3264 if (_matches(TokenType.CLOSE_PAREN)) { 2962 if (_matches(TokenType.CLOSE_PAREN)) {
3265 return new FormalParameterList( 2963 return new FormalParameterList(
3266 leftParenthesis, 2964 leftParenthesis, null, null, null, getAndAdvance());
3267 null,
3268 null,
3269 null,
3270 getAndAdvance());
3271 } 2965 }
3272 // 2966 //
3273 // Even though it is invalid to have default parameters outside of brackets, 2967 // Even though it is invalid to have default parameters outside of brackets,
3274 // required parameters inside of brackets, or multiple groups of default and 2968 // required parameters inside of brackets, or multiple groups of default and
3275 // named parameters, we allow all of these cases so that we can recover 2969 // named parameters, we allow all of these cases so that we can recover
3276 // better. 2970 // better.
3277 // 2971 //
3278 List<FormalParameter> parameters = new List<FormalParameter>(); 2972 List<FormalParameter> parameters = new List<FormalParameter>();
3279 List<FormalParameter> normalParameters = new List<FormalParameter>(); 2973 List<FormalParameter> normalParameters = new List<FormalParameter>();
3280 List<FormalParameter> positionalParameters = new List<FormalParameter>(); 2974 List<FormalParameter> positionalParameters = new List<FormalParameter>();
(...skipping 11 matching lines...) Expand all
3292 bool wasOptionalParameter = false; 2986 bool wasOptionalParameter = false;
3293 Token initialToken = null; 2987 Token initialToken = null;
3294 do { 2988 do {
3295 if (firstParameter) { 2989 if (firstParameter) {
3296 firstParameter = false; 2990 firstParameter = false;
3297 } else if (!_optional(TokenType.COMMA)) { 2991 } else if (!_optional(TokenType.COMMA)) {
3298 // TODO(brianwilkerson) The token is wrong, we need to recover from this 2992 // TODO(brianwilkerson) The token is wrong, we need to recover from this
3299 // case. 2993 // case.
3300 if (_getEndToken(leftParenthesis) != null) { 2994 if (_getEndToken(leftParenthesis) != null) {
3301 _reportErrorForCurrentToken( 2995 _reportErrorForCurrentToken(
3302 ParserErrorCode.EXPECTED_TOKEN, 2996 ParserErrorCode.EXPECTED_TOKEN, [TokenType.COMMA.lexeme]);
3303 [TokenType.COMMA.lexeme]);
3304 } else { 2997 } else {
3305 _reportErrorForToken( 2998 _reportErrorForToken(ParserErrorCode.MISSING_CLOSING_PARENTHESIS,
3306 ParserErrorCode.MISSING_CLOSING_PARENTHESIS,
3307 _currentToken.previous); 2999 _currentToken.previous);
3308 break; 3000 break;
3309 } 3001 }
3310 } 3002 }
3311 initialToken = _currentToken; 3003 initialToken = _currentToken;
3312 // 3004 //
3313 // Handle the beginning of parameter groups. 3005 // Handle the beginning of parameter groups.
3314 // 3006 //
3315 if (_matches(TokenType.OPEN_SQUARE_BRACKET)) { 3007 if (_matches(TokenType.OPEN_SQUARE_BRACKET)) {
3316 wasOptionalParameter = true; 3008 wasOptionalParameter = true;
(...skipping 25 matching lines...) Expand all
3342 kind = ParameterKind.NAMED; 3034 kind = ParameterKind.NAMED;
3343 } 3035 }
3344 // 3036 //
3345 // Parse and record the parameter. 3037 // Parse and record the parameter.
3346 // 3038 //
3347 FormalParameter parameter = _parseFormalParameter(kind); 3039 FormalParameter parameter = _parseFormalParameter(kind);
3348 parameters.add(parameter); 3040 parameters.add(parameter);
3349 currentParameters.add(parameter); 3041 currentParameters.add(parameter);
3350 if (kind == ParameterKind.REQUIRED && wasOptionalParameter) { 3042 if (kind == ParameterKind.REQUIRED && wasOptionalParameter) {
3351 _reportErrorForNode( 3043 _reportErrorForNode(
3352 ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS, 3044 ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS, parameter);
3353 parameter);
3354 } 3045 }
3355 // 3046 //
3356 // Handle the end of parameter groups. 3047 // Handle the end of parameter groups.
3357 // 3048 //
3358 // TODO(brianwilkerson) Improve the detection and reporting of missing and 3049 // TODO(brianwilkerson) Improve the detection and reporting of missing and
3359 // mismatched delimiters. 3050 // mismatched delimiters.
3360 if (_matches(TokenType.CLOSE_SQUARE_BRACKET)) { 3051 if (_matches(TokenType.CLOSE_SQUARE_BRACKET)) {
3361 rightSquareBracket = getAndAdvance(); 3052 rightSquareBracket = getAndAdvance();
3362 currentParameters = normalParameters; 3053 currentParameters = normalParameters;
3363 if (leftSquareBracket == null) { 3054 if (leftSquareBracket == null) {
3364 if (leftCurlyBracket != null) { 3055 if (leftCurlyBracket != null) {
3365 _reportErrorForCurrentToken( 3056 _reportErrorForCurrentToken(
3366 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, 3057 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, ["}"]);
3367 ["}"]);
3368 rightCurlyBracket = rightSquareBracket; 3058 rightCurlyBracket = rightSquareBracket;
3369 rightSquareBracket = null; 3059 rightSquareBracket = null;
3370 } else { 3060 } else {
3371 _reportErrorForCurrentToken( 3061 _reportErrorForCurrentToken(
3372 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, 3062 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, [
3373 ["["]); 3063 "["
3064 ]);
3374 } 3065 }
3375 } 3066 }
3376 kind = ParameterKind.REQUIRED; 3067 kind = ParameterKind.REQUIRED;
3377 } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { 3068 } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) {
3378 rightCurlyBracket = getAndAdvance(); 3069 rightCurlyBracket = getAndAdvance();
3379 currentParameters = normalParameters; 3070 currentParameters = normalParameters;
3380 if (leftCurlyBracket == null) { 3071 if (leftCurlyBracket == null) {
3381 if (leftSquareBracket != null) { 3072 if (leftSquareBracket != null) {
3382 _reportErrorForCurrentToken( 3073 _reportErrorForCurrentToken(
3383 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, 3074 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, ["]"]);
3384 ["]"]);
3385 rightSquareBracket = rightCurlyBracket; 3075 rightSquareBracket = rightCurlyBracket;
3386 rightCurlyBracket = null; 3076 rightCurlyBracket = null;
3387 } else { 3077 } else {
3388 _reportErrorForCurrentToken( 3078 _reportErrorForCurrentToken(
3389 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, 3079 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, [
3390 ["{"]); 3080 "{"
3081 ]);
3391 } 3082 }
3392 } 3083 }
3393 kind = ParameterKind.REQUIRED; 3084 kind = ParameterKind.REQUIRED;
3394 } 3085 }
3395 } while (!_matches(TokenType.CLOSE_PAREN) && 3086 } while (!_matches(TokenType.CLOSE_PAREN) &&
3396 !identical(initialToken, _currentToken)); 3087 !identical(initialToken, _currentToken));
3397 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); 3088 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN);
3398 // 3089 //
3399 // Check that the groups were closed correctly. 3090 // Check that the groups were closed correctly.
3400 // 3091 //
3401 if (leftSquareBracket != null && rightSquareBracket == null) { 3092 if (leftSquareBracket != null && rightSquareBracket == null) {
3402 _reportErrorForCurrentToken( 3093 _reportErrorForCurrentToken(
3403 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, 3094 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, ["]"]);
3404 ["]"]);
3405 } 3095 }
3406 if (leftCurlyBracket != null && rightCurlyBracket == null) { 3096 if (leftCurlyBracket != null && rightCurlyBracket == null) {
3407 _reportErrorForCurrentToken( 3097 _reportErrorForCurrentToken(
3408 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, 3098 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, ["}"]);
3409 ["}"]);
3410 } 3099 }
3411 // 3100 //
3412 // Build the parameter list. 3101 // Build the parameter list.
3413 // 3102 //
3414 if (leftSquareBracket == null) { 3103 if (leftSquareBracket == null) {
3415 leftSquareBracket = leftCurlyBracket; 3104 leftSquareBracket = leftCurlyBracket;
3416 } 3105 }
3417 if (rightSquareBracket == null) { 3106 if (rightSquareBracket == null) {
3418 rightSquareBracket = rightCurlyBracket; 3107 rightSquareBracket = rightCurlyBracket;
3419 } 3108 }
3420 return new FormalParameterList( 3109 return new FormalParameterList(leftParenthesis, parameters,
3421 leftParenthesis, 3110 leftSquareBracket, rightSquareBracket, rightParenthesis);
3422 parameters,
3423 leftSquareBracket,
3424 rightSquareBracket,
3425 rightParenthesis);
3426 } 3111 }
3427 3112
3428 /** 3113 /**
3429 * Parse a function expression. 3114 * Parse a function expression.
3430 * 3115 *
3431 * <pre> 3116 * <pre>
3432 * functionExpression ::= 3117 * functionExpression ::=
3433 * formalParameterList functionExpressionBody 3118 * formalParameterList functionExpressionBody
3434 * </pre> 3119 * </pre>
3435 * 3120 *
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3506 * logicalOrExpression ::= 3191 * logicalOrExpression ::=
3507 * logicalAndExpression ('||' logicalAndExpression)* 3192 * logicalAndExpression ('||' logicalAndExpression)*
3508 * </pre> 3193 * </pre>
3509 * 3194 *
3510 * @return the logical or expression that was parsed 3195 * @return the logical or expression that was parsed
3511 */ 3196 */
3512 Expression parseLogicalOrExpression() { 3197 Expression parseLogicalOrExpression() {
3513 Expression expression = _parseLogicalAndExpression(); 3198 Expression expression = _parseLogicalAndExpression();
3514 while (_matches(TokenType.BAR_BAR)) { 3199 while (_matches(TokenType.BAR_BAR)) {
3515 Token operator = getAndAdvance(); 3200 Token operator = getAndAdvance();
3516 expression = 3201 expression = new BinaryExpression(
3517 new BinaryExpression(expression, operator, _parseLogicalAndExpression( )); 3202 expression, operator, _parseLogicalAndExpression());
3518 } 3203 }
3519 return expression; 3204 return expression;
3520 } 3205 }
3521 3206
3522 /** 3207 /**
3523 * Parse a map literal entry. 3208 * Parse a map literal entry.
3524 * 3209 *
3525 * <pre> 3210 * <pre>
3526 * mapLiteralEntry ::= 3211 * mapLiteralEntry ::=
3527 * expression ':' expression 3212 * expression ':' expression
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3565 if (_matchesKeyword(Keyword.THIS)) { 3250 if (_matchesKeyword(Keyword.THIS)) {
3566 thisKeyword = getAndAdvance(); 3251 thisKeyword = getAndAdvance();
3567 period = _expect(TokenType.PERIOD); 3252 period = _expect(TokenType.PERIOD);
3568 } 3253 }
3569 SimpleIdentifier identifier = parseSimpleIdentifier(); 3254 SimpleIdentifier identifier = parseSimpleIdentifier();
3570 if (_matches(TokenType.OPEN_PAREN)) { 3255 if (_matches(TokenType.OPEN_PAREN)) {
3571 FormalParameterList parameters = parseFormalParameterList(); 3256 FormalParameterList parameters = parseFormalParameterList();
3572 if (thisKeyword == null) { 3257 if (thisKeyword == null) {
3573 if (holder.keyword != null) { 3258 if (holder.keyword != null) {
3574 _reportErrorForToken( 3259 _reportErrorForToken(
3575 ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, 3260 ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, holder.keyword);
3576 holder.keyword);
3577 } 3261 }
3578 return new FunctionTypedFormalParameter( 3262 return new FunctionTypedFormalParameter(commentAndMetadata.comment,
3579 commentAndMetadata.comment, 3263 commentAndMetadata.metadata, holder.type, identifier, parameters);
3580 commentAndMetadata.metadata,
3581 holder.type,
3582 identifier,
3583 parameters);
3584 } else { 3264 } else {
3585 return new FieldFormalParameter( 3265 return new FieldFormalParameter(commentAndMetadata.comment,
3586 commentAndMetadata.comment, 3266 commentAndMetadata.metadata, holder.keyword, holder.type,
3587 commentAndMetadata.metadata, 3267 thisKeyword, period, identifier, parameters);
3588 holder.keyword,
3589 holder.type,
3590 thisKeyword,
3591 period,
3592 identifier,
3593 parameters);
3594 } 3268 }
3595 } 3269 }
3596 TypeName type = holder.type; 3270 TypeName type = holder.type;
3597 if (type != null) { 3271 if (type != null) {
3598 if (_tokenMatchesKeyword(type.name.beginToken, Keyword.VOID)) { 3272 if (_tokenMatchesKeyword(type.name.beginToken, Keyword.VOID)) {
3599 _reportErrorForToken( 3273 _reportErrorForToken(
3600 ParserErrorCode.VOID_PARAMETER, 3274 ParserErrorCode.VOID_PARAMETER, type.name.beginToken);
3601 type.name.beginToken);
3602 } else if (holder.keyword != null && 3275 } else if (holder.keyword != null &&
3603 _tokenMatchesKeyword(holder.keyword, Keyword.VAR)) { 3276 _tokenMatchesKeyword(holder.keyword, Keyword.VAR)) {
3604 _reportErrorForToken(ParserErrorCode.VAR_AND_TYPE, holder.keyword); 3277 _reportErrorForToken(ParserErrorCode.VAR_AND_TYPE, holder.keyword);
3605 } 3278 }
3606 } 3279 }
3607 if (thisKeyword != null) { 3280 if (thisKeyword != null) {
3608 return new FieldFormalParameter( 3281 return new FieldFormalParameter(commentAndMetadata.comment,
3609 commentAndMetadata.comment, 3282 commentAndMetadata.metadata, holder.keyword, holder.type, thisKeyword,
3610 commentAndMetadata.metadata, 3283 period, identifier, null);
3611 holder.keyword,
3612 holder.type,
3613 thisKeyword,
3614 period,
3615 identifier,
3616 null);
3617 } 3284 }
3618 return new SimpleFormalParameter( 3285 return new SimpleFormalParameter(commentAndMetadata.comment,
3619 commentAndMetadata.comment, 3286 commentAndMetadata.metadata, holder.keyword, holder.type, identifier);
3620 commentAndMetadata.metadata,
3621 holder.keyword,
3622 holder.type,
3623 identifier);
3624 } 3287 }
3625 3288
3626 /** 3289 /**
3627 * Parse a prefixed identifier. 3290 * Parse a prefixed identifier.
3628 * 3291 *
3629 * <pre> 3292 * <pre>
3630 * prefixedIdentifier ::= 3293 * prefixedIdentifier ::=
3631 * identifier ('.' identifier)? 3294 * identifier ('.' identifier)?
3632 * </pre> 3295 * </pre>
3633 * 3296 *
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
3744 * @return the string literal that was parsed 3407 * @return the string literal that was parsed
3745 */ 3408 */
3746 StringLiteral parseStringLiteral() { 3409 StringLiteral parseStringLiteral() {
3747 List<StringLiteral> strings = new List<StringLiteral>(); 3410 List<StringLiteral> strings = new List<StringLiteral>();
3748 while (_matches(TokenType.STRING)) { 3411 while (_matches(TokenType.STRING)) {
3749 Token string = getAndAdvance(); 3412 Token string = getAndAdvance();
3750 if (_matches(TokenType.STRING_INTERPOLATION_EXPRESSION) || 3413 if (_matches(TokenType.STRING_INTERPOLATION_EXPRESSION) ||
3751 _matches(TokenType.STRING_INTERPOLATION_IDENTIFIER)) { 3414 _matches(TokenType.STRING_INTERPOLATION_IDENTIFIER)) {
3752 strings.add(_parseStringInterpolation(string)); 3415 strings.add(_parseStringInterpolation(string));
3753 } else { 3416 } else {
3754 strings.add( 3417 strings.add(new SimpleStringLiteral(
3755 new SimpleStringLiteral( 3418 string, _computeStringValue(string.lexeme, true, true)));
3756 string,
3757 _computeStringValue(string.lexeme, true, true)));
3758 } 3419 }
3759 } 3420 }
3760 if (strings.length < 1) { 3421 if (strings.length < 1) {
3761 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_STRING_LITERAL); 3422 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_STRING_LITERAL);
3762 return _createSyntheticStringLiteral(); 3423 return _createSyntheticStringLiteral();
3763 } else if (strings.length == 1) { 3424 } else if (strings.length == 1) {
3764 return strings[0]; 3425 return strings[0];
3765 } else { 3426 } else {
3766 return new AdjacentStrings(strings); 3427 return new AdjacentStrings(strings);
3767 } 3428 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3828 * </pre> 3489 * </pre>
3829 * 3490 *
3830 * @return the type parameter that was parsed 3491 * @return the type parameter that was parsed
3831 */ 3492 */
3832 TypeParameter parseTypeParameter() { 3493 TypeParameter parseTypeParameter() {
3833 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); 3494 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata();
3834 SimpleIdentifier name = parseSimpleIdentifier(); 3495 SimpleIdentifier name = parseSimpleIdentifier();
3835 if (_matchesKeyword(Keyword.EXTENDS)) { 3496 if (_matchesKeyword(Keyword.EXTENDS)) {
3836 Token keyword = getAndAdvance(); 3497 Token keyword = getAndAdvance();
3837 TypeName bound = parseTypeName(); 3498 TypeName bound = parseTypeName();
3838 return new TypeParameter( 3499 return new TypeParameter(commentAndMetadata.comment,
3839 commentAndMetadata.comment, 3500 commentAndMetadata.metadata, name, keyword, bound);
3840 commentAndMetadata.metadata,
3841 name,
3842 keyword,
3843 bound);
3844 } 3501 }
3845 return new TypeParameter( 3502 return new TypeParameter(commentAndMetadata.comment,
3846 commentAndMetadata.comment, 3503 commentAndMetadata.metadata, name, null, null);
3847 commentAndMetadata.metadata,
3848 name,
3849 null,
3850 null);
3851 } 3504 }
3852 3505
3853 /** 3506 /**
3854 * Parse a list of type parameters. 3507 * Parse a list of type parameters.
3855 * 3508 *
3856 * <pre> 3509 * <pre>
3857 * typeParameterList ::= 3510 * typeParameterList ::=
3858 * '<' typeParameter (',' typeParameter)* '>' 3511 * '<' typeParameter (',' typeParameter)* '>'
3859 * </pre> 3512 * </pre>
3860 * 3513 *
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3908 * @param scalarValue the value to be appended 3561 * @param scalarValue the value to be appended
3909 * @param startIndex the index of the first character representing the scalar value 3562 * @param startIndex the index of the first character representing the scalar value
3910 * @param endIndex the index of the last character representing the scalar val ue 3563 * @param endIndex the index of the last character representing the scalar val ue
3911 */ 3564 */
3912 void _appendScalarValue(StringBuffer buffer, String escapeSequence, 3565 void _appendScalarValue(StringBuffer buffer, String escapeSequence,
3913 int scalarValue, int startIndex, int endIndex) { 3566 int scalarValue, int startIndex, int endIndex) {
3914 if (scalarValue < 0 || 3567 if (scalarValue < 0 ||
3915 scalarValue > Character.MAX_CODE_POINT || 3568 scalarValue > Character.MAX_CODE_POINT ||
3916 (scalarValue >= 0xD800 && scalarValue <= 0xDFFF)) { 3569 (scalarValue >= 0xD800 && scalarValue <= 0xDFFF)) {
3917 _reportErrorForCurrentToken( 3570 _reportErrorForCurrentToken(
3918 ParserErrorCode.INVALID_CODE_POINT, 3571 ParserErrorCode.INVALID_CODE_POINT, [escapeSequence]);
3919 [escapeSequence]);
3920 return; 3572 return;
3921 } 3573 }
3922 if (scalarValue < Character.MAX_VALUE) { 3574 if (scalarValue < Character.MAX_VALUE) {
3923 buffer.writeCharCode(scalarValue); 3575 buffer.writeCharCode(scalarValue);
3924 } else { 3576 } else {
3925 buffer.write(Character.toChars(scalarValue)); 3577 buffer.write(Character.toChars(scalarValue));
3926 } 3578 }
3927 } 3579 }
3928 3580
3929 /** 3581 /**
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3981 } 3633 }
3982 3634
3983 /** 3635 /**
3984 * Convert the given method declaration into the nearest valid top-level funct ion declaration. 3636 * Convert the given method declaration into the nearest valid top-level funct ion declaration.
3985 * 3637 *
3986 * @param method the method to be converted 3638 * @param method the method to be converted
3987 * @return the function declaration that most closely captures the components of the given method 3639 * @return the function declaration that most closely captures the components of the given method
3988 * declaration 3640 * declaration
3989 */ 3641 */
3990 FunctionDeclaration _convertToFunctionDeclaration(MethodDeclaration method) => 3642 FunctionDeclaration _convertToFunctionDeclaration(MethodDeclaration method) =>
3991 new FunctionDeclaration( 3643 new FunctionDeclaration(method.documentationComment, method.metadata,
3992 method.documentationComment, 3644 method.externalKeyword, method.returnType, method.propertyKeyword,
3993 method.metadata, 3645 method.name, new FunctionExpression(method.parameters, method.body));
3994 method.externalKeyword,
3995 method.returnType,
3996 method.propertyKeyword,
3997 method.name,
3998 new FunctionExpression(method.parameters, method.body));
3999 3646
4000 /** 3647 /**
4001 * Return `true` if the current token could be the start of a compilation unit member. This 3648 * Return `true` if the current token could be the start of a compilation unit member. This
4002 * method is used for recovery purposes to decide when to stop skipping tokens after finding an 3649 * method is used for recovery purposes to decide when to stop skipping tokens after finding an
4003 * error while parsing a compilation unit member. 3650 * error while parsing a compilation unit member.
4004 * 3651 *
4005 * @return `true` if the current token could be the start of a compilation uni t member 3652 * @return `true` if the current token could be the start of a compilation uni t member
4006 */ 3653 */
4007 bool _couldBeStartOfCompilationUnitMember() { 3654 bool _couldBeStartOfCompilationUnitMember() {
4008 if ((_matchesKeyword(Keyword.IMPORT) || 3655 if ((_matchesKeyword(Keyword.IMPORT) ||
4009 _matchesKeyword(Keyword.EXPORT) || 3656 _matchesKeyword(Keyword.EXPORT) ||
4010 _matchesKeyword(Keyword.LIBRARY) || 3657 _matchesKeyword(Keyword.LIBRARY) ||
4011 _matchesKeyword(Keyword.PART)) && 3658 _matchesKeyword(Keyword.PART)) &&
4012 !_tokenMatches(_peek(), TokenType.PERIOD) && 3659 !_tokenMatches(_peek(), TokenType.PERIOD) &&
4013 !_tokenMatches(_peek(), TokenType.LT)) { 3660 !_tokenMatches(_peek(), TokenType.LT)) {
4014 // This looks like the start of a directive 3661 // This looks like the start of a directive
4015 return true; 3662 return true;
4016 } else if (_matchesKeyword(Keyword.CLASS)) { 3663 } else if (_matchesKeyword(Keyword.CLASS)) {
4017 // This looks like the start of a class definition 3664 // This looks like the start of a class definition
4018 return true; 3665 return true;
4019 } else if (_matchesKeyword(Keyword.TYPEDEF) && 3666 } else if (_matchesKeyword(Keyword.TYPEDEF) &&
4020 !_tokenMatches(_peek(), TokenType.PERIOD) && 3667 !_tokenMatches(_peek(), TokenType.PERIOD) &&
4021 !_tokenMatches(_peek(), TokenType.LT)) { 3668 !_tokenMatches(_peek(), TokenType.LT)) {
(...skipping 30 matching lines...) Expand all
4052 * @return the synthetic identifier that was created 3699 * @return the synthetic identifier that was created
4053 */ 3700 */
4054 SimpleIdentifier _createSyntheticIdentifier() { 3701 SimpleIdentifier _createSyntheticIdentifier() {
4055 Token syntheticToken; 3702 Token syntheticToken;
4056 if (_currentToken.type == TokenType.KEYWORD) { 3703 if (_currentToken.type == TokenType.KEYWORD) {
4057 // Consider current keyword token as an identifier. 3704 // Consider current keyword token as an identifier.
4058 // It is not always true, e.g. "^is T" where "^" is place the place for 3705 // It is not always true, e.g. "^is T" where "^" is place the place for
4059 // synthetic identifier. By creating SyntheticStringToken we can 3706 // synthetic identifier. By creating SyntheticStringToken we can
4060 // distinguish a real identifier from synthetic. In the code completion 3707 // distinguish a real identifier from synthetic. In the code completion
4061 // behavior will depend on a cursor position - before or on "is". 3708 // behavior will depend on a cursor position - before or on "is".
4062 syntheticToken = _injectToken( 3709 syntheticToken = _injectToken(new SyntheticStringToken(
4063 new SyntheticStringToken( 3710 TokenType.IDENTIFIER, _currentToken.lexeme, _currentToken.offset));
4064 TokenType.IDENTIFIER,
4065 _currentToken.lexeme,
4066 _currentToken.offset));
4067 } else { 3711 } else {
4068 syntheticToken = _createSyntheticToken(TokenType.IDENTIFIER); 3712 syntheticToken = _createSyntheticToken(TokenType.IDENTIFIER);
4069 } 3713 }
4070 return new SimpleIdentifier(syntheticToken); 3714 return new SimpleIdentifier(syntheticToken);
4071 } 3715 }
4072 3716
4073 /** 3717 /**
4074 * Create a synthetic token representing the given keyword. 3718 * Create a synthetic token representing the given keyword.
4075 * 3719 *
4076 * @return the synthetic token that was created 3720 * @return the synthetic token that was created
4077 */ 3721 */
4078 Token _createSyntheticKeyword(Keyword keyword) => 3722 Token _createSyntheticKeyword(Keyword keyword) => _injectToken(
4079 _injectToken(new Parser_SyntheticKeywordToken(keyword, _currentToken.offse t)); 3723 new Parser_SyntheticKeywordToken(keyword, _currentToken.offset));
4080 3724
4081 /** 3725 /**
4082 * Create a synthetic string literal. 3726 * Create a synthetic string literal.
4083 * 3727 *
4084 * @return the synthetic string literal that was created 3728 * @return the synthetic string literal that was created
4085 */ 3729 */
4086 SimpleStringLiteral _createSyntheticStringLiteral() => 3730 SimpleStringLiteral _createSyntheticStringLiteral() =>
4087 new SimpleStringLiteral(_createSyntheticToken(TokenType.STRING), ""); 3731 new SimpleStringLiteral(_createSyntheticToken(TokenType.STRING), "");
4088 3732
4089 /** 3733 /**
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
4147 */ 3791 */
4148 Token _expect(TokenType type) { 3792 Token _expect(TokenType type) {
4149 if (_matches(type)) { 3793 if (_matches(type)) {
4150 return getAndAdvance(); 3794 return getAndAdvance();
4151 } 3795 }
4152 // Remove uses of this method in favor of matches? 3796 // Remove uses of this method in favor of matches?
4153 // Pass in the error code to use to report the error? 3797 // Pass in the error code to use to report the error?
4154 if (type == TokenType.SEMICOLON) { 3798 if (type == TokenType.SEMICOLON) {
4155 if (_tokenMatches(_currentToken.next, TokenType.SEMICOLON)) { 3799 if (_tokenMatches(_currentToken.next, TokenType.SEMICOLON)) {
4156 _reportErrorForCurrentToken( 3800 _reportErrorForCurrentToken(
4157 ParserErrorCode.UNEXPECTED_TOKEN, 3801 ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken.lexeme]);
4158 [_currentToken.lexeme]);
4159 _advance(); 3802 _advance();
4160 return getAndAdvance(); 3803 return getAndAdvance();
4161 } 3804 }
4162 _reportErrorForToken( 3805 _reportErrorForToken(ParserErrorCode.EXPECTED_TOKEN,
4163 ParserErrorCode.EXPECTED_TOKEN, 3806 _currentToken.previous, [type.lexeme]);
4164 _currentToken.previous,
4165 [type.lexeme]);
4166 } else { 3807 } else {
4167 _reportErrorForCurrentToken( 3808 _reportErrorForCurrentToken(
4168 ParserErrorCode.EXPECTED_TOKEN, 3809 ParserErrorCode.EXPECTED_TOKEN, [type.lexeme]);
4169 [type.lexeme]);
4170 } 3810 }
4171 return _currentToken; 3811 return _currentToken;
4172 } 3812 }
4173 3813
4174 /** 3814 /**
4175 * If the current token has the type [TokenType.GT], return it after advancing to the next 3815 * If the current token has the type [TokenType.GT], return it after advancing to the next
4176 * token. Otherwise report an error and return the current token without advan cing. 3816 * token. Otherwise report an error and return the current token without advan cing.
4177 * 3817 *
4178 * @return the token that matched the given type 3818 * @return the token that matched the given type
4179 */ 3819 */
4180 Token _expectGt() { 3820 Token _expectGt() {
4181 if (_matchesGt()) { 3821 if (_matchesGt()) {
4182 return getAndAdvance(); 3822 return getAndAdvance();
4183 } 3823 }
4184 _reportErrorForCurrentToken( 3824 _reportErrorForCurrentToken(
4185 ParserErrorCode.EXPECTED_TOKEN, 3825 ParserErrorCode.EXPECTED_TOKEN, [TokenType.GT.lexeme]);
4186 [TokenType.GT.lexeme]);
4187 return _currentToken; 3826 return _currentToken;
4188 } 3827 }
4189 3828
4190 /** 3829 /**
4191 * If the current token is a keyword matching the given string, return it afte r advancing to the 3830 * If the current token is a keyword matching the given string, return it afte r advancing to the
4192 * next token. Otherwise report an error and return the current token without advancing. 3831 * next token. Otherwise report an error and return the current token without advancing.
4193 * 3832 *
4194 * @param keyword the keyword that is expected 3833 * @param keyword the keyword that is expected
4195 * @return the token that matched the given type 3834 * @return the token that matched the given type
4196 */ 3835 */
4197 Token _expectKeyword(Keyword keyword) { 3836 Token _expectKeyword(Keyword keyword) {
4198 if (_matchesKeyword(keyword)) { 3837 if (_matchesKeyword(keyword)) {
4199 return getAndAdvance(); 3838 return getAndAdvance();
4200 } 3839 }
4201 // Remove uses of this method in favor of matches? 3840 // Remove uses of this method in favor of matches?
4202 // Pass in the error code to use to report the error? 3841 // Pass in the error code to use to report the error?
4203 _reportErrorForCurrentToken( 3842 _reportErrorForCurrentToken(
4204 ParserErrorCode.EXPECTED_TOKEN, 3843 ParserErrorCode.EXPECTED_TOKEN, [keyword.syntax]);
4205 [keyword.syntax]);
4206 return _currentToken; 3844 return _currentToken;
4207 } 3845 }
4208 3846
4209 /** 3847 /**
4210 * If [currentToken] is a semicolon, returns it; otherwise reports error and c reates a 3848 * If [currentToken] is a semicolon, returns it; otherwise reports error and c reates a
4211 * synthetic one. 3849 * synthetic one.
4212 * 3850 *
4213 * TODO(scheglov) consider pushing this into [expect] 3851 * TODO(scheglov) consider pushing this into [expect]
4214 */ 3852 */
4215 Token _expectSemicolon() { 3853 Token _expectSemicolon() {
4216 if (_matches(TokenType.SEMICOLON)) { 3854 if (_matches(TokenType.SEMICOLON)) {
4217 return getAndAdvance(); 3855 return getAndAdvance();
4218 } else { 3856 } else {
4219 _reportErrorForToken( 3857 _reportErrorForToken(
4220 ParserErrorCode.EXPECTED_TOKEN, 3858 ParserErrorCode.EXPECTED_TOKEN, _currentToken.previous, [";"]);
4221 _currentToken.previous,
4222 [";"]);
4223 return _createSyntheticToken(TokenType.SEMICOLON); 3859 return _createSyntheticToken(TokenType.SEMICOLON);
4224 } 3860 }
4225 } 3861 }
4226 3862
4227 /** 3863 /**
4228 * Search the given list of ranges for a range that contains the given index. Return the range 3864 * Search the given list of ranges for a range that contains the given index. Return the range
4229 * that was found, or `null` if none of the ranges contain the index. 3865 * that was found, or `null` if none of the ranges contain the index.
4230 * 3866 *
4231 * @param ranges the ranges to be searched 3867 * @param ranges the ranges to be searched
4232 * @param index the index contained in the returned range 3868 * @param index the index contained in the returned range
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4270 } 3906 }
4271 while (index < length) { 3907 while (index < length) {
4272 int currentChar = comment.codeUnitAt(index); 3908 int currentChar = comment.codeUnitAt(index);
4273 if (currentChar == 0xD || currentChar == 0xA) { 3909 if (currentChar == 0xD || currentChar == 0xA) {
4274 index = index + 1; 3910 index = index + 1;
4275 while (index < length && 3911 while (index < length &&
4276 Character.isWhitespace(comment.codeUnitAt(index))) { 3912 Character.isWhitespace(comment.codeUnitAt(index))) {
4277 index = index + 1; 3913 index = index + 1;
4278 } 3914 }
4279 if (StringUtilities.startsWith6( 3915 if (StringUtilities.startsWith6(
4280 comment, 3916 comment, index, 0x2A, 0x20, 0x20, 0x20, 0x20, 0x20)) {
4281 index,
4282 0x2A,
4283 0x20,
4284 0x20,
4285 0x20,
4286 0x20,
4287 0x20)) {
4288 int end = index + 6; 3917 int end = index + 6;
4289 while (end < length && 3918 while (end < length &&
4290 comment.codeUnitAt(end) != 0xD && 3919 comment.codeUnitAt(end) != 0xD &&
4291 comment.codeUnitAt(end) != 0xA) { 3920 comment.codeUnitAt(end) != 0xA) {
4292 end = end + 1; 3921 end = end + 1;
4293 } 3922 }
4294 ranges.add(<int>[index, end]); 3923 ranges.add(<int>[index, end]);
4295 index = end; 3924 index = end;
4296 } 3925 }
4297 } else if (index + 1 < length && 3926 } else if (index + 1 < length &&
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
4391 */ 4020 */
4392 bool _isFunctionExpression(Token startToken) { 4021 bool _isFunctionExpression(Token startToken) {
4393 // Function expressions aren't allowed in initializer lists. 4022 // Function expressions aren't allowed in initializer lists.
4394 if (_inInitializer) { 4023 if (_inInitializer) {
4395 return false; 4024 return false;
4396 } 4025 }
4397 Token afterParameters = _skipFormalParameterList(startToken); 4026 Token afterParameters = _skipFormalParameterList(startToken);
4398 if (afterParameters == null) { 4027 if (afterParameters == null) {
4399 return false; 4028 return false;
4400 } 4029 }
4401 if (afterParameters.matchesAny( 4030 if (afterParameters
4402 [TokenType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) { 4031 .matchesAny([TokenType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) {
4403 return true; 4032 return true;
4404 } 4033 }
4405 String lexeme = afterParameters.lexeme; 4034 String lexeme = afterParameters.lexeme;
4406 return lexeme == ASYNC || lexeme == SYNC; 4035 return lexeme == ASYNC || lexeme == SYNC;
4407 } 4036 }
4408 4037
4409 /** 4038 /**
4410 * Return `true` if the given character is a valid hexadecimal digit. 4039 * Return `true` if the given character is a valid hexadecimal digit.
4411 * 4040 *
4412 * @param character the character being tested 4041 * @param character the character being tested
4413 * @return `true` if the character is a valid hexadecimal digit 4042 * @return `true` if the character is a valid hexadecimal digit
4414 */ 4043 */
4415 bool _isHexDigit(int character) => 4044 bool _isHexDigit(int character) => (0x30 <= character && character <= 0x39) ||
4416 (0x30 <= character && character <= 0x39) || 4045 (0x41 <= character && character <= 0x46) ||
4417 (0x41 <= character && character <= 0x46) || 4046 (0x61 <= character && character <= 0x66);
4418 (0x61 <= character && character <= 0x66);
4419 4047
4420 /** 4048 /**
4421 * Return `true` if the current token is the first token in an initialized var iable 4049 * Return `true` if the current token is the first token in an initialized var iable
4422 * declaration rather than an expression. This method assumes that we have alr eady skipped past 4050 * declaration rather than an expression. This method assumes that we have alr eady skipped past
4423 * any metadata that might be associated with the declaration. 4051 * any metadata that might be associated with the declaration.
4424 * 4052 *
4425 * <pre> 4053 * <pre>
4426 * initializedVariableDeclaration ::= 4054 * initializedVariableDeclaration ::=
4427 * declaredIdentifier ('=' expression)? (',' initializedIdentifier)* 4055 * declaredIdentifier ('=' expression)? (',' initializedIdentifier)*
4428 * 4056 *
(...skipping 18 matching lines...) Expand all
4447 */ 4075 */
4448 bool _isInitializedVariableDeclaration() { 4076 bool _isInitializedVariableDeclaration() {
4449 if (_matchesKeyword(Keyword.FINAL) || _matchesKeyword(Keyword.VAR)) { 4077 if (_matchesKeyword(Keyword.FINAL) || _matchesKeyword(Keyword.VAR)) {
4450 // An expression cannot start with a keyword other than 'const', 4078 // An expression cannot start with a keyword other than 'const',
4451 // 'rethrow', or 'throw'. 4079 // 'rethrow', or 'throw'.
4452 return true; 4080 return true;
4453 } 4081 }
4454 if (_matchesKeyword(Keyword.CONST)) { 4082 if (_matchesKeyword(Keyword.CONST)) {
4455 // Look to see whether we might be at the start of a list or map literal, 4083 // Look to see whether we might be at the start of a list or map literal,
4456 // otherwise this should be the start of a variable declaration. 4084 // otherwise this should be the start of a variable declaration.
4457 return !_peek().matchesAny( 4085 return !_peek().matchesAny([
4458 [ 4086 TokenType.LT,
4459 TokenType.LT, 4087 TokenType.OPEN_CURLY_BRACKET,
4460 TokenType.OPEN_CURLY_BRACKET, 4088 TokenType.OPEN_SQUARE_BRACKET,
4461 TokenType.OPEN_SQUARE_BRACKET, 4089 TokenType.INDEX
4462 TokenType.INDEX]); 4090 ]);
4463 } 4091 }
4464 // We know that we have an identifier, and need to see whether it might be 4092 // We know that we have an identifier, and need to see whether it might be
4465 // a type name. 4093 // a type name.
4466 Token token = _skipTypeName(_currentToken); 4094 Token token = _skipTypeName(_currentToken);
4467 if (token == null) { 4095 if (token == null) {
4468 // There was no type name, so this can't be a declaration. 4096 // There was no type name, so this can't be a declaration.
4469 return false; 4097 return false;
4470 } 4098 }
4471 token = _skipSimpleIdentifier(token); 4099 token = _skipSimpleIdentifier(token);
4472 if (token == null) { 4100 if (token == null) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
4697 Expression _parseAdditiveExpression() { 4325 Expression _parseAdditiveExpression() {
4698 Expression expression; 4326 Expression expression;
4699 if (_matchesKeyword(Keyword.SUPER) && 4327 if (_matchesKeyword(Keyword.SUPER) &&
4700 _currentToken.next.type.isAdditiveOperator) { 4328 _currentToken.next.type.isAdditiveOperator) {
4701 expression = new SuperExpression(getAndAdvance()); 4329 expression = new SuperExpression(getAndAdvance());
4702 } else { 4330 } else {
4703 expression = _parseMultiplicativeExpression(); 4331 expression = _parseMultiplicativeExpression();
4704 } 4332 }
4705 while (_currentToken.type.isAdditiveOperator) { 4333 while (_currentToken.type.isAdditiveOperator) {
4706 Token operator = getAndAdvance(); 4334 Token operator = getAndAdvance();
4707 expression = 4335 expression = new BinaryExpression(
4708 new BinaryExpression(expression, operator, _parseMultiplicativeExpress ion()); 4336 expression, operator, _parseMultiplicativeExpression());
4709 } 4337 }
4710 return expression; 4338 return expression;
4711 } 4339 }
4712 4340
4713 /** 4341 /**
4714 * Parse an assert statement. 4342 * Parse an assert statement.
4715 * 4343 *
4716 * <pre> 4344 * <pre>
4717 * assertStatement ::= 4345 * assertStatement ::=
4718 * 'assert' '(' conditionalExpression ')' ';' 4346 * 'assert' '(' conditionalExpression ')' ';'
4719 * </pre> 4347 * </pre>
4720 * 4348 *
4721 * @return the assert statement 4349 * @return the assert statement
4722 */ 4350 */
4723 AssertStatement _parseAssertStatement() { 4351 AssertStatement _parseAssertStatement() {
4724 Token keyword = _expectKeyword(Keyword.ASSERT); 4352 Token keyword = _expectKeyword(Keyword.ASSERT);
4725 Token leftParen = _expect(TokenType.OPEN_PAREN); 4353 Token leftParen = _expect(TokenType.OPEN_PAREN);
4726 Expression expression = parseExpression2(); 4354 Expression expression = parseExpression2();
4727 if (expression is AssignmentExpression) { 4355 if (expression is AssignmentExpression) {
4728 _reportErrorForNode( 4356 _reportErrorForNode(
4729 ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT, 4357 ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT, expression);
4730 expression);
4731 } else if (expression is CascadeExpression) { 4358 } else if (expression is CascadeExpression) {
4732 _reportErrorForNode( 4359 _reportErrorForNode(
4733 ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, 4360 ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, expression);
4734 expression);
4735 } else if (expression is ThrowExpression) { 4361 } else if (expression is ThrowExpression) {
4736 _reportErrorForNode( 4362 _reportErrorForNode(
4737 ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, 4363 ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, expression);
4738 expression);
4739 } else if (expression is RethrowExpression) { 4364 } else if (expression is RethrowExpression) {
4740 _reportErrorForNode( 4365 _reportErrorForNode(
4741 ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, 4366 ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, expression);
4742 expression);
4743 } 4367 }
4744 Token rightParen = _expect(TokenType.CLOSE_PAREN); 4368 Token rightParen = _expect(TokenType.CLOSE_PAREN);
4745 Token semicolon = _expect(TokenType.SEMICOLON); 4369 Token semicolon = _expect(TokenType.SEMICOLON);
4746 return new AssertStatement( 4370 return new AssertStatement(
4747 keyword, 4371 keyword, leftParen, expression, rightParen, semicolon);
4748 leftParen,
4749 expression,
4750 rightParen,
4751 semicolon);
4752 } 4372 }
4753 4373
4754 /** 4374 /**
4755 * Parse an assignable expression. 4375 * Parse an assignable expression.
4756 * 4376 *
4757 * <pre> 4377 * <pre>
4758 * assignableExpression ::= 4378 * assignableExpression ::=
4759 * primary (arguments* assignableSelector)+ 4379 * primary (arguments* assignableSelector)+
4760 * | 'super' assignableSelector 4380 * | 'super' assignableSelector
4761 * | identifier 4381 * | identifier
4762 * </pre> 4382 * </pre>
4763 * 4383 *
4764 * @param primaryAllowed `true` if the expression is allowed to be a primary w ithout any 4384 * @param primaryAllowed `true` if the expression is allowed to be a primary w ithout any
4765 * assignable selector 4385 * assignable selector
4766 * @return the assignable expression that was parsed 4386 * @return the assignable expression that was parsed
4767 */ 4387 */
4768 Expression _parseAssignableExpression(bool primaryAllowed) { 4388 Expression _parseAssignableExpression(bool primaryAllowed) {
4769 if (_matchesKeyword(Keyword.SUPER)) { 4389 if (_matchesKeyword(Keyword.SUPER)) {
4770 return _parseAssignableSelector( 4390 return _parseAssignableSelector(
4771 new SuperExpression(getAndAdvance()), 4391 new SuperExpression(getAndAdvance()), false);
4772 false);
4773 } 4392 }
4774 // 4393 //
4775 // A primary expression can start with an identifier. We resolve the 4394 // A primary expression can start with an identifier. We resolve the
4776 // ambiguity by determining whether the primary consists of anything other 4395 // ambiguity by determining whether the primary consists of anything other
4777 // than an identifier and/or is followed by an assignableSelector. 4396 // than an identifier and/or is followed by an assignableSelector.
4778 // 4397 //
4779 Expression expression = _parsePrimaryExpression(); 4398 Expression expression = _parsePrimaryExpression();
4780 bool isOptional = primaryAllowed || expression is SimpleIdentifier; 4399 bool isOptional = primaryAllowed || expression is SimpleIdentifier;
4781 while (true) { 4400 while (true) {
4782 while (_matches(TokenType.OPEN_PAREN)) { 4401 while (_matches(TokenType.OPEN_PAREN)) {
4783 ArgumentList argumentList = parseArgumentList(); 4402 ArgumentList argumentList = parseArgumentList();
4784 if (expression is SimpleIdentifier) { 4403 if (expression is SimpleIdentifier) {
4785 expression = 4404 expression = new MethodInvocation(
4786 new MethodInvocation(null, null, expression as SimpleIdentifier, a rgumentList); 4405 null, null, expression as SimpleIdentifier, argumentList);
4787 } else if (expression is PrefixedIdentifier) { 4406 } else if (expression is PrefixedIdentifier) {
4788 PrefixedIdentifier identifier = expression as PrefixedIdentifier; 4407 PrefixedIdentifier identifier = expression as PrefixedIdentifier;
4789 expression = new MethodInvocation( 4408 expression = new MethodInvocation(identifier.prefix,
4790 identifier.prefix, 4409 identifier.period, identifier.identifier, argumentList);
4791 identifier.period,
4792 identifier.identifier,
4793 argumentList);
4794 } else if (expression is PropertyAccess) { 4410 } else if (expression is PropertyAccess) {
4795 PropertyAccess access = expression as PropertyAccess; 4411 PropertyAccess access = expression as PropertyAccess;
4796 expression = new MethodInvocation( 4412 expression = new MethodInvocation(access.target, access.operator,
4797 access.target, 4413 access.propertyName, argumentList);
4798 access.operator,
4799 access.propertyName,
4800 argumentList);
4801 } else { 4414 } else {
4802 expression = 4415 expression =
4803 new FunctionExpressionInvocation(expression, argumentList); 4416 new FunctionExpressionInvocation(expression, argumentList);
4804 } 4417 }
4805 if (!primaryAllowed) { 4418 if (!primaryAllowed) {
4806 isOptional = false; 4419 isOptional = false;
4807 } 4420 }
4808 } 4421 }
4809 Expression selectorExpression = _parseAssignableSelector( 4422 Expression selectorExpression = _parseAssignableSelector(
4810 expression, 4423 expression, isOptional || (expression is PrefixedIdentifier));
4811 isOptional || (expression is PrefixedIdentifier));
4812 if (identical(selectorExpression, expression)) { 4424 if (identical(selectorExpression, expression)) {
4813 if (!isOptional && (expression is PrefixedIdentifier)) { 4425 if (!isOptional && (expression is PrefixedIdentifier)) {
4814 PrefixedIdentifier identifier = expression as PrefixedIdentifier; 4426 PrefixedIdentifier identifier = expression as PrefixedIdentifier;
4815 expression = new PropertyAccess( 4427 expression = new PropertyAccess(
4816 identifier.prefix, 4428 identifier.prefix, identifier.period, identifier.identifier);
4817 identifier.period,
4818 identifier.identifier);
4819 } 4429 }
4820 return expression; 4430 return expression;
4821 } 4431 }
4822 expression = selectorExpression; 4432 expression = selectorExpression;
4823 isOptional = true; 4433 isOptional = true;
4824 } 4434 }
4825 } 4435 }
4826 4436
4827 /** 4437 /**
4828 * Parse an assignable selector. 4438 * Parse an assignable selector.
(...skipping 11 matching lines...) Expand all
4840 */ 4450 */
4841 Expression _parseAssignableSelector(Expression prefix, bool optional) { 4451 Expression _parseAssignableSelector(Expression prefix, bool optional) {
4842 if (_matches(TokenType.OPEN_SQUARE_BRACKET)) { 4452 if (_matches(TokenType.OPEN_SQUARE_BRACKET)) {
4843 Token leftBracket = getAndAdvance(); 4453 Token leftBracket = getAndAdvance();
4844 bool wasInInitializer = _inInitializer; 4454 bool wasInInitializer = _inInitializer;
4845 _inInitializer = false; 4455 _inInitializer = false;
4846 try { 4456 try {
4847 Expression index = parseExpression2(); 4457 Expression index = parseExpression2();
4848 Token rightBracket = _expect(TokenType.CLOSE_SQUARE_BRACKET); 4458 Token rightBracket = _expect(TokenType.CLOSE_SQUARE_BRACKET);
4849 return new IndexExpression.forTarget( 4459 return new IndexExpression.forTarget(
4850 prefix, 4460 prefix, leftBracket, index, rightBracket);
4851 leftBracket,
4852 index,
4853 rightBracket);
4854 } finally { 4461 } finally {
4855 _inInitializer = wasInInitializer; 4462 _inInitializer = wasInInitializer;
4856 } 4463 }
4857 } else if (_matches(TokenType.PERIOD)) { 4464 } else if (_matches(TokenType.PERIOD)) {
4858 Token period = getAndAdvance(); 4465 Token period = getAndAdvance();
4859 return new PropertyAccess(prefix, period, parseSimpleIdentifier()); 4466 return new PropertyAccess(prefix, period, parseSimpleIdentifier());
4860 } else { 4467 } else {
4861 if (!optional) { 4468 if (!optional) {
4862 // Report the missing selector. 4469 // Report the missing selector.
4863 _reportErrorForCurrentToken( 4470 _reportErrorForCurrentToken(
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
4924 Expression _parseBitwiseXorExpression() { 4531 Expression _parseBitwiseXorExpression() {
4925 Expression expression; 4532 Expression expression;
4926 if (_matchesKeyword(Keyword.SUPER) && 4533 if (_matchesKeyword(Keyword.SUPER) &&
4927 _tokenMatches(_peek(), TokenType.CARET)) { 4534 _tokenMatches(_peek(), TokenType.CARET)) {
4928 expression = new SuperExpression(getAndAdvance()); 4535 expression = new SuperExpression(getAndAdvance());
4929 } else { 4536 } else {
4930 expression = _parseBitwiseAndExpression(); 4537 expression = _parseBitwiseAndExpression();
4931 } 4538 }
4932 while (_matches(TokenType.CARET)) { 4539 while (_matches(TokenType.CARET)) {
4933 Token operator = getAndAdvance(); 4540 Token operator = getAndAdvance();
4934 expression = 4541 expression = new BinaryExpression(
4935 new BinaryExpression(expression, operator, _parseBitwiseAndExpression( )); 4542 expression, operator, _parseBitwiseAndExpression());
4936 } 4543 }
4937 return expression; 4544 return expression;
4938 } 4545 }
4939 4546
4940 /** 4547 /**
4941 * Parse a break statement. 4548 * Parse a break statement.
4942 * 4549 *
4943 * <pre> 4550 * <pre>
4944 * breakStatement ::= 4551 * breakStatement ::=
4945 * 'break' identifier? ';' 4552 * 'break' identifier? ';'
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4983 SimpleIdentifier functionName = null; 4590 SimpleIdentifier functionName = null;
4984 if (_matchesIdentifier()) { 4591 if (_matchesIdentifier()) {
4985 functionName = parseSimpleIdentifier(); 4592 functionName = parseSimpleIdentifier();
4986 } else if (_currentToken.type == TokenType.OPEN_SQUARE_BRACKET) { 4593 } else if (_currentToken.type == TokenType.OPEN_SQUARE_BRACKET) {
4987 Token leftBracket = getAndAdvance(); 4594 Token leftBracket = getAndAdvance();
4988 bool wasInInitializer = _inInitializer; 4595 bool wasInInitializer = _inInitializer;
4989 _inInitializer = false; 4596 _inInitializer = false;
4990 try { 4597 try {
4991 Expression index = parseExpression2(); 4598 Expression index = parseExpression2();
4992 Token rightBracket = _expect(TokenType.CLOSE_SQUARE_BRACKET); 4599 Token rightBracket = _expect(TokenType.CLOSE_SQUARE_BRACKET);
4993 expression = 4600 expression = new IndexExpression.forCascade(
4994 new IndexExpression.forCascade(period, leftBracket, index, rightBrac ket); 4601 period, leftBracket, index, rightBracket);
4995 period = null; 4602 period = null;
4996 } finally { 4603 } finally {
4997 _inInitializer = wasInInitializer; 4604 _inInitializer = wasInInitializer;
4998 } 4605 }
4999 } else { 4606 } else {
5000 _reportErrorForToken( 4607 _reportErrorForToken(ParserErrorCode.MISSING_IDENTIFIER, _currentToken, [
5001 ParserErrorCode.MISSING_IDENTIFIER, 4608 _currentToken.lexeme
5002 _currentToken, 4609 ]);
5003 [_currentToken.lexeme]);
5004 functionName = _createSyntheticIdentifier(); 4610 functionName = _createSyntheticIdentifier();
5005 } 4611 }
5006 assert((expression == null && functionName != null) || 4612 assert((expression == null && functionName != null) ||
5007 (expression != null && functionName == null)); 4613 (expression != null && functionName == null));
5008 if (_currentToken.type == TokenType.OPEN_PAREN) { 4614 if (_currentToken.type == TokenType.OPEN_PAREN) {
5009 while (_currentToken.type == TokenType.OPEN_PAREN) { 4615 while (_currentToken.type == TokenType.OPEN_PAREN) {
5010 if (functionName != null) { 4616 if (functionName != null) {
5011 expression = 4617 expression = new MethodInvocation(
5012 new MethodInvocation(expression, period, functionName, parseArgume ntList()); 4618 expression, period, functionName, parseArgumentList());
5013 period = null; 4619 period = null;
5014 functionName = null; 4620 functionName = null;
5015 } else if (expression == null) { 4621 } else if (expression == null) {
5016 // It should not be possible to get here. 4622 // It should not be possible to get here.
5017 expression = new MethodInvocation( 4623 expression = new MethodInvocation(expression, period,
5018 expression, 4624 _createSyntheticIdentifier(), parseArgumentList());
5019 period,
5020 _createSyntheticIdentifier(),
5021 parseArgumentList());
5022 } else { 4625 } else {
5023 expression = 4626 expression =
5024 new FunctionExpressionInvocation(expression, parseArgumentList()); 4627 new FunctionExpressionInvocation(expression, parseArgumentList());
5025 } 4628 }
5026 } 4629 }
5027 } else if (functionName != null) { 4630 } else if (functionName != null) {
5028 expression = new PropertyAccess(expression, period, functionName); 4631 expression = new PropertyAccess(expression, period, functionName);
5029 period = null; 4632 period = null;
5030 } 4633 }
5031 assert(expression != null); 4634 assert(expression != null);
5032 bool progress = true; 4635 bool progress = true;
5033 while (progress) { 4636 while (progress) {
5034 progress = false; 4637 progress = false;
5035 Expression selector = _parseAssignableSelector(expression, true); 4638 Expression selector = _parseAssignableSelector(expression, true);
5036 if (!identical(selector, expression)) { 4639 if (!identical(selector, expression)) {
5037 expression = selector; 4640 expression = selector;
5038 progress = true; 4641 progress = true;
5039 while (_currentToken.type == TokenType.OPEN_PAREN) { 4642 while (_currentToken.type == TokenType.OPEN_PAREN) {
5040 if (expression is PropertyAccess) { 4643 if (expression is PropertyAccess) {
5041 PropertyAccess propertyAccess = expression as PropertyAccess; 4644 PropertyAccess propertyAccess = expression as PropertyAccess;
5042 expression = new MethodInvocation( 4645 expression = new MethodInvocation(propertyAccess.target,
5043 propertyAccess.target, 4646 propertyAccess.operator, propertyAccess.propertyName,
5044 propertyAccess.operator,
5045 propertyAccess.propertyName,
5046 parseArgumentList()); 4647 parseArgumentList());
5047 } else { 4648 } else {
5048 expression = 4649 expression = new FunctionExpressionInvocation(
5049 new FunctionExpressionInvocation(expression, parseArgumentList() ); 4650 expression, parseArgumentList());
5050 } 4651 }
5051 } 4652 }
5052 } 4653 }
5053 } 4654 }
5054 if (_currentToken.type.isAssignmentOperator) { 4655 if (_currentToken.type.isAssignmentOperator) {
5055 Token operator = getAndAdvance(); 4656 Token operator = getAndAdvance();
5056 _ensureAssignable(expression); 4657 _ensureAssignable(expression);
5057 expression = new AssignmentExpression( 4658 expression = new AssignmentExpression(
5058 expression, 4659 expression, operator, parseExpressionWithoutCascade());
5059 operator,
5060 parseExpressionWithoutCascade());
5061 } 4660 }
5062 return expression; 4661 return expression;
5063 } 4662 }
5064 4663
5065 /** 4664 /**
5066 * Parse a class declaration. 4665 * Parse a class declaration.
5067 * 4666 *
5068 * <pre> 4667 * <pre>
5069 * classDeclaration ::= 4668 * classDeclaration ::=
5070 * metadata 'abstract'? 'class' name typeParameterList? (extendsClause wit hClause?)? implementsClause? '{' classMembers '}' | 4669 * metadata 'abstract'? 'class' name typeParameterList? (extendsClause wit hClause?)? implementsClause? '{' classMembers '}' |
5071 * metadata 'abstract'? 'class' mixinApplicationClass 4670 * metadata 'abstract'? 'class' mixinApplicationClass
5072 * </pre> 4671 * </pre>
5073 * 4672 *
5074 * @param commentAndMetadata the metadata to be associated with the member 4673 * @param commentAndMetadata the metadata to be associated with the member
5075 * @param abstractKeyword the token for the keyword 'abstract', or `null` if t he keyword was 4674 * @param abstractKeyword the token for the keyword 'abstract', or `null` if t he keyword was
5076 * not given 4675 * not given
5077 * @return the class declaration that was parsed 4676 * @return the class declaration that was parsed
5078 */ 4677 */
5079 CompilationUnitMember 4678 CompilationUnitMember _parseClassDeclaration(
5080 _parseClassDeclaration(CommentAndMetadata commentAndMetadata, 4679 CommentAndMetadata commentAndMetadata, Token abstractKeyword) {
5081 Token abstractKeyword) {
5082 Token keyword = _expectKeyword(Keyword.CLASS); 4680 Token keyword = _expectKeyword(Keyword.CLASS);
5083 if (_matchesIdentifier()) { 4681 if (_matchesIdentifier()) {
5084 Token next = _peek(); 4682 Token next = _peek();
5085 if (_tokenMatches(next, TokenType.LT)) { 4683 if (_tokenMatches(next, TokenType.LT)) {
5086 next = _skipTypeParameterList(next); 4684 next = _skipTypeParameterList(next);
5087 if (next != null && _tokenMatches(next, TokenType.EQ)) { 4685 if (next != null && _tokenMatches(next, TokenType.EQ)) {
5088 return _parseClassTypeAlias( 4686 return _parseClassTypeAlias(
5089 commentAndMetadata, 4687 commentAndMetadata, abstractKeyword, keyword);
5090 abstractKeyword,
5091 keyword);
5092 } 4688 }
5093 } else if (_tokenMatches(next, TokenType.EQ)) { 4689 } else if (_tokenMatches(next, TokenType.EQ)) {
5094 return _parseClassTypeAlias( 4690 return _parseClassTypeAlias(
5095 commentAndMetadata, 4691 commentAndMetadata, abstractKeyword, keyword);
5096 abstractKeyword,
5097 keyword);
5098 } 4692 }
5099 } 4693 }
5100 SimpleIdentifier name = parseSimpleIdentifier(); 4694 SimpleIdentifier name = parseSimpleIdentifier();
5101 String className = name.name; 4695 String className = name.name;
5102 TypeParameterList typeParameters = null; 4696 TypeParameterList typeParameters = null;
5103 if (_matches(TokenType.LT)) { 4697 if (_matches(TokenType.LT)) {
5104 typeParameters = parseTypeParameterList(); 4698 typeParameters = parseTypeParameterList();
5105 } 4699 }
5106 // 4700 //
5107 // Parse the clauses. The parser accepts clauses in any order, but will 4701 // Parse the clauses. The parser accepts clauses in any order, but will
5108 // generate errors if they are not in the order required by the 4702 // generate errors if they are not in the order required by the
5109 // specification. 4703 // specification.
5110 // 4704 //
5111 ExtendsClause extendsClause = null; 4705 ExtendsClause extendsClause = null;
5112 WithClause withClause = null; 4706 WithClause withClause = null;
5113 ImplementsClause implementsClause = null; 4707 ImplementsClause implementsClause = null;
5114 bool foundClause = true; 4708 bool foundClause = true;
5115 while (foundClause) { 4709 while (foundClause) {
5116 if (_matchesKeyword(Keyword.EXTENDS)) { 4710 if (_matchesKeyword(Keyword.EXTENDS)) {
5117 if (extendsClause == null) { 4711 if (extendsClause == null) {
5118 extendsClause = parseExtendsClause(); 4712 extendsClause = parseExtendsClause();
5119 if (withClause != null) { 4713 if (withClause != null) {
5120 _reportErrorForToken( 4714 _reportErrorForToken(
5121 ParserErrorCode.WITH_BEFORE_EXTENDS, 4715 ParserErrorCode.WITH_BEFORE_EXTENDS, withClause.withKeyword);
5122 withClause.withKeyword);
5123 } else if (implementsClause != null) { 4716 } else if (implementsClause != null) {
5124 _reportErrorForToken( 4717 _reportErrorForToken(ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS,
5125 ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS,
5126 implementsClause.implementsKeyword); 4718 implementsClause.implementsKeyword);
5127 } 4719 }
5128 } else { 4720 } else {
5129 _reportErrorForToken( 4721 _reportErrorForToken(ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES,
5130 ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES,
5131 extendsClause.extendsKeyword); 4722 extendsClause.extendsKeyword);
5132 parseExtendsClause(); 4723 parseExtendsClause();
5133 } 4724 }
5134 } else if (_matchesKeyword(Keyword.WITH)) { 4725 } else if (_matchesKeyword(Keyword.WITH)) {
5135 if (withClause == null) { 4726 if (withClause == null) {
5136 withClause = parseWithClause(); 4727 withClause = parseWithClause();
5137 if (implementsClause != null) { 4728 if (implementsClause != null) {
5138 _reportErrorForToken( 4729 _reportErrorForToken(ParserErrorCode.IMPLEMENTS_BEFORE_WITH,
5139 ParserErrorCode.IMPLEMENTS_BEFORE_WITH,
5140 implementsClause.implementsKeyword); 4730 implementsClause.implementsKeyword);
5141 } 4731 }
5142 } else { 4732 } else {
5143 _reportErrorForToken( 4733 _reportErrorForToken(
5144 ParserErrorCode.MULTIPLE_WITH_CLAUSES, 4734 ParserErrorCode.MULTIPLE_WITH_CLAUSES, withClause.withKeyword);
5145 withClause.withKeyword);
5146 parseWithClause(); 4735 parseWithClause();
5147 // TODO(brianwilkerson) Should we merge the list of applied mixins 4736 // TODO(brianwilkerson) Should we merge the list of applied mixins
5148 // into a single list? 4737 // into a single list?
5149 } 4738 }
5150 } else if (_matchesKeyword(Keyword.IMPLEMENTS)) { 4739 } else if (_matchesKeyword(Keyword.IMPLEMENTS)) {
5151 if (implementsClause == null) { 4740 if (implementsClause == null) {
5152 implementsClause = parseImplementsClause(); 4741 implementsClause = parseImplementsClause();
5153 } else { 4742 } else {
5154 _reportErrorForToken( 4743 _reportErrorForToken(ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES,
5155 ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES,
5156 implementsClause.implementsKeyword); 4744 implementsClause.implementsKeyword);
5157 parseImplementsClause(); 4745 parseImplementsClause();
5158 // TODO(brianwilkerson) Should we merge the list of implemented 4746 // TODO(brianwilkerson) Should we merge the list of implemented
5159 // classes into a single list? 4747 // classes into a single list?
5160 } 4748 }
5161 } else { 4749 } else {
5162 foundClause = false; 4750 foundClause = false;
5163 } 4751 }
5164 } 4752 }
5165 if (withClause != null && extendsClause == null) { 4753 if (withClause != null && extendsClause == null) {
5166 _reportErrorForToken( 4754 _reportErrorForToken(
5167 ParserErrorCode.WITH_WITHOUT_EXTENDS, 4755 ParserErrorCode.WITH_WITHOUT_EXTENDS, withClause.withKeyword);
5168 withClause.withKeyword);
5169 } 4756 }
5170 // 4757 //
5171 // Look for and skip over the extra-lingual 'native' specification. 4758 // Look for and skip over the extra-lingual 'native' specification.
5172 // 4759 //
5173 NativeClause nativeClause = null; 4760 NativeClause nativeClause = null;
5174 if (_matchesString(_NATIVE) && _tokenMatches(_peek(), TokenType.STRING)) { 4761 if (_matchesString(_NATIVE) && _tokenMatches(_peek(), TokenType.STRING)) {
5175 nativeClause = _parseNativeClause(); 4762 nativeClause = _parseNativeClause();
5176 } 4763 }
5177 // 4764 //
5178 // Parse the body of the class. 4765 // Parse the body of the class.
5179 // 4766 //
5180 Token leftBracket = null; 4767 Token leftBracket = null;
5181 List<ClassMember> members = null; 4768 List<ClassMember> members = null;
5182 Token rightBracket = null; 4769 Token rightBracket = null;
5183 if (_matches(TokenType.OPEN_CURLY_BRACKET)) { 4770 if (_matches(TokenType.OPEN_CURLY_BRACKET)) {
5184 leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET); 4771 leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET);
5185 members = _parseClassMembers(className, _getEndToken(leftBracket)); 4772 members = _parseClassMembers(className, _getEndToken(leftBracket));
5186 rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); 4773 rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET);
5187 } else { 4774 } else {
5188 leftBracket = _createSyntheticToken(TokenType.OPEN_CURLY_BRACKET); 4775 leftBracket = _createSyntheticToken(TokenType.OPEN_CURLY_BRACKET);
5189 rightBracket = _createSyntheticToken(TokenType.CLOSE_CURLY_BRACKET); 4776 rightBracket = _createSyntheticToken(TokenType.CLOSE_CURLY_BRACKET);
5190 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CLASS_BODY); 4777 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CLASS_BODY);
5191 } 4778 }
5192 ClassDeclaration classDeclaration = new ClassDeclaration( 4779 ClassDeclaration classDeclaration = new ClassDeclaration(
5193 commentAndMetadata.comment, 4780 commentAndMetadata.comment, commentAndMetadata.metadata,
5194 commentAndMetadata.metadata, 4781 abstractKeyword, keyword, name, typeParameters, extendsClause,
5195 abstractKeyword, 4782 withClause, implementsClause, leftBracket, members, rightBracket);
5196 keyword,
5197 name,
5198 typeParameters,
5199 extendsClause,
5200 withClause,
5201 implementsClause,
5202 leftBracket,
5203 members,
5204 rightBracket);
5205 classDeclaration.nativeClause = nativeClause; 4783 classDeclaration.nativeClause = nativeClause;
5206 return classDeclaration; 4784 return classDeclaration;
5207 } 4785 }
5208 4786
5209 /** 4787 /**
5210 * Parse a list of class members. 4788 * Parse a list of class members.
5211 * 4789 *
5212 * <pre> 4790 * <pre>
5213 * classMembers ::= 4791 * classMembers ::=
5214 * (metadata memberDefinition)* 4792 * (metadata memberDefinition)*
5215 * </pre> 4793 * </pre>
5216 * 4794 *
5217 * @param className the name of the class whose members are being parsed 4795 * @param className the name of the class whose members are being parsed
5218 * @param closingBracket the closing bracket for the class, or `null` if the c losing bracket 4796 * @param closingBracket the closing bracket for the class, or `null` if the c losing bracket
5219 * is missing 4797 * is missing
5220 * @return the list of class members that were parsed 4798 * @return the list of class members that were parsed
5221 */ 4799 */
5222 List<ClassMember> _parseClassMembers(String className, Token closingBracket) { 4800 List<ClassMember> _parseClassMembers(String className, Token closingBracket) {
5223 List<ClassMember> members = new List<ClassMember>(); 4801 List<ClassMember> members = new List<ClassMember>();
5224 Token memberStart = _currentToken; 4802 Token memberStart = _currentToken;
5225 while (!_matches(TokenType.EOF) && 4803 while (!_matches(TokenType.EOF) &&
5226 !_matches(TokenType.CLOSE_CURLY_BRACKET) && 4804 !_matches(TokenType.CLOSE_CURLY_BRACKET) &&
5227 (closingBracket != null || 4805 (closingBracket != null ||
5228 (!_matchesKeyword(Keyword.CLASS) && !_matchesKeyword(Keyword.TYPEDEF )))) { 4806 (!_matchesKeyword(Keyword.CLASS) &&
4807 !_matchesKeyword(Keyword.TYPEDEF)))) {
5229 if (_matches(TokenType.SEMICOLON)) { 4808 if (_matches(TokenType.SEMICOLON)) {
5230 _reportErrorForToken( 4809 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [
5231 ParserErrorCode.UNEXPECTED_TOKEN, 4810 _currentToken.lexeme
5232 _currentToken, 4811 ]);
5233 [_currentToken.lexeme]);
5234 _advance(); 4812 _advance();
5235 } else { 4813 } else {
5236 ClassMember member = parseClassMember(className); 4814 ClassMember member = parseClassMember(className);
5237 if (member != null) { 4815 if (member != null) {
5238 members.add(member); 4816 members.add(member);
5239 } 4817 }
5240 } 4818 }
5241 if (identical(_currentToken, memberStart)) { 4819 if (identical(_currentToken, memberStart)) {
5242 _reportErrorForToken( 4820 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [
5243 ParserErrorCode.UNEXPECTED_TOKEN, 4821 _currentToken.lexeme
5244 _currentToken, 4822 ]);
5245 [_currentToken.lexeme]);
5246 _advance(); 4823 _advance();
5247 } 4824 }
5248 memberStart = _currentToken; 4825 memberStart = _currentToken;
5249 } 4826 }
5250 return members; 4827 return members;
5251 } 4828 }
5252 4829
5253 /** 4830 /**
5254 * Parse a class type alias. 4831 * Parse a class type alias.
5255 * 4832 *
(...skipping 17 matching lines...) Expand all
5273 if (_matches(TokenType.LT)) { 4850 if (_matches(TokenType.LT)) {
5274 typeParameters = parseTypeParameterList(); 4851 typeParameters = parseTypeParameterList();
5275 } 4852 }
5276 Token equals = _expect(TokenType.EQ); 4853 Token equals = _expect(TokenType.EQ);
5277 TypeName superclass = parseTypeName(); 4854 TypeName superclass = parseTypeName();
5278 WithClause withClause = null; 4855 WithClause withClause = null;
5279 if (_matchesKeyword(Keyword.WITH)) { 4856 if (_matchesKeyword(Keyword.WITH)) {
5280 withClause = parseWithClause(); 4857 withClause = parseWithClause();
5281 } else { 4858 } else {
5282 _reportErrorForCurrentToken( 4859 _reportErrorForCurrentToken(
5283 ParserErrorCode.EXPECTED_TOKEN, 4860 ParserErrorCode.EXPECTED_TOKEN, [Keyword.WITH.syntax]);
5284 [Keyword.WITH.syntax]);
5285 } 4861 }
5286 ImplementsClause implementsClause = null; 4862 ImplementsClause implementsClause = null;
5287 if (_matchesKeyword(Keyword.IMPLEMENTS)) { 4863 if (_matchesKeyword(Keyword.IMPLEMENTS)) {
5288 implementsClause = parseImplementsClause(); 4864 implementsClause = parseImplementsClause();
5289 } 4865 }
5290 Token semicolon; 4866 Token semicolon;
5291 if (_matches(TokenType.SEMICOLON)) { 4867 if (_matches(TokenType.SEMICOLON)) {
5292 semicolon = getAndAdvance(); 4868 semicolon = getAndAdvance();
5293 } else { 4869 } else {
5294 if (_matches(TokenType.OPEN_CURLY_BRACKET)) { 4870 if (_matches(TokenType.OPEN_CURLY_BRACKET)) {
5295 _reportErrorForCurrentToken( 4871 _reportErrorForCurrentToken(
5296 ParserErrorCode.EXPECTED_TOKEN, 4872 ParserErrorCode.EXPECTED_TOKEN, [TokenType.SEMICOLON.lexeme]);
5297 [TokenType.SEMICOLON.lexeme]);
5298 Token leftBracket = getAndAdvance(); 4873 Token leftBracket = getAndAdvance();
5299 _parseClassMembers(className.name, _getEndToken(leftBracket)); 4874 _parseClassMembers(className.name, _getEndToken(leftBracket));
5300 _expect(TokenType.CLOSE_CURLY_BRACKET); 4875 _expect(TokenType.CLOSE_CURLY_BRACKET);
5301 } else { 4876 } else {
5302 _reportErrorForToken( 4877 _reportErrorForToken(ParserErrorCode.EXPECTED_TOKEN,
5303 ParserErrorCode.EXPECTED_TOKEN, 4878 _currentToken.previous, [TokenType.SEMICOLON.lexeme]);
5304 _currentToken.previous,
5305 [TokenType.SEMICOLON.lexeme]);
5306 } 4879 }
5307 semicolon = _createSyntheticToken(TokenType.SEMICOLON); 4880 semicolon = _createSyntheticToken(TokenType.SEMICOLON);
5308 } 4881 }
5309 return new ClassTypeAlias( 4882 return new ClassTypeAlias(commentAndMetadata.comment,
5310 commentAndMetadata.comment, 4883 commentAndMetadata.metadata, classKeyword, className, typeParameters,
5311 commentAndMetadata.metadata, 4884 equals, abstractKeyword, superclass, withClause, implementsClause,
5312 classKeyword,
5313 className,
5314 typeParameters,
5315 equals,
5316 abstractKeyword,
5317 superclass,
5318 withClause,
5319 implementsClause,
5320 semicolon); 4885 semicolon);
5321 } 4886 }
5322 4887
5323 /** 4888 /**
5324 * Parse a list of combinators in a directive. 4889 * Parse a list of combinators in a directive.
5325 * 4890 *
5326 * <pre> 4891 * <pre>
5327 * combinator ::= 4892 * combinator ::=
5328 * 'show' identifier (',' identifier)* 4893 * 'show' identifier (',' identifier)*
5329 * | 'hide' identifier (',' identifier)* 4894 * | 'hide' identifier (',' identifier)*
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
5374 * <pre> 4939 * <pre>
5375 * commentReference ::= 4940 * commentReference ::=
5376 * 'new'? prefixedIdentifier 4941 * 'new'? prefixedIdentifier
5377 * </pre> 4942 * </pre>
5378 * 4943 *
5379 * @param referenceSource the source occurring between the square brackets wit hin a documentation 4944 * @param referenceSource the source occurring between the square brackets wit hin a documentation
5380 * comment 4945 * comment
5381 * @param sourceOffset the offset of the first character of the reference sour ce 4946 * @param sourceOffset the offset of the first character of the reference sour ce
5382 * @return the comment reference that was parsed, or `null` if no reference co uld be found 4947 * @return the comment reference that was parsed, or `null` if no reference co uld be found
5383 */ 4948 */
5384 CommentReference _parseCommentReference(String referenceSource, 4949 CommentReference _parseCommentReference(
5385 int sourceOffset) { 4950 String referenceSource, int sourceOffset) {
5386 // TODO(brianwilkerson) The errors are not getting the right offset/length 4951 // TODO(brianwilkerson) The errors are not getting the right offset/length
5387 // and are being duplicated. 4952 // and are being duplicated.
5388 if (referenceSource.length == 0) { 4953 if (referenceSource.length == 0) {
5389 Token syntheticToken = 4954 Token syntheticToken =
5390 new SyntheticStringToken(TokenType.IDENTIFIER, "", sourceOffset); 4955 new SyntheticStringToken(TokenType.IDENTIFIER, "", sourceOffset);
5391 return new CommentReference(null, new SimpleIdentifier(syntheticToken)); 4956 return new CommentReference(null, new SimpleIdentifier(syntheticToken));
5392 } 4957 }
5393 try { 4958 try {
5394 BooleanErrorListener listener = new BooleanErrorListener(); 4959 BooleanErrorListener listener = new BooleanErrorListener();
5395 Scanner scanner = new Scanner( 4960 Scanner scanner = new Scanner(
5396 null, 4961 null, new SubSequenceReader(referenceSource, sourceOffset), listener);
5397 new SubSequenceReader(referenceSource, sourceOffset),
5398 listener);
5399 scanner.setSourceStart(1, 1); 4962 scanner.setSourceStart(1, 1);
5400 Token firstToken = scanner.tokenize(); 4963 Token firstToken = scanner.tokenize();
5401 if (listener.errorReported) { 4964 if (listener.errorReported) {
5402 return null; 4965 return null;
5403 } 4966 }
5404 Token newKeyword = null; 4967 Token newKeyword = null;
5405 if (_tokenMatchesKeyword(firstToken, Keyword.NEW)) { 4968 if (_tokenMatchesKeyword(firstToken, Keyword.NEW)) {
5406 newKeyword = firstToken; 4969 newKeyword = firstToken;
5407 firstToken = firstToken.next; 4970 firstToken = firstToken.next;
5408 } 4971 }
5409 if (_tokenMatchesIdentifier(firstToken)) { 4972 if (_tokenMatchesIdentifier(firstToken)) {
5410 Token secondToken = firstToken.next; 4973 Token secondToken = firstToken.next;
5411 Token thirdToken = secondToken.next; 4974 Token thirdToken = secondToken.next;
5412 Token nextToken; 4975 Token nextToken;
5413 Identifier identifier; 4976 Identifier identifier;
5414 if (_tokenMatches(secondToken, TokenType.PERIOD) && 4977 if (_tokenMatches(secondToken, TokenType.PERIOD) &&
5415 _tokenMatchesIdentifier(thirdToken)) { 4978 _tokenMatchesIdentifier(thirdToken)) {
5416 identifier = new PrefixedIdentifier( 4979 identifier = new PrefixedIdentifier(new SimpleIdentifier(firstToken),
5417 new SimpleIdentifier(firstToken), 4980 secondToken, new SimpleIdentifier(thirdToken));
5418 secondToken,
5419 new SimpleIdentifier(thirdToken));
5420 nextToken = thirdToken.next; 4981 nextToken = thirdToken.next;
5421 } else { 4982 } else {
5422 identifier = new SimpleIdentifier(firstToken); 4983 identifier = new SimpleIdentifier(firstToken);
5423 nextToken = firstToken.next; 4984 nextToken = firstToken.next;
5424 } 4985 }
5425 if (nextToken.type != TokenType.EOF) { 4986 if (nextToken.type != TokenType.EOF) {
5426 return null; 4987 return null;
5427 } 4988 }
5428 return new CommentReference(newKeyword, identifier); 4989 return new CommentReference(newKeyword, identifier);
5429 } else if (_tokenMatchesKeyword(firstToken, Keyword.THIS) || 4990 } else if (_tokenMatchesKeyword(firstToken, Keyword.THIS) ||
(...skipping 20 matching lines...) Expand all
5450 * commentReference ::= 5011 * commentReference ::=
5451 * '[' 'new'? qualified ']' libraryReference? 5012 * '[' 'new'? qualified ']' libraryReference?
5452 * 5013 *
5453 * libraryReference ::= 5014 * libraryReference ::=
5454 * '(' stringLiteral ')' 5015 * '(' stringLiteral ')'
5455 * </pre> 5016 * </pre>
5456 * 5017 *
5457 * @param tokens the comment tokens representing the documentation comments to be parsed 5018 * @param tokens the comment tokens representing the documentation comments to be parsed
5458 * @return the comment references that were parsed 5019 * @return the comment references that were parsed
5459 */ 5020 */
5460 List<CommentReference> 5021 List<CommentReference> _parseCommentReferences(
5461 _parseCommentReferences(List<DocumentationCommentToken> tokens) { 5022 List<DocumentationCommentToken> tokens) {
5462 List<CommentReference> references = new List<CommentReference>(); 5023 List<CommentReference> references = new List<CommentReference>();
5463 for (DocumentationCommentToken token in tokens) { 5024 for (DocumentationCommentToken token in tokens) {
5464 String comment = token.lexeme; 5025 String comment = token.lexeme;
5465 int length = comment.length; 5026 int length = comment.length;
5466 List<List<int>> codeBlockRanges = _getCodeBlockRanges(comment); 5027 List<List<int>> codeBlockRanges = _getCodeBlockRanges(comment);
5467 int leftIndex = comment.indexOf('['); 5028 int leftIndex = comment.indexOf('[');
5468 while (leftIndex >= 0 && leftIndex + 1 < length) { 5029 while (leftIndex >= 0 && leftIndex + 1 < length) {
5469 List<int> range = _findRange(codeBlockRanges, leftIndex); 5030 List<int> range = _findRange(codeBlockRanges, leftIndex);
5470 if (range == null) { 5031 if (range == null) {
5471 int nameOffset = token.offset + leftIndex + 1; 5032 int nameOffset = token.offset + leftIndex + 1;
5472 int rightIndex = JavaString.indexOf(comment, ']', leftIndex); 5033 int rightIndex = JavaString.indexOf(comment, ']', leftIndex);
5473 if (rightIndex >= 0) { 5034 if (rightIndex >= 0) {
5474 int firstChar = comment.codeUnitAt(leftIndex + 1); 5035 int firstChar = comment.codeUnitAt(leftIndex + 1);
5475 if (firstChar != 0x27 && firstChar != 0x22) { 5036 if (firstChar != 0x27 && firstChar != 0x22) {
5476 if (_isLinkText(comment, rightIndex)) { 5037 if (_isLinkText(comment, rightIndex)) {
5477 // TODO(brianwilkerson) Handle the case where there's a library 5038 // TODO(brianwilkerson) Handle the case where there's a library
5478 // URI in the link text. 5039 // URI in the link text.
5479 } else { 5040 } else {
5480 CommentReference reference = _parseCommentReference( 5041 CommentReference reference = _parseCommentReference(
5481 comment.substring(leftIndex + 1, rightIndex), 5042 comment.substring(leftIndex + 1, rightIndex), nameOffset);
5482 nameOffset);
5483 if (reference != null) { 5043 if (reference != null) {
5484 references.add(reference); 5044 references.add(reference);
5485 token.references.add(reference.beginToken); 5045 token.references.add(reference.beginToken);
5486 } 5046 }
5487 } 5047 }
5488 } 5048 }
5489 } else { 5049 } else {
5490 // terminating ']' is not typed yet 5050 // terminating ']' is not typed yet
5491 int charAfterLeft = comment.codeUnitAt(leftIndex + 1); 5051 int charAfterLeft = comment.codeUnitAt(leftIndex + 1);
5492 if (Character.isLetterOrDigit(charAfterLeft)) { 5052 if (Character.isLetterOrDigit(charAfterLeft)) {
5493 int nameEnd = 5053 int nameEnd = StringUtilities.indexOfFirstNotLetterDigit(
5494 StringUtilities.indexOfFirstNotLetterDigit(comment, leftIndex + 1); 5054 comment, leftIndex + 1);
5495 String name = comment.substring(leftIndex + 1, nameEnd); 5055 String name = comment.substring(leftIndex + 1, nameEnd);
5496 Token nameToken = 5056 Token nameToken =
5497 new StringToken(TokenType.IDENTIFIER, name, nameOffset); 5057 new StringToken(TokenType.IDENTIFIER, name, nameOffset);
5498 references.add( 5058 references.add(
5499 new CommentReference(null, new SimpleIdentifier(nameToken))); 5059 new CommentReference(null, new SimpleIdentifier(nameToken)));
5500 } else { 5060 } else {
5501 Token nameToken = 5061 Token nameToken = new SyntheticStringToken(
5502 new SyntheticStringToken(TokenType.IDENTIFIER, "", nameOffset) ; 5062 TokenType.IDENTIFIER, "", nameOffset);
5503 references.add( 5063 references.add(
5504 new CommentReference(null, new SimpleIdentifier(nameToken))); 5064 new CommentReference(null, new SimpleIdentifier(nameToken)));
5505 } 5065 }
5506 // next character 5066 // next character
5507 rightIndex = leftIndex + 1; 5067 rightIndex = leftIndex + 1;
5508 } 5068 }
5509 leftIndex = JavaString.indexOf(comment, '[', rightIndex); 5069 leftIndex = JavaString.indexOf(comment, '[', rightIndex);
5510 } else { 5070 } else {
5511 leftIndex = JavaString.indexOf(comment, '[', range[1] + 1); 5071 leftIndex = JavaString.indexOf(comment, '[', range[1] + 1);
5512 } 5072 }
(...skipping 15 matching lines...) Expand all
5528 * | functionSignature functionBody 5088 * | functionSignature functionBody
5529 * | returnType? getOrSet identifier formalParameterList functionBody 5089 * | returnType? getOrSet identifier formalParameterList functionBody
5530 * | (final | const) type? staticFinalDeclarationList ';' 5090 * | (final | const) type? staticFinalDeclarationList ';'
5531 * | variableDeclaration ';' 5091 * | variableDeclaration ';'
5532 * </pre> 5092 * </pre>
5533 * 5093 *
5534 * @param commentAndMetadata the metadata to be associated with the member 5094 * @param commentAndMetadata the metadata to be associated with the member
5535 * @return the compilation unit member that was parsed, or `null` if what was parsed could 5095 * @return the compilation unit member that was parsed, or `null` if what was parsed could
5536 * not be represented as a compilation unit member 5096 * not be represented as a compilation unit member
5537 */ 5097 */
5538 CompilationUnitMember 5098 CompilationUnitMember _parseCompilationUnitMember(
5539 _parseCompilationUnitMember(CommentAndMetadata commentAndMetadata) { 5099 CommentAndMetadata commentAndMetadata) {
5540 Modifiers modifiers = _parseModifiers(); 5100 Modifiers modifiers = _parseModifiers();
5541 if (_matchesKeyword(Keyword.CLASS)) { 5101 if (_matchesKeyword(Keyword.CLASS)) {
5542 return _parseClassDeclaration( 5102 return _parseClassDeclaration(
5543 commentAndMetadata, 5103 commentAndMetadata, _validateModifiersForClass(modifiers));
5544 _validateModifiersForClass(modifiers));
5545 } else if (_matchesKeyword(Keyword.TYPEDEF) && 5104 } else if (_matchesKeyword(Keyword.TYPEDEF) &&
5546 !_tokenMatches(_peek(), TokenType.PERIOD) && 5105 !_tokenMatches(_peek(), TokenType.PERIOD) &&
5547 !_tokenMatches(_peek(), TokenType.LT) && 5106 !_tokenMatches(_peek(), TokenType.LT) &&
5548 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { 5107 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) {
5549 _validateModifiersForTypedef(modifiers); 5108 _validateModifiersForTypedef(modifiers);
5550 return _parseTypeAlias(commentAndMetadata); 5109 return _parseTypeAlias(commentAndMetadata);
5551 } else if (_matchesKeyword(Keyword.ENUM)) { 5110 } else if (_matchesKeyword(Keyword.ENUM)) {
5552 _validateModifiersForEnum(modifiers); 5111 _validateModifiersForEnum(modifiers);
5553 return _parseEnumDeclaration(commentAndMetadata); 5112 return _parseEnumDeclaration(commentAndMetadata);
5554 } 5113 }
5555 if (_matchesKeyword(Keyword.VOID)) { 5114 if (_matchesKeyword(Keyword.VOID)) {
5556 TypeName returnType = parseReturnType(); 5115 TypeName returnType = parseReturnType();
5557 if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) && 5116 if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) &&
5558 _tokenMatchesIdentifier(_peek())) { 5117 _tokenMatchesIdentifier(_peek())) {
5559 _validateModifiersForTopLevelFunction(modifiers); 5118 _validateModifiersForTopLevelFunction(modifiers);
5560 return _parseFunctionDeclaration( 5119 return _parseFunctionDeclaration(
5561 commentAndMetadata, 5120 commentAndMetadata, modifiers.externalKeyword, returnType);
5562 modifiers.externalKeyword,
5563 returnType);
5564 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { 5121 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) {
5565 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken); 5122 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken);
5566 return _convertToFunctionDeclaration( 5123 return _convertToFunctionDeclaration(_parseOperator(
5567 _parseOperator(commentAndMetadata, modifiers.externalKeyword, return Type)); 5124 commentAndMetadata, modifiers.externalKeyword, returnType));
5568 } else if (_matchesIdentifier() && 5125 } else if (_matchesIdentifier() &&
5569 _peek().matchesAny( 5126 _peek().matchesAny([
5570 [TokenType.OPEN_PAREN, TokenType.OPEN_CURLY_BRACKET, TokenType.FUN CTION])) { 5127 TokenType.OPEN_PAREN,
5128 TokenType.OPEN_CURLY_BRACKET,
5129 TokenType.FUNCTION
5130 ])) {
5571 _validateModifiersForTopLevelFunction(modifiers); 5131 _validateModifiersForTopLevelFunction(modifiers);
5572 return _parseFunctionDeclaration( 5132 return _parseFunctionDeclaration(
5573 commentAndMetadata, 5133 commentAndMetadata, modifiers.externalKeyword, returnType);
5574 modifiers.externalKeyword,
5575 returnType);
5576 } else { 5134 } else {
5577 // 5135 //
5578 // We have found an error of some kind. Try to recover. 5136 // We have found an error of some kind. Try to recover.
5579 // 5137 //
5580 if (_matchesIdentifier()) { 5138 if (_matchesIdentifier()) {
5581 if (_peek().matchesAny( 5139 if (_peek().matchesAny(
5582 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { 5140 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) {
5583 // 5141 //
5584 // We appear to have a variable declaration with a type of "void". 5142 // We appear to have a variable declaration with a type of "void".
5585 // 5143 //
5586 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType); 5144 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType);
5587 return new TopLevelVariableDeclaration( 5145 return new TopLevelVariableDeclaration(commentAndMetadata.comment,
5588 commentAndMetadata.comment,
5589 commentAndMetadata.metadata, 5146 commentAndMetadata.metadata,
5590 _parseVariableDeclarationListAfterType( 5147 _parseVariableDeclarationListAfterType(null,
5591 null, 5148 _validateModifiersForTopLevelVariable(modifiers), null),
5592 _validateModifiersForTopLevelVariable(modifiers),
5593 null),
5594 _expect(TokenType.SEMICOLON)); 5149 _expect(TokenType.SEMICOLON));
5595 } 5150 }
5596 } 5151 }
5597 _reportErrorForToken( 5152 _reportErrorForToken(
5598 ParserErrorCode.EXPECTED_EXECUTABLE, 5153 ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken);
5599 _currentToken);
5600 return null; 5154 return null;
5601 } 5155 }
5602 } else if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) && 5156 } else if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) &&
5603 _tokenMatchesIdentifier(_peek())) { 5157 _tokenMatchesIdentifier(_peek())) {
5604 _validateModifiersForTopLevelFunction(modifiers); 5158 _validateModifiersForTopLevelFunction(modifiers);
5605 return _parseFunctionDeclaration( 5159 return _parseFunctionDeclaration(
5606 commentAndMetadata, 5160 commentAndMetadata, modifiers.externalKeyword, null);
5607 modifiers.externalKeyword,
5608 null);
5609 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { 5161 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) {
5610 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken); 5162 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken);
5611 return _convertToFunctionDeclaration( 5163 return _convertToFunctionDeclaration(
5612 _parseOperator(commentAndMetadata, modifiers.externalKeyword, null)); 5164 _parseOperator(commentAndMetadata, modifiers.externalKeyword, null));
5613 } else if (!_matchesIdentifier()) { 5165 } else if (!_matchesIdentifier()) {
5614 Token keyword = modifiers.varKeyword; 5166 Token keyword = modifiers.varKeyword;
5615 if (keyword == null) { 5167 if (keyword == null) {
5616 keyword = modifiers.finalKeyword; 5168 keyword = modifiers.finalKeyword;
5617 } 5169 }
5618 if (keyword == null) { 5170 if (keyword == null) {
5619 keyword = modifiers.constKeyword; 5171 keyword = modifiers.constKeyword;
5620 } 5172 }
5621 if (keyword != null) { 5173 if (keyword != null) {
5622 // 5174 //
5623 // We appear to have found an incomplete top-level variable declaration. 5175 // We appear to have found an incomplete top-level variable declaration.
5624 // 5176 //
5625 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER); 5177 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER);
5626 List<VariableDeclaration> variables = new List<VariableDeclaration>(); 5178 List<VariableDeclaration> variables = new List<VariableDeclaration>();
5627 variables.add( 5179 variables.add(new VariableDeclaration(
5628 new VariableDeclaration(null, null, _createSyntheticIdentifier(), nu ll, null)); 5180 null, null, _createSyntheticIdentifier(), null, null));
5629 return new TopLevelVariableDeclaration( 5181 return new TopLevelVariableDeclaration(commentAndMetadata.comment,
5630 commentAndMetadata.comment,
5631 commentAndMetadata.metadata, 5182 commentAndMetadata.metadata,
5632 new VariableDeclarationList(null, null, keyword, null, variables), 5183 new VariableDeclarationList(null, null, keyword, null, variables),
5633 _expectSemicolon()); 5184 _expectSemicolon());
5634 } 5185 }
5635 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken); 5186 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken);
5636 return null; 5187 return null;
5637 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { 5188 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) {
5638 _validateModifiersForTopLevelFunction(modifiers); 5189 _validateModifiersForTopLevelFunction(modifiers);
5639 return _parseFunctionDeclaration( 5190 return _parseFunctionDeclaration(
5640 commentAndMetadata, 5191 commentAndMetadata, modifiers.externalKeyword, null);
5641 modifiers.externalKeyword, 5192 } else if (_peek()
5642 null); 5193 .matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) {
5643 } else if (_peek().matchesAny(
5644 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) {
5645 if (modifiers.constKeyword == null && 5194 if (modifiers.constKeyword == null &&
5646 modifiers.finalKeyword == null && 5195 modifiers.finalKeyword == null &&
5647 modifiers.varKeyword == null) { 5196 modifiers.varKeyword == null) {
5648 _reportErrorForCurrentToken( 5197 _reportErrorForCurrentToken(
5649 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE); 5198 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE);
5650 } 5199 }
5651 return new TopLevelVariableDeclaration( 5200 return new TopLevelVariableDeclaration(commentAndMetadata.comment,
5652 commentAndMetadata.comment, 5201 commentAndMetadata.metadata, _parseVariableDeclarationListAfterType(
5653 commentAndMetadata.metadata, 5202 null, _validateModifiersForTopLevelVariable(modifiers), null),
5654 _parseVariableDeclarationListAfterType(
5655 null,
5656 _validateModifiersForTopLevelVariable(modifiers),
5657 null),
5658 _expect(TokenType.SEMICOLON)); 5203 _expect(TokenType.SEMICOLON));
5659 } 5204 }
5660 TypeName returnType = parseReturnType(); 5205 TypeName returnType = parseReturnType();
5661 if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) && 5206 if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) &&
5662 _tokenMatchesIdentifier(_peek())) { 5207 _tokenMatchesIdentifier(_peek())) {
5663 _validateModifiersForTopLevelFunction(modifiers); 5208 _validateModifiersForTopLevelFunction(modifiers);
5664 return _parseFunctionDeclaration( 5209 return _parseFunctionDeclaration(
5665 commentAndMetadata, 5210 commentAndMetadata, modifiers.externalKeyword, returnType);
5666 modifiers.externalKeyword,
5667 returnType);
5668 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { 5211 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) {
5669 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken); 5212 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken);
5670 return _convertToFunctionDeclaration( 5213 return _convertToFunctionDeclaration(_parseOperator(
5671 _parseOperator(commentAndMetadata, modifiers.externalKeyword, returnTy pe)); 5214 commentAndMetadata, modifiers.externalKeyword, returnType));
5672 } else if (_matches(TokenType.AT)) { 5215 } else if (_matches(TokenType.AT)) {
5673 return new TopLevelVariableDeclaration( 5216 return new TopLevelVariableDeclaration(commentAndMetadata.comment,
5674 commentAndMetadata.comment, 5217 commentAndMetadata.metadata, _parseVariableDeclarationListAfterType(
5675 commentAndMetadata.metadata, 5218 null, _validateModifiersForTopLevelVariable(modifiers),
5676 _parseVariableDeclarationListAfterType( 5219 returnType), _expect(TokenType.SEMICOLON));
5677 null,
5678 _validateModifiersForTopLevelVariable(modifiers),
5679 returnType),
5680 _expect(TokenType.SEMICOLON));
5681 } else if (!_matchesIdentifier()) { 5220 } else if (!_matchesIdentifier()) {
5682 // TODO(brianwilkerson) Generalize this error. We could also be parsing a 5221 // TODO(brianwilkerson) Generalize this error. We could also be parsing a
5683 // top-level variable at this point. 5222 // top-level variable at this point.
5684 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken); 5223 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken);
5685 Token semicolon; 5224 Token semicolon;
5686 if (_matches(TokenType.SEMICOLON)) { 5225 if (_matches(TokenType.SEMICOLON)) {
5687 semicolon = getAndAdvance(); 5226 semicolon = getAndAdvance();
5688 } else { 5227 } else {
5689 semicolon = _createSyntheticToken(TokenType.SEMICOLON); 5228 semicolon = _createSyntheticToken(TokenType.SEMICOLON);
5690 } 5229 }
5691 List<VariableDeclaration> variables = new List<VariableDeclaration>(); 5230 List<VariableDeclaration> variables = new List<VariableDeclaration>();
5692 variables.add( 5231 variables.add(new VariableDeclaration(
5693 new VariableDeclaration(null, null, _createSyntheticIdentifier(), null , null)); 5232 null, null, _createSyntheticIdentifier(), null, null));
5694 return new TopLevelVariableDeclaration( 5233 return new TopLevelVariableDeclaration(commentAndMetadata.comment,
5695 commentAndMetadata.comment,
5696 commentAndMetadata.metadata, 5234 commentAndMetadata.metadata,
5697 new VariableDeclarationList(null, null, null, returnType, variables), 5235 new VariableDeclarationList(null, null, null, returnType, variables),
5698 semicolon); 5236 semicolon);
5699 } 5237 }
5700 if (_peek().matchesAny( 5238 if (_peek().matchesAny([
5701 [TokenType.OPEN_PAREN, TokenType.FUNCTION, TokenType.OPEN_CURLY_BRACKET] )) { 5239 TokenType.OPEN_PAREN,
5240 TokenType.FUNCTION,
5241 TokenType.OPEN_CURLY_BRACKET
5242 ])) {
5702 _validateModifiersForTopLevelFunction(modifiers); 5243 _validateModifiersForTopLevelFunction(modifiers);
5703 return _parseFunctionDeclaration( 5244 return _parseFunctionDeclaration(
5704 commentAndMetadata, 5245 commentAndMetadata, modifiers.externalKeyword, returnType);
5705 modifiers.externalKeyword,
5706 returnType);
5707 } 5246 }
5708 return new TopLevelVariableDeclaration( 5247 return new TopLevelVariableDeclaration(commentAndMetadata.comment,
5709 commentAndMetadata.comment, 5248 commentAndMetadata.metadata, _parseVariableDeclarationListAfterType(
5710 commentAndMetadata.metadata, 5249 null, _validateModifiersForTopLevelVariable(modifiers), returnType),
5711 _parseVariableDeclarationListAfterType(
5712 null,
5713 _validateModifiersForTopLevelVariable(modifiers),
5714 returnType),
5715 _expect(TokenType.SEMICOLON)); 5250 _expect(TokenType.SEMICOLON));
5716 } 5251 }
5717 5252
5718 /** 5253 /**
5719 * Parse a const expression. 5254 * Parse a const expression.
5720 * 5255 *
5721 * <pre> 5256 * <pre>
5722 * constExpression ::= 5257 * constExpression ::=
5723 * instanceCreationExpression 5258 * instanceCreationExpression
5724 * | listLiteral 5259 * | listLiteral
5725 * | mapLiteral 5260 * | mapLiteral
5726 * </pre> 5261 * </pre>
5727 * 5262 *
5728 * @return the const expression that was parsed 5263 * @return the const expression that was parsed
5729 */ 5264 */
5730 Expression _parseConstExpression() { 5265 Expression _parseConstExpression() {
5731 Token keyword = _expectKeyword(Keyword.CONST); 5266 Token keyword = _expectKeyword(Keyword.CONST);
5732 if (_matches(TokenType.OPEN_SQUARE_BRACKET) || _matches(TokenType.INDEX)) { 5267 if (_matches(TokenType.OPEN_SQUARE_BRACKET) || _matches(TokenType.INDEX)) {
5733 return _parseListLiteral(keyword, null); 5268 return _parseListLiteral(keyword, null);
5734 } else if (_matches(TokenType.OPEN_CURLY_BRACKET)) { 5269 } else if (_matches(TokenType.OPEN_CURLY_BRACKET)) {
5735 return _parseMapLiteral(keyword, null); 5270 return _parseMapLiteral(keyword, null);
5736 } else if (_matches(TokenType.LT)) { 5271 } else if (_matches(TokenType.LT)) {
5737 return _parseListOrMapLiteral(keyword); 5272 return _parseListOrMapLiteral(keyword);
5738 } 5273 }
5739 return _parseInstanceCreationExpression(keyword); 5274 return _parseInstanceCreationExpression(keyword);
5740 } 5275 }
5741 5276
5742 ConstructorDeclaration 5277 ConstructorDeclaration _parseConstructor(
5743 _parseConstructor(CommentAndMetadata commentAndMetadata, Token externalKey word, 5278 CommentAndMetadata commentAndMetadata, Token externalKeyword,
5744 Token constKeyword, Token factoryKeyword, SimpleIdentifier returnType, 5279 Token constKeyword, Token factoryKeyword, SimpleIdentifier returnType,
5745 Token period, SimpleIdentifier name, FormalParameterList parameters) { 5280 Token period, SimpleIdentifier name, FormalParameterList parameters) {
5746 bool bodyAllowed = externalKeyword == null; 5281 bool bodyAllowed = externalKeyword == null;
5747 Token separator = null; 5282 Token separator = null;
5748 List<ConstructorInitializer> initializers = null; 5283 List<ConstructorInitializer> initializers = null;
5749 if (_matches(TokenType.COLON)) { 5284 if (_matches(TokenType.COLON)) {
5750 separator = getAndAdvance(); 5285 separator = getAndAdvance();
5751 initializers = new List<ConstructorInitializer>(); 5286 initializers = new List<ConstructorInitializer>();
5752 do { 5287 do {
5753 if (_matchesKeyword(Keyword.THIS)) { 5288 if (_matchesKeyword(Keyword.THIS)) {
(...skipping 11 matching lines...) Expand all
5765 initializers.add(_parseSuperConstructorInvocation()); 5300 initializers.add(_parseSuperConstructorInvocation());
5766 } else if (_matches(TokenType.OPEN_CURLY_BRACKET) || 5301 } else if (_matches(TokenType.OPEN_CURLY_BRACKET) ||
5767 _matches(TokenType.FUNCTION)) { 5302 _matches(TokenType.FUNCTION)) {
5768 _reportErrorForCurrentToken(ParserErrorCode.MISSING_INITIALIZER); 5303 _reportErrorForCurrentToken(ParserErrorCode.MISSING_INITIALIZER);
5769 } else { 5304 } else {
5770 initializers.add(_parseConstructorFieldInitializer()); 5305 initializers.add(_parseConstructorFieldInitializer());
5771 } 5306 }
5772 } while (_optional(TokenType.COMMA)); 5307 } while (_optional(TokenType.COMMA));
5773 if (factoryKeyword != null) { 5308 if (factoryKeyword != null) {
5774 _reportErrorForToken( 5309 _reportErrorForToken(
5775 ParserErrorCode.FACTORY_WITH_INITIALIZERS, 5310 ParserErrorCode.FACTORY_WITH_INITIALIZERS, factoryKeyword);
5776 factoryKeyword);
5777 } 5311 }
5778 } 5312 }
5779 ConstructorName redirectedConstructor = null; 5313 ConstructorName redirectedConstructor = null;
5780 FunctionBody body; 5314 FunctionBody body;
5781 if (_matches(TokenType.EQ)) { 5315 if (_matches(TokenType.EQ)) {
5782 separator = getAndAdvance(); 5316 separator = getAndAdvance();
5783 redirectedConstructor = parseConstructorName(); 5317 redirectedConstructor = parseConstructorName();
5784 body = new EmptyFunctionBody(_expect(TokenType.SEMICOLON)); 5318 body = new EmptyFunctionBody(_expect(TokenType.SEMICOLON));
5785 if (factoryKeyword == null) { 5319 if (factoryKeyword == null) {
5786 _reportErrorForNode( 5320 _reportErrorForNode(
5787 ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR, 5321 ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR,
5788 redirectedConstructor); 5322 redirectedConstructor);
5789 } 5323 }
5790 } else { 5324 } else {
5791 body = 5325 body = _parseFunctionBody(
5792 _parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, false) ; 5326 true, ParserErrorCode.MISSING_FUNCTION_BODY, false);
5793 if (constKeyword != null && 5327 if (constKeyword != null &&
5794 factoryKeyword != null && 5328 factoryKeyword != null &&
5795 externalKeyword == null) { 5329 externalKeyword == null) {
5796 _reportErrorForToken(ParserErrorCode.CONST_FACTORY, factoryKeyword); 5330 _reportErrorForToken(ParserErrorCode.CONST_FACTORY, factoryKeyword);
5797 } else if (body is EmptyFunctionBody) { 5331 } else if (body is EmptyFunctionBody) {
5798 if (factoryKeyword != null && externalKeyword == null) { 5332 if (factoryKeyword != null && externalKeyword == null) {
5799 _reportErrorForToken( 5333 _reportErrorForToken(
5800 ParserErrorCode.FACTORY_WITHOUT_BODY, 5334 ParserErrorCode.FACTORY_WITHOUT_BODY, factoryKeyword);
5801 factoryKeyword);
5802 } 5335 }
5803 } else { 5336 } else {
5804 if (constKeyword != null) { 5337 if (constKeyword != null) {
5805 _reportErrorForNode( 5338 _reportErrorForNode(
5806 ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, 5339 ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, body);
5807 body);
5808 } else if (!bodyAllowed) { 5340 } else if (!bodyAllowed) {
5809 _reportErrorForNode( 5341 _reportErrorForNode(
5810 ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, 5342 ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, body);
5811 body);
5812 } 5343 }
5813 } 5344 }
5814 } 5345 }
5815 return new ConstructorDeclaration( 5346 return new ConstructorDeclaration(commentAndMetadata.comment,
5816 commentAndMetadata.comment, 5347 commentAndMetadata.metadata, externalKeyword, constKeyword,
5817 commentAndMetadata.metadata, 5348 factoryKeyword, returnType, period, name, parameters, separator,
5818 externalKeyword, 5349 initializers, redirectedConstructor, body);
5819 constKeyword,
5820 factoryKeyword,
5821 returnType,
5822 period,
5823 name,
5824 parameters,
5825 separator,
5826 initializers,
5827 redirectedConstructor,
5828 body);
5829 } 5350 }
5830 5351
5831 /** 5352 /**
5832 * Parse a field initializer within a constructor. 5353 * Parse a field initializer within a constructor.
5833 * 5354 *
5834 * <pre> 5355 * <pre>
5835 * fieldInitializer: 5356 * fieldInitializer:
5836 * ('this' '.')? identifier '=' conditionalExpression cascadeSection* 5357 * ('this' '.')? identifier '=' conditionalExpression cascadeSection*
5837 * </pre> 5358 * </pre>
5838 * 5359 *
(...skipping 13 matching lines...) Expand all
5852 } else if (!_matchesKeyword(Keyword.THIS) && 5373 } else if (!_matchesKeyword(Keyword.THIS) &&
5853 !_matchesKeyword(Keyword.SUPER) && 5374 !_matchesKeyword(Keyword.SUPER) &&
5854 !_matches(TokenType.OPEN_CURLY_BRACKET) && 5375 !_matches(TokenType.OPEN_CURLY_BRACKET) &&
5855 !_matches(TokenType.FUNCTION)) { 5376 !_matches(TokenType.FUNCTION)) {
5856 _reportErrorForCurrentToken( 5377 _reportErrorForCurrentToken(
5857 ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER); 5378 ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER);
5858 equals = _createSyntheticToken(TokenType.EQ); 5379 equals = _createSyntheticToken(TokenType.EQ);
5859 } else { 5380 } else {
5860 _reportErrorForCurrentToken( 5381 _reportErrorForCurrentToken(
5861 ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER); 5382 ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER);
5862 return new ConstructorFieldInitializer( 5383 return new ConstructorFieldInitializer(keyword, period, fieldName,
5863 keyword, 5384 _createSyntheticToken(TokenType.EQ), _createSyntheticIdentifier());
5864 period,
5865 fieldName,
5866 _createSyntheticToken(TokenType.EQ),
5867 _createSyntheticIdentifier());
5868 } 5385 }
5869 bool wasInInitializer = _inInitializer; 5386 bool wasInInitializer = _inInitializer;
5870 _inInitializer = true; 5387 _inInitializer = true;
5871 try { 5388 try {
5872 Expression expression = parseConditionalExpression(); 5389 Expression expression = parseConditionalExpression();
5873 TokenType tokenType = _currentToken.type; 5390 TokenType tokenType = _currentToken.type;
5874 if (tokenType == TokenType.PERIOD_PERIOD) { 5391 if (tokenType == TokenType.PERIOD_PERIOD) {
5875 List<Expression> cascadeSections = new List<Expression>(); 5392 List<Expression> cascadeSections = new List<Expression>();
5876 while (tokenType == TokenType.PERIOD_PERIOD) { 5393 while (tokenType == TokenType.PERIOD_PERIOD) {
5877 Expression section = _parseCascadeSection(); 5394 Expression section = _parseCascadeSection();
5878 if (section != null) { 5395 if (section != null) {
5879 cascadeSections.add(section); 5396 cascadeSections.add(section);
5880 } 5397 }
5881 tokenType = _currentToken.type; 5398 tokenType = _currentToken.type;
5882 } 5399 }
5883 expression = new CascadeExpression(expression, cascadeSections); 5400 expression = new CascadeExpression(expression, cascadeSections);
5884 } 5401 }
5885 return new ConstructorFieldInitializer( 5402 return new ConstructorFieldInitializer(
5886 keyword, 5403 keyword, period, fieldName, equals, expression);
5887 period,
5888 fieldName,
5889 equals,
5890 expression);
5891 } finally { 5404 } finally {
5892 _inInitializer = wasInInitializer; 5405 _inInitializer = wasInInitializer;
5893 } 5406 }
5894 } 5407 }
5895 5408
5896 /** 5409 /**
5897 * Parse a continue statement. 5410 * Parse a continue statement.
5898 * 5411 *
5899 * <pre> 5412 * <pre>
5900 * continueStatement ::= 5413 * continueStatement ::=
5901 * 'continue' identifier? ';' 5414 * 'continue' identifier? ';'
5902 * </pre> 5415 * </pre>
5903 * 5416 *
5904 * @return the continue statement that was parsed 5417 * @return the continue statement that was parsed
5905 */ 5418 */
5906 Statement _parseContinueStatement() { 5419 Statement _parseContinueStatement() {
5907 Token continueKeyword = _expectKeyword(Keyword.CONTINUE); 5420 Token continueKeyword = _expectKeyword(Keyword.CONTINUE);
5908 if (!_inLoop && !_inSwitch) { 5421 if (!_inLoop && !_inSwitch) {
5909 _reportErrorForToken( 5422 _reportErrorForToken(
5910 ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP, 5423 ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP, continueKeyword);
5911 continueKeyword);
5912 } 5424 }
5913 SimpleIdentifier label = null; 5425 SimpleIdentifier label = null;
5914 if (_matchesIdentifier()) { 5426 if (_matchesIdentifier()) {
5915 label = parseSimpleIdentifier(); 5427 label = parseSimpleIdentifier();
5916 } 5428 }
5917 if (_inSwitch && !_inLoop && label == null) { 5429 if (_inSwitch && !_inLoop && label == null) {
5918 _reportErrorForToken( 5430 _reportErrorForToken(
5919 ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE, 5431 ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE, continueKeyword);
5920 continueKeyword);
5921 } 5432 }
5922 Token semicolon = _expect(TokenType.SEMICOLON); 5433 Token semicolon = _expect(TokenType.SEMICOLON);
5923 return new ContinueStatement(continueKeyword, label, semicolon); 5434 return new ContinueStatement(continueKeyword, label, semicolon);
5924 } 5435 }
5925 5436
5926 /** 5437 /**
5927 * Parse a directive. 5438 * Parse a directive.
5928 * 5439 *
5929 * <pre> 5440 * <pre>
5930 * directive ::= 5441 * directive ::=
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5969 CompilationUnit _parseDirectives() { 5480 CompilationUnit _parseDirectives() {
5970 Token firstToken = _currentToken; 5481 Token firstToken = _currentToken;
5971 ScriptTag scriptTag = null; 5482 ScriptTag scriptTag = null;
5972 if (_matches(TokenType.SCRIPT_TAG)) { 5483 if (_matches(TokenType.SCRIPT_TAG)) {
5973 scriptTag = new ScriptTag(getAndAdvance()); 5484 scriptTag = new ScriptTag(getAndAdvance());
5974 } 5485 }
5975 List<Directive> directives = new List<Directive>(); 5486 List<Directive> directives = new List<Directive>();
5976 while (!_matches(TokenType.EOF)) { 5487 while (!_matches(TokenType.EOF)) {
5977 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); 5488 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata();
5978 if ((_matchesKeyword(Keyword.IMPORT) || 5489 if ((_matchesKeyword(Keyword.IMPORT) ||
5979 _matchesKeyword(Keyword.EXPORT) || 5490 _matchesKeyword(Keyword.EXPORT) ||
5980 _matchesKeyword(Keyword.LIBRARY) || 5491 _matchesKeyword(Keyword.LIBRARY) ||
5981 _matchesKeyword(Keyword.PART)) && 5492 _matchesKeyword(Keyword.PART)) &&
5982 !_tokenMatches(_peek(), TokenType.PERIOD) && 5493 !_tokenMatches(_peek(), TokenType.PERIOD) &&
5983 !_tokenMatches(_peek(), TokenType.LT) && 5494 !_tokenMatches(_peek(), TokenType.LT) &&
5984 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { 5495 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) {
5985 directives.add(_parseDirective(commentAndMetadata)); 5496 directives.add(_parseDirective(commentAndMetadata));
5986 } else if (_matches(TokenType.SEMICOLON)) { 5497 } else if (_matches(TokenType.SEMICOLON)) {
5987 _advance(); 5498 _advance();
5988 } else { 5499 } else {
5989 while (!_matches(TokenType.EOF)) { 5500 while (!_matches(TokenType.EOF)) {
5990 _advance(); 5501 _advance();
5991 } 5502 }
5992 return new CompilationUnit( 5503 return new CompilationUnit(firstToken, scriptTag, directives,
5993 firstToken, 5504 new List<CompilationUnitMember>(), _currentToken);
5994 scriptTag,
5995 directives,
5996 new List<CompilationUnitMember>(),
5997 _currentToken);
5998 } 5505 }
5999 } 5506 }
6000 return new CompilationUnit( 5507 return new CompilationUnit(firstToken, scriptTag, directives,
6001 firstToken, 5508 new List<CompilationUnitMember>(), _currentToken);
6002 scriptTag,
6003 directives,
6004 new List<CompilationUnitMember>(),
6005 _currentToken);
6006 } 5509 }
6007 5510
6008 /** 5511 /**
6009 * Parse a documentation comment. 5512 * Parse a documentation comment.
6010 * 5513 *
6011 * <pre> 5514 * <pre>
6012 * documentationComment ::= 5515 * documentationComment ::=
6013 * multiLineComment? 5516 * multiLineComment?
6014 * | singleLineComment* 5517 * | singleLineComment*
6015 * </pre> 5518 * </pre>
6016 * 5519 *
6017 * @return the documentation comment that was parsed, or `null` if there was n o comment 5520 * @return the documentation comment that was parsed, or `null` if there was n o comment
6018 */ 5521 */
6019 Comment _parseDocumentationComment() { 5522 Comment _parseDocumentationComment() {
6020 List<DocumentationCommentToken> documentationTokens = 5523 List<DocumentationCommentToken> documentationTokens =
6021 <DocumentationCommentToken>[ 5524 <DocumentationCommentToken>[];
6022 ];
6023 CommentToken commentToken = _currentToken.precedingComments; 5525 CommentToken commentToken = _currentToken.precedingComments;
6024 while (commentToken != null) { 5526 while (commentToken != null) {
6025 if (commentToken is DocumentationCommentToken) { 5527 if (commentToken is DocumentationCommentToken) {
6026 if (documentationTokens.isNotEmpty) { 5528 if (documentationTokens.isNotEmpty) {
6027 if (commentToken.type == TokenType.SINGLE_LINE_COMMENT) { 5529 if (commentToken.type == TokenType.SINGLE_LINE_COMMENT) {
6028 if (documentationTokens[0].type != TokenType.SINGLE_LINE_COMMENT) { 5530 if (documentationTokens[0].type != TokenType.SINGLE_LINE_COMMENT) {
6029 documentationTokens.clear(); 5531 documentationTokens.clear();
6030 } 5532 }
6031 } else { 5533 } else {
6032 documentationTokens.clear(); 5534 documentationTokens.clear();
6033 } 5535 }
6034 } 5536 }
6035 documentationTokens.add(commentToken); 5537 documentationTokens.add(commentToken);
6036 } 5538 }
6037 commentToken = commentToken.next; 5539 commentToken = commentToken.next;
6038 } 5540 }
6039 if (documentationTokens.isEmpty) { 5541 if (documentationTokens.isEmpty) {
6040 return null; 5542 return null;
6041 } 5543 }
6042 List<CommentReference> references = 5544 List<CommentReference> references =
6043 _parseCommentReferences(documentationTokens); 5545 _parseCommentReferences(documentationTokens);
6044 return Comment.createDocumentationCommentWithReferences( 5546 return Comment.createDocumentationCommentWithReferences(
6045 documentationTokens, 5547 documentationTokens, references);
6046 references);
6047 } 5548 }
6048 5549
6049 /** 5550 /**
6050 * Parse a do statement. 5551 * Parse a do statement.
6051 * 5552 *
6052 * <pre> 5553 * <pre>
6053 * doStatement ::= 5554 * doStatement ::=
6054 * 'do' statement 'while' '(' expression ')' ';' 5555 * 'do' statement 'while' '(' expression ')' ';'
6055 * </pre> 5556 * </pre>
6056 * 5557 *
6057 * @return the do statement that was parsed 5558 * @return the do statement that was parsed
6058 */ 5559 */
6059 Statement _parseDoStatement() { 5560 Statement _parseDoStatement() {
6060 bool wasInLoop = _inLoop; 5561 bool wasInLoop = _inLoop;
6061 _inLoop = true; 5562 _inLoop = true;
6062 try { 5563 try {
6063 Token doKeyword = _expectKeyword(Keyword.DO); 5564 Token doKeyword = _expectKeyword(Keyword.DO);
6064 Statement body = parseStatement2(); 5565 Statement body = parseStatement2();
6065 Token whileKeyword = _expectKeyword(Keyword.WHILE); 5566 Token whileKeyword = _expectKeyword(Keyword.WHILE);
6066 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); 5567 Token leftParenthesis = _expect(TokenType.OPEN_PAREN);
6067 Expression condition = parseExpression2(); 5568 Expression condition = parseExpression2();
6068 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); 5569 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN);
6069 Token semicolon = _expect(TokenType.SEMICOLON); 5570 Token semicolon = _expect(TokenType.SEMICOLON);
6070 return new DoStatement( 5571 return new DoStatement(doKeyword, body, whileKeyword, leftParenthesis,
6071 doKeyword, 5572 condition, rightParenthesis, semicolon);
6072 body,
6073 whileKeyword,
6074 leftParenthesis,
6075 condition,
6076 rightParenthesis,
6077 semicolon);
6078 } finally { 5573 } finally {
6079 _inLoop = wasInLoop; 5574 _inLoop = wasInLoop;
6080 } 5575 }
6081 } 5576 }
6082 5577
6083 /** 5578 /**
6084 * Parse an empty statement. 5579 * Parse an empty statement.
6085 * 5580 *
6086 * <pre> 5581 * <pre>
6087 * emptyStatement ::= 5582 * emptyStatement ::=
6088 * ';' 5583 * ';'
6089 * </pre> 5584 * </pre>
6090 * 5585 *
6091 * @return the empty statement that was parsed 5586 * @return the empty statement that was parsed
6092 */ 5587 */
6093 Statement _parseEmptyStatement() => new EmptyStatement(getAndAdvance()); 5588 Statement _parseEmptyStatement() => new EmptyStatement(getAndAdvance());
6094 5589
6095 EnumConstantDeclaration _parseEnumConstantDeclaration() { 5590 EnumConstantDeclaration _parseEnumConstantDeclaration() {
6096 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); 5591 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata();
6097 SimpleIdentifier name; 5592 SimpleIdentifier name;
6098 if (_matchesIdentifier()) { 5593 if (_matchesIdentifier()) {
6099 name = parseSimpleIdentifier(); 5594 name = parseSimpleIdentifier();
6100 } else { 5595 } else {
6101 name = _createSyntheticIdentifier(); 5596 name = _createSyntheticIdentifier();
6102 } 5597 }
6103 if (commentAndMetadata.metadata.isNotEmpty) { 5598 if (commentAndMetadata.metadata.isNotEmpty) {
6104 _reportErrorForNode( 5599 _reportErrorForNode(ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT,
6105 ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT,
6106 commentAndMetadata.metadata[0]); 5600 commentAndMetadata.metadata[0]);
6107 } 5601 }
6108 return new EnumConstantDeclaration( 5602 return new EnumConstantDeclaration(
6109 commentAndMetadata.comment, 5603 commentAndMetadata.comment, commentAndMetadata.metadata, name);
6110 commentAndMetadata.metadata,
6111 name);
6112 } 5604 }
6113 5605
6114 /** 5606 /**
6115 * Parse an enum declaration. 5607 * Parse an enum declaration.
6116 * 5608 *
6117 * <pre> 5609 * <pre>
6118 * enumType ::= 5610 * enumType ::=
6119 * metadata 'enum' id '{' id (',' id)* (',')? '}' 5611 * metadata 'enum' id '{' id (',' id)* (',')? '}'
6120 * </pre> 5612 * </pre>
6121 * 5613 *
(...skipping 24 matching lines...) Expand all
6146 break; 5638 break;
6147 } 5639 }
6148 constants.add(_parseEnumConstantDeclaration()); 5640 constants.add(_parseEnumConstantDeclaration());
6149 } 5641 }
6150 rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); 5642 rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET);
6151 } else { 5643 } else {
6152 leftBracket = _createSyntheticToken(TokenType.OPEN_CURLY_BRACKET); 5644 leftBracket = _createSyntheticToken(TokenType.OPEN_CURLY_BRACKET);
6153 rightBracket = _createSyntheticToken(TokenType.CLOSE_CURLY_BRACKET); 5645 rightBracket = _createSyntheticToken(TokenType.CLOSE_CURLY_BRACKET);
6154 _reportErrorForCurrentToken(ParserErrorCode.MISSING_ENUM_BODY); 5646 _reportErrorForCurrentToken(ParserErrorCode.MISSING_ENUM_BODY);
6155 } 5647 }
6156 return new EnumDeclaration( 5648 return new EnumDeclaration(commentAndMetadata.comment,
6157 commentAndMetadata.comment, 5649 commentAndMetadata.metadata, keyword, name, leftBracket, constants,
6158 commentAndMetadata.metadata,
6159 keyword,
6160 name,
6161 leftBracket,
6162 constants,
6163 rightBracket); 5650 rightBracket);
6164 } 5651 }
6165 5652
6166 /** 5653 /**
6167 * Parse an equality expression. 5654 * Parse an equality expression.
6168 * 5655 *
6169 * <pre> 5656 * <pre>
6170 * equalityExpression ::= 5657 * equalityExpression ::=
6171 * relationalExpression (equalityOperator relationalExpression)? 5658 * relationalExpression (equalityOperator relationalExpression)?
6172 * | 'super' equalityOperator relationalExpression 5659 * | 'super' equalityOperator relationalExpression
6173 * </pre> 5660 * </pre>
6174 * 5661 *
6175 * @return the equality expression that was parsed 5662 * @return the equality expression that was parsed
6176 */ 5663 */
6177 Expression _parseEqualityExpression() { 5664 Expression _parseEqualityExpression() {
6178 Expression expression; 5665 Expression expression;
6179 if (_matchesKeyword(Keyword.SUPER) && 5666 if (_matchesKeyword(Keyword.SUPER) &&
6180 _currentToken.next.type.isEqualityOperator) { 5667 _currentToken.next.type.isEqualityOperator) {
6181 expression = new SuperExpression(getAndAdvance()); 5668 expression = new SuperExpression(getAndAdvance());
6182 } else { 5669 } else {
6183 expression = _parseRelationalExpression(); 5670 expression = _parseRelationalExpression();
6184 } 5671 }
6185 bool leftEqualityExpression = false; 5672 bool leftEqualityExpression = false;
6186 while (_currentToken.type.isEqualityOperator) { 5673 while (_currentToken.type.isEqualityOperator) {
6187 Token operator = getAndAdvance(); 5674 Token operator = getAndAdvance();
6188 if (leftEqualityExpression) { 5675 if (leftEqualityExpression) {
6189 _reportErrorForNode( 5676 _reportErrorForNode(
6190 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND, 5677 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND, expression);
6191 expression);
6192 } 5678 }
6193 expression = 5679 expression = new BinaryExpression(
6194 new BinaryExpression(expression, operator, _parseRelationalExpression( )); 5680 expression, operator, _parseRelationalExpression());
6195 leftEqualityExpression = true; 5681 leftEqualityExpression = true;
6196 } 5682 }
6197 return expression; 5683 return expression;
6198 } 5684 }
6199 5685
6200 /** 5686 /**
6201 * Parse an export directive. 5687 * Parse an export directive.
6202 * 5688 *
6203 * <pre> 5689 * <pre>
6204 * exportDirective ::= 5690 * exportDirective ::=
6205 * metadata 'export' stringLiteral combinator*';' 5691 * metadata 'export' stringLiteral combinator*';'
6206 * </pre> 5692 * </pre>
6207 * 5693 *
6208 * @param commentAndMetadata the metadata to be associated with the directive 5694 * @param commentAndMetadata the metadata to be associated with the directive
6209 * @return the export directive that was parsed 5695 * @return the export directive that was parsed
6210 */ 5696 */
6211 ExportDirective _parseExportDirective(CommentAndMetadata commentAndMetadata) { 5697 ExportDirective _parseExportDirective(CommentAndMetadata commentAndMetadata) {
6212 Token exportKeyword = _expectKeyword(Keyword.EXPORT); 5698 Token exportKeyword = _expectKeyword(Keyword.EXPORT);
6213 StringLiteral libraryUri = _parseUri(); 5699 StringLiteral libraryUri = _parseUri();
6214 List<Combinator> combinators = _parseCombinators(); 5700 List<Combinator> combinators = _parseCombinators();
6215 Token semicolon = _expectSemicolon(); 5701 Token semicolon = _expectSemicolon();
6216 return new ExportDirective( 5702 return new ExportDirective(commentAndMetadata.comment,
6217 commentAndMetadata.comment, 5703 commentAndMetadata.metadata, exportKeyword, libraryUri, combinators,
6218 commentAndMetadata.metadata,
6219 exportKeyword,
6220 libraryUri,
6221 combinators,
6222 semicolon); 5704 semicolon);
6223 } 5705 }
6224 5706
6225 /** 5707 /**
6226 * Parse a list of expressions. 5708 * Parse a list of expressions.
6227 * 5709 *
6228 * <pre> 5710 * <pre>
6229 * expressionList ::= 5711 * expressionList ::=
6230 * expression (',' expression)* 5712 * expression (',' expression)*
6231 * </pre> 5713 * </pre>
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
6292 * delimiters 5774 * delimiters
6293 * @return the formal parameter that was parsed 5775 * @return the formal parameter that was parsed
6294 */ 5776 */
6295 FormalParameter _parseFormalParameter(ParameterKind kind) { 5777 FormalParameter _parseFormalParameter(ParameterKind kind) {
6296 NormalFormalParameter parameter = parseNormalFormalParameter(); 5778 NormalFormalParameter parameter = parseNormalFormalParameter();
6297 if (_matches(TokenType.EQ)) { 5779 if (_matches(TokenType.EQ)) {
6298 Token seperator = getAndAdvance(); 5780 Token seperator = getAndAdvance();
6299 Expression defaultValue = parseExpression2(); 5781 Expression defaultValue = parseExpression2();
6300 if (kind == ParameterKind.NAMED) { 5782 if (kind == ParameterKind.NAMED) {
6301 _reportErrorForToken( 5783 _reportErrorForToken(
6302 ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER, 5784 ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER, seperator);
6303 seperator);
6304 } else if (kind == ParameterKind.REQUIRED) { 5785 } else if (kind == ParameterKind.REQUIRED) {
6305 _reportErrorForNode( 5786 _reportErrorForNode(
6306 ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, 5787 ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, parameter);
6307 parameter);
6308 } 5788 }
6309 return new DefaultFormalParameter( 5789 return new DefaultFormalParameter(
6310 parameter, 5790 parameter, kind, seperator, defaultValue);
6311 kind,
6312 seperator,
6313 defaultValue);
6314 } else if (_matches(TokenType.COLON)) { 5791 } else if (_matches(TokenType.COLON)) {
6315 Token seperator = getAndAdvance(); 5792 Token seperator = getAndAdvance();
6316 Expression defaultValue = parseExpression2(); 5793 Expression defaultValue = parseExpression2();
6317 if (kind == ParameterKind.POSITIONAL) { 5794 if (kind == ParameterKind.POSITIONAL) {
6318 _reportErrorForToken( 5795 _reportErrorForToken(
6319 ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER, 5796 ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER,
6320 seperator); 5797 seperator);
6321 } else if (kind == ParameterKind.REQUIRED) { 5798 } else if (kind == ParameterKind.REQUIRED) {
6322 _reportErrorForNode( 5799 _reportErrorForNode(
6323 ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, 5800 ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, parameter);
6324 parameter);
6325 } 5801 }
6326 return new DefaultFormalParameter( 5802 return new DefaultFormalParameter(
6327 parameter, 5803 parameter, kind, seperator, defaultValue);
6328 kind,
6329 seperator,
6330 defaultValue);
6331 } else if (kind != ParameterKind.REQUIRED) { 5804 } else if (kind != ParameterKind.REQUIRED) {
6332 return new DefaultFormalParameter(parameter, kind, null, null); 5805 return new DefaultFormalParameter(parameter, kind, null, null);
6333 } 5806 }
6334 return parameter; 5807 return parameter;
6335 } 5808 }
6336 5809
6337 /** 5810 /**
6338 * Parse a for statement. 5811 * Parse a for statement.
6339 * 5812 *
6340 * <pre> 5813 * <pre>
(...skipping 26 matching lines...) Expand all
6367 Expression initialization = null; 5840 Expression initialization = null;
6368 if (!_matches(TokenType.SEMICOLON)) { 5841 if (!_matches(TokenType.SEMICOLON)) {
6369 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); 5842 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata();
6370 if (_matchesIdentifier() && 5843 if (_matchesIdentifier() &&
6371 (_tokenMatchesKeyword(_peek(), Keyword.IN) || 5844 (_tokenMatchesKeyword(_peek(), Keyword.IN) ||
6372 _tokenMatches(_peek(), TokenType.COLON))) { 5845 _tokenMatches(_peek(), TokenType.COLON))) {
6373 List<VariableDeclaration> variables = new List<VariableDeclaration>(); 5846 List<VariableDeclaration> variables = new List<VariableDeclaration>();
6374 SimpleIdentifier variableName = parseSimpleIdentifier(); 5847 SimpleIdentifier variableName = parseSimpleIdentifier();
6375 variables.add( 5848 variables.add(
6376 new VariableDeclaration(null, null, variableName, null, null)); 5849 new VariableDeclaration(null, null, variableName, null, null));
6377 variableList = new VariableDeclarationList( 5850 variableList = new VariableDeclarationList(commentAndMetadata.comment,
6378 commentAndMetadata.comment, 5851 commentAndMetadata.metadata, null, null, variables);
6379 commentAndMetadata.metadata,
6380 null,
6381 null,
6382 variables);
6383 } else if (_isInitializedVariableDeclaration()) { 5852 } else if (_isInitializedVariableDeclaration()) {
6384 variableList = 5853 variableList =
6385 _parseVariableDeclarationListAfterMetadata(commentAndMetadata); 5854 _parseVariableDeclarationListAfterMetadata(commentAndMetadata);
6386 } else { 5855 } else {
6387 initialization = parseExpression2(); 5856 initialization = parseExpression2();
6388 } 5857 }
6389 if (_matchesKeyword(Keyword.IN) || _matches(TokenType.COLON)) { 5858 if (_matchesKeyword(Keyword.IN) || _matches(TokenType.COLON)) {
6390 if (_matches(TokenType.COLON)) { 5859 if (_matches(TokenType.COLON)) {
6391 _reportErrorForCurrentToken(ParserErrorCode.COLON_IN_PLACE_OF_IN); 5860 _reportErrorForCurrentToken(ParserErrorCode.COLON_IN_PLACE_OF_IN);
6392 } 5861 }
6393 DeclaredIdentifier loopVariable = null; 5862 DeclaredIdentifier loopVariable = null;
6394 SimpleIdentifier identifier = null; 5863 SimpleIdentifier identifier = null;
6395 if (variableList == null) { 5864 if (variableList == null) {
6396 // We found: <expression> 'in' 5865 // We found: <expression> 'in'
6397 _reportErrorForCurrentToken( 5866 _reportErrorForCurrentToken(
6398 ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH); 5867 ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH);
6399 } else { 5868 } else {
6400 NodeList<VariableDeclaration> variables = variableList.variables; 5869 NodeList<VariableDeclaration> variables = variableList.variables;
6401 if (variables.length > 1) { 5870 if (variables.length > 1) {
6402 _reportErrorForCurrentToken( 5871 _reportErrorForCurrentToken(
6403 ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, 5872 ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [
6404 [variables.length.toString()]); 5873 variables.length.toString()
5874 ]);
6405 } 5875 }
6406 VariableDeclaration variable = variables[0]; 5876 VariableDeclaration variable = variables[0];
6407 if (variable.initializer != null) { 5877 if (variable.initializer != null) {
6408 _reportErrorForCurrentToken( 5878 _reportErrorForCurrentToken(
6409 ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH); 5879 ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH);
6410 } 5880 }
6411 Token keyword = variableList.keyword; 5881 Token keyword = variableList.keyword;
6412 TypeName type = variableList.type; 5882 TypeName type = variableList.type;
6413 if (keyword != null || type != null) { 5883 if (keyword != null || type != null) {
6414 loopVariable = new DeclaredIdentifier( 5884 loopVariable = new DeclaredIdentifier(commentAndMetadata.comment,
6415 commentAndMetadata.comment, 5885 commentAndMetadata.metadata, keyword, type, variable.name);
6416 commentAndMetadata.metadata,
6417 keyword,
6418 type,
6419 variable.name);
6420 } else { 5886 } else {
6421 if (!commentAndMetadata.metadata.isEmpty) { 5887 if (!commentAndMetadata.metadata.isEmpty) {
6422 // TODO(jwren) metadata isn't allowed before the identifier in 5888 // TODO(jwren) metadata isn't allowed before the identifier in
6423 // "identifier in expression", add warning if commentAndMetadata 5889 // "identifier in expression", add warning if commentAndMetadata
6424 // has content 5890 // has content
6425 } 5891 }
6426 identifier = variable.name; 5892 identifier = variable.name;
6427 } 5893 }
6428 } 5894 }
6429 Token inKeyword = getAndAdvance(); 5895 Token inKeyword = getAndAdvance();
6430 Expression iterator = parseExpression2(); 5896 Expression iterator = parseExpression2();
6431 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); 5897 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN);
6432 Statement body = parseStatement2(); 5898 Statement body = parseStatement2();
6433 if (loopVariable == null) { 5899 if (loopVariable == null) {
6434 return new ForEachStatement.con2( 5900 return new ForEachStatement.con2(awaitKeyword, forKeyword,
6435 awaitKeyword, 5901 leftParenthesis, identifier, inKeyword, iterator,
6436 forKeyword, 5902 rightParenthesis, body);
6437 leftParenthesis,
6438 identifier,
6439 inKeyword,
6440 iterator,
6441 rightParenthesis,
6442 body);
6443 } 5903 }
6444 return new ForEachStatement.con1( 5904 return new ForEachStatement.con1(awaitKeyword, forKeyword,
6445 awaitKeyword, 5905 leftParenthesis, loopVariable, inKeyword, iterator,
6446 forKeyword, 5906 rightParenthesis, body);
6447 leftParenthesis,
6448 loopVariable,
6449 inKeyword,
6450 iterator,
6451 rightParenthesis,
6452 body);
6453 } 5907 }
6454 } 5908 }
6455 if (awaitKeyword != null) { 5909 if (awaitKeyword != null) {
6456 _reportErrorForToken( 5910 _reportErrorForToken(
6457 ParserErrorCode.INVALID_AWAIT_IN_FOR, 5911 ParserErrorCode.INVALID_AWAIT_IN_FOR, awaitKeyword);
6458 awaitKeyword);
6459 } 5912 }
6460 Token leftSeparator = _expect(TokenType.SEMICOLON); 5913 Token leftSeparator = _expect(TokenType.SEMICOLON);
6461 Expression condition = null; 5914 Expression condition = null;
6462 if (!_matches(TokenType.SEMICOLON)) { 5915 if (!_matches(TokenType.SEMICOLON)) {
6463 condition = parseExpression2(); 5916 condition = parseExpression2();
6464 } 5917 }
6465 Token rightSeparator = _expect(TokenType.SEMICOLON); 5918 Token rightSeparator = _expect(TokenType.SEMICOLON);
6466 List<Expression> updaters = null; 5919 List<Expression> updaters = null;
6467 if (!_matches(TokenType.CLOSE_PAREN)) { 5920 if (!_matches(TokenType.CLOSE_PAREN)) {
6468 updaters = _parseExpressionList(); 5921 updaters = _parseExpressionList();
6469 } 5922 }
6470 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); 5923 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN);
6471 Statement body = parseStatement2(); 5924 Statement body = parseStatement2();
6472 return new ForStatement( 5925 return new ForStatement(forKeyword, leftParenthesis, variableList,
6473 forKeyword, 5926 initialization, leftSeparator, condition, rightSeparator, updaters,
6474 leftParenthesis, 5927 rightParenthesis, body);
6475 variableList,
6476 initialization,
6477 leftSeparator,
6478 condition,
6479 rightSeparator,
6480 updaters,
6481 rightParenthesis,
6482 body);
6483 } finally { 5928 } finally {
6484 _inLoop = wasInLoop; 5929 _inLoop = wasInLoop;
6485 } 5930 }
6486 } 5931 }
6487 5932
6488 /** 5933 /**
6489 * Parse a function body. 5934 * Parse a function body.
6490 * 5935 *
6491 * <pre> 5936 * <pre>
6492 * functionBody ::= 5937 * functionBody ::=
6493 * '=>' expression ';' 5938 * '=>' expression ';'
6494 * | block 5939 * | block
6495 * 5940 *
6496 * functionExpressionBody ::= 5941 * functionExpressionBody ::=
6497 * '=>' expression 5942 * '=>' expression
6498 * | block 5943 * | block
6499 * </pre> 5944 * </pre>
6500 * 5945 *
6501 * @param mayBeEmpty `true` if the function body is allowed to be empty 5946 * @param mayBeEmpty `true` if the function body is allowed to be empty
6502 * @param emptyErrorCode the error code to report if function body expected, b ut not found 5947 * @param emptyErrorCode the error code to report if function body expected, b ut not found
6503 * @param inExpression `true` if the function body is being parsed as part of an expression 5948 * @param inExpression `true` if the function body is being parsed as part of an expression
6504 * and therefore does not have a terminating semicolon 5949 * and therefore does not have a terminating semicolon
6505 * @return the function body that was parsed 5950 * @return the function body that was parsed
6506 */ 5951 */
6507 FunctionBody _parseFunctionBody(bool mayBeEmpty, 5952 FunctionBody _parseFunctionBody(
6508 ParserErrorCode emptyErrorCode, bool inExpression) { 5953 bool mayBeEmpty, ParserErrorCode emptyErrorCode, bool inExpression) {
6509 bool wasInAsync = _inAsync; 5954 bool wasInAsync = _inAsync;
6510 bool wasInGenerator = _inGenerator; 5955 bool wasInGenerator = _inGenerator;
6511 bool wasInLoop = _inLoop; 5956 bool wasInLoop = _inLoop;
6512 bool wasInSwitch = _inSwitch; 5957 bool wasInSwitch = _inSwitch;
6513 _inAsync = false; 5958 _inAsync = false;
6514 _inGenerator = false; 5959 _inGenerator = false;
6515 _inLoop = false; 5960 _inLoop = false;
6516 _inSwitch = false; 5961 _inSwitch = false;
6517 try { 5962 try {
6518 if (_matches(TokenType.SEMICOLON)) { 5963 if (_matches(TokenType.SEMICOLON)) {
6519 if (!mayBeEmpty) { 5964 if (!mayBeEmpty) {
6520 _reportErrorForCurrentToken(emptyErrorCode); 5965 _reportErrorForCurrentToken(emptyErrorCode);
6521 } 5966 }
6522 return new EmptyFunctionBody(getAndAdvance()); 5967 return new EmptyFunctionBody(getAndAdvance());
6523 } else if (_matchesString(_NATIVE)) { 5968 } else if (_matchesString(_NATIVE)) {
6524 Token nativeToken = getAndAdvance(); 5969 Token nativeToken = getAndAdvance();
6525 StringLiteral stringLiteral = null; 5970 StringLiteral stringLiteral = null;
6526 if (_matches(TokenType.STRING)) { 5971 if (_matches(TokenType.STRING)) {
6527 stringLiteral = parseStringLiteral(); 5972 stringLiteral = parseStringLiteral();
6528 } 5973 }
6529 return new NativeFunctionBody( 5974 return new NativeFunctionBody(
6530 nativeToken, 5975 nativeToken, stringLiteral, _expect(TokenType.SEMICOLON));
6531 stringLiteral,
6532 _expect(TokenType.SEMICOLON));
6533 } 5976 }
6534 Token keyword = null; 5977 Token keyword = null;
6535 Token star = null; 5978 Token star = null;
6536 if (_matchesString(ASYNC)) { 5979 if (_matchesString(ASYNC)) {
6537 keyword = getAndAdvance(); 5980 keyword = getAndAdvance();
6538 if (_matches(TokenType.STAR)) { 5981 if (_matches(TokenType.STAR)) {
6539 star = getAndAdvance(); 5982 star = getAndAdvance();
6540 _inGenerator = true; 5983 _inGenerator = true;
6541 } 5984 }
6542 _inAsync = true; 5985 _inAsync = true;
6543 } else if (_matchesString(SYNC)) { 5986 } else if (_matchesString(SYNC)) {
6544 keyword = getAndAdvance(); 5987 keyword = getAndAdvance();
6545 if (_matches(TokenType.STAR)) { 5988 if (_matches(TokenType.STAR)) {
6546 star = getAndAdvance(); 5989 star = getAndAdvance();
6547 _inGenerator = true; 5990 _inGenerator = true;
6548 } 5991 }
6549 } 5992 }
6550 if (_matches(TokenType.FUNCTION)) { 5993 if (_matches(TokenType.FUNCTION)) {
6551 if (keyword != null) { 5994 if (keyword != null) {
6552 if (!_tokenMatchesString(keyword, ASYNC)) { 5995 if (!_tokenMatchesString(keyword, ASYNC)) {
6553 _reportErrorForToken(ParserErrorCode.INVALID_SYNC, keyword); 5996 _reportErrorForToken(ParserErrorCode.INVALID_SYNC, keyword);
6554 keyword = null; 5997 keyword = null;
6555 } else if (star != null) { 5998 } else if (star != null) {
6556 _reportErrorForToken( 5999 _reportErrorForToken(
6557 ParserErrorCode.INVALID_STAR_AFTER_ASYNC, 6000 ParserErrorCode.INVALID_STAR_AFTER_ASYNC, star);
6558 star);
6559 } 6001 }
6560 } 6002 }
6561 Token functionDefinition = getAndAdvance(); 6003 Token functionDefinition = getAndAdvance();
6562 if (_matchesKeyword(Keyword.RETURN)) { 6004 if (_matchesKeyword(Keyword.RETURN)) {
6563 _reportErrorForToken( 6005 _reportErrorForToken(
6564 ParserErrorCode.UNEXPECTED_TOKEN, 6006 ParserErrorCode.UNEXPECTED_TOKEN, getAndAdvance());
6565 getAndAdvance());
6566 } 6007 }
6567 Expression expression = parseExpression2(); 6008 Expression expression = parseExpression2();
6568 Token semicolon = null; 6009 Token semicolon = null;
6569 if (!inExpression) { 6010 if (!inExpression) {
6570 semicolon = _expect(TokenType.SEMICOLON); 6011 semicolon = _expect(TokenType.SEMICOLON);
6571 } 6012 }
6572 if (!_parseFunctionBodies) { 6013 if (!_parseFunctionBodies) {
6573 return new EmptyFunctionBody( 6014 return new EmptyFunctionBody(
6574 _createSyntheticToken(TokenType.SEMICOLON)); 6015 _createSyntheticToken(TokenType.SEMICOLON));
6575 } 6016 }
6576 return new ExpressionFunctionBody( 6017 return new ExpressionFunctionBody(
6577 keyword, 6018 keyword, functionDefinition, expression, semicolon);
6578 functionDefinition,
6579 expression,
6580 semicolon);
6581 } else if (_matches(TokenType.OPEN_CURLY_BRACKET)) { 6019 } else if (_matches(TokenType.OPEN_CURLY_BRACKET)) {
6582 if (keyword != null) { 6020 if (keyword != null) {
6583 if (_tokenMatchesString(keyword, SYNC) && star == null) { 6021 if (_tokenMatchesString(keyword, SYNC) && star == null) {
6584 _reportErrorForToken( 6022 _reportErrorForToken(
6585 ParserErrorCode.MISSING_STAR_AFTER_SYNC, 6023 ParserErrorCode.MISSING_STAR_AFTER_SYNC, keyword);
6586 keyword);
6587 } 6024 }
6588 } 6025 }
6589 if (!_parseFunctionBodies) { 6026 if (!_parseFunctionBodies) {
6590 _skipBlock(); 6027 _skipBlock();
6591 return new EmptyFunctionBody( 6028 return new EmptyFunctionBody(
6592 _createSyntheticToken(TokenType.SEMICOLON)); 6029 _createSyntheticToken(TokenType.SEMICOLON));
6593 } 6030 }
6594 return new BlockFunctionBody(keyword, star, parseBlock()); 6031 return new BlockFunctionBody(keyword, star, parseBlock());
6595 } else { 6032 } else {
6596 // Invalid function body 6033 // Invalid function body
(...skipping 18 matching lines...) Expand all
6615 * | returnType? getOrSet identifier formalParameterList functionBody 6052 * | returnType? getOrSet identifier formalParameterList functionBody
6616 * </pre> 6053 * </pre>
6617 * 6054 *
6618 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the 6055 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the
6619 * declaration 6056 * declaration
6620 * @param externalKeyword the 'external' keyword, or `null` if the function is not external 6057 * @param externalKeyword the 'external' keyword, or `null` if the function is not external
6621 * @param returnType the return type, or `null` if there is no return type 6058 * @param returnType the return type, or `null` if there is no return type
6622 * @param isStatement `true` if the function declaration is being parsed as a statement 6059 * @param isStatement `true` if the function declaration is being parsed as a statement
6623 * @return the function declaration that was parsed 6060 * @return the function declaration that was parsed
6624 */ 6061 */
6625 FunctionDeclaration 6062 FunctionDeclaration _parseFunctionDeclaration(
6626 _parseFunctionDeclaration(CommentAndMetadata commentAndMetadata, 6063 CommentAndMetadata commentAndMetadata, Token externalKeyword,
6627 Token externalKeyword, TypeName returnType) { 6064 TypeName returnType) {
6628 Token keyword = null; 6065 Token keyword = null;
6629 bool isGetter = false; 6066 bool isGetter = false;
6630 if (_matchesKeyword(Keyword.GET) && 6067 if (_matchesKeyword(Keyword.GET) &&
6631 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { 6068 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) {
6632 keyword = getAndAdvance(); 6069 keyword = getAndAdvance();
6633 isGetter = true; 6070 isGetter = true;
6634 } else if (_matchesKeyword(Keyword.SET) && 6071 } else if (_matchesKeyword(Keyword.SET) &&
6635 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { 6072 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) {
6636 keyword = getAndAdvance(); 6073 keyword = getAndAdvance();
6637 } 6074 }
6638 SimpleIdentifier name = parseSimpleIdentifier(); 6075 SimpleIdentifier name = parseSimpleIdentifier();
6639 FormalParameterList parameters = null; 6076 FormalParameterList parameters = null;
6640 if (!isGetter) { 6077 if (!isGetter) {
6641 if (_matches(TokenType.OPEN_PAREN)) { 6078 if (_matches(TokenType.OPEN_PAREN)) {
6642 parameters = parseFormalParameterList(); 6079 parameters = parseFormalParameterList();
6643 _validateFormalParameterList(parameters); 6080 _validateFormalParameterList(parameters);
6644 } else { 6081 } else {
6645 _reportErrorForCurrentToken( 6082 _reportErrorForCurrentToken(
6646 ParserErrorCode.MISSING_FUNCTION_PARAMETERS); 6083 ParserErrorCode.MISSING_FUNCTION_PARAMETERS);
6647 } 6084 }
6648 } else if (_matches(TokenType.OPEN_PAREN)) { 6085 } else if (_matches(TokenType.OPEN_PAREN)) {
6649 _reportErrorForCurrentToken(ParserErrorCode.GETTER_WITH_PARAMETERS); 6086 _reportErrorForCurrentToken(ParserErrorCode.GETTER_WITH_PARAMETERS);
6650 parseFormalParameterList(); 6087 parseFormalParameterList();
6651 } 6088 }
6652 FunctionBody body; 6089 FunctionBody body;
6653 if (externalKeyword == null) { 6090 if (externalKeyword == null) {
6654 body = 6091 body = _parseFunctionBody(
6655 _parseFunctionBody(false, ParserErrorCode.MISSING_FUNCTION_BODY, false ); 6092 false, ParserErrorCode.MISSING_FUNCTION_BODY, false);
6656 } else { 6093 } else {
6657 body = new EmptyFunctionBody(_expect(TokenType.SEMICOLON)); 6094 body = new EmptyFunctionBody(_expect(TokenType.SEMICOLON));
6658 } 6095 }
6659 // if (!isStatement && matches(TokenType.SEMICOLON)) { 6096 // if (!isStatement && matches(TokenType.SEMICOLON)) {
6660 // // TODO(brianwilkerson) Improve this error message. 6097 // // TODO(brianwilkerson) Improve this error message.
6661 // reportError(ParserErrorCode.UNEXPECTED_TOKEN, currentToken.getLexeme ()); 6098 // reportError(ParserErrorCode.UNEXPECTED_TOKEN, currentToken.getLexeme ());
6662 // advance(); 6099 // advance();
6663 // } 6100 // }
6664 return new FunctionDeclaration( 6101 return new FunctionDeclaration(commentAndMetadata.comment,
6665 commentAndMetadata.comment, 6102 commentAndMetadata.metadata, externalKeyword, returnType, keyword, name,
6666 commentAndMetadata.metadata,
6667 externalKeyword,
6668 returnType,
6669 keyword,
6670 name,
6671 new FunctionExpression(parameters, body)); 6103 new FunctionExpression(parameters, body));
6672 } 6104 }
6673 6105
6674 /** 6106 /**
6675 * Parse a function declaration statement. 6107 * Parse a function declaration statement.
6676 * 6108 *
6677 * <pre> 6109 * <pre>
6678 * functionDeclarationStatement ::= 6110 * functionDeclarationStatement ::=
6679 * functionSignature functionBody 6111 * functionSignature functionBody
6680 * </pre> 6112 * </pre>
6681 * 6113 *
6682 * @return the function declaration statement that was parsed 6114 * @return the function declaration statement that was parsed
6683 */ 6115 */
6684 Statement _parseFunctionDeclarationStatement() { 6116 Statement _parseFunctionDeclarationStatement() {
6685 Modifiers modifiers = _parseModifiers(); 6117 Modifiers modifiers = _parseModifiers();
6686 _validateModifiersForFunctionDeclarationStatement(modifiers); 6118 _validateModifiersForFunctionDeclarationStatement(modifiers);
6687 return _parseFunctionDeclarationStatementAfterReturnType( 6119 return _parseFunctionDeclarationStatementAfterReturnType(
6688 _parseCommentAndMetadata(), 6120 _parseCommentAndMetadata(), _parseOptionalReturnType());
6689 _parseOptionalReturnType());
6690 } 6121 }
6691 6122
6692 /** 6123 /**
6693 * Parse a function declaration statement. 6124 * Parse a function declaration statement.
6694 * 6125 *
6695 * <pre> 6126 * <pre>
6696 * functionDeclarationStatement ::= 6127 * functionDeclarationStatement ::=
6697 * functionSignature functionBody 6128 * functionSignature functionBody
6698 * </pre> 6129 * </pre>
6699 * 6130 *
6700 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the 6131 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the
6701 * declaration 6132 * declaration
6702 * @param returnType the return type, or `null` if there is no return type 6133 * @param returnType the return type, or `null` if there is no return type
6703 * @return the function declaration statement that was parsed 6134 * @return the function declaration statement that was parsed
6704 */ 6135 */
6705 Statement 6136 Statement _parseFunctionDeclarationStatementAfterReturnType(
6706 _parseFunctionDeclarationStatementAfterReturnType(CommentAndMetadata comme ntAndMetadata, 6137 CommentAndMetadata commentAndMetadata, TypeName returnType) {
6707 TypeName returnType) {
6708 FunctionDeclaration declaration = 6138 FunctionDeclaration declaration =
6709 _parseFunctionDeclaration(commentAndMetadata, null, returnType); 6139 _parseFunctionDeclaration(commentAndMetadata, null, returnType);
6710 Token propertyKeyword = declaration.propertyKeyword; 6140 Token propertyKeyword = declaration.propertyKeyword;
6711 if (propertyKeyword != null) { 6141 if (propertyKeyword != null) {
6712 if ((propertyKeyword as KeywordToken).keyword == Keyword.GET) { 6142 if ((propertyKeyword as KeywordToken).keyword == Keyword.GET) {
6713 _reportErrorForToken( 6143 _reportErrorForToken(
6714 ParserErrorCode.GETTER_IN_FUNCTION, 6144 ParserErrorCode.GETTER_IN_FUNCTION, propertyKeyword);
6715 propertyKeyword);
6716 } else { 6145 } else {
6717 _reportErrorForToken( 6146 _reportErrorForToken(
6718 ParserErrorCode.SETTER_IN_FUNCTION, 6147 ParserErrorCode.SETTER_IN_FUNCTION, propertyKeyword);
6719 propertyKeyword);
6720 } 6148 }
6721 } 6149 }
6722 return new FunctionDeclarationStatement(declaration); 6150 return new FunctionDeclarationStatement(declaration);
6723 } 6151 }
6724 6152
6725 /** 6153 /**
6726 * Parse a function type alias. 6154 * Parse a function type alias.
6727 * 6155 *
6728 * <pre> 6156 * <pre>
6729 * functionTypeAlias ::= 6157 * functionTypeAlias ::=
6730 * functionPrefix typeParameterList? formalParameterList ';' 6158 * functionPrefix typeParameterList? formalParameterList ';'
6731 * 6159 *
6732 * functionPrefix ::= 6160 * functionPrefix ::=
6733 * returnType? name 6161 * returnType? name
6734 * </pre> 6162 * </pre>
6735 * 6163 *
6736 * @param commentAndMetadata the metadata to be associated with the member 6164 * @param commentAndMetadata the metadata to be associated with the member
6737 * @param keyword the token representing the 'typedef' keyword 6165 * @param keyword the token representing the 'typedef' keyword
6738 * @return the function type alias that was parsed 6166 * @return the function type alias that was parsed
6739 */ 6167 */
6740 FunctionTypeAlias 6168 FunctionTypeAlias _parseFunctionTypeAlias(
6741 _parseFunctionTypeAlias(CommentAndMetadata commentAndMetadata, Token keywo rd) { 6169 CommentAndMetadata commentAndMetadata, Token keyword) {
6742 TypeName returnType = null; 6170 TypeName returnType = null;
6743 if (hasReturnTypeInTypeAlias) { 6171 if (hasReturnTypeInTypeAlias) {
6744 returnType = parseReturnType(); 6172 returnType = parseReturnType();
6745 } 6173 }
6746 SimpleIdentifier name = parseSimpleIdentifier(); 6174 SimpleIdentifier name = parseSimpleIdentifier();
6747 TypeParameterList typeParameters = null; 6175 TypeParameterList typeParameters = null;
6748 if (_matches(TokenType.LT)) { 6176 if (_matches(TokenType.LT)) {
6749 typeParameters = parseTypeParameterList(); 6177 typeParameters = parseTypeParameterList();
6750 } 6178 }
6751 if (_matches(TokenType.SEMICOLON) || _matches(TokenType.EOF)) { 6179 if (_matches(TokenType.SEMICOLON) || _matches(TokenType.EOF)) {
6752 _reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS); 6180 _reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS);
6753 FormalParameterList parameters = new FormalParameterList( 6181 FormalParameterList parameters = new FormalParameterList(
6754 _createSyntheticToken(TokenType.OPEN_PAREN), 6182 _createSyntheticToken(TokenType.OPEN_PAREN), null, null, null,
6755 null,
6756 null,
6757 null,
6758 _createSyntheticToken(TokenType.CLOSE_PAREN)); 6183 _createSyntheticToken(TokenType.CLOSE_PAREN));
6759 Token semicolon = _expect(TokenType.SEMICOLON); 6184 Token semicolon = _expect(TokenType.SEMICOLON);
6760 return new FunctionTypeAlias( 6185 return new FunctionTypeAlias(commentAndMetadata.comment,
6761 commentAndMetadata.comment, 6186 commentAndMetadata.metadata, keyword, returnType, name,
6762 commentAndMetadata.metadata, 6187 typeParameters, parameters, semicolon);
6763 keyword,
6764 returnType,
6765 name,
6766 typeParameters,
6767 parameters,
6768 semicolon);
6769 } else if (!_matches(TokenType.OPEN_PAREN)) { 6188 } else if (!_matches(TokenType.OPEN_PAREN)) {
6770 _reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS); 6189 _reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS);
6771 // TODO(brianwilkerson) Recover from this error. At the very least we 6190 // TODO(brianwilkerson) Recover from this error. At the very least we
6772 // should skip to the start of the next valid compilation unit member, 6191 // should skip to the start of the next valid compilation unit member,
6773 // allowing for the possibility of finding the typedef parameters before 6192 // allowing for the possibility of finding the typedef parameters before
6774 // that point. 6193 // that point.
6775 return new FunctionTypeAlias( 6194 return new FunctionTypeAlias(commentAndMetadata.comment,
6776 commentAndMetadata.comment, 6195 commentAndMetadata.metadata, keyword, returnType, name,
6777 commentAndMetadata.metadata, 6196 typeParameters, new FormalParameterList(
6778 keyword, 6197 _createSyntheticToken(TokenType.OPEN_PAREN), null, null, null,
6779 returnType,
6780 name,
6781 typeParameters,
6782 new FormalParameterList(
6783 _createSyntheticToken(TokenType.OPEN_PAREN),
6784 null,
6785 null,
6786 null,
6787 _createSyntheticToken(TokenType.CLOSE_PAREN)), 6198 _createSyntheticToken(TokenType.CLOSE_PAREN)),
6788 _createSyntheticToken(TokenType.SEMICOLON)); 6199 _createSyntheticToken(TokenType.SEMICOLON));
6789 } 6200 }
6790 FormalParameterList parameters = parseFormalParameterList(); 6201 FormalParameterList parameters = parseFormalParameterList();
6791 _validateFormalParameterList(parameters); 6202 _validateFormalParameterList(parameters);
6792 Token semicolon = _expect(TokenType.SEMICOLON); 6203 Token semicolon = _expect(TokenType.SEMICOLON);
6793 return new FunctionTypeAlias( 6204 return new FunctionTypeAlias(commentAndMetadata.comment,
6794 commentAndMetadata.comment, 6205 commentAndMetadata.metadata, keyword, returnType, name, typeParameters,
6795 commentAndMetadata.metadata, 6206 parameters, semicolon);
6796 keyword,
6797 returnType,
6798 name,
6799 typeParameters,
6800 parameters,
6801 semicolon);
6802 } 6207 }
6803 6208
6804 /** 6209 /**
6805 * Parse a getter. 6210 * Parse a getter.
6806 * 6211 *
6807 * <pre> 6212 * <pre>
6808 * getter ::= 6213 * getter ::=
6809 * getterSignature functionBody? 6214 * getterSignature functionBody?
6810 * 6215 *
6811 * getterSignature ::= 6216 * getterSignature ::=
(...skipping 13 matching lines...) Expand all
6825 Token propertyKeyword = _expectKeyword(Keyword.GET); 6230 Token propertyKeyword = _expectKeyword(Keyword.GET);
6826 SimpleIdentifier name = parseSimpleIdentifier(); 6231 SimpleIdentifier name = parseSimpleIdentifier();
6827 if (_matches(TokenType.OPEN_PAREN) && 6232 if (_matches(TokenType.OPEN_PAREN) &&
6828 _tokenMatches(_peek(), TokenType.CLOSE_PAREN)) { 6233 _tokenMatches(_peek(), TokenType.CLOSE_PAREN)) {
6829 _reportErrorForCurrentToken(ParserErrorCode.GETTER_WITH_PARAMETERS); 6234 _reportErrorForCurrentToken(ParserErrorCode.GETTER_WITH_PARAMETERS);
6830 _advance(); 6235 _advance();
6831 _advance(); 6236 _advance();
6832 } 6237 }
6833 FunctionBody body = _parseFunctionBody( 6238 FunctionBody body = _parseFunctionBody(
6834 externalKeyword != null || staticKeyword == null, 6239 externalKeyword != null || staticKeyword == null,
6835 ParserErrorCode.STATIC_GETTER_WITHOUT_BODY, 6240 ParserErrorCode.STATIC_GETTER_WITHOUT_BODY, false);
6836 false);
6837 if (externalKeyword != null && body is! EmptyFunctionBody) { 6241 if (externalKeyword != null && body is! EmptyFunctionBody) {
6838 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_GETTER_WITH_BODY); 6242 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_GETTER_WITH_BODY);
6839 } 6243 }
6840 return new MethodDeclaration( 6244 return new MethodDeclaration(commentAndMetadata.comment,
6841 commentAndMetadata.comment, 6245 commentAndMetadata.metadata, externalKeyword, staticKeyword, returnType,
6842 commentAndMetadata.metadata, 6246 propertyKeyword, null, name, null, body);
6843 externalKeyword,
6844 staticKeyword,
6845 returnType,
6846 propertyKeyword,
6847 null,
6848 name,
6849 null,
6850 body);
6851 } 6247 }
6852 6248
6853 /** 6249 /**
6854 * Parse a list of identifiers. 6250 * Parse a list of identifiers.
6855 * 6251 *
6856 * <pre> 6252 * <pre>
6857 * identifierList ::= 6253 * identifierList ::=
6858 * identifier (',' identifier)* 6254 * identifier (',' identifier)*
6859 * </pre> 6255 * </pre>
6860 * 6256 *
(...skipping 24 matching lines...) Expand all
6885 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); 6281 Token leftParenthesis = _expect(TokenType.OPEN_PAREN);
6886 Expression condition = parseExpression2(); 6282 Expression condition = parseExpression2();
6887 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); 6283 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN);
6888 Statement thenStatement = parseStatement2(); 6284 Statement thenStatement = parseStatement2();
6889 Token elseKeyword = null; 6285 Token elseKeyword = null;
6890 Statement elseStatement = null; 6286 Statement elseStatement = null;
6891 if (_matchesKeyword(Keyword.ELSE)) { 6287 if (_matchesKeyword(Keyword.ELSE)) {
6892 elseKeyword = getAndAdvance(); 6288 elseKeyword = getAndAdvance();
6893 elseStatement = parseStatement2(); 6289 elseStatement = parseStatement2();
6894 } 6290 }
6895 return new IfStatement( 6291 return new IfStatement(ifKeyword, leftParenthesis, condition,
6896 ifKeyword, 6292 rightParenthesis, thenStatement, elseKeyword, elseStatement);
6897 leftParenthesis,
6898 condition,
6899 rightParenthesis,
6900 thenStatement,
6901 elseKeyword,
6902 elseStatement);
6903 } 6293 }
6904 6294
6905 /** 6295 /**
6906 * Parse an import directive. 6296 * Parse an import directive.
6907 * 6297 *
6908 * <pre> 6298 * <pre>
6909 * importDirective ::= 6299 * importDirective ::=
6910 * metadata 'import' stringLiteral ('as' identifier)? combinator*';' 6300 * metadata 'import' stringLiteral ('as' identifier)? combinator*';'
6911 * </pre> 6301 * </pre>
6912 * 6302 *
(...skipping 11 matching lines...) Expand all
6924 } 6314 }
6925 if (_matchesKeyword(Keyword.AS)) { 6315 if (_matchesKeyword(Keyword.AS)) {
6926 asToken = getAndAdvance(); 6316 asToken = getAndAdvance();
6927 prefix = parseSimpleIdentifier(); 6317 prefix = parseSimpleIdentifier();
6928 } else if (deferredToken != null) { 6318 } else if (deferredToken != null) {
6929 _reportErrorForCurrentToken( 6319 _reportErrorForCurrentToken(
6930 ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT); 6320 ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT);
6931 } 6321 }
6932 List<Combinator> combinators = _parseCombinators(); 6322 List<Combinator> combinators = _parseCombinators();
6933 Token semicolon = _expectSemicolon(); 6323 Token semicolon = _expectSemicolon();
6934 return new ImportDirective( 6324 return new ImportDirective(commentAndMetadata.comment,
6935 commentAndMetadata.comment, 6325 commentAndMetadata.metadata, importKeyword, libraryUri, deferredToken,
6936 commentAndMetadata.metadata, 6326 asToken, prefix, combinators, semicolon);
6937 importKeyword,
6938 libraryUri,
6939 deferredToken,
6940 asToken,
6941 prefix,
6942 combinators,
6943 semicolon);
6944 } 6327 }
6945 6328
6946 /** 6329 /**
6947 * Parse a list of initialized identifiers. 6330 * Parse a list of initialized identifiers.
6948 * 6331 *
6949 * <pre> 6332 * <pre>
6950 * ?? ::= 6333 * ?? ::=
6951 * 'static'? ('var' | type) initializedIdentifierList ';' 6334 * 'static'? ('var' | type) initializedIdentifierList ';'
6952 * | 'final' type? initializedIdentifierList ';' 6335 * | 'final' type? initializedIdentifierList ';'
6953 * 6336 *
6954 * initializedIdentifierList ::= 6337 * initializedIdentifierList ::=
6955 * initializedIdentifier (',' initializedIdentifier)* 6338 * initializedIdentifier (',' initializedIdentifier)*
6956 * 6339 *
6957 * initializedIdentifier ::= 6340 * initializedIdentifier ::=
6958 * identifier ('=' expression)? 6341 * identifier ('=' expression)?
6959 * </pre> 6342 * </pre>
6960 * 6343 *
6961 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the 6344 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the
6962 * declaration 6345 * declaration
6963 * @param staticKeyword the static keyword, or `null` if the getter is not sta tic 6346 * @param staticKeyword the static keyword, or `null` if the getter is not sta tic
6964 * @param keyword the token representing the 'final', 'const' or 'var' keyword , or `null` if 6347 * @param keyword the token representing the 'final', 'const' or 'var' keyword , or `null` if
6965 * there is no keyword 6348 * there is no keyword
6966 * @param type the type that has already been parsed, or `null` if 'var' was p rovided 6349 * @param type the type that has already been parsed, or `null` if 'var' was p rovided
6967 * @return the getter that was parsed 6350 * @return the getter that was parsed
6968 */ 6351 */
6969 FieldDeclaration 6352 FieldDeclaration _parseInitializedIdentifierList(
6970 _parseInitializedIdentifierList(CommentAndMetadata commentAndMetadata, 6353 CommentAndMetadata commentAndMetadata, Token staticKeyword, Token keyword,
6971 Token staticKeyword, Token keyword, TypeName type) { 6354 TypeName type) {
6972 VariableDeclarationList fieldList = 6355 VariableDeclarationList fieldList =
6973 _parseVariableDeclarationListAfterType(null, keyword, type); 6356 _parseVariableDeclarationListAfterType(null, keyword, type);
6974 return new FieldDeclaration( 6357 return new FieldDeclaration(commentAndMetadata.comment,
6975 commentAndMetadata.comment, 6358 commentAndMetadata.metadata, staticKeyword, fieldList,
6976 commentAndMetadata.metadata,
6977 staticKeyword,
6978 fieldList,
6979 _expect(TokenType.SEMICOLON)); 6359 _expect(TokenType.SEMICOLON));
6980 } 6360 }
6981 6361
6982 /** 6362 /**
6983 * Parse an instance creation expression. 6363 * Parse an instance creation expression.
6984 * 6364 *
6985 * <pre> 6365 * <pre>
6986 * instanceCreationExpression ::= 6366 * instanceCreationExpression ::=
6987 * ('new' | 'const') type ('.' identifier)? argumentList 6367 * ('new' | 'const') type ('.' identifier)? argumentList
6988 * </pre> 6368 * </pre>
6989 * 6369 *
6990 * @param keyword the 'new' or 'const' keyword that introduces the expression 6370 * @param keyword the 'new' or 'const' keyword that introduces the expression
6991 * @return the instance creation expression that was parsed 6371 * @return the instance creation expression that was parsed
6992 */ 6372 */
6993 InstanceCreationExpression _parseInstanceCreationExpression(Token keyword) { 6373 InstanceCreationExpression _parseInstanceCreationExpression(Token keyword) {
6994 ConstructorName constructorName = parseConstructorName(); 6374 ConstructorName constructorName = parseConstructorName();
6995 ArgumentList argumentList = parseArgumentList(); 6375 ArgumentList argumentList = parseArgumentList();
6996 return new InstanceCreationExpression( 6376 return new InstanceCreationExpression(
6997 keyword, 6377 keyword, constructorName, argumentList);
6998 constructorName,
6999 argumentList);
7000 } 6378 }
7001 6379
7002 /** 6380 /**
7003 * Parse a library directive. 6381 * Parse a library directive.
7004 * 6382 *
7005 * <pre> 6383 * <pre>
7006 * libraryDirective ::= 6384 * libraryDirective ::=
7007 * metadata 'library' identifier ';' 6385 * metadata 'library' identifier ';'
7008 * </pre> 6386 * </pre>
7009 * 6387 *
7010 * @param commentAndMetadata the metadata to be associated with the directive 6388 * @param commentAndMetadata the metadata to be associated with the directive
7011 * @return the library directive that was parsed 6389 * @return the library directive that was parsed
7012 */ 6390 */
7013 LibraryDirective 6391 LibraryDirective _parseLibraryDirective(
7014 _parseLibraryDirective(CommentAndMetadata commentAndMetadata) { 6392 CommentAndMetadata commentAndMetadata) {
7015 Token keyword = _expectKeyword(Keyword.LIBRARY); 6393 Token keyword = _expectKeyword(Keyword.LIBRARY);
7016 LibraryIdentifier libraryName = 6394 LibraryIdentifier libraryName = _parseLibraryName(
7017 _parseLibraryName(ParserErrorCode.MISSING_NAME_IN_LIBRARY_DIRECTIVE, key word); 6395 ParserErrorCode.MISSING_NAME_IN_LIBRARY_DIRECTIVE, keyword);
7018 Token semicolon = _expect(TokenType.SEMICOLON); 6396 Token semicolon = _expect(TokenType.SEMICOLON);
7019 return new LibraryDirective( 6397 return new LibraryDirective(commentAndMetadata.comment,
7020 commentAndMetadata.comment, 6398 commentAndMetadata.metadata, keyword, libraryName, semicolon);
7021 commentAndMetadata.metadata,
7022 keyword,
7023 libraryName,
7024 semicolon);
7025 } 6399 }
7026 6400
7027 /** 6401 /**
7028 * Parse a library name. 6402 * Parse a library name.
7029 * 6403 *
7030 * <pre> 6404 * <pre>
7031 * libraryName ::= 6405 * libraryName ::=
7032 * libraryIdentifier 6406 * libraryIdentifier
7033 * </pre> 6407 * </pre>
7034 * 6408 *
7035 * @param missingNameError the error code to be used if the library name is mi ssing 6409 * @param missingNameError the error code to be used if the library name is mi ssing
7036 * @param missingNameToken the token associated with the error produced if the library name is 6410 * @param missingNameToken the token associated with the error produced if the library name is
7037 * missing 6411 * missing
7038 * @return the library name that was parsed 6412 * @return the library name that was parsed
7039 */ 6413 */
7040 LibraryIdentifier _parseLibraryName(ParserErrorCode missingNameError, 6414 LibraryIdentifier _parseLibraryName(
7041 Token missingNameToken) { 6415 ParserErrorCode missingNameError, Token missingNameToken) {
7042 if (_matchesIdentifier()) { 6416 if (_matchesIdentifier()) {
7043 return parseLibraryIdentifier(); 6417 return parseLibraryIdentifier();
7044 } else if (_matches(TokenType.STRING)) { 6418 } else if (_matches(TokenType.STRING)) {
7045 // TODO(brianwilkerson) Recovery: This should be extended to handle 6419 // TODO(brianwilkerson) Recovery: This should be extended to handle
7046 // arbitrary tokens until we can find a token that can start a compilation 6420 // arbitrary tokens until we can find a token that can start a compilation
7047 // unit member. 6421 // unit member.
7048 StringLiteral string = parseStringLiteral(); 6422 StringLiteral string = parseStringLiteral();
7049 _reportErrorForNode(ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME, string); 6423 _reportErrorForNode(ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME, string);
7050 } else { 6424 } else {
7051 _reportErrorForToken(missingNameError, missingNameToken); 6425 _reportErrorForToken(missingNameError, missingNameToken);
(...skipping 10 matching lines...) Expand all
7062 * listLiteral ::= 6436 * listLiteral ::=
7063 * 'const'? typeArguments? '[' (expressionList ','?)? ']' 6437 * 'const'? typeArguments? '[' (expressionList ','?)? ']'
7064 * </pre> 6438 * </pre>
7065 * 6439 *
7066 * @param modifier the 'const' modifier appearing before the literal, or `null ` if there is 6440 * @param modifier the 'const' modifier appearing before the literal, or `null ` if there is
7067 * no modifier 6441 * no modifier
7068 * @param typeArguments the type arguments appearing before the literal, or `n ull` if there 6442 * @param typeArguments the type arguments appearing before the literal, or `n ull` if there
7069 * are no type arguments 6443 * are no type arguments
7070 * @return the list literal that was parsed 6444 * @return the list literal that was parsed
7071 */ 6445 */
7072 ListLiteral _parseListLiteral(Token modifier, 6446 ListLiteral _parseListLiteral(
7073 TypeArgumentList typeArguments) { 6447 Token modifier, TypeArgumentList typeArguments) {
7074 // may be empty list literal 6448 // may be empty list literal
7075 if (_matches(TokenType.INDEX)) { 6449 if (_matches(TokenType.INDEX)) {
7076 BeginToken leftBracket = 6450 BeginToken leftBracket = _createToken(
7077 _createToken(_currentToken, TokenType.OPEN_SQUARE_BRACKET, isBegin: tr ue); 6451 _currentToken, TokenType.OPEN_SQUARE_BRACKET, isBegin: true);
7078 Token rightBracket = 6452 Token rightBracket =
7079 new Token(TokenType.CLOSE_SQUARE_BRACKET, _currentToken.offset + 1); 6453 new Token(TokenType.CLOSE_SQUARE_BRACKET, _currentToken.offset + 1);
7080 leftBracket.endToken = rightBracket; 6454 leftBracket.endToken = rightBracket;
7081 rightBracket.setNext(_currentToken.next); 6455 rightBracket.setNext(_currentToken.next);
7082 leftBracket.setNext(rightBracket); 6456 leftBracket.setNext(rightBracket);
7083 _currentToken.previous.setNext(leftBracket); 6457 _currentToken.previous.setNext(leftBracket);
7084 _currentToken = _currentToken.next; 6458 _currentToken = _currentToken.next;
7085 return new ListLiteral( 6459 return new ListLiteral(
7086 modifier, 6460 modifier, typeArguments, leftBracket, null, rightBracket);
7087 typeArguments,
7088 leftBracket,
7089 null,
7090 rightBracket);
7091 } 6461 }
7092 // open 6462 // open
7093 Token leftBracket = _expect(TokenType.OPEN_SQUARE_BRACKET); 6463 Token leftBracket = _expect(TokenType.OPEN_SQUARE_BRACKET);
7094 if (_matches(TokenType.CLOSE_SQUARE_BRACKET)) { 6464 if (_matches(TokenType.CLOSE_SQUARE_BRACKET)) {
7095 return new ListLiteral( 6465 return new ListLiteral(
7096 modifier, 6466 modifier, typeArguments, leftBracket, null, getAndAdvance());
7097 typeArguments,
7098 leftBracket,
7099 null,
7100 getAndAdvance());
7101 } 6467 }
7102 bool wasInInitializer = _inInitializer; 6468 bool wasInInitializer = _inInitializer;
7103 _inInitializer = false; 6469 _inInitializer = false;
7104 try { 6470 try {
7105 List<Expression> elements = new List<Expression>(); 6471 List<Expression> elements = new List<Expression>();
7106 elements.add(parseExpression2()); 6472 elements.add(parseExpression2());
7107 while (_optional(TokenType.COMMA)) { 6473 while (_optional(TokenType.COMMA)) {
7108 if (_matches(TokenType.CLOSE_SQUARE_BRACKET)) { 6474 if (_matches(TokenType.CLOSE_SQUARE_BRACKET)) {
7109 return new ListLiteral( 6475 return new ListLiteral(
7110 modifier, 6476 modifier, typeArguments, leftBracket, elements, getAndAdvance());
7111 typeArguments,
7112 leftBracket,
7113 elements,
7114 getAndAdvance());
7115 } 6477 }
7116 elements.add(parseExpression2()); 6478 elements.add(parseExpression2());
7117 } 6479 }
7118 Token rightBracket = _expect(TokenType.CLOSE_SQUARE_BRACKET); 6480 Token rightBracket = _expect(TokenType.CLOSE_SQUARE_BRACKET);
7119 return new ListLiteral( 6481 return new ListLiteral(
7120 modifier, 6482 modifier, typeArguments, leftBracket, elements, rightBracket);
7121 typeArguments,
7122 leftBracket,
7123 elements,
7124 rightBracket);
7125 } finally { 6483 } finally {
7126 _inInitializer = wasInInitializer; 6484 _inInitializer = wasInInitializer;
7127 } 6485 }
7128 } 6486 }
7129 6487
7130 /** 6488 /**
7131 * Parse a list or map literal. 6489 * Parse a list or map literal.
7132 * 6490 *
7133 * <pre> 6491 * <pre>
7134 * listOrMapLiteral ::= 6492 * listOrMapLiteral ::=
(...skipping 10 matching lines...) Expand all
7145 if (_matches(TokenType.LT)) { 6503 if (_matches(TokenType.LT)) {
7146 typeArguments = parseTypeArgumentList(); 6504 typeArguments = parseTypeArgumentList();
7147 } 6505 }
7148 if (_matches(TokenType.OPEN_CURLY_BRACKET)) { 6506 if (_matches(TokenType.OPEN_CURLY_BRACKET)) {
7149 return _parseMapLiteral(modifier, typeArguments); 6507 return _parseMapLiteral(modifier, typeArguments);
7150 } else if (_matches(TokenType.OPEN_SQUARE_BRACKET) || 6508 } else if (_matches(TokenType.OPEN_SQUARE_BRACKET) ||
7151 _matches(TokenType.INDEX)) { 6509 _matches(TokenType.INDEX)) {
7152 return _parseListLiteral(modifier, typeArguments); 6510 return _parseListLiteral(modifier, typeArguments);
7153 } 6511 }
7154 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL); 6512 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL);
7155 return new ListLiteral( 6513 return new ListLiteral(modifier, typeArguments,
7156 modifier, 6514 _createSyntheticToken(TokenType.OPEN_SQUARE_BRACKET), null,
7157 typeArguments,
7158 _createSyntheticToken(TokenType.OPEN_SQUARE_BRACKET),
7159 null,
7160 _createSyntheticToken(TokenType.CLOSE_SQUARE_BRACKET)); 6515 _createSyntheticToken(TokenType.CLOSE_SQUARE_BRACKET));
7161 } 6516 }
7162 6517
7163 /** 6518 /**
7164 * Parse a logical and expression. 6519 * Parse a logical and expression.
7165 * 6520 *
7166 * <pre> 6521 * <pre>
7167 * logicalAndExpression ::= 6522 * logicalAndExpression ::=
7168 * equalityExpression ('&&' equalityExpression)* 6523 * equalityExpression ('&&' equalityExpression)*
7169 * </pre> 6524 * </pre>
7170 * 6525 *
7171 * @return the logical and expression that was parsed 6526 * @return the logical and expression that was parsed
7172 */ 6527 */
7173 Expression _parseLogicalAndExpression() { 6528 Expression _parseLogicalAndExpression() {
7174 Expression expression = _parseEqualityExpression(); 6529 Expression expression = _parseEqualityExpression();
7175 while (_matches(TokenType.AMPERSAND_AMPERSAND)) { 6530 while (_matches(TokenType.AMPERSAND_AMPERSAND)) {
7176 Token operator = getAndAdvance(); 6531 Token operator = getAndAdvance();
7177 expression = 6532 expression = new BinaryExpression(
7178 new BinaryExpression(expression, operator, _parseEqualityExpression()) ; 6533 expression, operator, _parseEqualityExpression());
7179 } 6534 }
7180 return expression; 6535 return expression;
7181 } 6536 }
7182 6537
7183 /** 6538 /**
7184 * Parse a map literal. 6539 * Parse a map literal.
7185 * 6540 *
7186 * <pre> 6541 * <pre>
7187 * mapLiteral ::= 6542 * mapLiteral ::=
7188 * 'const'? typeArguments? '{' (mapLiteralEntry (',' mapLiteralEntry)* ',' ?)? '}' 6543 * 'const'? typeArguments? '{' (mapLiteralEntry (',' mapLiteralEntry)* ',' ?)? '}'
7189 * </pre> 6544 * </pre>
7190 * 6545 *
7191 * @param modifier the 'const' modifier appearing before the literal, or `null ` if there is 6546 * @param modifier the 'const' modifier appearing before the literal, or `null ` if there is
7192 * no modifier 6547 * no modifier
7193 * @param typeArguments the type arguments that were declared, or `null` if th ere are no 6548 * @param typeArguments the type arguments that were declared, or `null` if th ere are no
7194 * type arguments 6549 * type arguments
7195 * @return the map literal that was parsed 6550 * @return the map literal that was parsed
7196 */ 6551 */
7197 MapLiteral _parseMapLiteral(Token modifier, TypeArgumentList typeArguments) { 6552 MapLiteral _parseMapLiteral(Token modifier, TypeArgumentList typeArguments) {
7198 Token leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET); 6553 Token leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET);
7199 List<MapLiteralEntry> entries = new List<MapLiteralEntry>(); 6554 List<MapLiteralEntry> entries = new List<MapLiteralEntry>();
7200 if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { 6555 if (_matches(TokenType.CLOSE_CURLY_BRACKET)) {
7201 return new MapLiteral( 6556 return new MapLiteral(
7202 modifier, 6557 modifier, typeArguments, leftBracket, entries, getAndAdvance());
7203 typeArguments,
7204 leftBracket,
7205 entries,
7206 getAndAdvance());
7207 } 6558 }
7208 bool wasInInitializer = _inInitializer; 6559 bool wasInInitializer = _inInitializer;
7209 _inInitializer = false; 6560 _inInitializer = false;
7210 try { 6561 try {
7211 entries.add(parseMapLiteralEntry()); 6562 entries.add(parseMapLiteralEntry());
7212 while (_optional(TokenType.COMMA)) { 6563 while (_optional(TokenType.COMMA)) {
7213 if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { 6564 if (_matches(TokenType.CLOSE_CURLY_BRACKET)) {
7214 return new MapLiteral( 6565 return new MapLiteral(
7215 modifier, 6566 modifier, typeArguments, leftBracket, entries, getAndAdvance());
7216 typeArguments,
7217 leftBracket,
7218 entries,
7219 getAndAdvance());
7220 } 6567 }
7221 entries.add(parseMapLiteralEntry()); 6568 entries.add(parseMapLiteralEntry());
7222 } 6569 }
7223 Token rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); 6570 Token rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET);
7224 return new MapLiteral( 6571 return new MapLiteral(
7225 modifier, 6572 modifier, typeArguments, leftBracket, entries, rightBracket);
7226 typeArguments,
7227 leftBracket,
7228 entries,
7229 rightBracket);
7230 } finally { 6573 } finally {
7231 _inInitializer = wasInInitializer; 6574 _inInitializer = wasInInitializer;
7232 } 6575 }
7233 } 6576 }
7234 6577
7235 /** 6578 /**
7236 * Parse a method declaration. 6579 * Parse a method declaration.
7237 * 6580 *
7238 * <pre> 6581 * <pre>
7239 * functionDeclaration ::= 6582 * functionDeclaration ::=
7240 * ('external' 'static'?)? functionSignature functionBody 6583 * ('external' 'static'?)? functionSignature functionBody
7241 * | 'external'? functionSignature ';' 6584 * | 'external'? functionSignature ';'
7242 * </pre> 6585 * </pre>
7243 * 6586 *
7244 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the 6587 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the
7245 * declaration 6588 * declaration
7246 * @param externalKeyword the 'external' token 6589 * @param externalKeyword the 'external' token
7247 * @param staticKeyword the static keyword, or `null` if the getter is not sta tic 6590 * @param staticKeyword the static keyword, or `null` if the getter is not sta tic
7248 * @param returnType the return type of the method 6591 * @param returnType the return type of the method
7249 * @param name the name of the method 6592 * @param name the name of the method
7250 * @param parameters the parameters to the method 6593 * @param parameters the parameters to the method
7251 * @return the method declaration that was parsed 6594 * @return the method declaration that was parsed
7252 */ 6595 */
7253 MethodDeclaration 6596 MethodDeclaration _parseMethodDeclarationAfterParameters(
7254 _parseMethodDeclarationAfterParameters(CommentAndMetadata commentAndMetada ta, 6597 CommentAndMetadata commentAndMetadata, Token externalKeyword,
7255 Token externalKeyword, Token staticKeyword, TypeName returnType, 6598 Token staticKeyword, TypeName returnType, SimpleIdentifier name,
7256 SimpleIdentifier name, FormalParameterList parameters) { 6599 FormalParameterList parameters) {
7257 FunctionBody body = _parseFunctionBody( 6600 FunctionBody body = _parseFunctionBody(
7258 externalKeyword != null || staticKeyword == null, 6601 externalKeyword != null || staticKeyword == null,
7259 ParserErrorCode.MISSING_FUNCTION_BODY, 6602 ParserErrorCode.MISSING_FUNCTION_BODY, false);
7260 false);
7261 if (externalKeyword != null) { 6603 if (externalKeyword != null) {
7262 if (body is! EmptyFunctionBody) { 6604 if (body is! EmptyFunctionBody) {
7263 _reportErrorForNode(ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, body); 6605 _reportErrorForNode(ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, body);
7264 } 6606 }
7265 } else if (staticKeyword != null) { 6607 } else if (staticKeyword != null) {
7266 if (body is EmptyFunctionBody) { 6608 if (body is EmptyFunctionBody) {
7267 _reportErrorForNode(ParserErrorCode.ABSTRACT_STATIC_METHOD, body); 6609 _reportErrorForNode(ParserErrorCode.ABSTRACT_STATIC_METHOD, body);
7268 } 6610 }
7269 } 6611 }
7270 return new MethodDeclaration( 6612 return new MethodDeclaration(commentAndMetadata.comment,
7271 commentAndMetadata.comment, 6613 commentAndMetadata.metadata, externalKeyword, staticKeyword, returnType,
7272 commentAndMetadata.metadata, 6614 null, null, name, parameters, body);
7273 externalKeyword,
7274 staticKeyword,
7275 returnType,
7276 null,
7277 null,
7278 name,
7279 parameters,
7280 body);
7281 } 6615 }
7282 6616
7283 /** 6617 /**
7284 * Parse a method declaration. 6618 * Parse a method declaration.
7285 * 6619 *
7286 * <pre> 6620 * <pre>
7287 * functionDeclaration ::= 6621 * functionDeclaration ::=
7288 * 'external'? 'static'? functionSignature functionBody 6622 * 'external'? 'static'? functionSignature functionBody
7289 * | 'external'? functionSignature ';' 6623 * | 'external'? functionSignature ';'
7290 * </pre> 6624 * </pre>
7291 * 6625 *
7292 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the 6626 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the
7293 * declaration 6627 * declaration
7294 * @param externalKeyword the 'external' token 6628 * @param externalKeyword the 'external' token
7295 * @param staticKeyword the static keyword, or `null` if the getter is not sta tic 6629 * @param staticKeyword the static keyword, or `null` if the getter is not sta tic
7296 * @param returnType the return type of the method 6630 * @param returnType the return type of the method
7297 * @return the method declaration that was parsed 6631 * @return the method declaration that was parsed
7298 */ 6632 */
7299 MethodDeclaration 6633 MethodDeclaration _parseMethodDeclarationAfterReturnType(
7300 _parseMethodDeclarationAfterReturnType(CommentAndMetadata commentAndMetada ta, 6634 CommentAndMetadata commentAndMetadata, Token externalKeyword,
7301 Token externalKeyword, Token staticKeyword, TypeName returnType) { 6635 Token staticKeyword, TypeName returnType) {
7302 SimpleIdentifier methodName = parseSimpleIdentifier(); 6636 SimpleIdentifier methodName = parseSimpleIdentifier();
7303 FormalParameterList parameters; 6637 FormalParameterList parameters;
7304 if (!_matches(TokenType.OPEN_PAREN) && 6638 if (!_matches(TokenType.OPEN_PAREN) &&
7305 (_matches(TokenType.OPEN_CURLY_BRACKET) || _matches(TokenType.FUNCTION)) ) { 6639 (_matches(TokenType.OPEN_CURLY_BRACKET) ||
6640 _matches(TokenType.FUNCTION))) {
7306 _reportErrorForToken( 6641 _reportErrorForToken(
7307 ParserErrorCode.MISSING_METHOD_PARAMETERS, 6642 ParserErrorCode.MISSING_METHOD_PARAMETERS, _currentToken.previous);
7308 _currentToken.previous);
7309 parameters = new FormalParameterList( 6643 parameters = new FormalParameterList(
7310 _createSyntheticToken(TokenType.OPEN_PAREN), 6644 _createSyntheticToken(TokenType.OPEN_PAREN), null, null, null,
7311 null,
7312 null,
7313 null,
7314 _createSyntheticToken(TokenType.CLOSE_PAREN)); 6645 _createSyntheticToken(TokenType.CLOSE_PAREN));
7315 } else { 6646 } else {
7316 parameters = parseFormalParameterList(); 6647 parameters = parseFormalParameterList();
7317 } 6648 }
7318 _validateFormalParameterList(parameters); 6649 _validateFormalParameterList(parameters);
7319 return _parseMethodDeclarationAfterParameters( 6650 return _parseMethodDeclarationAfterParameters(commentAndMetadata,
7320 commentAndMetadata, 6651 externalKeyword, staticKeyword, returnType, methodName, parameters);
7321 externalKeyword,
7322 staticKeyword,
7323 returnType,
7324 methodName,
7325 parameters);
7326 } 6652 }
7327 6653
7328 /** 6654 /**
7329 * Parse the modifiers preceding a declaration. This method allows the modifie rs to appear in any 6655 * Parse the modifiers preceding a declaration. This method allows the modifie rs to appear in any
7330 * order but does generate errors for duplicated modifiers. Checks for other p roblems, such as 6656 * order but does generate errors for duplicated modifiers. Checks for other p roblems, such as
7331 * having the modifiers appear in the wrong order or specifying both 'const' a nd 'final', are 6657 * having the modifiers appear in the wrong order or specifying both 'const' a nd 'final', are
7332 * reported in one of the methods whose name is prefixed with `validateModifie rsFor`. 6658 * reported in one of the methods whose name is prefixed with `validateModifie rsFor`.
7333 * 6659 *
7334 * <pre> 6660 * <pre>
7335 * modifiers ::= 6661 * modifiers ::=
7336 * ('abstract' | 'const' | 'external' | 'factory' | 'final' | 'static' | ' var')* 6662 * ('abstract' | 'const' | 'external' | 'factory' | 'final' | 'static' | ' var')*
7337 * </pre> 6663 * </pre>
7338 * 6664 *
7339 * @return the modifiers that were parsed 6665 * @return the modifiers that were parsed
7340 */ 6666 */
7341 Modifiers _parseModifiers() { 6667 Modifiers _parseModifiers() {
7342 Modifiers modifiers = new Modifiers(); 6668 Modifiers modifiers = new Modifiers();
7343 bool progress = true; 6669 bool progress = true;
7344 while (progress) { 6670 while (progress) {
7345 if (_tokenMatches(_peek(), TokenType.PERIOD) || 6671 if (_tokenMatches(_peek(), TokenType.PERIOD) ||
7346 _tokenMatches(_peek(), TokenType.LT) || 6672 _tokenMatches(_peek(), TokenType.LT) ||
7347 _tokenMatches(_peek(), TokenType.OPEN_PAREN)) { 6673 _tokenMatches(_peek(), TokenType.OPEN_PAREN)) {
7348 return modifiers; 6674 return modifiers;
7349 } 6675 }
7350 if (_matchesKeyword(Keyword.ABSTRACT)) { 6676 if (_matchesKeyword(Keyword.ABSTRACT)) {
7351 if (modifiers.abstractKeyword != null) { 6677 if (modifiers.abstractKeyword != null) {
7352 _reportErrorForCurrentToken( 6678 _reportErrorForCurrentToken(
7353 ParserErrorCode.DUPLICATED_MODIFIER, 6679 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]);
7354 [_currentToken.lexeme]);
7355 _advance(); 6680 _advance();
7356 } else { 6681 } else {
7357 modifiers.abstractKeyword = getAndAdvance(); 6682 modifiers.abstractKeyword = getAndAdvance();
7358 } 6683 }
7359 } else if (_matchesKeyword(Keyword.CONST)) { 6684 } else if (_matchesKeyword(Keyword.CONST)) {
7360 if (modifiers.constKeyword != null) { 6685 if (modifiers.constKeyword != null) {
7361 _reportErrorForCurrentToken( 6686 _reportErrorForCurrentToken(
7362 ParserErrorCode.DUPLICATED_MODIFIER, 6687 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]);
7363 [_currentToken.lexeme]);
7364 _advance(); 6688 _advance();
7365 } else { 6689 } else {
7366 modifiers.constKeyword = getAndAdvance(); 6690 modifiers.constKeyword = getAndAdvance();
7367 } 6691 }
7368 } else if (_matchesKeyword(Keyword.EXTERNAL) && 6692 } else if (_matchesKeyword(Keyword.EXTERNAL) &&
7369 !_tokenMatches(_peek(), TokenType.PERIOD) && 6693 !_tokenMatches(_peek(), TokenType.PERIOD) &&
7370 !_tokenMatches(_peek(), TokenType.LT)) { 6694 !_tokenMatches(_peek(), TokenType.LT)) {
7371 if (modifiers.externalKeyword != null) { 6695 if (modifiers.externalKeyword != null) {
7372 _reportErrorForCurrentToken( 6696 _reportErrorForCurrentToken(
7373 ParserErrorCode.DUPLICATED_MODIFIER, 6697 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]);
7374 [_currentToken.lexeme]);
7375 _advance(); 6698 _advance();
7376 } else { 6699 } else {
7377 modifiers.externalKeyword = getAndAdvance(); 6700 modifiers.externalKeyword = getAndAdvance();
7378 } 6701 }
7379 } else if (_matchesKeyword(Keyword.FACTORY) && 6702 } else if (_matchesKeyword(Keyword.FACTORY) &&
7380 !_tokenMatches(_peek(), TokenType.PERIOD) && 6703 !_tokenMatches(_peek(), TokenType.PERIOD) &&
7381 !_tokenMatches(_peek(), TokenType.LT)) { 6704 !_tokenMatches(_peek(), TokenType.LT)) {
7382 if (modifiers.factoryKeyword != null) { 6705 if (modifiers.factoryKeyword != null) {
7383 _reportErrorForCurrentToken( 6706 _reportErrorForCurrentToken(
7384 ParserErrorCode.DUPLICATED_MODIFIER, 6707 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]);
7385 [_currentToken.lexeme]);
7386 _advance(); 6708 _advance();
7387 } else { 6709 } else {
7388 modifiers.factoryKeyword = getAndAdvance(); 6710 modifiers.factoryKeyword = getAndAdvance();
7389 } 6711 }
7390 } else if (_matchesKeyword(Keyword.FINAL)) { 6712 } else if (_matchesKeyword(Keyword.FINAL)) {
7391 if (modifiers.finalKeyword != null) { 6713 if (modifiers.finalKeyword != null) {
7392 _reportErrorForCurrentToken( 6714 _reportErrorForCurrentToken(
7393 ParserErrorCode.DUPLICATED_MODIFIER, 6715 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]);
7394 [_currentToken.lexeme]);
7395 _advance(); 6716 _advance();
7396 } else { 6717 } else {
7397 modifiers.finalKeyword = getAndAdvance(); 6718 modifiers.finalKeyword = getAndAdvance();
7398 } 6719 }
7399 } else if (_matchesKeyword(Keyword.STATIC) && 6720 } else if (_matchesKeyword(Keyword.STATIC) &&
7400 !_tokenMatches(_peek(), TokenType.PERIOD) && 6721 !_tokenMatches(_peek(), TokenType.PERIOD) &&
7401 !_tokenMatches(_peek(), TokenType.LT)) { 6722 !_tokenMatches(_peek(), TokenType.LT)) {
7402 if (modifiers.staticKeyword != null) { 6723 if (modifiers.staticKeyword != null) {
7403 _reportErrorForCurrentToken( 6724 _reportErrorForCurrentToken(
7404 ParserErrorCode.DUPLICATED_MODIFIER, 6725 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]);
7405 [_currentToken.lexeme]);
7406 _advance(); 6726 _advance();
7407 } else { 6727 } else {
7408 modifiers.staticKeyword = getAndAdvance(); 6728 modifiers.staticKeyword = getAndAdvance();
7409 } 6729 }
7410 } else if (_matchesKeyword(Keyword.VAR)) { 6730 } else if (_matchesKeyword(Keyword.VAR)) {
7411 if (modifiers.varKeyword != null) { 6731 if (modifiers.varKeyword != null) {
7412 _reportErrorForCurrentToken( 6732 _reportErrorForCurrentToken(
7413 ParserErrorCode.DUPLICATED_MODIFIER, 6733 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]);
7414 [_currentToken.lexeme]);
7415 _advance(); 6734 _advance();
7416 } else { 6735 } else {
7417 modifiers.varKeyword = getAndAdvance(); 6736 modifiers.varKeyword = getAndAdvance();
7418 } 6737 }
7419 } else { 6738 } else {
7420 progress = false; 6739 progress = false;
7421 } 6740 }
7422 } 6741 }
7423 return modifiers; 6742 return modifiers;
7424 } 6743 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
7503 * @return the non-labeled statement that was parsed 6822 * @return the non-labeled statement that was parsed
7504 */ 6823 */
7505 Statement _parseNonLabeledStatement() { 6824 Statement _parseNonLabeledStatement() {
7506 // TODO(brianwilkerson) Pass the comment and metadata on where appropriate. 6825 // TODO(brianwilkerson) Pass the comment and metadata on where appropriate.
7507 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); 6826 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata();
7508 if (_matches(TokenType.OPEN_CURLY_BRACKET)) { 6827 if (_matches(TokenType.OPEN_CURLY_BRACKET)) {
7509 if (_tokenMatches(_peek(), TokenType.STRING)) { 6828 if (_tokenMatches(_peek(), TokenType.STRING)) {
7510 Token afterString = _skipStringLiteral(_currentToken.next); 6829 Token afterString = _skipStringLiteral(_currentToken.next);
7511 if (afterString != null && afterString.type == TokenType.COLON) { 6830 if (afterString != null && afterString.type == TokenType.COLON) {
7512 return new ExpressionStatement( 6831 return new ExpressionStatement(
7513 parseExpression2(), 6832 parseExpression2(), _expect(TokenType.SEMICOLON));
7514 _expect(TokenType.SEMICOLON));
7515 } 6833 }
7516 } 6834 }
7517 return parseBlock(); 6835 return parseBlock();
7518 } else if (_matches(TokenType.KEYWORD) && 6836 } else if (_matches(TokenType.KEYWORD) &&
7519 !(_currentToken as KeywordToken).keyword.isPseudoKeyword) { 6837 !(_currentToken as KeywordToken).keyword.isPseudoKeyword) {
7520 Keyword keyword = (_currentToken as KeywordToken).keyword; 6838 Keyword keyword = (_currentToken as KeywordToken).keyword;
7521 // TODO(jwren) compute some metrics to figure out a better order for this 6839 // TODO(jwren) compute some metrics to figure out a better order for this
7522 // if-then sequence to optimize performance 6840 // if-then sequence to optimize performance
7523 if (keyword == Keyword.ASSERT) { 6841 if (keyword == Keyword.ASSERT) {
7524 return _parseAssertStatement(); 6842 return _parseAssertStatement();
7525 } else if (keyword == Keyword.BREAK) { 6843 } else if (keyword == Keyword.BREAK) {
7526 return _parseBreakStatement(); 6844 return _parseBreakStatement();
7527 } else if (keyword == Keyword.CONTINUE) { 6845 } else if (keyword == Keyword.CONTINUE) {
7528 return _parseContinueStatement(); 6846 return _parseContinueStatement();
7529 } else if (keyword == Keyword.DO) { 6847 } else if (keyword == Keyword.DO) {
7530 return _parseDoStatement(); 6848 return _parseDoStatement();
7531 } else if (keyword == Keyword.FOR) { 6849 } else if (keyword == Keyword.FOR) {
7532 return _parseForStatement(); 6850 return _parseForStatement();
7533 } else if (keyword == Keyword.IF) { 6851 } else if (keyword == Keyword.IF) {
7534 return _parseIfStatement(); 6852 return _parseIfStatement();
7535 } else if (keyword == Keyword.RETHROW) { 6853 } else if (keyword == Keyword.RETHROW) {
7536 return new ExpressionStatement( 6854 return new ExpressionStatement(
7537 _parseRethrowExpression(), 6855 _parseRethrowExpression(), _expect(TokenType.SEMICOLON));
7538 _expect(TokenType.SEMICOLON));
7539 } else if (keyword == Keyword.RETURN) { 6856 } else if (keyword == Keyword.RETURN) {
7540 return _parseReturnStatement(); 6857 return _parseReturnStatement();
7541 } else if (keyword == Keyword.SWITCH) { 6858 } else if (keyword == Keyword.SWITCH) {
7542 return _parseSwitchStatement(); 6859 return _parseSwitchStatement();
7543 } else if (keyword == Keyword.THROW) { 6860 } else if (keyword == Keyword.THROW) {
7544 return new ExpressionStatement( 6861 return new ExpressionStatement(
7545 _parseThrowExpression(), 6862 _parseThrowExpression(), _expect(TokenType.SEMICOLON));
7546 _expect(TokenType.SEMICOLON));
7547 } else if (keyword == Keyword.TRY) { 6863 } else if (keyword == Keyword.TRY) {
7548 return _parseTryStatement(); 6864 return _parseTryStatement();
7549 } else if (keyword == Keyword.WHILE) { 6865 } else if (keyword == Keyword.WHILE) {
7550 return _parseWhileStatement(); 6866 return _parseWhileStatement();
7551 } else if (keyword == Keyword.VAR || keyword == Keyword.FINAL) { 6867 } else if (keyword == Keyword.VAR || keyword == Keyword.FINAL) {
7552 return _parseVariableDeclarationStatementAfterMetadata( 6868 return _parseVariableDeclarationStatementAfterMetadata(
7553 commentAndMetadata); 6869 commentAndMetadata);
7554 } else if (keyword == Keyword.VOID) { 6870 } else if (keyword == Keyword.VOID) {
7555 TypeName returnType = parseReturnType(); 6871 TypeName returnType = parseReturnType();
7556 if (_matchesIdentifier() && 6872 if (_matchesIdentifier() &&
7557 _peek().matchesAny( 6873 _peek().matchesAny([
7558 [TokenType.OPEN_PAREN, TokenType.OPEN_CURLY_BRACKET, TokenType.F UNCTION])) { 6874 TokenType.OPEN_PAREN,
6875 TokenType.OPEN_CURLY_BRACKET,
6876 TokenType.FUNCTION
6877 ])) {
7559 return _parseFunctionDeclarationStatementAfterReturnType( 6878 return _parseFunctionDeclarationStatementAfterReturnType(
7560 commentAndMetadata, 6879 commentAndMetadata, returnType);
7561 returnType);
7562 } else { 6880 } else {
7563 // 6881 //
7564 // We have found an error of some kind. Try to recover. 6882 // We have found an error of some kind. Try to recover.
7565 // 6883 //
7566 if (_matchesIdentifier()) { 6884 if (_matchesIdentifier()) {
7567 if (_peek().matchesAny( 6885 if (_peek().matchesAny(
7568 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { 6886 [TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) {
7569 // 6887 //
7570 // We appear to have a variable declaration with a type of "void". 6888 // We appear to have a variable declaration with a type of "void".
7571 // 6889 //
7572 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType); 6890 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType);
7573 return _parseVariableDeclarationStatementAfterMetadata( 6891 return _parseVariableDeclarationStatementAfterMetadata(
7574 commentAndMetadata); 6892 commentAndMetadata);
7575 } 6893 }
7576 } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { 6894 } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) {
7577 // 6895 //
7578 // We appear to have found an incomplete statement at the end of a 6896 // We appear to have found an incomplete statement at the end of a
7579 // block. Parse it as a variable declaration. 6897 // block. Parse it as a variable declaration.
7580 // 6898 //
7581 return _parseVariableDeclarationStatementAfterType( 6899 return _parseVariableDeclarationStatementAfterType(
7582 commentAndMetadata, 6900 commentAndMetadata, null, returnType);
7583 null,
7584 returnType);
7585 } 6901 }
7586 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT); 6902 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT);
7587 // TODO(brianwilkerson) Recover from this error. 6903 // TODO(brianwilkerson) Recover from this error.
7588 return new EmptyStatement(_createSyntheticToken(TokenType.SEMICOLON)); 6904 return new EmptyStatement(_createSyntheticToken(TokenType.SEMICOLON));
7589 } 6905 }
7590 } else if (keyword == Keyword.CONST) { 6906 } else if (keyword == Keyword.CONST) {
7591 if (_peek().matchesAny( 6907 if (_peek().matchesAny([
7592 [ 6908 TokenType.LT,
7593 TokenType.LT, 6909 TokenType.OPEN_CURLY_BRACKET,
7594 TokenType.OPEN_CURLY_BRACKET, 6910 TokenType.OPEN_SQUARE_BRACKET,
7595 TokenType.OPEN_SQUARE_BRACKET, 6911 TokenType.INDEX
7596 TokenType.INDEX])) { 6912 ])) {
7597 return new ExpressionStatement( 6913 return new ExpressionStatement(
7598 parseExpression2(), 6914 parseExpression2(), _expect(TokenType.SEMICOLON));
7599 _expect(TokenType.SEMICOLON));
7600 } else if (_tokenMatches(_peek(), TokenType.IDENTIFIER)) { 6915 } else if (_tokenMatches(_peek(), TokenType.IDENTIFIER)) {
7601 Token afterType = _skipTypeName(_peek()); 6916 Token afterType = _skipTypeName(_peek());
7602 if (afterType != null) { 6917 if (afterType != null) {
7603 if (_tokenMatches(afterType, TokenType.OPEN_PAREN) || 6918 if (_tokenMatches(afterType, TokenType.OPEN_PAREN) ||
7604 (_tokenMatches(afterType, TokenType.PERIOD) && 6919 (_tokenMatches(afterType, TokenType.PERIOD) &&
7605 _tokenMatches(afterType.next, TokenType.IDENTIFIER) && 6920 _tokenMatches(afterType.next, TokenType.IDENTIFIER) &&
7606 _tokenMatches(afterType.next.next, TokenType.OPEN_PAREN))) { 6921 _tokenMatches(afterType.next.next, TokenType.OPEN_PAREN))) {
7607 return new ExpressionStatement( 6922 return new ExpressionStatement(
7608 parseExpression2(), 6923 parseExpression2(), _expect(TokenType.SEMICOLON));
7609 _expect(TokenType.SEMICOLON));
7610 } 6924 }
7611 } 6925 }
7612 } 6926 }
7613 return _parseVariableDeclarationStatementAfterMetadata( 6927 return _parseVariableDeclarationStatementAfterMetadata(
7614 commentAndMetadata); 6928 commentAndMetadata);
7615 } else if (keyword == Keyword.NEW || 6929 } else if (keyword == Keyword.NEW ||
7616 keyword == Keyword.TRUE || 6930 keyword == Keyword.TRUE ||
7617 keyword == Keyword.FALSE || 6931 keyword == Keyword.FALSE ||
7618 keyword == Keyword.NULL || 6932 keyword == Keyword.NULL ||
7619 keyword == Keyword.SUPER || 6933 keyword == Keyword.SUPER ||
7620 keyword == Keyword.THIS) { 6934 keyword == Keyword.THIS) {
7621 return new ExpressionStatement( 6935 return new ExpressionStatement(
7622 parseExpression2(), 6936 parseExpression2(), _expect(TokenType.SEMICOLON));
7623 _expect(TokenType.SEMICOLON));
7624 } else { 6937 } else {
7625 // 6938 //
7626 // We have found an error of some kind. Try to recover. 6939 // We have found an error of some kind. Try to recover.
7627 // 6940 //
7628 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT); 6941 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT);
7629 return new EmptyStatement(_createSyntheticToken(TokenType.SEMICOLON)); 6942 return new EmptyStatement(_createSyntheticToken(TokenType.SEMICOLON));
7630 } 6943 }
7631 } else if (_inGenerator && _matchesString(_YIELD)) { 6944 } else if (_inGenerator && _matchesString(_YIELD)) {
7632 return _parseYieldStatement(); 6945 return _parseYieldStatement();
7633 } else if (_inAsync && _matchesString(_AWAIT)) { 6946 } else if (_inAsync && _matchesString(_AWAIT)) {
7634 if (_tokenMatchesKeyword(_peek(), Keyword.FOR)) { 6947 if (_tokenMatchesKeyword(_peek(), Keyword.FOR)) {
7635 return _parseForStatement(); 6948 return _parseForStatement();
7636 } 6949 }
7637 return new ExpressionStatement( 6950 return new ExpressionStatement(
7638 parseExpression2(), 6951 parseExpression2(), _expect(TokenType.SEMICOLON));
7639 _expect(TokenType.SEMICOLON));
7640 } else if (_matchesString(_AWAIT) && 6952 } else if (_matchesString(_AWAIT) &&
7641 _tokenMatchesKeyword(_peek(), Keyword.FOR)) { 6953 _tokenMatchesKeyword(_peek(), Keyword.FOR)) {
7642 Token awaitToken = _currentToken; 6954 Token awaitToken = _currentToken;
7643 Statement statement = _parseForStatement(); 6955 Statement statement = _parseForStatement();
7644 if (statement is! ForStatement) { 6956 if (statement is! ForStatement) {
7645 _reportErrorForToken( 6957 _reportErrorForToken(
7646 CompileTimeErrorCode.ASYNC_FOR_IN_WRONG_CONTEXT, 6958 CompileTimeErrorCode.ASYNC_FOR_IN_WRONG_CONTEXT, awaitToken);
7647 awaitToken);
7648 } 6959 }
7649 return statement; 6960 return statement;
7650 } else if (_matches(TokenType.SEMICOLON)) { 6961 } else if (_matches(TokenType.SEMICOLON)) {
7651 return _parseEmptyStatement(); 6962 return _parseEmptyStatement();
7652 } else if (_isInitializedVariableDeclaration()) { 6963 } else if (_isInitializedVariableDeclaration()) {
7653 return _parseVariableDeclarationStatementAfterMetadata( 6964 return _parseVariableDeclarationStatementAfterMetadata(
7654 commentAndMetadata); 6965 commentAndMetadata);
7655 } else if (_isFunctionDeclaration()) { 6966 } else if (_isFunctionDeclaration()) {
7656 return _parseFunctionDeclarationStatement(); 6967 return _parseFunctionDeclarationStatement();
7657 } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { 6968 } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) {
7658 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT); 6969 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT);
7659 return new EmptyStatement(_createSyntheticToken(TokenType.SEMICOLON)); 6970 return new EmptyStatement(_createSyntheticToken(TokenType.SEMICOLON));
7660 } else { 6971 } else {
7661 return new ExpressionStatement( 6972 return new ExpressionStatement(
7662 parseExpression2(), 6973 parseExpression2(), _expect(TokenType.SEMICOLON));
7663 _expect(TokenType.SEMICOLON));
7664 } 6974 }
7665 } 6975 }
7666 6976
7667 /** 6977 /**
7668 * Parse an operator declaration. 6978 * Parse an operator declaration.
7669 * 6979 *
7670 * <pre> 6980 * <pre>
7671 * operatorDeclaration ::= 6981 * operatorDeclaration ::=
7672 * operatorSignature (';' | functionBody) 6982 * operatorSignature (';' | functionBody)
7673 * 6983 *
7674 * operatorSignature ::= 6984 * operatorSignature ::=
7675 * 'external'? returnType? 'operator' operator formalParameterList 6985 * 'external'? returnType? 'operator' operator formalParameterList
7676 * </pre> 6986 * </pre>
7677 * 6987 *
7678 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the 6988 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the
7679 * declaration 6989 * declaration
7680 * @param externalKeyword the 'external' token 6990 * @param externalKeyword the 'external' token
7681 * @param the return type that has already been parsed, or `null` if there was no return 6991 * @param the return type that has already been parsed, or `null` if there was no return
7682 * type 6992 * type
7683 * @return the operator declaration that was parsed 6993 * @return the operator declaration that was parsed
7684 */ 6994 */
7685 MethodDeclaration _parseOperator(CommentAndMetadata commentAndMetadata, 6995 MethodDeclaration _parseOperator(CommentAndMetadata commentAndMetadata,
7686 Token externalKeyword, TypeName returnType) { 6996 Token externalKeyword, TypeName returnType) {
7687 Token operatorKeyword; 6997 Token operatorKeyword;
7688 if (_matchesKeyword(Keyword.OPERATOR)) { 6998 if (_matchesKeyword(Keyword.OPERATOR)) {
7689 operatorKeyword = getAndAdvance(); 6999 operatorKeyword = getAndAdvance();
7690 } else { 7000 } else {
7691 _reportErrorForToken( 7001 _reportErrorForToken(
7692 ParserErrorCode.MISSING_KEYWORD_OPERATOR, 7002 ParserErrorCode.MISSING_KEYWORD_OPERATOR, _currentToken);
7693 _currentToken);
7694 operatorKeyword = _createSyntheticKeyword(Keyword.OPERATOR); 7003 operatorKeyword = _createSyntheticKeyword(Keyword.OPERATOR);
7695 } 7004 }
7696 if (!_currentToken.isUserDefinableOperator) { 7005 if (!_currentToken.isUserDefinableOperator) {
7697 _reportErrorForCurrentToken( 7006 _reportErrorForCurrentToken(
7698 ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, 7007 ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, [_currentToken.lexeme]);
7699 [_currentToken.lexeme]);
7700 } 7008 }
7701 SimpleIdentifier name = new SimpleIdentifier(getAndAdvance()); 7009 SimpleIdentifier name = new SimpleIdentifier(getAndAdvance());
7702 if (_matches(TokenType.EQ)) { 7010 if (_matches(TokenType.EQ)) {
7703 Token previous = _currentToken.previous; 7011 Token previous = _currentToken.previous;
7704 if ((_tokenMatches(previous, TokenType.EQ_EQ) || 7012 if ((_tokenMatches(previous, TokenType.EQ_EQ) ||
7705 _tokenMatches(previous, TokenType.BANG_EQ)) && 7013 _tokenMatches(previous, TokenType.BANG_EQ)) &&
7706 _currentToken.offset == previous.offset + 2) { 7014 _currentToken.offset == previous.offset + 2) {
7707 _reportErrorForCurrentToken( 7015 _reportErrorForCurrentToken(ParserErrorCode.INVALID_OPERATOR, [
7708 ParserErrorCode.INVALID_OPERATOR, 7016 "${previous.lexeme}${_currentToken.lexeme}"
7709 ["${previous.lexeme}${_currentToken.lexeme}"]); 7017 ]);
7710 _advance(); 7018 _advance();
7711 } 7019 }
7712 } 7020 }
7713 FormalParameterList parameters = parseFormalParameterList(); 7021 FormalParameterList parameters = parseFormalParameterList();
7714 _validateFormalParameterList(parameters); 7022 _validateFormalParameterList(parameters);
7715 FunctionBody body = 7023 FunctionBody body =
7716 _parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, false); 7024 _parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, false);
7717 if (externalKeyword != null && body is! EmptyFunctionBody) { 7025 if (externalKeyword != null && body is! EmptyFunctionBody) {
7718 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY); 7026 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY);
7719 } 7027 }
7720 return new MethodDeclaration( 7028 return new MethodDeclaration(commentAndMetadata.comment,
7721 commentAndMetadata.comment, 7029 commentAndMetadata.metadata, externalKeyword, null, returnType, null,
7722 commentAndMetadata.metadata, 7030 operatorKeyword, name, parameters, body);
7723 externalKeyword,
7724 null,
7725 returnType,
7726 null,
7727 operatorKeyword,
7728 name,
7729 parameters,
7730 body);
7731 } 7031 }
7732 7032
7733 /** 7033 /**
7734 * Parse a return type if one is given, otherwise return `null` without advanc ing. 7034 * Parse a return type if one is given, otherwise return `null` without advanc ing.
7735 * 7035 *
7736 * @return the return type that was parsed 7036 * @return the return type that was parsed
7737 */ 7037 */
7738 TypeName _parseOptionalReturnType() { 7038 TypeName _parseOptionalReturnType() {
7739 if (_matchesKeyword(Keyword.VOID)) { 7039 if (_matchesKeyword(Keyword.VOID)) {
7740 return parseReturnType(); 7040 return parseReturnType();
7741 } else if (_matchesIdentifier() && 7041 } else if (_matchesIdentifier() &&
7742 !_matchesKeyword(Keyword.GET) && 7042 !_matchesKeyword(Keyword.GET) &&
7743 !_matchesKeyword(Keyword.SET) && 7043 !_matchesKeyword(Keyword.SET) &&
7744 !_matchesKeyword(Keyword.OPERATOR) && 7044 !_matchesKeyword(Keyword.OPERATOR) &&
7745 (_tokenMatchesIdentifier(_peek()) || _tokenMatches(_peek(), TokenType.LT ))) { 7045 (_tokenMatchesIdentifier(_peek()) ||
7046 _tokenMatches(_peek(), TokenType.LT))) {
7746 return parseReturnType(); 7047 return parseReturnType();
7747 } else if (_matchesIdentifier() && 7048 } else if (_matchesIdentifier() &&
7748 _tokenMatches(_peek(), TokenType.PERIOD) && 7049 _tokenMatches(_peek(), TokenType.PERIOD) &&
7749 _tokenMatchesIdentifier(_peekAt(2)) && 7050 _tokenMatchesIdentifier(_peekAt(2)) &&
7750 (_tokenMatchesIdentifier(_peekAt(3)) || 7051 (_tokenMatchesIdentifier(_peekAt(3)) ||
7751 _tokenMatches(_peekAt(3), TokenType.LT))) { 7052 _tokenMatches(_peekAt(3), TokenType.LT))) {
7752 return parseReturnType(); 7053 return parseReturnType();
7753 } 7054 }
7754 return null; 7055 return null;
7755 } 7056 }
(...skipping 10 matching lines...) Expand all
7766 * </pre> 7067 * </pre>
7767 * 7068 *
7768 * @param commentAndMetadata the metadata to be associated with the directive 7069 * @param commentAndMetadata the metadata to be associated with the directive
7769 * @return the part or part-of directive that was parsed 7070 * @return the part or part-of directive that was parsed
7770 */ 7071 */
7771 Directive _parsePartDirective(CommentAndMetadata commentAndMetadata) { 7072 Directive _parsePartDirective(CommentAndMetadata commentAndMetadata) {
7772 Token partKeyword = _expectKeyword(Keyword.PART); 7073 Token partKeyword = _expectKeyword(Keyword.PART);
7773 if (_matchesString(_OF)) { 7074 if (_matchesString(_OF)) {
7774 Token ofKeyword = getAndAdvance(); 7075 Token ofKeyword = getAndAdvance();
7775 LibraryIdentifier libraryName = _parseLibraryName( 7076 LibraryIdentifier libraryName = _parseLibraryName(
7776 ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE, 7077 ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE, ofKeyword);
7777 ofKeyword);
7778 Token semicolon = _expect(TokenType.SEMICOLON); 7078 Token semicolon = _expect(TokenType.SEMICOLON);
7779 return new PartOfDirective( 7079 return new PartOfDirective(commentAndMetadata.comment,
7780 commentAndMetadata.comment, 7080 commentAndMetadata.metadata, partKeyword, ofKeyword, libraryName,
7781 commentAndMetadata.metadata,
7782 partKeyword,
7783 ofKeyword,
7784 libraryName,
7785 semicolon); 7081 semicolon);
7786 } 7082 }
7787 StringLiteral partUri = _parseUri(); 7083 StringLiteral partUri = _parseUri();
7788 Token semicolon = _expect(TokenType.SEMICOLON); 7084 Token semicolon = _expect(TokenType.SEMICOLON);
7789 return new PartDirective( 7085 return new PartDirective(commentAndMetadata.comment,
7790 commentAndMetadata.comment, 7086 commentAndMetadata.metadata, partKeyword, partUri, semicolon);
7791 commentAndMetadata.metadata,
7792 partKeyword,
7793 partUri,
7794 semicolon);
7795 } 7087 }
7796 7088
7797 /** 7089 /**
7798 * Parse a postfix expression. 7090 * Parse a postfix expression.
7799 * 7091 *
7800 * <pre> 7092 * <pre>
7801 * postfixExpression ::= 7093 * postfixExpression ::=
7802 * assignableExpression postfixOperator 7094 * assignableExpression postfixOperator
7803 * | primary selector* 7095 * | primary selector*
7804 * 7096 *
7805 * selector ::= 7097 * selector ::=
7806 * assignableSelector 7098 * assignableSelector
7807 * | argumentList 7099 * | argumentList
7808 * </pre> 7100 * </pre>
7809 * 7101 *
7810 * @return the postfix expression that was parsed 7102 * @return the postfix expression that was parsed
7811 */ 7103 */
7812 Expression _parsePostfixExpression() { 7104 Expression _parsePostfixExpression() {
7813 Expression operand = _parseAssignableExpression(true); 7105 Expression operand = _parseAssignableExpression(true);
7814 if (_matches(TokenType.OPEN_SQUARE_BRACKET) || 7106 if (_matches(TokenType.OPEN_SQUARE_BRACKET) ||
7815 _matches(TokenType.PERIOD) || 7107 _matches(TokenType.PERIOD) ||
7816 _matches(TokenType.OPEN_PAREN)) { 7108 _matches(TokenType.OPEN_PAREN)) {
7817 do { 7109 do {
7818 if (_matches(TokenType.OPEN_PAREN)) { 7110 if (_matches(TokenType.OPEN_PAREN)) {
7819 ArgumentList argumentList = parseArgumentList(); 7111 ArgumentList argumentList = parseArgumentList();
7820 if (operand is PropertyAccess) { 7112 if (operand is PropertyAccess) {
7821 PropertyAccess access = operand as PropertyAccess; 7113 PropertyAccess access = operand as PropertyAccess;
7822 operand = new MethodInvocation( 7114 operand = new MethodInvocation(access.target, access.operator,
7823 access.target, 7115 access.propertyName, argumentList);
7824 access.operator,
7825 access.propertyName,
7826 argumentList);
7827 } else { 7116 } else {
7828 operand = new FunctionExpressionInvocation(operand, argumentList); 7117 operand = new FunctionExpressionInvocation(operand, argumentList);
7829 } 7118 }
7830 } else { 7119 } else {
7831 operand = _parseAssignableSelector(operand, true); 7120 operand = _parseAssignableSelector(operand, true);
7832 } 7121 }
7833 } while (_matches(TokenType.OPEN_SQUARE_BRACKET) || 7122 } while (_matches(TokenType.OPEN_SQUARE_BRACKET) ||
7834 _matches(TokenType.PERIOD) || 7123 _matches(TokenType.PERIOD) ||
7835 _matches(TokenType.OPEN_PAREN)); 7124 _matches(TokenType.OPEN_PAREN));
7836 return operand; 7125 return operand;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
7868 * | listLiteral 7157 * | listLiteral
7869 * </pre> 7158 * </pre>
7870 * 7159 *
7871 * @return the primary expression that was parsed 7160 * @return the primary expression that was parsed
7872 */ 7161 */
7873 Expression _parsePrimaryExpression() { 7162 Expression _parsePrimaryExpression() {
7874 if (_matchesKeyword(Keyword.THIS)) { 7163 if (_matchesKeyword(Keyword.THIS)) {
7875 return new ThisExpression(getAndAdvance()); 7164 return new ThisExpression(getAndAdvance());
7876 } else if (_matchesKeyword(Keyword.SUPER)) { 7165 } else if (_matchesKeyword(Keyword.SUPER)) {
7877 return _parseAssignableSelector( 7166 return _parseAssignableSelector(
7878 new SuperExpression(getAndAdvance()), 7167 new SuperExpression(getAndAdvance()), false);
7879 false);
7880 } else if (_matchesKeyword(Keyword.NULL)) { 7168 } else if (_matchesKeyword(Keyword.NULL)) {
7881 return new NullLiteral(getAndAdvance()); 7169 return new NullLiteral(getAndAdvance());
7882 } else if (_matchesKeyword(Keyword.FALSE)) { 7170 } else if (_matchesKeyword(Keyword.FALSE)) {
7883 return new BooleanLiteral(getAndAdvance(), false); 7171 return new BooleanLiteral(getAndAdvance(), false);
7884 } else if (_matchesKeyword(Keyword.TRUE)) { 7172 } else if (_matchesKeyword(Keyword.TRUE)) {
7885 return new BooleanLiteral(getAndAdvance(), true); 7173 return new BooleanLiteral(getAndAdvance(), true);
7886 } else if (_matches(TokenType.DOUBLE)) { 7174 } else if (_matches(TokenType.DOUBLE)) {
7887 Token token = getAndAdvance(); 7175 Token token = getAndAdvance();
7888 double value = 0.0; 7176 double value = 0.0;
7889 try { 7177 try {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
7938 if (_isFunctionExpression(_currentToken)) { 7226 if (_isFunctionExpression(_currentToken)) {
7939 return parseFunctionExpression(); 7227 return parseFunctionExpression();
7940 } 7228 }
7941 Token leftParenthesis = getAndAdvance(); 7229 Token leftParenthesis = getAndAdvance();
7942 bool wasInInitializer = _inInitializer; 7230 bool wasInInitializer = _inInitializer;
7943 _inInitializer = false; 7231 _inInitializer = false;
7944 try { 7232 try {
7945 Expression expression = parseExpression2(); 7233 Expression expression = parseExpression2();
7946 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); 7234 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN);
7947 return new ParenthesizedExpression( 7235 return new ParenthesizedExpression(
7948 leftParenthesis, 7236 leftParenthesis, expression, rightParenthesis);
7949 expression,
7950 rightParenthesis);
7951 } finally { 7237 } finally {
7952 _inInitializer = wasInInitializer; 7238 _inInitializer = wasInInitializer;
7953 } 7239 }
7954 } else if (_matches(TokenType.LT)) { 7240 } else if (_matches(TokenType.LT)) {
7955 return _parseListOrMapLiteral(null); 7241 return _parseListOrMapLiteral(null);
7956 } else if (_matches(TokenType.QUESTION) && 7242 } else if (_matches(TokenType.QUESTION) &&
7957 _tokenMatches(_peek(), TokenType.IDENTIFIER)) { 7243 _tokenMatches(_peek(), TokenType.IDENTIFIER)) {
7958 _reportErrorForCurrentToken( 7244 _reportErrorForCurrentToken(
7959 ParserErrorCode.UNEXPECTED_TOKEN, 7245 ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken.lexeme]);
7960 [_currentToken.lexeme]);
7961 _advance(); 7246 _advance();
7962 return _parsePrimaryExpression(); 7247 return _parsePrimaryExpression();
7963 } else if (_matchesKeyword(Keyword.VOID)) { 7248 } else if (_matchesKeyword(Keyword.VOID)) {
7964 // 7249 //
7965 // Recover from having a return type of "void" where a return type is not 7250 // Recover from having a return type of "void" where a return type is not
7966 // expected. 7251 // expected.
7967 // 7252 //
7968 // TODO(brianwilkerson) Improve this error message. 7253 // TODO(brianwilkerson) Improve this error message.
7969 _reportErrorForCurrentToken( 7254 _reportErrorForCurrentToken(
7970 ParserErrorCode.UNEXPECTED_TOKEN, 7255 ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken.lexeme]);
7971 [_currentToken.lexeme]);
7972 _advance(); 7256 _advance();
7973 return _parsePrimaryExpression(); 7257 return _parsePrimaryExpression();
7974 } else if (_matches(TokenType.HASH)) { 7258 } else if (_matches(TokenType.HASH)) {
7975 return _parseSymbolLiteral(); 7259 return _parseSymbolLiteral();
7976 } else { 7260 } else {
7977 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER); 7261 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER);
7978 return _createSyntheticIdentifier(); 7262 return _createSyntheticIdentifier();
7979 } 7263 }
7980 } 7264 }
7981 7265
(...skipping 10 matching lines...) Expand all
7992 RedirectingConstructorInvocation _parseRedirectingConstructorInvocation() { 7276 RedirectingConstructorInvocation _parseRedirectingConstructorInvocation() {
7993 Token keyword = _expectKeyword(Keyword.THIS); 7277 Token keyword = _expectKeyword(Keyword.THIS);
7994 Token period = null; 7278 Token period = null;
7995 SimpleIdentifier constructorName = null; 7279 SimpleIdentifier constructorName = null;
7996 if (_matches(TokenType.PERIOD)) { 7280 if (_matches(TokenType.PERIOD)) {
7997 period = getAndAdvance(); 7281 period = getAndAdvance();
7998 constructorName = parseSimpleIdentifier(); 7282 constructorName = parseSimpleIdentifier();
7999 } 7283 }
8000 ArgumentList argumentList = parseArgumentList(); 7284 ArgumentList argumentList = parseArgumentList();
8001 return new RedirectingConstructorInvocation( 7285 return new RedirectingConstructorInvocation(
8002 keyword, 7286 keyword, period, constructorName, argumentList);
8003 period,
8004 constructorName,
8005 argumentList);
8006 } 7287 }
8007 7288
8008 /** 7289 /**
8009 * Parse a relational expression. 7290 * Parse a relational expression.
8010 * 7291 *
8011 * <pre> 7292 * <pre>
8012 * relationalExpression ::= 7293 * relationalExpression ::=
8013 * bitwiseOrExpression ('is' '!'? type | 'as' type | relationalOperator bi twiseOrExpression)? 7294 * bitwiseOrExpression ('is' '!'? type | 'as' type | relationalOperator bi twiseOrExpression)?
8014 * | 'super' relationalOperator bitwiseOrExpression 7295 * | 'super' relationalOperator bitwiseOrExpression
8015 * </pre> 7296 * </pre>
8016 * 7297 *
8017 * @return the relational expression that was parsed 7298 * @return the relational expression that was parsed
8018 */ 7299 */
8019 Expression _parseRelationalExpression() { 7300 Expression _parseRelationalExpression() {
8020 if (_matchesKeyword(Keyword.SUPER) && 7301 if (_matchesKeyword(Keyword.SUPER) &&
8021 _currentToken.next.type.isRelationalOperator) { 7302 _currentToken.next.type.isRelationalOperator) {
8022 Expression expression = new SuperExpression(getAndAdvance()); 7303 Expression expression = new SuperExpression(getAndAdvance());
8023 Token operator = getAndAdvance(); 7304 Token operator = getAndAdvance();
8024 expression = 7305 expression = new BinaryExpression(
8025 new BinaryExpression(expression, operator, parseBitwiseOrExpression()) ; 7306 expression, operator, parseBitwiseOrExpression());
8026 return expression; 7307 return expression;
8027 } 7308 }
8028 Expression expression = parseBitwiseOrExpression(); 7309 Expression expression = parseBitwiseOrExpression();
8029 if (_matchesKeyword(Keyword.AS)) { 7310 if (_matchesKeyword(Keyword.AS)) {
8030 Token asOperator = getAndAdvance(); 7311 Token asOperator = getAndAdvance();
8031 expression = new AsExpression(expression, asOperator, parseTypeName()); 7312 expression = new AsExpression(expression, asOperator, parseTypeName());
8032 } else if (_matchesKeyword(Keyword.IS)) { 7313 } else if (_matchesKeyword(Keyword.IS)) {
8033 Token isOperator = getAndAdvance(); 7314 Token isOperator = getAndAdvance();
8034 Token notOperator = null; 7315 Token notOperator = null;
8035 if (_matches(TokenType.BANG)) { 7316 if (_matches(TokenType.BANG)) {
8036 notOperator = getAndAdvance(); 7317 notOperator = getAndAdvance();
8037 } 7318 }
8038 expression = 7319 expression = new IsExpression(
8039 new IsExpression(expression, isOperator, notOperator, parseTypeName()) ; 7320 expression, isOperator, notOperator, parseTypeName());
8040 } else if (_currentToken.type.isRelationalOperator) { 7321 } else if (_currentToken.type.isRelationalOperator) {
8041 Token operator = getAndAdvance(); 7322 Token operator = getAndAdvance();
8042 expression = 7323 expression = new BinaryExpression(
8043 new BinaryExpression(expression, operator, parseBitwiseOrExpression()) ; 7324 expression, operator, parseBitwiseOrExpression());
8044 } 7325 }
8045 return expression; 7326 return expression;
8046 } 7327 }
8047 7328
8048 /** 7329 /**
8049 * Parse a rethrow expression. 7330 * Parse a rethrow expression.
8050 * 7331 *
8051 * <pre> 7332 * <pre>
8052 * rethrowExpression ::= 7333 * rethrowExpression ::=
8053 * 'rethrow' 7334 * 'rethrow'
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
8098 * @return the setter that was parsed 7379 * @return the setter that was parsed
8099 */ 7380 */
8100 MethodDeclaration _parseSetter(CommentAndMetadata commentAndMetadata, 7381 MethodDeclaration _parseSetter(CommentAndMetadata commentAndMetadata,
8101 Token externalKeyword, Token staticKeyword, TypeName returnType) { 7382 Token externalKeyword, Token staticKeyword, TypeName returnType) {
8102 Token propertyKeyword = _expectKeyword(Keyword.SET); 7383 Token propertyKeyword = _expectKeyword(Keyword.SET);
8103 SimpleIdentifier name = parseSimpleIdentifier(); 7384 SimpleIdentifier name = parseSimpleIdentifier();
8104 FormalParameterList parameters = parseFormalParameterList(); 7385 FormalParameterList parameters = parseFormalParameterList();
8105 _validateFormalParameterList(parameters); 7386 _validateFormalParameterList(parameters);
8106 FunctionBody body = _parseFunctionBody( 7387 FunctionBody body = _parseFunctionBody(
8107 externalKeyword != null || staticKeyword == null, 7388 externalKeyword != null || staticKeyword == null,
8108 ParserErrorCode.STATIC_SETTER_WITHOUT_BODY, 7389 ParserErrorCode.STATIC_SETTER_WITHOUT_BODY, false);
8109 false);
8110 if (externalKeyword != null && body is! EmptyFunctionBody) { 7390 if (externalKeyword != null && body is! EmptyFunctionBody) {
8111 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_SETTER_WITH_BODY); 7391 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_SETTER_WITH_BODY);
8112 } 7392 }
8113 return new MethodDeclaration( 7393 return new MethodDeclaration(commentAndMetadata.comment,
8114 commentAndMetadata.comment, 7394 commentAndMetadata.metadata, externalKeyword, staticKeyword, returnType,
8115 commentAndMetadata.metadata, 7395 propertyKeyword, null, name, parameters, body);
8116 externalKeyword,
8117 staticKeyword,
8118 returnType,
8119 propertyKeyword,
8120 null,
8121 name,
8122 parameters,
8123 body);
8124 } 7396 }
8125 7397
8126 /** 7398 /**
8127 * Parse a shift expression. 7399 * Parse a shift expression.
8128 * 7400 *
8129 * <pre> 7401 * <pre>
8130 * shiftExpression ::= 7402 * shiftExpression ::=
8131 * additiveExpression (shiftOperator additiveExpression)* 7403 * additiveExpression (shiftOperator additiveExpression)*
8132 * | 'super' (shiftOperator additiveExpression)+ 7404 * | 'super' (shiftOperator additiveExpression)+
8133 * </pre> 7405 * </pre>
8134 * 7406 *
8135 * @return the shift expression that was parsed 7407 * @return the shift expression that was parsed
8136 */ 7408 */
8137 Expression _parseShiftExpression() { 7409 Expression _parseShiftExpression() {
8138 Expression expression; 7410 Expression expression;
8139 if (_matchesKeyword(Keyword.SUPER) && 7411 if (_matchesKeyword(Keyword.SUPER) &&
8140 _currentToken.next.type.isShiftOperator) { 7412 _currentToken.next.type.isShiftOperator) {
8141 expression = new SuperExpression(getAndAdvance()); 7413 expression = new SuperExpression(getAndAdvance());
8142 } else { 7414 } else {
8143 expression = _parseAdditiveExpression(); 7415 expression = _parseAdditiveExpression();
8144 } 7416 }
8145 while (_currentToken.type.isShiftOperator) { 7417 while (_currentToken.type.isShiftOperator) {
8146 Token operator = getAndAdvance(); 7418 Token operator = getAndAdvance();
8147 expression = 7419 expression = new BinaryExpression(
8148 new BinaryExpression(expression, operator, _parseAdditiveExpression()) ; 7420 expression, operator, _parseAdditiveExpression());
8149 } 7421 }
8150 return expression; 7422 return expression;
8151 } 7423 }
8152 7424
8153 /** 7425 /**
8154 * Parse a list of statements within a switch statement. 7426 * Parse a list of statements within a switch statement.
8155 * 7427 *
8156 * <pre> 7428 * <pre>
8157 * statements ::= 7429 * statements ::=
8158 * statement* 7430 * statement*
8159 * </pre> 7431 * </pre>
8160 * 7432 *
8161 * @return the statements that were parsed 7433 * @return the statements that were parsed
8162 */ 7434 */
8163 List<Statement> _parseStatementList() { 7435 List<Statement> _parseStatementList() {
8164 List<Statement> statements = new List<Statement>(); 7436 List<Statement> statements = new List<Statement>();
8165 Token statementStart = _currentToken; 7437 Token statementStart = _currentToken;
8166 while (!_matches(TokenType.EOF) && 7438 while (!_matches(TokenType.EOF) &&
8167 !_matches(TokenType.CLOSE_CURLY_BRACKET) && 7439 !_matches(TokenType.CLOSE_CURLY_BRACKET) &&
8168 !_isSwitchMember()) { 7440 !_isSwitchMember()) {
8169 statements.add(parseStatement2()); 7441 statements.add(parseStatement2());
8170 if (identical(_currentToken, statementStart)) { 7442 if (identical(_currentToken, statementStart)) {
8171 _reportErrorForToken( 7443 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [
8172 ParserErrorCode.UNEXPECTED_TOKEN, 7444 _currentToken.lexeme
8173 _currentToken, 7445 ]);
8174 [_currentToken.lexeme]);
8175 _advance(); 7446 _advance();
8176 } 7447 }
8177 statementStart = _currentToken; 7448 statementStart = _currentToken;
8178 } 7449 }
8179 return statements; 7450 return statements;
8180 } 7451 }
8181 7452
8182 /** 7453 /**
8183 * Parse a string literal that contains interpolations. 7454 * Parse a string literal that contains interpolations.
8184 * 7455 *
8185 * @return the string literal that was parsed 7456 * @return the string literal that was parsed
8186 */ 7457 */
8187 StringInterpolation _parseStringInterpolation(Token string) { 7458 StringInterpolation _parseStringInterpolation(Token string) {
8188 List<InterpolationElement> elements = new List<InterpolationElement>(); 7459 List<InterpolationElement> elements = new List<InterpolationElement>();
8189 bool hasMore = 7460 bool hasMore = _matches(TokenType.STRING_INTERPOLATION_EXPRESSION) ||
8190 _matches(TokenType.STRING_INTERPOLATION_EXPRESSION) ||
8191 _matches(TokenType.STRING_INTERPOLATION_IDENTIFIER); 7461 _matches(TokenType.STRING_INTERPOLATION_IDENTIFIER);
8192 elements.add( 7462 elements.add(new InterpolationString(
8193 new InterpolationString( 7463 string, _computeStringValue(string.lexeme, true, !hasMore)));
8194 string,
8195 _computeStringValue(string.lexeme, true, !hasMore)));
8196 while (hasMore) { 7464 while (hasMore) {
8197 if (_matches(TokenType.STRING_INTERPOLATION_EXPRESSION)) { 7465 if (_matches(TokenType.STRING_INTERPOLATION_EXPRESSION)) {
8198 Token openToken = getAndAdvance(); 7466 Token openToken = getAndAdvance();
8199 bool wasInInitializer = _inInitializer; 7467 bool wasInInitializer = _inInitializer;
8200 _inInitializer = false; 7468 _inInitializer = false;
8201 try { 7469 try {
8202 Expression expression = parseExpression2(); 7470 Expression expression = parseExpression2();
8203 Token rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); 7471 Token rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET);
8204 elements.add( 7472 elements.add(
8205 new InterpolationExpression(openToken, expression, rightBracket)); 7473 new InterpolationExpression(openToken, expression, rightBracket));
8206 } finally { 7474 } finally {
8207 _inInitializer = wasInInitializer; 7475 _inInitializer = wasInInitializer;
8208 } 7476 }
8209 } else { 7477 } else {
8210 Token openToken = getAndAdvance(); 7478 Token openToken = getAndAdvance();
8211 Expression expression = null; 7479 Expression expression = null;
8212 if (_matchesKeyword(Keyword.THIS)) { 7480 if (_matchesKeyword(Keyword.THIS)) {
8213 expression = new ThisExpression(getAndAdvance()); 7481 expression = new ThisExpression(getAndAdvance());
8214 } else { 7482 } else {
8215 expression = parseSimpleIdentifier(); 7483 expression = parseSimpleIdentifier();
8216 } 7484 }
8217 elements.add(new InterpolationExpression(openToken, expression, null)); 7485 elements.add(new InterpolationExpression(openToken, expression, null));
8218 } 7486 }
8219 if (_matches(TokenType.STRING)) { 7487 if (_matches(TokenType.STRING)) {
8220 string = getAndAdvance(); 7488 string = getAndAdvance();
8221 hasMore = _matches(TokenType.STRING_INTERPOLATION_EXPRESSION) || 7489 hasMore = _matches(TokenType.STRING_INTERPOLATION_EXPRESSION) ||
8222 _matches(TokenType.STRING_INTERPOLATION_IDENTIFIER); 7490 _matches(TokenType.STRING_INTERPOLATION_IDENTIFIER);
8223 elements.add( 7491 elements.add(new InterpolationString(
8224 new InterpolationString( 7492 string, _computeStringValue(string.lexeme, false, !hasMore)));
8225 string,
8226 _computeStringValue(string.lexeme, false, !hasMore)));
8227 } else { 7493 } else {
8228 hasMore = false; 7494 hasMore = false;
8229 } 7495 }
8230 } 7496 }
8231 return new StringInterpolation(elements); 7497 return new StringInterpolation(elements);
8232 } 7498 }
8233 7499
8234 /** 7500 /**
8235 * Parse a super constructor invocation. 7501 * Parse a super constructor invocation.
8236 * 7502 *
8237 * <pre> 7503 * <pre>
8238 * superConstructorInvocation ::= 7504 * superConstructorInvocation ::=
8239 * 'super' ('.' identifier)? arguments 7505 * 'super' ('.' identifier)? arguments
8240 * </pre> 7506 * </pre>
8241 * 7507 *
8242 * @return the super constructor invocation that was parsed 7508 * @return the super constructor invocation that was parsed
8243 */ 7509 */
8244 SuperConstructorInvocation _parseSuperConstructorInvocation() { 7510 SuperConstructorInvocation _parseSuperConstructorInvocation() {
8245 Token keyword = _expectKeyword(Keyword.SUPER); 7511 Token keyword = _expectKeyword(Keyword.SUPER);
8246 Token period = null; 7512 Token period = null;
8247 SimpleIdentifier constructorName = null; 7513 SimpleIdentifier constructorName = null;
8248 if (_matches(TokenType.PERIOD)) { 7514 if (_matches(TokenType.PERIOD)) {
8249 period = getAndAdvance(); 7515 period = getAndAdvance();
8250 constructorName = parseSimpleIdentifier(); 7516 constructorName = parseSimpleIdentifier();
8251 } 7517 }
8252 ArgumentList argumentList = parseArgumentList(); 7518 ArgumentList argumentList = parseArgumentList();
8253 return new SuperConstructorInvocation( 7519 return new SuperConstructorInvocation(
8254 keyword, 7520 keyword, period, constructorName, argumentList);
8255 period,
8256 constructorName,
8257 argumentList);
8258 } 7521 }
8259 7522
8260 /** 7523 /**
8261 * Parse a switch statement. 7524 * Parse a switch statement.
8262 * 7525 *
8263 * <pre> 7526 * <pre>
8264 * switchStatement ::= 7527 * switchStatement ::=
8265 * 'switch' '(' expression ')' '{' switchCase* defaultCase? '}' 7528 * 'switch' '(' expression ')' '{' switchCase* defaultCase? '}'
8266 * 7529 *
8267 * switchCase ::= 7530 * switchCase ::=
(...skipping 13 matching lines...) Expand all
8281 Token keyword = _expectKeyword(Keyword.SWITCH); 7544 Token keyword = _expectKeyword(Keyword.SWITCH);
8282 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); 7545 Token leftParenthesis = _expect(TokenType.OPEN_PAREN);
8283 Expression expression = parseExpression2(); 7546 Expression expression = parseExpression2();
8284 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); 7547 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN);
8285 Token leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET); 7548 Token leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET);
8286 Token defaultKeyword = null; 7549 Token defaultKeyword = null;
8287 List<SwitchMember> members = new List<SwitchMember>(); 7550 List<SwitchMember> members = new List<SwitchMember>();
8288 while (!_matches(TokenType.EOF) && 7551 while (!_matches(TokenType.EOF) &&
8289 !_matches(TokenType.CLOSE_CURLY_BRACKET)) { 7552 !_matches(TokenType.CLOSE_CURLY_BRACKET)) {
8290 List<Label> labels = new List<Label>(); 7553 List<Label> labels = new List<Label>();
8291 while (_matchesIdentifier() && 7554 while (
8292 _tokenMatches(_peek(), TokenType.COLON)) { 7555 _matchesIdentifier() && _tokenMatches(_peek(), TokenType.COLON)) {
8293 SimpleIdentifier identifier = parseSimpleIdentifier(); 7556 SimpleIdentifier identifier = parseSimpleIdentifier();
8294 String label = identifier.token.lexeme; 7557 String label = identifier.token.lexeme;
8295 if (definedLabels.contains(label)) { 7558 if (definedLabels.contains(label)) {
8296 _reportErrorForToken( 7559 _reportErrorForToken(
8297 ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, 7560 ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT,
8298 identifier.token, 7561 identifier.token, [label]);
8299 [label]);
8300 } else { 7562 } else {
8301 definedLabels.add(label); 7563 definedLabels.add(label);
8302 } 7564 }
8303 Token colon = _expect(TokenType.COLON); 7565 Token colon = _expect(TokenType.COLON);
8304 labels.add(new Label(identifier, colon)); 7566 labels.add(new Label(identifier, colon));
8305 } 7567 }
8306 if (_matchesKeyword(Keyword.CASE)) { 7568 if (_matchesKeyword(Keyword.CASE)) {
8307 Token caseKeyword = getAndAdvance(); 7569 Token caseKeyword = getAndAdvance();
8308 Expression caseExpression = parseExpression2(); 7570 Expression caseExpression = parseExpression2();
8309 Token colon = _expect(TokenType.COLON); 7571 Token colon = _expect(TokenType.COLON);
8310 members.add( 7572 members.add(new SwitchCase(labels, caseKeyword, caseExpression, colon,
8311 new SwitchCase( 7573 _parseStatementList()));
8312 labels,
8313 caseKeyword,
8314 caseExpression,
8315 colon,
8316 _parseStatementList()));
8317 if (defaultKeyword != null) { 7574 if (defaultKeyword != null) {
8318 _reportErrorForToken( 7575 _reportErrorForToken(
8319 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE, 7576 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE,
8320 caseKeyword); 7577 caseKeyword);
8321 } 7578 }
8322 } else if (_matchesKeyword(Keyword.DEFAULT)) { 7579 } else if (_matchesKeyword(Keyword.DEFAULT)) {
8323 if (defaultKeyword != null) { 7580 if (defaultKeyword != null) {
8324 _reportErrorForToken( 7581 _reportErrorForToken(
8325 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, 7582 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, _peek());
8326 _peek());
8327 } 7583 }
8328 defaultKeyword = getAndAdvance(); 7584 defaultKeyword = getAndAdvance();
8329 Token colon = _expect(TokenType.COLON); 7585 Token colon = _expect(TokenType.COLON);
8330 members.add( 7586 members.add(new SwitchDefault(
8331 new SwitchDefault(labels, defaultKeyword, colon, _parseStatementLi st())); 7587 labels, defaultKeyword, colon, _parseStatementList()));
8332 } else { 7588 } else {
8333 // We need to advance, otherwise we could end up in an infinite loop, 7589 // We need to advance, otherwise we could end up in an infinite loop,
8334 // but this could be a lot smarter about recovering from the error. 7590 // but this could be a lot smarter about recovering from the error.
8335 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_CASE_OR_DEFAULT); 7591 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_CASE_OR_DEFAULT);
8336 while (!_matches(TokenType.EOF) && 7592 while (!_matches(TokenType.EOF) &&
8337 !_matches(TokenType.CLOSE_CURLY_BRACKET) && 7593 !_matches(TokenType.CLOSE_CURLY_BRACKET) &&
8338 !_matchesKeyword(Keyword.CASE) && 7594 !_matchesKeyword(Keyword.CASE) &&
8339 !_matchesKeyword(Keyword.DEFAULT)) { 7595 !_matchesKeyword(Keyword.DEFAULT)) {
8340 _advance(); 7596 _advance();
8341 } 7597 }
8342 } 7598 }
8343 } 7599 }
8344 Token rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); 7600 Token rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET);
8345 return new SwitchStatement( 7601 return new SwitchStatement(keyword, leftParenthesis, expression,
8346 keyword, 7602 rightParenthesis, leftBracket, members, rightBracket);
8347 leftParenthesis,
8348 expression,
8349 rightParenthesis,
8350 leftBracket,
8351 members,
8352 rightBracket);
8353 } finally { 7603 } finally {
8354 _inSwitch = wasInSwitch; 7604 _inSwitch = wasInSwitch;
8355 } 7605 }
8356 } 7606 }
8357 7607
8358 /** 7608 /**
8359 * Parse a symbol literal. 7609 * Parse a symbol literal.
8360 * 7610 *
8361 * <pre> 7611 * <pre>
8362 * symbolLiteral ::= 7612 * symbolLiteral ::=
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
8398 * throwExpression ::= 7648 * throwExpression ::=
8399 * 'throw' expression 7649 * 'throw' expression
8400 * </pre> 7650 * </pre>
8401 * 7651 *
8402 * @return the throw expression that was parsed 7652 * @return the throw expression that was parsed
8403 */ 7653 */
8404 Expression _parseThrowExpression() { 7654 Expression _parseThrowExpression() {
8405 Token keyword = _expectKeyword(Keyword.THROW); 7655 Token keyword = _expectKeyword(Keyword.THROW);
8406 if (_matches(TokenType.SEMICOLON) || _matches(TokenType.CLOSE_PAREN)) { 7656 if (_matches(TokenType.SEMICOLON) || _matches(TokenType.CLOSE_PAREN)) {
8407 _reportErrorForToken( 7657 _reportErrorForToken(
8408 ParserErrorCode.MISSING_EXPRESSION_IN_THROW, 7658 ParserErrorCode.MISSING_EXPRESSION_IN_THROW, _currentToken);
8409 _currentToken);
8410 return new ThrowExpression(keyword, _createSyntheticIdentifier()); 7659 return new ThrowExpression(keyword, _createSyntheticIdentifier());
8411 } 7660 }
8412 Expression expression = parseExpression2(); 7661 Expression expression = parseExpression2();
8413 return new ThrowExpression(keyword, expression); 7662 return new ThrowExpression(keyword, expression);
8414 } 7663 }
8415 7664
8416 /** 7665 /**
8417 * Parse a throw expression. 7666 * Parse a throw expression.
8418 * 7667 *
8419 * <pre> 7668 * <pre>
8420 * throwExpressionWithoutCascade ::= 7669 * throwExpressionWithoutCascade ::=
8421 * 'throw' expressionWithoutCascade 7670 * 'throw' expressionWithoutCascade
8422 * </pre> 7671 * </pre>
8423 * 7672 *
8424 * @return the throw expression that was parsed 7673 * @return the throw expression that was parsed
8425 */ 7674 */
8426 Expression _parseThrowExpressionWithoutCascade() { 7675 Expression _parseThrowExpressionWithoutCascade() {
8427 Token keyword = _expectKeyword(Keyword.THROW); 7676 Token keyword = _expectKeyword(Keyword.THROW);
8428 if (_matches(TokenType.SEMICOLON) || _matches(TokenType.CLOSE_PAREN)) { 7677 if (_matches(TokenType.SEMICOLON) || _matches(TokenType.CLOSE_PAREN)) {
8429 _reportErrorForToken( 7678 _reportErrorForToken(
8430 ParserErrorCode.MISSING_EXPRESSION_IN_THROW, 7679 ParserErrorCode.MISSING_EXPRESSION_IN_THROW, _currentToken);
8431 _currentToken);
8432 return new ThrowExpression(keyword, _createSyntheticIdentifier()); 7680 return new ThrowExpression(keyword, _createSyntheticIdentifier());
8433 } 7681 }
8434 Expression expression = parseExpressionWithoutCascade(); 7682 Expression expression = parseExpressionWithoutCascade();
8435 return new ThrowExpression(keyword, expression); 7683 return new ThrowExpression(keyword, expression);
8436 } 7684 }
8437 7685
8438 /** 7686 /**
8439 * Parse a try statement. 7687 * Parse a try statement.
8440 * 7688 *
8441 * <pre> 7689 * <pre>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
8477 catchKeyword = getAndAdvance(); 7725 catchKeyword = getAndAdvance();
8478 leftParenthesis = _expect(TokenType.OPEN_PAREN); 7726 leftParenthesis = _expect(TokenType.OPEN_PAREN);
8479 exceptionParameter = parseSimpleIdentifier(); 7727 exceptionParameter = parseSimpleIdentifier();
8480 if (_matches(TokenType.COMMA)) { 7728 if (_matches(TokenType.COMMA)) {
8481 comma = getAndAdvance(); 7729 comma = getAndAdvance();
8482 stackTraceParameter = parseSimpleIdentifier(); 7730 stackTraceParameter = parseSimpleIdentifier();
8483 } 7731 }
8484 rightParenthesis = _expect(TokenType.CLOSE_PAREN); 7732 rightParenthesis = _expect(TokenType.CLOSE_PAREN);
8485 } 7733 }
8486 Block catchBody = parseBlock(); 7734 Block catchBody = parseBlock();
8487 catchClauses.add( 7735 catchClauses.add(new CatchClause(onKeyword, exceptionType, catchKeyword,
8488 new CatchClause( 7736 leftParenthesis, exceptionParameter, comma, stackTraceParameter,
8489 onKeyword, 7737 rightParenthesis, catchBody));
8490 exceptionType,
8491 catchKeyword,
8492 leftParenthesis,
8493 exceptionParameter,
8494 comma,
8495 stackTraceParameter,
8496 rightParenthesis,
8497 catchBody));
8498 } 7738 }
8499 Token finallyKeyword = null; 7739 Token finallyKeyword = null;
8500 if (_matchesKeyword(Keyword.FINALLY)) { 7740 if (_matchesKeyword(Keyword.FINALLY)) {
8501 finallyKeyword = getAndAdvance(); 7741 finallyKeyword = getAndAdvance();
8502 finallyClause = parseBlock(); 7742 finallyClause = parseBlock();
8503 } else { 7743 } else {
8504 if (catchClauses.isEmpty) { 7744 if (catchClauses.isEmpty) {
8505 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CATCH_OR_FINALLY); 7745 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CATCH_OR_FINALLY);
8506 } 7746 }
8507 } 7747 }
8508 return new TryStatement( 7748 return new TryStatement(
8509 tryKeyword, 7749 tryKeyword, body, catchClauses, finallyKeyword, finallyClause);
8510 body,
8511 catchClauses,
8512 finallyKeyword,
8513 finallyClause);
8514 } 7750 }
8515 7751
8516 /** 7752 /**
8517 * Parse a type alias. 7753 * Parse a type alias.
8518 * 7754 *
8519 * <pre> 7755 * <pre>
8520 * typeAlias ::= 7756 * typeAlias ::=
8521 * 'typedef' typeAliasBody 7757 * 'typedef' typeAliasBody
8522 * 7758 *
8523 * typeAliasBody ::= 7759 * typeAliasBody ::=
(...skipping 19 matching lines...) Expand all
8543 TypeAlias _parseTypeAlias(CommentAndMetadata commentAndMetadata) { 7779 TypeAlias _parseTypeAlias(CommentAndMetadata commentAndMetadata) {
8544 Token keyword = _expectKeyword(Keyword.TYPEDEF); 7780 Token keyword = _expectKeyword(Keyword.TYPEDEF);
8545 if (_matchesIdentifier()) { 7781 if (_matchesIdentifier()) {
8546 Token next = _peek(); 7782 Token next = _peek();
8547 if (_tokenMatches(next, TokenType.LT)) { 7783 if (_tokenMatches(next, TokenType.LT)) {
8548 next = _skipTypeParameterList(next); 7784 next = _skipTypeParameterList(next);
8549 if (next != null && _tokenMatches(next, TokenType.EQ)) { 7785 if (next != null && _tokenMatches(next, TokenType.EQ)) {
8550 TypeAlias typeAlias = 7786 TypeAlias typeAlias =
8551 _parseClassTypeAlias(commentAndMetadata, null, keyword); 7787 _parseClassTypeAlias(commentAndMetadata, null, keyword);
8552 _reportErrorForToken( 7788 _reportErrorForToken(
8553 ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, 7789 ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyword);
8554 keyword);
8555 return typeAlias; 7790 return typeAlias;
8556 } 7791 }
8557 } else if (_tokenMatches(next, TokenType.EQ)) { 7792 } else if (_tokenMatches(next, TokenType.EQ)) {
8558 TypeAlias typeAlias = 7793 TypeAlias typeAlias =
8559 _parseClassTypeAlias(commentAndMetadata, null, keyword); 7794 _parseClassTypeAlias(commentAndMetadata, null, keyword);
8560 _reportErrorForToken( 7795 _reportErrorForToken(
8561 ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, 7796 ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyword);
8562 keyword);
8563 return typeAlias; 7797 return typeAlias;
8564 } 7798 }
8565 } 7799 }
8566 return _parseFunctionTypeAlias(commentAndMetadata, keyword); 7800 return _parseFunctionTypeAlias(commentAndMetadata, keyword);
8567 } 7801 }
8568 7802
8569 /** 7803 /**
8570 * Parse a unary expression. 7804 * Parse a unary expression.
8571 * 7805 *
8572 * <pre> 7806 * <pre>
(...skipping 16 matching lines...) Expand all
8589 if (_matchesKeyword(Keyword.SUPER)) { 7823 if (_matchesKeyword(Keyword.SUPER)) {
8590 if (_tokenMatches(_peek(), TokenType.OPEN_SQUARE_BRACKET) || 7824 if (_tokenMatches(_peek(), TokenType.OPEN_SQUARE_BRACKET) ||
8591 _tokenMatches(_peek(), TokenType.PERIOD)) { 7825 _tokenMatches(_peek(), TokenType.PERIOD)) {
8592 // "prefixOperator unaryExpression" 7826 // "prefixOperator unaryExpression"
8593 // --> "prefixOperator postfixExpression" 7827 // --> "prefixOperator postfixExpression"
8594 // --> "prefixOperator primary selector*" 7828 // --> "prefixOperator primary selector*"
8595 // --> "prefixOperator 'super' assignableSelector selector*" 7829 // --> "prefixOperator 'super' assignableSelector selector*"
8596 return new PrefixExpression(operator, _parseUnaryExpression()); 7830 return new PrefixExpression(operator, _parseUnaryExpression());
8597 } 7831 }
8598 return new PrefixExpression( 7832 return new PrefixExpression(
8599 operator, 7833 operator, new SuperExpression(getAndAdvance()));
8600 new SuperExpression(getAndAdvance()));
8601 } 7834 }
8602 return new PrefixExpression(operator, _parseUnaryExpression()); 7835 return new PrefixExpression(operator, _parseUnaryExpression());
8603 } else if (_currentToken.type.isIncrementOperator) { 7836 } else if (_currentToken.type.isIncrementOperator) {
8604 Token operator = getAndAdvance(); 7837 Token operator = getAndAdvance();
8605 if (_matchesKeyword(Keyword.SUPER)) { 7838 if (_matchesKeyword(Keyword.SUPER)) {
8606 if (_tokenMatches(_peek(), TokenType.OPEN_SQUARE_BRACKET) || 7839 if (_tokenMatches(_peek(), TokenType.OPEN_SQUARE_BRACKET) ||
8607 _tokenMatches(_peek(), TokenType.PERIOD)) { 7840 _tokenMatches(_peek(), TokenType.PERIOD)) {
8608 // --> "prefixOperator 'super' assignableSelector selector*" 7841 // --> "prefixOperator 'super' assignableSelector selector*"
8609 return new PrefixExpression(operator, _parseUnaryExpression()); 7842 return new PrefixExpression(operator, _parseUnaryExpression());
8610 } 7843 }
8611 // 7844 //
8612 // Even though it is not valid to use an incrementing operator 7845 // Even though it is not valid to use an incrementing operator
8613 // ('++' or '--') before 'super', we can (and therefore must) interpret 7846 // ('++' or '--') before 'super', we can (and therefore must) interpret
8614 // "--super" as semantically equivalent to "-(-super)". Unfortunately, 7847 // "--super" as semantically equivalent to "-(-super)". Unfortunately,
8615 // we cannot do the same for "++super" because "+super" is also not 7848 // we cannot do the same for "++super" because "+super" is also not
8616 // valid. 7849 // valid.
8617 // 7850 //
8618 if (operator.type == TokenType.MINUS_MINUS) { 7851 if (operator.type == TokenType.MINUS_MINUS) {
8619 Token firstOperator = _createToken(operator, TokenType.MINUS); 7852 Token firstOperator = _createToken(operator, TokenType.MINUS);
8620 Token secondOperator = 7853 Token secondOperator =
8621 new Token(TokenType.MINUS, operator.offset + 1); 7854 new Token(TokenType.MINUS, operator.offset + 1);
8622 secondOperator.setNext(_currentToken); 7855 secondOperator.setNext(_currentToken);
8623 firstOperator.setNext(secondOperator); 7856 firstOperator.setNext(secondOperator);
8624 operator.previous.setNext(firstOperator); 7857 operator.previous.setNext(firstOperator);
8625 return new PrefixExpression( 7858 return new PrefixExpression(firstOperator, new PrefixExpression(
8626 firstOperator, 7859 secondOperator, new SuperExpression(getAndAdvance())));
8627 new PrefixExpression(secondOperator, new SuperExpression(getAndAdv ance())));
8628 } else { 7860 } else {
8629 // Invalid operator before 'super' 7861 // Invalid operator before 'super'
8630 _reportErrorForCurrentToken( 7862 _reportErrorForCurrentToken(
8631 ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, 7863 ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, [operator.lexeme]);
8632 [operator.lexeme]);
8633 return new PrefixExpression( 7864 return new PrefixExpression(
8634 operator, 7865 operator, new SuperExpression(getAndAdvance()));
8635 new SuperExpression(getAndAdvance()));
8636 } 7866 }
8637 } 7867 }
8638 return new PrefixExpression(operator, _parseAssignableExpression(false)); 7868 return new PrefixExpression(operator, _parseAssignableExpression(false));
8639 } else if (_matches(TokenType.PLUS)) { 7869 } else if (_matches(TokenType.PLUS)) {
8640 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER); 7870 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER);
8641 return _createSyntheticIdentifier(); 7871 return _createSyntheticIdentifier();
8642 } else if (_inAsync && _matchesString(_AWAIT)) { 7872 } else if (_inAsync && _matchesString(_AWAIT)) {
8643 return _parseAwaitExpression(); 7873 return _parseAwaitExpression();
8644 } 7874 }
8645 return _parsePostfixExpression(); 7875 return _parsePostfixExpression();
8646 } 7876 }
8647 7877
8648 /** 7878 /**
8649 * Parse a string literal representing a URI. 7879 * Parse a string literal representing a URI.
8650 */ 7880 */
8651 StringLiteral _parseUri() { 7881 StringLiteral _parseUri() {
8652 bool iskeywordAfterUri(Token token) => 7882 bool iskeywordAfterUri(Token token) => token.lexeme == Keyword.AS.syntax ||
8653 token.lexeme == Keyword.AS.syntax || 7883 token.lexeme == _HIDE ||
8654 token.lexeme == _HIDE || 7884 token.lexeme == _SHOW;
8655 token.lexeme == _SHOW;
8656 if (!_matches(TokenType.STRING) && 7885 if (!_matches(TokenType.STRING) &&
8657 !_matches(TokenType.SEMICOLON) && 7886 !_matches(TokenType.SEMICOLON) &&
8658 !iskeywordAfterUri(_currentToken)) { 7887 !iskeywordAfterUri(_currentToken)) {
8659 // Attempt to recover in the case where the URI was not enclosed in 7888 // Attempt to recover in the case where the URI was not enclosed in
8660 // quotes. 7889 // quotes.
8661 Token token = _currentToken; 7890 Token token = _currentToken;
8662 while ((_tokenMatchesIdentifier(token) && !iskeywordAfterUri(token)) || 7891 while ((_tokenMatchesIdentifier(token) && !iskeywordAfterUri(token)) ||
8663 _tokenMatches(token, TokenType.COLON) || 7892 _tokenMatches(token, TokenType.COLON) ||
8664 _tokenMatches(token, TokenType.SLASH) || 7893 _tokenMatches(token, TokenType.SLASH) ||
8665 _tokenMatches(token, TokenType.PERIOD) || 7894 _tokenMatches(token, TokenType.PERIOD) ||
(...skipping 15 matching lines...) Expand all
8681 if (token.offset != endOffset || token.precedingComments != null) { 7910 if (token.offset != endOffset || token.precedingComments != null) {
8682 return parseStringLiteral(); 7911 return parseStringLiteral();
8683 } 7912 }
8684 buffer.write(token.lexeme); 7913 buffer.write(token.lexeme);
8685 endOffset = token.end; 7914 endOffset = token.end;
8686 } 7915 }
8687 String value = buffer.toString(); 7916 String value = buffer.toString();
8688 Token newToken = 7917 Token newToken =
8689 new StringToken(TokenType.STRING, "'$value'", _currentToken.offset); 7918 new StringToken(TokenType.STRING, "'$value'", _currentToken.offset);
8690 _reportErrorForToken( 7919 _reportErrorForToken(
8691 ParserErrorCode.NON_STRING_LITERAL_AS_URI, 7920 ParserErrorCode.NON_STRING_LITERAL_AS_URI, newToken);
8692 newToken);
8693 _currentToken = endToken.next; 7921 _currentToken = endToken.next;
8694 return new SimpleStringLiteral(newToken, value); 7922 return new SimpleStringLiteral(newToken, value);
8695 } 7923 }
8696 } 7924 }
8697 return parseStringLiteral(); 7925 return parseStringLiteral();
8698 } 7926 }
8699 7927
8700 /** 7928 /**
8701 * Parse a variable declaration. 7929 * Parse a variable declaration.
8702 * 7930 *
8703 * <pre> 7931 * <pre>
8704 * variableDeclaration ::= 7932 * variableDeclaration ::=
8705 * identifier ('=' expression)? 7933 * identifier ('=' expression)?
8706 * </pre> 7934 * </pre>
8707 * 7935 *
8708 * @return the variable declaration that was parsed 7936 * @return the variable declaration that was parsed
8709 */ 7937 */
8710 VariableDeclaration _parseVariableDeclaration() { 7938 VariableDeclaration _parseVariableDeclaration() {
8711 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); 7939 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata();
8712 SimpleIdentifier name = parseSimpleIdentifier(); 7940 SimpleIdentifier name = parseSimpleIdentifier();
8713 Token equals = null; 7941 Token equals = null;
8714 Expression initializer = null; 7942 Expression initializer = null;
8715 if (_matches(TokenType.EQ)) { 7943 if (_matches(TokenType.EQ)) {
8716 equals = getAndAdvance(); 7944 equals = getAndAdvance();
8717 initializer = parseExpression2(); 7945 initializer = parseExpression2();
8718 } 7946 }
8719 return new VariableDeclaration( 7947 return new VariableDeclaration(commentAndMetadata.comment,
8720 commentAndMetadata.comment, 7948 commentAndMetadata.metadata, name, equals, initializer);
8721 commentAndMetadata.metadata,
8722 name,
8723 equals,
8724 initializer);
8725 } 7949 }
8726 7950
8727 /** 7951 /**
8728 * Parse a variable declaration list. 7952 * Parse a variable declaration list.
8729 * 7953 *
8730 * <pre> 7954 * <pre>
8731 * variableDeclarationList ::= 7955 * variableDeclarationList ::=
8732 * finalConstVarOrType variableDeclaration (',' variableDeclaration)* 7956 * finalConstVarOrType variableDeclaration (',' variableDeclaration)*
8733 * </pre> 7957 * </pre>
8734 * 7958 *
8735 * @param commentAndMetadata the metadata to be associated with the variable d eclaration list 7959 * @param commentAndMetadata the metadata to be associated with the variable d eclaration list
8736 * @return the variable declaration list that was parsed 7960 * @return the variable declaration list that was parsed
8737 */ 7961 */
8738 VariableDeclarationList 7962 VariableDeclarationList _parseVariableDeclarationListAfterMetadata(
8739 _parseVariableDeclarationListAfterMetadata(CommentAndMetadata commentAndMe tadata) { 7963 CommentAndMetadata commentAndMetadata) {
8740 FinalConstVarOrType holder = _parseFinalConstVarOrType(false); 7964 FinalConstVarOrType holder = _parseFinalConstVarOrType(false);
8741 return _parseVariableDeclarationListAfterType( 7965 return _parseVariableDeclarationListAfterType(
8742 commentAndMetadata, 7966 commentAndMetadata, holder.keyword, holder.type);
8743 holder.keyword,
8744 holder.type);
8745 } 7967 }
8746 7968
8747 /** 7969 /**
8748 * Parse a variable declaration list. 7970 * Parse a variable declaration list.
8749 * 7971 *
8750 * <pre> 7972 * <pre>
8751 * variableDeclarationList ::= 7973 * variableDeclarationList ::=
8752 * finalConstVarOrType variableDeclaration (',' variableDeclaration)* 7974 * finalConstVarOrType variableDeclaration (',' variableDeclaration)*
8753 * </pre> 7975 * </pre>
8754 * 7976 *
8755 * @param commentAndMetadata the metadata to be associated with the variable d eclaration list, or 7977 * @param commentAndMetadata the metadata to be associated with the variable d eclaration list, or
8756 * `null` if there is no attempt at parsing the comment and metadata 7978 * `null` if there is no attempt at parsing the comment and metadata
8757 * @param keyword the token representing the 'final', 'const' or 'var' keyword , or `null` if 7979 * @param keyword the token representing the 'final', 'const' or 'var' keyword , or `null` if
8758 * there is no keyword 7980 * there is no keyword
8759 * @param type the type of the variables in the list 7981 * @param type the type of the variables in the list
8760 * @return the variable declaration list that was parsed 7982 * @return the variable declaration list that was parsed
8761 */ 7983 */
8762 VariableDeclarationList 7984 VariableDeclarationList _parseVariableDeclarationListAfterType(
8763 _parseVariableDeclarationListAfterType(CommentAndMetadata commentAndMetada ta, 7985 CommentAndMetadata commentAndMetadata, Token keyword, TypeName type) {
8764 Token keyword, TypeName type) {
8765 if (type != null && 7986 if (type != null &&
8766 keyword != null && 7987 keyword != null &&
8767 _tokenMatchesKeyword(keyword, Keyword.VAR)) { 7988 _tokenMatchesKeyword(keyword, Keyword.VAR)) {
8768 _reportErrorForToken(ParserErrorCode.VAR_AND_TYPE, keyword); 7989 _reportErrorForToken(ParserErrorCode.VAR_AND_TYPE, keyword);
8769 } 7990 }
8770 List<VariableDeclaration> variables = new List<VariableDeclaration>(); 7991 List<VariableDeclaration> variables = new List<VariableDeclaration>();
8771 variables.add(_parseVariableDeclaration()); 7992 variables.add(_parseVariableDeclaration());
8772 while (_matches(TokenType.COMMA)) { 7993 while (_matches(TokenType.COMMA)) {
8773 _advance(); 7994 _advance();
8774 variables.add(_parseVariableDeclaration()); 7995 variables.add(_parseVariableDeclaration());
8775 } 7996 }
8776 return new VariableDeclarationList( 7997 return new VariableDeclarationList(
8777 commentAndMetadata != null ? commentAndMetadata.comment : null, 7998 commentAndMetadata != null ? commentAndMetadata.comment : null,
8778 commentAndMetadata != null ? commentAndMetadata.metadata : null, 7999 commentAndMetadata != null ? commentAndMetadata.metadata : null,
8779 keyword, 8000 keyword, type, variables);
8780 type,
8781 variables);
8782 } 8001 }
8783 8002
8784 /** 8003 /**
8785 * Parse a variable declaration statement. 8004 * Parse a variable declaration statement.
8786 * 8005 *
8787 * <pre> 8006 * <pre>
8788 * variableDeclarationStatement ::= 8007 * variableDeclarationStatement ::=
8789 * variableDeclarationList ';' 8008 * variableDeclarationList ';'
8790 * </pre> 8009 * </pre>
8791 * 8010 *
8792 * @param commentAndMetadata the metadata to be associated with the variable d eclaration 8011 * @param commentAndMetadata the metadata to be associated with the variable d eclaration
8793 * statement, or `null` if there is no attempt at parsing the comment and metadata 8012 * statement, or `null` if there is no attempt at parsing the comment and metadata
8794 * @return the variable declaration statement that was parsed 8013 * @return the variable declaration statement that was parsed
8795 */ 8014 */
8796 VariableDeclarationStatement 8015 VariableDeclarationStatement _parseVariableDeclarationStatementAfterMetadata(
8797 _parseVariableDeclarationStatementAfterMetadata(CommentAndMetadata comment AndMetadata) { 8016 CommentAndMetadata commentAndMetadata) {
8798 // Token startToken = currentToken; 8017 // Token startToken = currentToken;
8799 VariableDeclarationList variableList = 8018 VariableDeclarationList variableList =
8800 _parseVariableDeclarationListAfterMetadata(commentAndMetadata); 8019 _parseVariableDeclarationListAfterMetadata(commentAndMetadata);
8801 // if (!matches(TokenType.SEMICOLON)) { 8020 // if (!matches(TokenType.SEMICOLON)) {
8802 // if (matches(startToken, Keyword.VAR) && isTypedIdentifier(startToken .getNext())) { 8021 // if (matches(startToken, Keyword.VAR) && isTypedIdentifier(startToken .getNext())) {
8803 // // TODO(brianwilkerson) This appears to be of the form "var type v ariable". We should do 8022 // // TODO(brianwilkerson) This appears to be of the form "var type v ariable". We should do
8804 // // a better job of recovering in this case. 8023 // // a better job of recovering in this case.
8805 // } 8024 // }
8806 // } 8025 // }
8807 Token semicolon = _expect(TokenType.SEMICOLON); 8026 Token semicolon = _expect(TokenType.SEMICOLON);
8808 return new VariableDeclarationStatement(variableList, semicolon); 8027 return new VariableDeclarationStatement(variableList, semicolon);
8809 } 8028 }
8810 8029
8811 /** 8030 /**
8812 * Parse a variable declaration statement. 8031 * Parse a variable declaration statement.
8813 * 8032 *
8814 * <pre> 8033 * <pre>
8815 * variableDeclarationStatement ::= 8034 * variableDeclarationStatement ::=
8816 * variableDeclarationList ';' 8035 * variableDeclarationList ';'
8817 * </pre> 8036 * </pre>
8818 * 8037 *
8819 * @param commentAndMetadata the metadata to be associated with the variable d eclaration 8038 * @param commentAndMetadata the metadata to be associated with the variable d eclaration
8820 * statement, or `null` if there is no attempt at parsing the comment and metadata 8039 * statement, or `null` if there is no attempt at parsing the comment and metadata
8821 * @param keyword the token representing the 'final', 'const' or 'var' keyword , or `null` if 8040 * @param keyword the token representing the 'final', 'const' or 'var' keyword , or `null` if
8822 * there is no keyword 8041 * there is no keyword
8823 * @param type the type of the variables in the list 8042 * @param type the type of the variables in the list
8824 * @return the variable declaration statement that was parsed 8043 * @return the variable declaration statement that was parsed
8825 */ 8044 */
8826 VariableDeclarationStatement 8045 VariableDeclarationStatement _parseVariableDeclarationStatementAfterType(
8827 _parseVariableDeclarationStatementAfterType(CommentAndMetadata commentAndM etadata, 8046 CommentAndMetadata commentAndMetadata, Token keyword, TypeName type) {
8828 Token keyword, TypeName type) {
8829 VariableDeclarationList variableList = 8047 VariableDeclarationList variableList =
8830 _parseVariableDeclarationListAfterType(commentAndMetadata, keyword, type ); 8048 _parseVariableDeclarationListAfterType(
8049 commentAndMetadata, keyword, type);
8831 Token semicolon = _expect(TokenType.SEMICOLON); 8050 Token semicolon = _expect(TokenType.SEMICOLON);
8832 return new VariableDeclarationStatement(variableList, semicolon); 8051 return new VariableDeclarationStatement(variableList, semicolon);
8833 } 8052 }
8834 8053
8835 /** 8054 /**
8836 * Parse a while statement. 8055 * Parse a while statement.
8837 * 8056 *
8838 * <pre> 8057 * <pre>
8839 * whileStatement ::= 8058 * whileStatement ::=
8840 * 'while' '(' expression ')' statement 8059 * 'while' '(' expression ')' statement
8841 * </pre> 8060 * </pre>
8842 * 8061 *
8843 * @return the while statement that was parsed 8062 * @return the while statement that was parsed
8844 */ 8063 */
8845 Statement _parseWhileStatement() { 8064 Statement _parseWhileStatement() {
8846 bool wasInLoop = _inLoop; 8065 bool wasInLoop = _inLoop;
8847 _inLoop = true; 8066 _inLoop = true;
8848 try { 8067 try {
8849 Token keyword = _expectKeyword(Keyword.WHILE); 8068 Token keyword = _expectKeyword(Keyword.WHILE);
8850 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); 8069 Token leftParenthesis = _expect(TokenType.OPEN_PAREN);
8851 Expression condition = parseExpression2(); 8070 Expression condition = parseExpression2();
8852 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); 8071 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN);
8853 Statement body = parseStatement2(); 8072 Statement body = parseStatement2();
8854 return new WhileStatement( 8073 return new WhileStatement(
8855 keyword, 8074 keyword, leftParenthesis, condition, rightParenthesis, body);
8856 leftParenthesis,
8857 condition,
8858 rightParenthesis,
8859 body);
8860 } finally { 8075 } finally {
8861 _inLoop = wasInLoop; 8076 _inLoop = wasInLoop;
8862 } 8077 }
8863 } 8078 }
8864 8079
8865 /** 8080 /**
8866 * Parse a yield statement. 8081 * Parse a yield statement.
8867 * 8082 *
8868 * <pre> 8083 * <pre>
8869 * yieldStatement ::= 8084 * yieldStatement ::=
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
8931 8146
8932 /** 8147 /**
8933 * Report an error with the given error code and arguments. 8148 * Report an error with the given error code and arguments.
8934 * 8149 *
8935 * @param errorCode the error code of the error to be reported 8150 * @param errorCode the error code of the error to be reported
8936 * @param node the node specifying the location of the error 8151 * @param node the node specifying the location of the error
8937 * @param arguments the arguments to the error, used to compose the error mess age 8152 * @param arguments the arguments to the error, used to compose the error mess age
8938 */ 8153 */
8939 void _reportErrorForNode(ParserErrorCode errorCode, AstNode node, 8154 void _reportErrorForNode(ParserErrorCode errorCode, AstNode node,
8940 [List<Object> arguments]) { 8155 [List<Object> arguments]) {
8941 _reportError( 8156 _reportError(new AnalysisError.con2(
8942 new AnalysisError.con2( 8157 _source, node.offset, node.length, errorCode, arguments));
8943 _source,
8944 node.offset,
8945 node.length,
8946 errorCode,
8947 arguments));
8948 } 8158 }
8949 8159
8950 /** 8160 /**
8951 * Report an error with the given error code and arguments. 8161 * Report an error with the given error code and arguments.
8952 * 8162 *
8953 * @param errorCode the error code of the error to be reported 8163 * @param errorCode the error code of the error to be reported
8954 * @param token the token specifying the location of the error 8164 * @param token the token specifying the location of the error
8955 * @param arguments the arguments to the error, used to compose the error mess age 8165 * @param arguments the arguments to the error, used to compose the error mess age
8956 */ 8166 */
8957 void _reportErrorForToken(ErrorCode errorCode, Token token, 8167 void _reportErrorForToken(ErrorCode errorCode, Token token,
8958 [List<Object> arguments]) { 8168 [List<Object> arguments]) {
8959 if (token.type == TokenType.EOF) { 8169 if (token.type == TokenType.EOF) {
8960 token = token.previous; 8170 token = token.previous;
8961 } 8171 }
8962 _reportError( 8172 _reportError(new AnalysisError.con2(_source, token.offset,
8963 new AnalysisError.con2( 8173 math.max(token.length, 1), errorCode, arguments));
8964 _source,
8965 token.offset,
8966 math.max(token.length, 1),
8967 errorCode,
8968 arguments));
8969 } 8174 }
8970 8175
8971 /** 8176 /**
8972 * Skips a block with all containing blocks. 8177 * Skips a block with all containing blocks.
8973 */ 8178 */
8974 void _skipBlock() { 8179 void _skipBlock() {
8975 Token endToken = (_currentToken as BeginToken).endToken; 8180 Token endToken = (_currentToken as BeginToken).endToken;
8976 if (endToken == null) { 8181 if (endToken == null) {
8977 endToken = _currentToken.next; 8182 endToken = _currentToken.next;
8978 while (!identical(endToken, _currentToken)) { 8183 while (!identical(endToken, _currentToken)) {
8979 _currentToken = endToken; 8184 _currentToken = endToken;
8980 endToken = _currentToken.next; 8185 endToken = _currentToken.next;
8981 } 8186 }
8982 _reportErrorForToken( 8187 _reportErrorForToken(
8983 ParserErrorCode.EXPECTED_TOKEN, 8188 ParserErrorCode.EXPECTED_TOKEN, _currentToken.previous, ["}"]);
8984 _currentToken.previous,
8985 ["}"]);
8986 } else { 8189 } else {
8987 _currentToken = endToken.next; 8190 _currentToken = endToken.next;
8988 } 8191 }
8989 } 8192 }
8990 8193
8991 /** 8194 /**
8992 * Parse the 'final', 'const', 'var' or type preceding a variable declaration, starting at the 8195 * Parse the 'final', 'const', 'var' or type preceding a variable declaration, starting at the
8993 * given token, without actually creating a type or changing the current token . Return the token 8196 * given token, without actually creating a type or changing the current token . Return the token
8994 * following the type that was parsed, or `null` if the given token is not the first token 8197 * following the type that was parsed, or `null` if the given token is not the first token
8995 * in a valid type. 8198 * in a valid type.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
9080 return null; 8283 return null;
9081 } 8284 }
9082 Token next = startToken.next; 8285 Token next = startToken.next;
9083 if (_tokenMatches(next, TokenType.CLOSE_PAREN)) { 8286 if (_tokenMatches(next, TokenType.CLOSE_PAREN)) {
9084 return next.next; 8287 return next.next;
9085 } 8288 }
9086 // 8289 //
9087 // Look to see whether the token after the open parenthesis is something 8290 // Look to see whether the token after the open parenthesis is something
9088 // that should only occur at the beginning of a parameter list. 8291 // that should only occur at the beginning of a parameter list.
9089 // 8292 //
9090 if (next.matchesAny( 8293 if (next.matchesAny([
9091 [TokenType.AT, TokenType.OPEN_SQUARE_BRACKET, TokenType.OPEN_CURLY_BRACK ET]) || 8294 TokenType.AT,
8295 TokenType.OPEN_SQUARE_BRACKET,
8296 TokenType.OPEN_CURLY_BRACKET
8297 ]) ||
9092 _tokenMatchesKeyword(next, Keyword.VOID) || 8298 _tokenMatchesKeyword(next, Keyword.VOID) ||
9093 (_tokenMatchesIdentifier(next) && 8299 (_tokenMatchesIdentifier(next) &&
9094 (next.next.matchesAny([TokenType.COMMA, TokenType.CLOSE_PAREN])))) { 8300 (next.next.matchesAny([TokenType.COMMA, TokenType.CLOSE_PAREN])))) {
9095 return _skipPastMatchingToken(startToken); 8301 return _skipPastMatchingToken(startToken);
9096 } 8302 }
9097 // 8303 //
9098 // Look to see whether the first parameter is a function typed parameter 8304 // Look to see whether the first parameter is a function typed parameter
9099 // without a return type. 8305 // without a return type.
9100 // 8306 //
9101 if (_tokenMatchesIdentifier(next) && 8307 if (_tokenMatchesIdentifier(next) &&
9102 _tokenMatches(next.next, TokenType.OPEN_PAREN)) { 8308 _tokenMatches(next.next, TokenType.OPEN_PAREN)) {
9103 Token afterParameters = _skipFormalParameterList(next.next); 8309 Token afterParameters = _skipFormalParameterList(next.next);
9104 if (afterParameters != null && 8310 if (afterParameters != null &&
9105 (afterParameters.matchesAny([TokenType.COMMA, TokenType.CLOSE_PAREN])) ) { 8311 (afterParameters
8312 .matchesAny([TokenType.COMMA, TokenType.CLOSE_PAREN]))) {
9106 return _skipPastMatchingToken(startToken); 8313 return _skipPastMatchingToken(startToken);
9107 } 8314 }
9108 } 8315 }
9109 // 8316 //
9110 // Look to see whether the first parameter has a type or is a function typed 8317 // Look to see whether the first parameter has a type or is a function typed
9111 // parameter with a return type. 8318 // parameter with a return type.
9112 // 8319 //
9113 Token afterType = _skipFinalConstVarOrType(next); 8320 Token afterType = _skipFinalConstVarOrType(next);
9114 if (afterType == null) { 8321 if (afterType == null) {
9115 return null; 8322 return null;
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
9452 (token as KeywordToken).keyword.isPseudoKeyword); 8659 (token as KeywordToken).keyword.isPseudoKeyword);
9453 8660
9454 /** 8661 /**
9455 * Return `true` if the given token matches the given keyword. 8662 * Return `true` if the given token matches the given keyword.
9456 * 8663 *
9457 * @param token the token being tested 8664 * @param token the token being tested
9458 * @param keyword the keyword that is being tested for 8665 * @param keyword the keyword that is being tested for
9459 * @return `true` if the given token matches the given keyword 8666 * @return `true` if the given token matches the given keyword
9460 */ 8667 */
9461 bool _tokenMatchesKeyword(Token token, Keyword keyword) => 8668 bool _tokenMatchesKeyword(Token token, Keyword keyword) =>
9462 token.type == TokenType.KEYWORD && (token as KeywordToken).keyword == keyw ord; 8669 token.type == TokenType.KEYWORD &&
8670 (token as KeywordToken).keyword == keyword;
9463 8671
9464 /** 8672 /**
9465 * Return `true` if the given token matches the given identifier. 8673 * Return `true` if the given token matches the given identifier.
9466 * 8674 *
9467 * @param token the token being tested 8675 * @param token the token being tested
9468 * @param identifier the identifier that can optionally appear in the current location 8676 * @param identifier the identifier that can optionally appear in the current location
9469 * @return `true` if the current token matches the given identifier 8677 * @return `true` if the current token matches the given identifier
9470 */ 8678 */
9471 bool _tokenMatchesString(Token token, String identifier) => 8679 bool _tokenMatchesString(Token token, String identifier) =>
9472 token.type == TokenType.IDENTIFIER && token.lexeme == identifier; 8680 token.type == TokenType.IDENTIFIER && token.lexeme == identifier;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
9520 // Illegal escape sequence: not enough hex digits 8728 // Illegal escape sequence: not enough hex digits
9521 _reportErrorForCurrentToken(ParserErrorCode.INVALID_HEX_ESCAPE); 8729 _reportErrorForCurrentToken(ParserErrorCode.INVALID_HEX_ESCAPE);
9522 return length; 8730 return length;
9523 } 8731 }
9524 int firstDigit = lexeme.codeUnitAt(currentIndex + 1); 8732 int firstDigit = lexeme.codeUnitAt(currentIndex + 1);
9525 int secondDigit = lexeme.codeUnitAt(currentIndex + 2); 8733 int secondDigit = lexeme.codeUnitAt(currentIndex + 2);
9526 if (!_isHexDigit(firstDigit) || !_isHexDigit(secondDigit)) { 8734 if (!_isHexDigit(firstDigit) || !_isHexDigit(secondDigit)) {
9527 // Illegal escape sequence: invalid hex digit 8735 // Illegal escape sequence: invalid hex digit
9528 _reportErrorForCurrentToken(ParserErrorCode.INVALID_HEX_ESCAPE); 8736 _reportErrorForCurrentToken(ParserErrorCode.INVALID_HEX_ESCAPE);
9529 } else { 8737 } else {
9530 int charCode = 8738 int charCode = (Character.digit(firstDigit, 16) << 4) +
9531 (Character.digit(firstDigit, 16) << 4) +
9532 Character.digit(secondDigit, 16); 8739 Character.digit(secondDigit, 16);
9533 buffer.writeCharCode(charCode); 8740 buffer.writeCharCode(charCode);
9534 } 8741 }
9535 return currentIndex + 3; 8742 return currentIndex + 3;
9536 } else if (currentChar == 0x75) { 8743 } else if (currentChar == 0x75) {
9537 currentIndex++; 8744 currentIndex++;
9538 if (currentIndex >= length) { 8745 if (currentIndex >= length) {
9539 // Illegal escape sequence: not enough hex digits 8746 // Illegal escape sequence: not enough hex digits
9540 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE); 8747 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE);
9541 return length; 8748 return length;
(...skipping 27 matching lines...) Expand all
9569 // Illegal escape sequence: incomplete escape 8776 // Illegal escape sequence: incomplete escape
9570 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE); 8777 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE);
9571 return length; 8778 return length;
9572 } 8779 }
9573 currentChar = lexeme.codeUnitAt(currentIndex); 8780 currentChar = lexeme.codeUnitAt(currentIndex);
9574 } 8781 }
9575 if (digitCount < 1 || digitCount > 6) { 8782 if (digitCount < 1 || digitCount > 6) {
9576 // Illegal escape sequence: not enough or too many hex digits 8783 // Illegal escape sequence: not enough or too many hex digits
9577 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE); 8784 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE);
9578 } 8785 }
9579 _appendScalarValue( 8786 _appendScalarValue(buffer, lexeme.substring(index, currentIndex + 1),
9580 buffer, 8787 value, index, currentIndex);
9581 lexeme.substring(index, currentIndex + 1),
9582 value,
9583 index,
9584 currentIndex);
9585 return currentIndex + 1; 8788 return currentIndex + 1;
9586 } else { 8789 } else {
9587 if (currentIndex + 3 >= length) { 8790 if (currentIndex + 3 >= length) {
9588 // Illegal escape sequence: not enough hex digits 8791 // Illegal escape sequence: not enough hex digits
9589 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE); 8792 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE);
9590 return length; 8793 return length;
9591 } 8794 }
9592 int firstDigit = currentChar; 8795 int firstDigit = currentChar;
9593 int secondDigit = lexeme.codeUnitAt(currentIndex + 1); 8796 int secondDigit = lexeme.codeUnitAt(currentIndex + 1);
9594 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2); 8797 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2);
9595 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3); 8798 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3);
9596 if (!_isHexDigit(firstDigit) || 8799 if (!_isHexDigit(firstDigit) ||
9597 !_isHexDigit(secondDigit) || 8800 !_isHexDigit(secondDigit) ||
9598 !_isHexDigit(thirdDigit) || 8801 !_isHexDigit(thirdDigit) ||
9599 !_isHexDigit(fourthDigit)) { 8802 !_isHexDigit(fourthDigit)) {
9600 // Illegal escape sequence: invalid hex digits 8803 // Illegal escape sequence: invalid hex digits
9601 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE); 8804 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE);
9602 } else { 8805 } else {
9603 _appendScalarValue( 8806 _appendScalarValue(buffer, lexeme.substring(index, currentIndex + 1),
9604 buffer,
9605 lexeme.substring(index, currentIndex + 1),
9606 (((((Character.digit(firstDigit, 16) << 4) + 8807 (((((Character.digit(firstDigit, 16) << 4) +
9607 Character.digit(secondDigit, 16)) << 8808 Character.digit(secondDigit, 16)) <<
9608 4) + 8809 4) +
9609 Character.digit(thirdDigit, 16)) << 8810 Character.digit(thirdDigit, 16)) <<
9610 4) + 8811 4) +
9611 Character.digit(fourthDigit, 16), 8812 Character.digit(fourthDigit, 16), index, currentIndex + 3);
9612 index,
9613 currentIndex + 3);
9614 } 8813 }
9615 return currentIndex + 4; 8814 return currentIndex + 4;
9616 } 8815 }
9617 } else { 8816 } else {
9618 buffer.writeCharCode(currentChar); 8817 buffer.writeCharCode(currentChar);
9619 } 8818 }
9620 return currentIndex + 1; 8819 return currentIndex + 1;
9621 } 8820 }
9622 8821
9623 /** 8822 /**
(...skipping 29 matching lines...) Expand all
9653 * 8852 *
9654 * @param modifiers the modifiers being validated 8853 * @param modifiers the modifiers being validated
9655 */ 8854 */
9656 Token _validateModifiersForClass(Modifiers modifiers) { 8855 Token _validateModifiersForClass(Modifiers modifiers) {
9657 _validateModifiersForTopLevelDeclaration(modifiers); 8856 _validateModifiersForTopLevelDeclaration(modifiers);
9658 if (modifiers.constKeyword != null) { 8857 if (modifiers.constKeyword != null) {
9659 _reportErrorForToken(ParserErrorCode.CONST_CLASS, modifiers.constKeyword); 8858 _reportErrorForToken(ParserErrorCode.CONST_CLASS, modifiers.constKeyword);
9660 } 8859 }
9661 if (modifiers.externalKeyword != null) { 8860 if (modifiers.externalKeyword != null) {
9662 _reportErrorForToken( 8861 _reportErrorForToken(
9663 ParserErrorCode.EXTERNAL_CLASS, 8862 ParserErrorCode.EXTERNAL_CLASS, modifiers.externalKeyword);
9664 modifiers.externalKeyword);
9665 } 8863 }
9666 if (modifiers.finalKeyword != null) { 8864 if (modifiers.finalKeyword != null) {
9667 _reportErrorForToken(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword); 8865 _reportErrorForToken(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword);
9668 } 8866 }
9669 if (modifiers.varKeyword != null) { 8867 if (modifiers.varKeyword != null) {
9670 _reportErrorForToken(ParserErrorCode.VAR_CLASS, modifiers.varKeyword); 8868 _reportErrorForToken(ParserErrorCode.VAR_CLASS, modifiers.varKeyword);
9671 } 8869 }
9672 return modifiers.abstractKeyword; 8870 return modifiers.abstractKeyword;
9673 } 8871 }
9674 8872
9675 /** 8873 /**
9676 * Validate that the given set of modifiers is appropriate for a constructor a nd return the 8874 * Validate that the given set of modifiers is appropriate for a constructor a nd return the
9677 * 'const' keyword if there is one. 8875 * 'const' keyword if there is one.
9678 * 8876 *
9679 * @param modifiers the modifiers being validated 8877 * @param modifiers the modifiers being validated
9680 * @return the 'const' or 'final' keyword associated with the constructor 8878 * @return the 'const' or 'final' keyword associated with the constructor
9681 */ 8879 */
9682 Token _validateModifiersForConstructor(Modifiers modifiers) { 8880 Token _validateModifiersForConstructor(Modifiers modifiers) {
9683 if (modifiers.abstractKeyword != null) { 8881 if (modifiers.abstractKeyword != null) {
9684 _reportErrorForToken( 8882 _reportErrorForToken(
9685 ParserErrorCode.ABSTRACT_CLASS_MEMBER, 8883 ParserErrorCode.ABSTRACT_CLASS_MEMBER, modifiers.abstractKeyword);
9686 modifiers.abstractKeyword);
9687 } 8884 }
9688 if (modifiers.finalKeyword != null) { 8885 if (modifiers.finalKeyword != null) {
9689 _reportErrorForToken( 8886 _reportErrorForToken(
9690 ParserErrorCode.FINAL_CONSTRUCTOR, 8887 ParserErrorCode.FINAL_CONSTRUCTOR, modifiers.finalKeyword);
9691 modifiers.finalKeyword);
9692 } 8888 }
9693 if (modifiers.staticKeyword != null) { 8889 if (modifiers.staticKeyword != null) {
9694 _reportErrorForToken( 8890 _reportErrorForToken(
9695 ParserErrorCode.STATIC_CONSTRUCTOR, 8891 ParserErrorCode.STATIC_CONSTRUCTOR, modifiers.staticKeyword);
9696 modifiers.staticKeyword);
9697 } 8892 }
9698 if (modifiers.varKeyword != null) { 8893 if (modifiers.varKeyword != null) {
9699 _reportErrorForToken( 8894 _reportErrorForToken(
9700 ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, 8895 ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, modifiers.varKeyword);
9701 modifiers.varKeyword);
9702 } 8896 }
9703 Token externalKeyword = modifiers.externalKeyword; 8897 Token externalKeyword = modifiers.externalKeyword;
9704 Token constKeyword = modifiers.constKeyword; 8898 Token constKeyword = modifiers.constKeyword;
9705 Token factoryKeyword = modifiers.factoryKeyword; 8899 Token factoryKeyword = modifiers.factoryKeyword;
9706 if (externalKeyword != null && 8900 if (externalKeyword != null &&
9707 constKeyword != null && 8901 constKeyword != null &&
9708 constKeyword.offset < externalKeyword.offset) { 8902 constKeyword.offset < externalKeyword.offset) {
9709 _reportErrorForToken( 8903 _reportErrorForToken(
9710 ParserErrorCode.EXTERNAL_AFTER_CONST, 8904 ParserErrorCode.EXTERNAL_AFTER_CONST, externalKeyword);
9711 externalKeyword);
9712 } 8905 }
9713 if (externalKeyword != null && 8906 if (externalKeyword != null &&
9714 factoryKeyword != null && 8907 factoryKeyword != null &&
9715 factoryKeyword.offset < externalKeyword.offset) { 8908 factoryKeyword.offset < externalKeyword.offset) {
9716 _reportErrorForToken( 8909 _reportErrorForToken(
9717 ParserErrorCode.EXTERNAL_AFTER_FACTORY, 8910 ParserErrorCode.EXTERNAL_AFTER_FACTORY, externalKeyword);
9718 externalKeyword);
9719 } 8911 }
9720 return constKeyword; 8912 return constKeyword;
9721 } 8913 }
9722 8914
9723 /** 8915 /**
9724 * Validate that the given set of modifiers is appropriate for a class and ret urn the 'abstract' 8916 * Validate that the given set of modifiers is appropriate for a class and ret urn the 'abstract'
9725 * keyword if there is one. 8917 * keyword if there is one.
9726 * 8918 *
9727 * @param modifiers the modifiers being validated 8919 * @param modifiers the modifiers being validated
9728 */ 8920 */
9729 void _validateModifiersForEnum(Modifiers modifiers) { 8921 void _validateModifiersForEnum(Modifiers modifiers) {
9730 _validateModifiersForTopLevelDeclaration(modifiers); 8922 _validateModifiersForTopLevelDeclaration(modifiers);
9731 if (modifiers.abstractKeyword != null) { 8923 if (modifiers.abstractKeyword != null) {
9732 _reportErrorForToken( 8924 _reportErrorForToken(
9733 ParserErrorCode.ABSTRACT_ENUM, 8925 ParserErrorCode.ABSTRACT_ENUM, modifiers.abstractKeyword);
9734 modifiers.abstractKeyword);
9735 } 8926 }
9736 if (modifiers.constKeyword != null) { 8927 if (modifiers.constKeyword != null) {
9737 _reportErrorForToken(ParserErrorCode.CONST_ENUM, modifiers.constKeyword); 8928 _reportErrorForToken(ParserErrorCode.CONST_ENUM, modifiers.constKeyword);
9738 } 8929 }
9739 if (modifiers.externalKeyword != null) { 8930 if (modifiers.externalKeyword != null) {
9740 _reportErrorForToken( 8931 _reportErrorForToken(
9741 ParserErrorCode.EXTERNAL_ENUM, 8932 ParserErrorCode.EXTERNAL_ENUM, modifiers.externalKeyword);
9742 modifiers.externalKeyword);
9743 } 8933 }
9744 if (modifiers.finalKeyword != null) { 8934 if (modifiers.finalKeyword != null) {
9745 _reportErrorForToken(ParserErrorCode.FINAL_ENUM, modifiers.finalKeyword); 8935 _reportErrorForToken(ParserErrorCode.FINAL_ENUM, modifiers.finalKeyword);
9746 } 8936 }
9747 if (modifiers.varKeyword != null) { 8937 if (modifiers.varKeyword != null) {
9748 _reportErrorForToken(ParserErrorCode.VAR_ENUM, modifiers.varKeyword); 8938 _reportErrorForToken(ParserErrorCode.VAR_ENUM, modifiers.varKeyword);
9749 } 8939 }
9750 } 8940 }
9751 8941
9752 /** 8942 /**
9753 * Validate that the given set of modifiers is appropriate for a field and ret urn the 'final', 8943 * Validate that the given set of modifiers is appropriate for a field and ret urn the 'final',
9754 * 'const' or 'var' keyword if there is one. 8944 * 'const' or 'var' keyword if there is one.
9755 * 8945 *
9756 * @param modifiers the modifiers being validated 8946 * @param modifiers the modifiers being validated
9757 * @return the 'final', 'const' or 'var' keyword associated with the field 8947 * @return the 'final', 'const' or 'var' keyword associated with the field
9758 */ 8948 */
9759 Token _validateModifiersForField(Modifiers modifiers) { 8949 Token _validateModifiersForField(Modifiers modifiers) {
9760 if (modifiers.abstractKeyword != null) { 8950 if (modifiers.abstractKeyword != null) {
9761 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER); 8951 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER);
9762 } 8952 }
9763 if (modifiers.externalKeyword != null) { 8953 if (modifiers.externalKeyword != null) {
9764 _reportErrorForToken( 8954 _reportErrorForToken(
9765 ParserErrorCode.EXTERNAL_FIELD, 8955 ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword);
9766 modifiers.externalKeyword);
9767 } 8956 }
9768 if (modifiers.factoryKeyword != null) { 8957 if (modifiers.factoryKeyword != null) {
9769 _reportErrorForToken( 8958 _reportErrorForToken(
9770 ParserErrorCode.NON_CONSTRUCTOR_FACTORY, 8959 ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKeyword);
9771 modifiers.factoryKeyword);
9772 } 8960 }
9773 Token staticKeyword = modifiers.staticKeyword; 8961 Token staticKeyword = modifiers.staticKeyword;
9774 Token constKeyword = modifiers.constKeyword; 8962 Token constKeyword = modifiers.constKeyword;
9775 Token finalKeyword = modifiers.finalKeyword; 8963 Token finalKeyword = modifiers.finalKeyword;
9776 Token varKeyword = modifiers.varKeyword; 8964 Token varKeyword = modifiers.varKeyword;
9777 if (constKeyword != null) { 8965 if (constKeyword != null) {
9778 if (finalKeyword != null) { 8966 if (finalKeyword != null) {
9779 _reportErrorForToken(ParserErrorCode.CONST_AND_FINAL, finalKeyword); 8967 _reportErrorForToken(ParserErrorCode.CONST_AND_FINAL, finalKeyword);
9780 } 8968 }
9781 if (varKeyword != null) { 8969 if (varKeyword != null) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
9821 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method. 9009 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method.
9822 * 9010 *
9823 * @param modifiers the modifiers being validated 9011 * @param modifiers the modifiers being validated
9824 */ 9012 */
9825 void _validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) { 9013 void _validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) {
9826 if (modifiers.abstractKeyword != null) { 9014 if (modifiers.abstractKeyword != null) {
9827 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER); 9015 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER);
9828 } 9016 }
9829 if (modifiers.constKeyword != null) { 9017 if (modifiers.constKeyword != null) {
9830 _reportErrorForToken( 9018 _reportErrorForToken(
9831 ParserErrorCode.CONST_METHOD, 9019 ParserErrorCode.CONST_METHOD, modifiers.constKeyword);
9832 modifiers.constKeyword);
9833 } 9020 }
9834 if (modifiers.factoryKeyword != null) { 9021 if (modifiers.factoryKeyword != null) {
9835 _reportErrorForToken( 9022 _reportErrorForToken(
9836 ParserErrorCode.NON_CONSTRUCTOR_FACTORY, 9023 ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKeyword);
9837 modifiers.factoryKeyword);
9838 } 9024 }
9839 if (modifiers.finalKeyword != null) { 9025 if (modifiers.finalKeyword != null) {
9840 _reportErrorForToken( 9026 _reportErrorForToken(
9841 ParserErrorCode.FINAL_METHOD, 9027 ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword);
9842 modifiers.finalKeyword);
9843 } 9028 }
9844 if (modifiers.varKeyword != null) { 9029 if (modifiers.varKeyword != null) {
9845 _reportErrorForToken( 9030 _reportErrorForToken(
9846 ParserErrorCode.VAR_RETURN_TYPE, 9031 ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword);
9847 modifiers.varKeyword);
9848 } 9032 }
9849 Token externalKeyword = modifiers.externalKeyword; 9033 Token externalKeyword = modifiers.externalKeyword;
9850 Token staticKeyword = modifiers.staticKeyword; 9034 Token staticKeyword = modifiers.staticKeyword;
9851 if (externalKeyword != null && 9035 if (externalKeyword != null &&
9852 staticKeyword != null && 9036 staticKeyword != null &&
9853 staticKeyword.offset < externalKeyword.offset) { 9037 staticKeyword.offset < externalKeyword.offset) {
9854 _reportErrorForToken( 9038 _reportErrorForToken(
9855 ParserErrorCode.EXTERNAL_AFTER_STATIC, 9039 ParserErrorCode.EXTERNAL_AFTER_STATIC, externalKeyword);
9856 externalKeyword);
9857 } 9040 }
9858 } 9041 }
9859 9042
9860 /** 9043 /**
9861 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method. 9044 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method.
9862 * 9045 *
9863 * @param modifiers the modifiers being validated 9046 * @param modifiers the modifiers being validated
9864 */ 9047 */
9865 void _validateModifiersForOperator(Modifiers modifiers) { 9048 void _validateModifiersForOperator(Modifiers modifiers) {
9866 if (modifiers.abstractKeyword != null) { 9049 if (modifiers.abstractKeyword != null) {
9867 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER); 9050 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER);
9868 } 9051 }
9869 if (modifiers.constKeyword != null) { 9052 if (modifiers.constKeyword != null) {
9870 _reportErrorForToken( 9053 _reportErrorForToken(
9871 ParserErrorCode.CONST_METHOD, 9054 ParserErrorCode.CONST_METHOD, modifiers.constKeyword);
9872 modifiers.constKeyword);
9873 } 9055 }
9874 if (modifiers.factoryKeyword != null) { 9056 if (modifiers.factoryKeyword != null) {
9875 _reportErrorForToken( 9057 _reportErrorForToken(
9876 ParserErrorCode.NON_CONSTRUCTOR_FACTORY, 9058 ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKeyword);
9877 modifiers.factoryKeyword);
9878 } 9059 }
9879 if (modifiers.finalKeyword != null) { 9060 if (modifiers.finalKeyword != null) {
9880 _reportErrorForToken( 9061 _reportErrorForToken(
9881 ParserErrorCode.FINAL_METHOD, 9062 ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword);
9882 modifiers.finalKeyword);
9883 } 9063 }
9884 if (modifiers.staticKeyword != null) { 9064 if (modifiers.staticKeyword != null) {
9885 _reportErrorForToken( 9065 _reportErrorForToken(
9886 ParserErrorCode.STATIC_OPERATOR, 9066 ParserErrorCode.STATIC_OPERATOR, modifiers.staticKeyword);
9887 modifiers.staticKeyword);
9888 } 9067 }
9889 if (modifiers.varKeyword != null) { 9068 if (modifiers.varKeyword != null) {
9890 _reportErrorForToken( 9069 _reportErrorForToken(
9891 ParserErrorCode.VAR_RETURN_TYPE, 9070 ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword);
9892 modifiers.varKeyword);
9893 } 9071 }
9894 } 9072 }
9895 9073
9896 /** 9074 /**
9897 * Validate that the given set of modifiers is appropriate for a top-level dec laration. 9075 * Validate that the given set of modifiers is appropriate for a top-level dec laration.
9898 * 9076 *
9899 * @param modifiers the modifiers being validated 9077 * @param modifiers the modifiers being validated
9900 */ 9078 */
9901 void _validateModifiersForTopLevelDeclaration(Modifiers modifiers) { 9079 void _validateModifiersForTopLevelDeclaration(Modifiers modifiers) {
9902 if (modifiers.factoryKeyword != null) { 9080 if (modifiers.factoryKeyword != null) {
9903 _reportErrorForToken( 9081 _reportErrorForToken(ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION,
9904 ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION,
9905 modifiers.factoryKeyword); 9082 modifiers.factoryKeyword);
9906 } 9083 }
9907 if (modifiers.staticKeyword != null) { 9084 if (modifiers.staticKeyword != null) {
9908 _reportErrorForToken( 9085 _reportErrorForToken(ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION,
9909 ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION,
9910 modifiers.staticKeyword); 9086 modifiers.staticKeyword);
9911 } 9087 }
9912 } 9088 }
9913 9089
9914 /** 9090 /**
9915 * Validate that the given set of modifiers is appropriate for a top-level fun ction. 9091 * Validate that the given set of modifiers is appropriate for a top-level fun ction.
9916 * 9092 *
9917 * @param modifiers the modifiers being validated 9093 * @param modifiers the modifiers being validated
9918 */ 9094 */
9919 void _validateModifiersForTopLevelFunction(Modifiers modifiers) { 9095 void _validateModifiersForTopLevelFunction(Modifiers modifiers) {
9920 _validateModifiersForTopLevelDeclaration(modifiers); 9096 _validateModifiersForTopLevelDeclaration(modifiers);
9921 if (modifiers.abstractKeyword != null) { 9097 if (modifiers.abstractKeyword != null) {
9922 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION); 9098 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION);
9923 } 9099 }
9924 if (modifiers.constKeyword != null) { 9100 if (modifiers.constKeyword != null) {
9925 _reportErrorForToken(ParserErrorCode.CONST_CLASS, modifiers.constKeyword); 9101 _reportErrorForToken(ParserErrorCode.CONST_CLASS, modifiers.constKeyword);
9926 } 9102 }
9927 if (modifiers.finalKeyword != null) { 9103 if (modifiers.finalKeyword != null) {
9928 _reportErrorForToken(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword); 9104 _reportErrorForToken(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword);
9929 } 9105 }
9930 if (modifiers.varKeyword != null) { 9106 if (modifiers.varKeyword != null) {
9931 _reportErrorForToken( 9107 _reportErrorForToken(
9932 ParserErrorCode.VAR_RETURN_TYPE, 9108 ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword);
9933 modifiers.varKeyword);
9934 } 9109 }
9935 } 9110 }
9936 9111
9937 /** 9112 /**
9938 * Validate that the given set of modifiers is appropriate for a field and ret urn the 'final', 9113 * Validate that the given set of modifiers is appropriate for a field and ret urn the 'final',
9939 * 'const' or 'var' keyword if there is one. 9114 * 'const' or 'var' keyword if there is one.
9940 * 9115 *
9941 * @param modifiers the modifiers being validated 9116 * @param modifiers the modifiers being validated
9942 * @return the 'final', 'const' or 'var' keyword associated with the field 9117 * @return the 'final', 'const' or 'var' keyword associated with the field
9943 */ 9118 */
9944 Token _validateModifiersForTopLevelVariable(Modifiers modifiers) { 9119 Token _validateModifiersForTopLevelVariable(Modifiers modifiers) {
9945 _validateModifiersForTopLevelDeclaration(modifiers); 9120 _validateModifiersForTopLevelDeclaration(modifiers);
9946 if (modifiers.abstractKeyword != null) { 9121 if (modifiers.abstractKeyword != null) {
9947 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE); 9122 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE);
9948 } 9123 }
9949 if (modifiers.externalKeyword != null) { 9124 if (modifiers.externalKeyword != null) {
9950 _reportErrorForToken( 9125 _reportErrorForToken(
9951 ParserErrorCode.EXTERNAL_FIELD, 9126 ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword);
9952 modifiers.externalKeyword);
9953 } 9127 }
9954 Token constKeyword = modifiers.constKeyword; 9128 Token constKeyword = modifiers.constKeyword;
9955 Token finalKeyword = modifiers.finalKeyword; 9129 Token finalKeyword = modifiers.finalKeyword;
9956 Token varKeyword = modifiers.varKeyword; 9130 Token varKeyword = modifiers.varKeyword;
9957 if (constKeyword != null) { 9131 if (constKeyword != null) {
9958 if (finalKeyword != null) { 9132 if (finalKeyword != null) {
9959 _reportErrorForToken(ParserErrorCode.CONST_AND_FINAL, finalKeyword); 9133 _reportErrorForToken(ParserErrorCode.CONST_AND_FINAL, finalKeyword);
9960 } 9134 }
9961 if (varKeyword != null) { 9135 if (varKeyword != null) {
9962 _reportErrorForToken(ParserErrorCode.CONST_AND_VAR, varKeyword); 9136 _reportErrorForToken(ParserErrorCode.CONST_AND_VAR, varKeyword);
9963 } 9137 }
9964 } else if (finalKeyword != null) { 9138 } else if (finalKeyword != null) {
9965 if (varKeyword != null) { 9139 if (varKeyword != null) {
9966 _reportErrorForToken(ParserErrorCode.FINAL_AND_VAR, varKeyword); 9140 _reportErrorForToken(ParserErrorCode.FINAL_AND_VAR, varKeyword);
9967 } 9141 }
9968 } 9142 }
9969 return Token.lexicallyFirst([constKeyword, finalKeyword, varKeyword]); 9143 return Token.lexicallyFirst([constKeyword, finalKeyword, varKeyword]);
9970 } 9144 }
9971 9145
9972 /** 9146 /**
9973 * Validate that the given set of modifiers is appropriate for a class and ret urn the 'abstract' 9147 * Validate that the given set of modifiers is appropriate for a class and ret urn the 'abstract'
9974 * keyword if there is one. 9148 * keyword if there is one.
9975 * 9149 *
9976 * @param modifiers the modifiers being validated 9150 * @param modifiers the modifiers being validated
9977 */ 9151 */
9978 void _validateModifiersForTypedef(Modifiers modifiers) { 9152 void _validateModifiersForTypedef(Modifiers modifiers) {
9979 _validateModifiersForTopLevelDeclaration(modifiers); 9153 _validateModifiersForTopLevelDeclaration(modifiers);
9980 if (modifiers.abstractKeyword != null) { 9154 if (modifiers.abstractKeyword != null) {
9981 _reportErrorForToken( 9155 _reportErrorForToken(
9982 ParserErrorCode.ABSTRACT_TYPEDEF, 9156 ParserErrorCode.ABSTRACT_TYPEDEF, modifiers.abstractKeyword);
9983 modifiers.abstractKeyword);
9984 } 9157 }
9985 if (modifiers.constKeyword != null) { 9158 if (modifiers.constKeyword != null) {
9986 _reportErrorForToken( 9159 _reportErrorForToken(
9987 ParserErrorCode.CONST_TYPEDEF, 9160 ParserErrorCode.CONST_TYPEDEF, modifiers.constKeyword);
9988 modifiers.constKeyword);
9989 } 9161 }
9990 if (modifiers.externalKeyword != null) { 9162 if (modifiers.externalKeyword != null) {
9991 _reportErrorForToken( 9163 _reportErrorForToken(
9992 ParserErrorCode.EXTERNAL_TYPEDEF, 9164 ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.externalKeyword);
9993 modifiers.externalKeyword);
9994 } 9165 }
9995 if (modifiers.finalKeyword != null) { 9166 if (modifiers.finalKeyword != null) {
9996 _reportErrorForToken( 9167 _reportErrorForToken(
9997 ParserErrorCode.FINAL_TYPEDEF, 9168 ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword);
9998 modifiers.finalKeyword);
9999 } 9169 }
10000 if (modifiers.varKeyword != null) { 9170 if (modifiers.varKeyword != null) {
10001 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword); 9171 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword);
10002 } 9172 }
10003 } 9173 }
10004 } 9174 }
10005 /** 9175 /**
10006 * Instances of the class `SyntheticKeywordToken` implement a synthetic keyword token. 9176 * Instances of the class `SyntheticKeywordToken` implement a synthetic keyword token.
10007 */ 9177 */
10008 class Parser_SyntheticKeywordToken extends KeywordToken { 9178 class Parser_SyntheticKeywordToken extends KeywordToken {
10009 /** 9179 /**
10010 * Initialize a newly created token to represent the given keyword. 9180 * Initialize a newly created token to represent the given keyword.
10011 * 9181 *
10012 * @param keyword the keyword being represented by this token 9182 * @param keyword the keyword being represented by this token
10013 * @param offset the offset from the beginning of the file to the first charac ter in the token 9183 * @param offset the offset from the beginning of the file to the first charac ter in the token
10014 */ 9184 */
10015 Parser_SyntheticKeywordToken(Keyword keyword, int offset) 9185 Parser_SyntheticKeywordToken(Keyword keyword, int offset)
10016 : super(keyword, offset); 9186 : super(keyword, offset);
10017 9187
10018 @override 9188 @override
10019 int get length => 0; 9189 int get length => 0;
10020 9190
10021 @override 9191 @override
10022 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); 9192 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset);
10023 } 9193 }
10024 9194
10025
10026 /** 9195 /**
10027 * The enumeration `ParserErrorCode` defines the error codes used for errors 9196 * The enumeration `ParserErrorCode` defines the error codes used for errors
10028 * detected by the parser. The convention for this class is for the name of the 9197 * detected by the parser. The convention for this class is for the name of the
10029 * error code to indicate the problem that caused the error to be generated and 9198 * error code to indicate the problem that caused the error to be generated and
10030 * for the error message to explain what is wrong and, when appropriate, how the 9199 * for the error message to explain what is wrong and, when appropriate, how the
10031 * problem can be corrected. 9200 * problem can be corrected.
10032 */ 9201 */
10033 class ParserErrorCode extends ErrorCode { 9202 class ParserErrorCode extends ErrorCode {
10034 static const ParserErrorCode ABSTRACT_CLASS_MEMBER = const ParserErrorCode( 9203 static const ParserErrorCode ABSTRACT_CLASS_MEMBER = const ParserErrorCode(
10035 'ABSTRACT_CLASS_MEMBER', 9204 'ABSTRACT_CLASS_MEMBER',
10036 "Members of classes cannot be declared to be 'abstract'"); 9205 "Members of classes cannot be declared to be 'abstract'");
10037 9206
10038 static const ParserErrorCode ABSTRACT_ENUM = const ParserErrorCode( 9207 static const ParserErrorCode ABSTRACT_ENUM = const ParserErrorCode(
10039 'ABSTRACT_ENUM', 9208 'ABSTRACT_ENUM', "Enums cannot be declared to be 'abstract'");
10040 "Enums cannot be declared to be 'abstract'");
10041 9209
10042 static const ParserErrorCode ABSTRACT_STATIC_METHOD = const ParserErrorCode( 9210 static const ParserErrorCode ABSTRACT_STATIC_METHOD = const ParserErrorCode(
10043 'ABSTRACT_STATIC_METHOD', 9211 'ABSTRACT_STATIC_METHOD',
10044 "Static methods cannot be declared to be 'abstract'"); 9212 "Static methods cannot be declared to be 'abstract'");
10045 9213
10046 static const ParserErrorCode ABSTRACT_TOP_LEVEL_FUNCTION = 9214 static const ParserErrorCode ABSTRACT_TOP_LEVEL_FUNCTION =
10047 const ParserErrorCode( 9215 const ParserErrorCode('ABSTRACT_TOP_LEVEL_FUNCTION',
10048 'ABSTRACT_TOP_LEVEL_FUNCTION',
10049 "Top-level functions cannot be declared to be 'abstract'"); 9216 "Top-level functions cannot be declared to be 'abstract'");
10050 9217
10051 static const ParserErrorCode ABSTRACT_TOP_LEVEL_VARIABLE = 9218 static const ParserErrorCode ABSTRACT_TOP_LEVEL_VARIABLE =
10052 const ParserErrorCode( 9219 const ParserErrorCode('ABSTRACT_TOP_LEVEL_VARIABLE',
10053 'ABSTRACT_TOP_LEVEL_VARIABLE',
10054 "Top-level variables cannot be declared to be 'abstract'"); 9220 "Top-level variables cannot be declared to be 'abstract'");
10055 9221
10056 static const ParserErrorCode ABSTRACT_TYPEDEF = const ParserErrorCode( 9222 static const ParserErrorCode ABSTRACT_TYPEDEF = const ParserErrorCode(
10057 'ABSTRACT_TYPEDEF', 9223 'ABSTRACT_TYPEDEF', "Type aliases cannot be declared to be 'abstract'");
10058 "Type aliases cannot be declared to be 'abstract'");
10059 9224
10060 static const ParserErrorCode ANNOTATION_ON_ENUM_CONSTANT = 9225 static const ParserErrorCode ANNOTATION_ON_ENUM_CONSTANT =
10061 const ParserErrorCode( 9226 const ParserErrorCode('ANNOTATION_ON_ENUM_CONSTANT',
10062 'ANNOTATION_ON_ENUM_CONSTANT',
10063 "Enum constants cannot have annotations"); 9227 "Enum constants cannot have annotations");
10064 9228
10065 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_ASSIGNMENT = 9229 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_ASSIGNMENT =
10066 const ParserErrorCode( 9230 const ParserErrorCode('ASSERT_DOES_NOT_TAKE_ASSIGNMENT',
10067 'ASSERT_DOES_NOT_TAKE_ASSIGNMENT',
10068 "Assert cannot be called on an assignment"); 9231 "Assert cannot be called on an assignment");
10069 9232
10070 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_CASCADE = 9233 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_CASCADE =
10071 const ParserErrorCode( 9234 const ParserErrorCode(
10072 'ASSERT_DOES_NOT_TAKE_CASCADE', 9235 'ASSERT_DOES_NOT_TAKE_CASCADE', "Assert cannot be called on cascade");
10073 "Assert cannot be called on cascade");
10074 9236
10075 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_THROW = 9237 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_THROW =
10076 const ParserErrorCode( 9238 const ParserErrorCode(
10077 'ASSERT_DOES_NOT_TAKE_THROW', 9239 'ASSERT_DOES_NOT_TAKE_THROW', "Assert cannot be called on throws");
10078 "Assert cannot be called on throws");
10079 9240
10080 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_RETHROW = 9241 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_RETHROW =
10081 const ParserErrorCode( 9242 const ParserErrorCode('ASSERT_DOES_NOT_TAKE_RETHROW',
10082 'ASSERT_DOES_NOT_TAKE_RETHROW',
10083 "Assert cannot be called on rethrows"); 9243 "Assert cannot be called on rethrows");
10084 9244
10085 /** 9245 /**
10086 * 16.32 Identifier Reference: It is a compile-time error if any of the 9246 * 16.32 Identifier Reference: It is a compile-time error if any of the
10087 * identifiers async, await, or yield is used as an identifier in a function 9247 * identifiers async, await, or yield is used as an identifier in a function
10088 * body marked with either async, async*, or sync*. 9248 * body marked with either async, async*, or sync*.
10089 */ 9249 */
10090 static const ParserErrorCode ASYNC_KEYWORD_USED_AS_IDENTIFIER = 9250 static const ParserErrorCode ASYNC_KEYWORD_USED_AS_IDENTIFIER =
10091 const ParserErrorCode( 9251 const ParserErrorCode('ASYNC_KEYWORD_USED_AS_IDENTIFIER',
10092 'ASYNC_KEYWORD_USED_AS_IDENTIFIER',
10093 "The keywords 'async', 'await', and 'yield' may not be used as identif iers in an asynchronous or generator function."); 9252 "The keywords 'async', 'await', and 'yield' may not be used as identif iers in an asynchronous or generator function.");
10094 9253
10095 static const ParserErrorCode BREAK_OUTSIDE_OF_LOOP = const ParserErrorCode( 9254 static const ParserErrorCode BREAK_OUTSIDE_OF_LOOP = const ParserErrorCode(
10096 'BREAK_OUTSIDE_OF_LOOP', 9255 'BREAK_OUTSIDE_OF_LOOP',
10097 "A break statement cannot be used outside of a loop or switch statement"); 9256 "A break statement cannot be used outside of a loop or switch statement");
10098 9257
10099 static const ParserErrorCode CLASS_IN_CLASS = const ParserErrorCode( 9258 static const ParserErrorCode CLASS_IN_CLASS = const ParserErrorCode(
10100 'CLASS_IN_CLASS', 9259 'CLASS_IN_CLASS', "Classes cannot be declared inside other classes");
10101 "Classes cannot be declared inside other classes");
10102 9260
10103 static const ParserErrorCode COLON_IN_PLACE_OF_IN = const ParserErrorCode( 9261 static const ParserErrorCode COLON_IN_PLACE_OF_IN = const ParserErrorCode(
10104 'COLON_IN_PLACE_OF_IN', 9262 'COLON_IN_PLACE_OF_IN', "For-in loops use 'in' rather than a colon");
10105 "For-in loops use 'in' rather than a colon");
10106 9263
10107 static const ParserErrorCode CONST_AND_FINAL = const ParserErrorCode( 9264 static const ParserErrorCode CONST_AND_FINAL = const ParserErrorCode(
10108 'CONST_AND_FINAL', 9265 'CONST_AND_FINAL',
10109 "Members cannot be declared to be both 'const' and 'final'"); 9266 "Members cannot be declared to be both 'const' and 'final'");
10110 9267
10111 static const ParserErrorCode CONST_AND_VAR = const ParserErrorCode( 9268 static const ParserErrorCode CONST_AND_VAR = const ParserErrorCode(
10112 'CONST_AND_VAR', 9269 'CONST_AND_VAR',
10113 "Members cannot be declared to be both 'const' and 'var'"); 9270 "Members cannot be declared to be both 'const' and 'var'");
10114 9271
10115 static const ParserErrorCode CONST_CLASS = const ParserErrorCode( 9272 static const ParserErrorCode CONST_CLASS = const ParserErrorCode(
10116 'CONST_CLASS', 9273 'CONST_CLASS', "Classes cannot be declared to be 'const'");
10117 "Classes cannot be declared to be 'const'");
10118 9274
10119 static const ParserErrorCode CONST_CONSTRUCTOR_WITH_BODY = 9275 static const ParserErrorCode CONST_CONSTRUCTOR_WITH_BODY =
10120 const ParserErrorCode( 9276 const ParserErrorCode('CONST_CONSTRUCTOR_WITH_BODY',
10121 'CONST_CONSTRUCTOR_WITH_BODY',
10122 "'const' constructors cannot have a body"); 9277 "'const' constructors cannot have a body");
10123 9278
10124 static const ParserErrorCode CONST_ENUM = 9279 static const ParserErrorCode CONST_ENUM = const ParserErrorCode(
10125 const ParserErrorCode('CONST_ENUM', "Enums cannot be declared to be 'const '"); 9280 'CONST_ENUM', "Enums cannot be declared to be 'const'");
10126 9281
10127 static const ParserErrorCode CONST_FACTORY = const ParserErrorCode( 9282 static const ParserErrorCode CONST_FACTORY = const ParserErrorCode(
10128 'CONST_FACTORY', 9283 'CONST_FACTORY',
10129 "Only redirecting factory constructors can be declared to be 'const'"); 9284 "Only redirecting factory constructors can be declared to be 'const'");
10130 9285
10131 static const ParserErrorCode CONST_METHOD = const ParserErrorCode( 9286 static const ParserErrorCode CONST_METHOD = const ParserErrorCode(
10132 'CONST_METHOD', 9287 'CONST_METHOD',
10133 "Getters, setters and methods cannot be declared to be 'const'"); 9288 "Getters, setters and methods cannot be declared to be 'const'");
10134 9289
10135 static const ParserErrorCode CONST_TYPEDEF = const ParserErrorCode( 9290 static const ParserErrorCode CONST_TYPEDEF = const ParserErrorCode(
10136 'CONST_TYPEDEF', 9291 'CONST_TYPEDEF', "Type aliases cannot be declared to be 'const'");
10137 "Type aliases cannot be declared to be 'const'");
10138 9292
10139 static const ParserErrorCode CONSTRUCTOR_WITH_RETURN_TYPE = 9293 static const ParserErrorCode CONSTRUCTOR_WITH_RETURN_TYPE =
10140 const ParserErrorCode( 9294 const ParserErrorCode('CONSTRUCTOR_WITH_RETURN_TYPE',
10141 'CONSTRUCTOR_WITH_RETURN_TYPE',
10142 "Constructors cannot have a return type"); 9295 "Constructors cannot have a return type");
10143 9296
10144 static const ParserErrorCode CONTINUE_OUTSIDE_OF_LOOP = const ParserErrorCode( 9297 static const ParserErrorCode CONTINUE_OUTSIDE_OF_LOOP = const ParserErrorCode(
10145 'CONTINUE_OUTSIDE_OF_LOOP', 9298 'CONTINUE_OUTSIDE_OF_LOOP',
10146 "A continue statement cannot be used outside of a loop or switch statement "); 9299 "A continue statement cannot be used outside of a loop or switch statement ");
10147 9300
10148 static const ParserErrorCode CONTINUE_WITHOUT_LABEL_IN_CASE = 9301 static const ParserErrorCode CONTINUE_WITHOUT_LABEL_IN_CASE =
10149 const ParserErrorCode( 9302 const ParserErrorCode('CONTINUE_WITHOUT_LABEL_IN_CASE',
10150 'CONTINUE_WITHOUT_LABEL_IN_CASE',
10151 "A continue statement in a switch statement must have a label as a tar get"); 9303 "A continue statement in a switch statement must have a label as a tar get");
10152 9304
10153 static const ParserErrorCode DEPRECATED_CLASS_TYPE_ALIAS = 9305 static const ParserErrorCode DEPRECATED_CLASS_TYPE_ALIAS =
10154 const ParserErrorCode( 9306 const ParserErrorCode('DEPRECATED_CLASS_TYPE_ALIAS',
10155 'DEPRECATED_CLASS_TYPE_ALIAS',
10156 "The 'typedef' mixin application was replaced with 'class'"); 9307 "The 'typedef' mixin application was replaced with 'class'");
10157 9308
10158 static const ParserErrorCode DIRECTIVE_AFTER_DECLARATION = 9309 static const ParserErrorCode DIRECTIVE_AFTER_DECLARATION =
10159 const ParserErrorCode( 9310 const ParserErrorCode('DIRECTIVE_AFTER_DECLARATION',
10160 'DIRECTIVE_AFTER_DECLARATION',
10161 "Directives must appear before any declarations"); 9311 "Directives must appear before any declarations");
10162 9312
10163 static const ParserErrorCode DUPLICATE_LABEL_IN_SWITCH_STATEMENT = 9313 static const ParserErrorCode DUPLICATE_LABEL_IN_SWITCH_STATEMENT =
10164 const ParserErrorCode( 9314 const ParserErrorCode('DUPLICATE_LABEL_IN_SWITCH_STATEMENT',
10165 'DUPLICATE_LABEL_IN_SWITCH_STATEMENT',
10166 "The label {0} was already used in this switch statement"); 9315 "The label {0} was already used in this switch statement");
10167 9316
10168 static const ParserErrorCode DUPLICATED_MODIFIER = const ParserErrorCode( 9317 static const ParserErrorCode DUPLICATED_MODIFIER = const ParserErrorCode(
10169 'DUPLICATED_MODIFIER', 9318 'DUPLICATED_MODIFIER', "The modifier '{0}' was already specified.");
10170 "The modifier '{0}' was already specified.");
10171 9319
10172 static const ParserErrorCode EMPTY_ENUM_BODY = const ParserErrorCode( 9320 static const ParserErrorCode EMPTY_ENUM_BODY = const ParserErrorCode(
10173 'EMPTY_ENUM_BODY', 9321 'EMPTY_ENUM_BODY', "An enum must declare at least one constant name");
10174 "An enum must declare at least one constant name");
10175 9322
10176 static const ParserErrorCode EQUALITY_CANNOT_BE_EQUALITY_OPERAND = 9323 static const ParserErrorCode EQUALITY_CANNOT_BE_EQUALITY_OPERAND =
10177 const ParserErrorCode( 9324 const ParserErrorCode('EQUALITY_CANNOT_BE_EQUALITY_OPERAND',
10178 'EQUALITY_CANNOT_BE_EQUALITY_OPERAND',
10179 "Equality expression cannot be operand of another equality expression. "); 9325 "Equality expression cannot be operand of another equality expression. ");
10180 9326
10181 static const ParserErrorCode EXPECTED_CASE_OR_DEFAULT = const ParserErrorCode( 9327 static const ParserErrorCode EXPECTED_CASE_OR_DEFAULT = const ParserErrorCode(
10182 'EXPECTED_CASE_OR_DEFAULT', 9328 'EXPECTED_CASE_OR_DEFAULT', "Expected 'case' or 'default'");
10183 "Expected 'case' or 'default'");
10184 9329
10185 static const ParserErrorCode EXPECTED_CLASS_MEMBER = 9330 static const ParserErrorCode EXPECTED_CLASS_MEMBER =
10186 const ParserErrorCode('EXPECTED_CLASS_MEMBER', "Expected a class member"); 9331 const ParserErrorCode('EXPECTED_CLASS_MEMBER', "Expected a class member");
10187 9332
10188 static const ParserErrorCode EXPECTED_EXECUTABLE = const ParserErrorCode( 9333 static const ParserErrorCode EXPECTED_EXECUTABLE = const ParserErrorCode(
10189 'EXPECTED_EXECUTABLE', 9334 'EXPECTED_EXECUTABLE',
10190 "Expected a method, getter, setter or operator declaration"); 9335 "Expected a method, getter, setter or operator declaration");
10191 9336
10192 static const ParserErrorCode EXPECTED_LIST_OR_MAP_LITERAL = 9337 static const ParserErrorCode EXPECTED_LIST_OR_MAP_LITERAL =
10193 const ParserErrorCode( 9338 const ParserErrorCode(
10194 'EXPECTED_LIST_OR_MAP_LITERAL', 9339 'EXPECTED_LIST_OR_MAP_LITERAL', "Expected a list or map literal");
10195 "Expected a list or map literal");
10196 9340
10197 static const ParserErrorCode EXPECTED_STRING_LITERAL = 9341 static const ParserErrorCode EXPECTED_STRING_LITERAL = const ParserErrorCode(
10198 const ParserErrorCode('EXPECTED_STRING_LITERAL', "Expected a string litera l"); 9342 'EXPECTED_STRING_LITERAL', "Expected a string literal");
10199 9343
10200 static const ParserErrorCode EXPECTED_TOKEN = 9344 static const ParserErrorCode EXPECTED_TOKEN =
10201 const ParserErrorCode('EXPECTED_TOKEN', "Expected to find '{0}'"); 9345 const ParserErrorCode('EXPECTED_TOKEN', "Expected to find '{0}'");
10202 9346
10203 static const ParserErrorCode EXPECTED_TYPE_NAME = 9347 static const ParserErrorCode EXPECTED_TYPE_NAME =
10204 const ParserErrorCode('EXPECTED_TYPE_NAME', "Expected a type name"); 9348 const ParserErrorCode('EXPECTED_TYPE_NAME', "Expected a type name");
10205 9349
10206 static const ParserErrorCode EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE = 9350 static const ParserErrorCode EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE =
10207 const ParserErrorCode( 9351 const ParserErrorCode('EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
10208 'EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
10209 "Export directives must preceed part directives"); 9352 "Export directives must preceed part directives");
10210 9353
10211 static const ParserErrorCode EXTERNAL_AFTER_CONST = const ParserErrorCode( 9354 static const ParserErrorCode EXTERNAL_AFTER_CONST = const ParserErrorCode(
10212 'EXTERNAL_AFTER_CONST', 9355 'EXTERNAL_AFTER_CONST',
10213 "The modifier 'external' should be before the modifier 'const'"); 9356 "The modifier 'external' should be before the modifier 'const'");
10214 9357
10215 static const ParserErrorCode EXTERNAL_AFTER_FACTORY = const ParserErrorCode( 9358 static const ParserErrorCode EXTERNAL_AFTER_FACTORY = const ParserErrorCode(
10216 'EXTERNAL_AFTER_FACTORY', 9359 'EXTERNAL_AFTER_FACTORY',
10217 "The modifier 'external' should be before the modifier 'factory'"); 9360 "The modifier 'external' should be before the modifier 'factory'");
10218 9361
10219 static const ParserErrorCode EXTERNAL_AFTER_STATIC = const ParserErrorCode( 9362 static const ParserErrorCode EXTERNAL_AFTER_STATIC = const ParserErrorCode(
10220 'EXTERNAL_AFTER_STATIC', 9363 'EXTERNAL_AFTER_STATIC',
10221 "The modifier 'external' should be before the modifier 'static'"); 9364 "The modifier 'external' should be before the modifier 'static'");
10222 9365
10223 static const ParserErrorCode EXTERNAL_CLASS = const ParserErrorCode( 9366 static const ParserErrorCode EXTERNAL_CLASS = const ParserErrorCode(
10224 'EXTERNAL_CLASS', 9367 'EXTERNAL_CLASS', "Classes cannot be declared to be 'external'");
10225 "Classes cannot be declared to be 'external'");
10226 9368
10227 static const ParserErrorCode EXTERNAL_CONSTRUCTOR_WITH_BODY = 9369 static const ParserErrorCode EXTERNAL_CONSTRUCTOR_WITH_BODY =
10228 const ParserErrorCode( 9370 const ParserErrorCode('EXTERNAL_CONSTRUCTOR_WITH_BODY',
10229 'EXTERNAL_CONSTRUCTOR_WITH_BODY',
10230 "External constructors cannot have a body"); 9371 "External constructors cannot have a body");
10231 9372
10232 static const ParserErrorCode EXTERNAL_ENUM = const ParserErrorCode( 9373 static const ParserErrorCode EXTERNAL_ENUM = const ParserErrorCode(
10233 'EXTERNAL_ENUM', 9374 'EXTERNAL_ENUM', "Enums cannot be declared to be 'external'");
10234 "Enums cannot be declared to be 'external'");
10235 9375
10236 static const ParserErrorCode EXTERNAL_FIELD = const ParserErrorCode( 9376 static const ParserErrorCode EXTERNAL_FIELD = const ParserErrorCode(
10237 'EXTERNAL_FIELD', 9377 'EXTERNAL_FIELD', "Fields cannot be declared to be 'external'");
10238 "Fields cannot be declared to be 'external'");
10239 9378
10240 static const ParserErrorCode EXTERNAL_GETTER_WITH_BODY = 9379 static const ParserErrorCode EXTERNAL_GETTER_WITH_BODY =
10241 const ParserErrorCode( 9380 const ParserErrorCode(
10242 'EXTERNAL_GETTER_WITH_BODY', 9381 'EXTERNAL_GETTER_WITH_BODY', "External getters cannot have a body");
10243 "External getters cannot have a body");
10244 9382
10245 static const ParserErrorCode EXTERNAL_METHOD_WITH_BODY = 9383 static const ParserErrorCode EXTERNAL_METHOD_WITH_BODY =
10246 const ParserErrorCode( 9384 const ParserErrorCode(
10247 'EXTERNAL_METHOD_WITH_BODY', 9385 'EXTERNAL_METHOD_WITH_BODY', "External methods cannot have a body");
10248 "External methods cannot have a body");
10249 9386
10250 static const ParserErrorCode EXTERNAL_OPERATOR_WITH_BODY = 9387 static const ParserErrorCode EXTERNAL_OPERATOR_WITH_BODY =
10251 const ParserErrorCode( 9388 const ParserErrorCode('EXTERNAL_OPERATOR_WITH_BODY',
10252 'EXTERNAL_OPERATOR_WITH_BODY',
10253 "External operators cannot have a body"); 9389 "External operators cannot have a body");
10254 9390
10255 static const ParserErrorCode EXTERNAL_SETTER_WITH_BODY = 9391 static const ParserErrorCode EXTERNAL_SETTER_WITH_BODY =
10256 const ParserErrorCode( 9392 const ParserErrorCode(
10257 'EXTERNAL_SETTER_WITH_BODY', 9393 'EXTERNAL_SETTER_WITH_BODY', "External setters cannot have a body");
10258 "External setters cannot have a body");
10259 9394
10260 static const ParserErrorCode EXTERNAL_TYPEDEF = const ParserErrorCode( 9395 static const ParserErrorCode EXTERNAL_TYPEDEF = const ParserErrorCode(
10261 'EXTERNAL_TYPEDEF', 9396 'EXTERNAL_TYPEDEF', "Type aliases cannot be declared to be 'external'");
10262 "Type aliases cannot be declared to be 'external'");
10263 9397
10264 static const ParserErrorCode FACTORY_TOP_LEVEL_DECLARATION = 9398 static const ParserErrorCode FACTORY_TOP_LEVEL_DECLARATION =
10265 const ParserErrorCode( 9399 const ParserErrorCode('FACTORY_TOP_LEVEL_DECLARATION',
10266 'FACTORY_TOP_LEVEL_DECLARATION',
10267 "Top-level declarations cannot be declared to be 'factory'"); 9400 "Top-level declarations cannot be declared to be 'factory'");
10268 9401
10269 static const ParserErrorCode FACTORY_WITH_INITIALIZERS = 9402 static const ParserErrorCode FACTORY_WITH_INITIALIZERS =
10270 const ParserErrorCode( 9403 const ParserErrorCode('FACTORY_WITH_INITIALIZERS',
10271 'FACTORY_WITH_INITIALIZERS',
10272 "A 'factory' constructor cannot have initializers", 9404 "A 'factory' constructor cannot have initializers",
10273 "Either remove the 'factory' keyword to make this a generative " 9405 "Either remove the 'factory' keyword to make this a generative "
10274 "constructor or remove the initializers."); 9406 "constructor or remove the initializers.");
10275 9407
10276 static const ParserErrorCode FACTORY_WITHOUT_BODY = const ParserErrorCode( 9408 static const ParserErrorCode FACTORY_WITHOUT_BODY = const ParserErrorCode(
10277 'FACTORY_WITHOUT_BODY', 9409 'FACTORY_WITHOUT_BODY',
10278 "A non-redirecting 'factory' constructor must have a body"); 9410 "A non-redirecting 'factory' constructor must have a body");
10279 9411
10280 static const ParserErrorCode FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR = 9412 static const ParserErrorCode FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR =
10281 const ParserErrorCode( 9413 const ParserErrorCode('FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR',
10282 'FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR',
10283 "Field initializers can only be used in a constructor"); 9414 "Field initializers can only be used in a constructor");
10284 9415
10285 static const ParserErrorCode FINAL_AND_VAR = const ParserErrorCode( 9416 static const ParserErrorCode FINAL_AND_VAR = const ParserErrorCode(
10286 'FINAL_AND_VAR', 9417 'FINAL_AND_VAR',
10287 "Members cannot be declared to be both 'final' and 'var'"); 9418 "Members cannot be declared to be both 'final' and 'var'");
10288 9419
10289 static const ParserErrorCode FINAL_CLASS = const ParserErrorCode( 9420 static const ParserErrorCode FINAL_CLASS = const ParserErrorCode(
10290 'FINAL_CLASS', 9421 'FINAL_CLASS', "Classes cannot be declared to be 'final'");
10291 "Classes cannot be declared to be 'final'");
10292 9422
10293 static const ParserErrorCode FINAL_CONSTRUCTOR = const ParserErrorCode( 9423 static const ParserErrorCode FINAL_CONSTRUCTOR = const ParserErrorCode(
10294 'FINAL_CONSTRUCTOR', 9424 'FINAL_CONSTRUCTOR', "A constructor cannot be declared to be 'final'");
10295 "A constructor cannot be declared to be 'final'");
10296 9425
10297 static const ParserErrorCode FINAL_ENUM = 9426 static const ParserErrorCode FINAL_ENUM = const ParserErrorCode(
10298 const ParserErrorCode('FINAL_ENUM', "Enums cannot be declared to be 'final '"); 9427 'FINAL_ENUM', "Enums cannot be declared to be 'final'");
10299 9428
10300 static const ParserErrorCode FINAL_METHOD = const ParserErrorCode( 9429 static const ParserErrorCode FINAL_METHOD = const ParserErrorCode(
10301 'FINAL_METHOD', 9430 'FINAL_METHOD',
10302 "Getters, setters and methods cannot be declared to be 'final'"); 9431 "Getters, setters and methods cannot be declared to be 'final'");
10303 9432
10304 static const ParserErrorCode FINAL_TYPEDEF = const ParserErrorCode( 9433 static const ParserErrorCode FINAL_TYPEDEF = const ParserErrorCode(
10305 'FINAL_TYPEDEF', 9434 'FINAL_TYPEDEF', "Type aliases cannot be declared to be 'final'");
10306 "Type aliases cannot be declared to be 'final'");
10307 9435
10308 static const ParserErrorCode FUNCTION_TYPED_PARAMETER_VAR = 9436 static const ParserErrorCode FUNCTION_TYPED_PARAMETER_VAR = const ParserErrorC ode(
10309 const ParserErrorCode( 9437 'FUNCTION_TYPED_PARAMETER_VAR',
10310 'FUNCTION_TYPED_PARAMETER_VAR', 9438 "Function typed parameters cannot specify 'const', 'final' or 'var' instea d of return type");
10311 "Function typed parameters cannot specify 'const', 'final' or 'var' in stead of return type");
10312 9439
10313 static const ParserErrorCode GETTER_IN_FUNCTION = const ParserErrorCode( 9440 static const ParserErrorCode GETTER_IN_FUNCTION = const ParserErrorCode(
10314 'GETTER_IN_FUNCTION', 9441 'GETTER_IN_FUNCTION',
10315 "Getters cannot be defined within methods or functions"); 9442 "Getters cannot be defined within methods or functions");
10316 9443
10317 static const ParserErrorCode GETTER_WITH_PARAMETERS = const ParserErrorCode( 9444 static const ParserErrorCode GETTER_WITH_PARAMETERS = const ParserErrorCode(
10318 'GETTER_WITH_PARAMETERS', 9445 'GETTER_WITH_PARAMETERS',
10319 "Getter should be declared without a parameter list"); 9446 "Getter should be declared without a parameter list");
10320 9447
10321 static const ParserErrorCode ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE = 9448 static const ParserErrorCode ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE =
10322 const ParserErrorCode( 9449 const ParserErrorCode('ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE',
10323 'ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE',
10324 "Illegal assignment to non-assignable expression"); 9450 "Illegal assignment to non-assignable expression");
10325 9451
10326 static const ParserErrorCode IMPLEMENTS_BEFORE_EXTENDS = 9452 static const ParserErrorCode IMPLEMENTS_BEFORE_EXTENDS =
10327 const ParserErrorCode( 9453 const ParserErrorCode('IMPLEMENTS_BEFORE_EXTENDS',
10328 'IMPLEMENTS_BEFORE_EXTENDS',
10329 "The extends clause must be before the implements clause"); 9454 "The extends clause must be before the implements clause");
10330 9455
10331 static const ParserErrorCode IMPLEMENTS_BEFORE_WITH = const ParserErrorCode( 9456 static const ParserErrorCode IMPLEMENTS_BEFORE_WITH = const ParserErrorCode(
10332 'IMPLEMENTS_BEFORE_WITH', 9457 'IMPLEMENTS_BEFORE_WITH',
10333 "The with clause must be before the implements clause"); 9458 "The with clause must be before the implements clause");
10334 9459
10335 static const ParserErrorCode IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE = 9460 static const ParserErrorCode IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE =
10336 const ParserErrorCode( 9461 const ParserErrorCode('IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
10337 'IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
10338 "Import directives must preceed part directives"); 9462 "Import directives must preceed part directives");
10339 9463
10340 static const ParserErrorCode INITIALIZED_VARIABLE_IN_FOR_EACH = 9464 static const ParserErrorCode INITIALIZED_VARIABLE_IN_FOR_EACH =
10341 const ParserErrorCode( 9465 const ParserErrorCode('INITIALIZED_VARIABLE_IN_FOR_EACH',
10342 'INITIALIZED_VARIABLE_IN_FOR_EACH',
10343 "The loop variable in a for-each loop cannot be initialized"); 9466 "The loop variable in a for-each loop cannot be initialized");
10344 9467
10345 static const ParserErrorCode INVALID_AWAIT_IN_FOR = const ParserErrorCode( 9468 static const ParserErrorCode INVALID_AWAIT_IN_FOR = const ParserErrorCode(
10346 'INVALID_AWAIT_IN_FOR', 9469 'INVALID_AWAIT_IN_FOR',
10347 "The modifier 'await' is not allowed for a normal 'for' statement", 9470 "The modifier 'await' is not allowed for a normal 'for' statement",
10348 "Remove the keyword or use a for-each statement."); 9471 "Remove the keyword or use a for-each statement.");
10349 9472
10350 static const ParserErrorCode INVALID_CODE_POINT = const ParserErrorCode( 9473 static const ParserErrorCode INVALID_CODE_POINT = const ParserErrorCode(
10351 'INVALID_CODE_POINT', 9474 'INVALID_CODE_POINT',
10352 "The escape sequence '{0}' is not a valid code point"); 9475 "The escape sequence '{0}' is not a valid code point");
10353 9476
10354 static const ParserErrorCode INVALID_COMMENT_REFERENCE = 9477 static const ParserErrorCode INVALID_COMMENT_REFERENCE = const ParserErrorCode (
10355 const ParserErrorCode( 9478 'INVALID_COMMENT_REFERENCE',
10356 'INVALID_COMMENT_REFERENCE', 9479 "Comment references should contain a possibly prefixed identifier and can start with 'new', but should not contain anything else");
10357 "Comment references should contain a possibly prefixed identifier and can start with 'new', but should not contain anything else");
10358 9480
10359 static const ParserErrorCode INVALID_HEX_ESCAPE = const ParserErrorCode( 9481 static const ParserErrorCode INVALID_HEX_ESCAPE = const ParserErrorCode(
10360 'INVALID_HEX_ESCAPE', 9482 'INVALID_HEX_ESCAPE',
10361 "An escape sequence starting with '\\x' must be followed by 2 hexidecimal digits"); 9483 "An escape sequence starting with '\\x' must be followed by 2 hexidecimal digits");
10362 9484
10363 static const ParserErrorCode INVALID_OPERATOR = const ParserErrorCode( 9485 static const ParserErrorCode INVALID_OPERATOR = const ParserErrorCode(
10364 'INVALID_OPERATOR', 9486 'INVALID_OPERATOR', "The string '{0}' is not a valid operator");
10365 "The string '{0}' is not a valid operator");
10366 9487
10367 static const ParserErrorCode INVALID_OPERATOR_FOR_SUPER = 9488 static const ParserErrorCode INVALID_OPERATOR_FOR_SUPER =
10368 const ParserErrorCode( 9489 const ParserErrorCode('INVALID_OPERATOR_FOR_SUPER',
10369 'INVALID_OPERATOR_FOR_SUPER',
10370 "The operator '{0}' cannot be used with 'super'"); 9490 "The operator '{0}' cannot be used with 'super'");
10371 9491
10372 static const ParserErrorCode INVALID_STAR_AFTER_ASYNC = const ParserErrorCode( 9492 static const ParserErrorCode INVALID_STAR_AFTER_ASYNC = const ParserErrorCode(
10373 'INVALID_STAR_AFTER_ASYNC', 9493 'INVALID_STAR_AFTER_ASYNC',
10374 "The modifier 'async*' is not allowed for an expression function body", 9494 "The modifier 'async*' is not allowed for an expression function body",
10375 "Convert the body to a block."); 9495 "Convert the body to a block.");
10376 9496
10377 static const ParserErrorCode INVALID_SYNC = const ParserErrorCode( 9497 static const ParserErrorCode INVALID_SYNC = const ParserErrorCode(
10378 'INVALID_SYNC', 9498 'INVALID_SYNC',
10379 "The modifier 'sync' is not allowed for an exrpression function body", 9499 "The modifier 'sync' is not allowed for an exrpression function body",
10380 "Convert the body to a block."); 9500 "Convert the body to a block.");
10381 9501
10382 static const ParserErrorCode INVALID_UNICODE_ESCAPE = const ParserErrorCode( 9502 static const ParserErrorCode INVALID_UNICODE_ESCAPE = const ParserErrorCode(
10383 'INVALID_UNICODE_ESCAPE', 9503 'INVALID_UNICODE_ESCAPE',
10384 "An escape sequence starting with '\\u' must be followed by 4 hexidecimal digits or from 1 to 6 digits between '{' and '}'"); 9504 "An escape sequence starting with '\\u' must be followed by 4 hexidecimal digits or from 1 to 6 digits between '{' and '}'");
10385 9505
10386 static const ParserErrorCode LIBRARY_DIRECTIVE_NOT_FIRST = 9506 static const ParserErrorCode LIBRARY_DIRECTIVE_NOT_FIRST =
10387 const ParserErrorCode( 9507 const ParserErrorCode('LIBRARY_DIRECTIVE_NOT_FIRST',
10388 'LIBRARY_DIRECTIVE_NOT_FIRST',
10389 "The library directive must appear before all other directives"); 9508 "The library directive must appear before all other directives");
10390 9509
10391 static const ParserErrorCode LOCAL_FUNCTION_DECLARATION_MODIFIER = 9510 static const ParserErrorCode LOCAL_FUNCTION_DECLARATION_MODIFIER =
10392 const ParserErrorCode( 9511 const ParserErrorCode('LOCAL_FUNCTION_DECLARATION_MODIFIER',
10393 'LOCAL_FUNCTION_DECLARATION_MODIFIER',
10394 "Local function declarations cannot specify any modifier"); 9512 "Local function declarations cannot specify any modifier");
10395 9513
10396 static const ParserErrorCode MISSING_ASSIGNABLE_SELECTOR = 9514 static const ParserErrorCode MISSING_ASSIGNABLE_SELECTOR =
10397 const ParserErrorCode( 9515 const ParserErrorCode('MISSING_ASSIGNABLE_SELECTOR',
10398 'MISSING_ASSIGNABLE_SELECTOR',
10399 "Missing selector such as \".<identifier>\" or \"[0]\""); 9516 "Missing selector such as \".<identifier>\" or \"[0]\"");
10400 9517
10401 static const ParserErrorCode MISSING_ASSIGNMENT_IN_INITIALIZER = 9518 static const ParserErrorCode MISSING_ASSIGNMENT_IN_INITIALIZER =
10402 const ParserErrorCode( 9519 const ParserErrorCode('MISSING_ASSIGNMENT_IN_INITIALIZER',
10403 'MISSING_ASSIGNMENT_IN_INITIALIZER',
10404 "Expected an assignment after the field name"); 9520 "Expected an assignment after the field name");
10405 9521
10406 static const ParserErrorCode MISSING_CATCH_OR_FINALLY = const ParserErrorCode( 9522 static const ParserErrorCode MISSING_CATCH_OR_FINALLY = const ParserErrorCode(
10407 'MISSING_CATCH_OR_FINALLY', 9523 'MISSING_CATCH_OR_FINALLY',
10408 "A try statement must have either a catch or finally clause"); 9524 "A try statement must have either a catch or finally clause");
10409 9525
10410 static const ParserErrorCode MISSING_CLASS_BODY = const ParserErrorCode( 9526 static const ParserErrorCode MISSING_CLASS_BODY = const ParserErrorCode(
10411 'MISSING_CLASS_BODY', 9527 'MISSING_CLASS_BODY',
10412 "A class definition must have a body, even if it is empty"); 9528 "A class definition must have a body, even if it is empty");
10413 9529
10414 static const ParserErrorCode MISSING_CLOSING_PARENTHESIS = 9530 static const ParserErrorCode MISSING_CLOSING_PARENTHESIS =
10415 const ParserErrorCode( 9531 const ParserErrorCode(
10416 'MISSING_CLOSING_PARENTHESIS', 9532 'MISSING_CLOSING_PARENTHESIS', "The closing parenthesis is missing");
10417 "The closing parenthesis is missing");
10418 9533
10419 static const ParserErrorCode MISSING_CONST_FINAL_VAR_OR_TYPE = 9534 static const ParserErrorCode MISSING_CONST_FINAL_VAR_OR_TYPE =
10420 const ParserErrorCode( 9535 const ParserErrorCode('MISSING_CONST_FINAL_VAR_OR_TYPE',
10421 'MISSING_CONST_FINAL_VAR_OR_TYPE',
10422 "Variables must be declared using the keywords 'const', 'final', 'var' or a type name"); 9536 "Variables must be declared using the keywords 'const', 'final', 'var' or a type name");
10423 9537
10424 static const ParserErrorCode MISSING_ENUM_BODY = const ParserErrorCode( 9538 static const ParserErrorCode MISSING_ENUM_BODY = const ParserErrorCode(
10425 'MISSING_ENUM_BODY', 9539 'MISSING_ENUM_BODY',
10426 "An enum definition must have a body with at least one constant name"); 9540 "An enum definition must have a body with at least one constant name");
10427 9541
10428 static const ParserErrorCode MISSING_EXPRESSION_IN_INITIALIZER = 9542 static const ParserErrorCode MISSING_EXPRESSION_IN_INITIALIZER =
10429 const ParserErrorCode( 9543 const ParserErrorCode('MISSING_EXPRESSION_IN_INITIALIZER',
10430 'MISSING_EXPRESSION_IN_INITIALIZER',
10431 "Expected an expression after the assignment operator"); 9544 "Expected an expression after the assignment operator");
10432 9545
10433 static const ParserErrorCode MISSING_EXPRESSION_IN_THROW = 9546 static const ParserErrorCode MISSING_EXPRESSION_IN_THROW =
10434 const ParserErrorCode( 9547 const ParserErrorCode('MISSING_EXPRESSION_IN_THROW',
10435 'MISSING_EXPRESSION_IN_THROW',
10436 "Throw expressions must compute the object to be thrown"); 9548 "Throw expressions must compute the object to be thrown");
10437 9549
10438 static const ParserErrorCode MISSING_FUNCTION_BODY = const ParserErrorCode( 9550 static const ParserErrorCode MISSING_FUNCTION_BODY = const ParserErrorCode(
10439 'MISSING_FUNCTION_BODY', 9551 'MISSING_FUNCTION_BODY', "A function body must be provided");
10440 "A function body must be provided");
10441 9552
10442 static const ParserErrorCode MISSING_FUNCTION_PARAMETERS = 9553 static const ParserErrorCode MISSING_FUNCTION_PARAMETERS =
10443 const ParserErrorCode( 9554 const ParserErrorCode('MISSING_FUNCTION_PARAMETERS',
10444 'MISSING_FUNCTION_PARAMETERS',
10445 "Functions must have an explicit list of parameters"); 9555 "Functions must have an explicit list of parameters");
10446 9556
10447 static const ParserErrorCode MISSING_METHOD_PARAMETERS = 9557 static const ParserErrorCode MISSING_METHOD_PARAMETERS =
10448 const ParserErrorCode( 9558 const ParserErrorCode('MISSING_METHOD_PARAMETERS',
10449 'MISSING_METHOD_PARAMETERS',
10450 "Methods must have an explicit list of parameters"); 9559 "Methods must have an explicit list of parameters");
10451 9560
10452 static const ParserErrorCode MISSING_GET = const ParserErrorCode( 9561 static const ParserErrorCode MISSING_GET = const ParserErrorCode(
10453 'MISSING_GET', 9562 'MISSING_GET',
10454 "Getters must have the keyword 'get' before the getter name"); 9563 "Getters must have the keyword 'get' before the getter name");
10455 9564
10456 static const ParserErrorCode MISSING_IDENTIFIER = 9565 static const ParserErrorCode MISSING_IDENTIFIER =
10457 const ParserErrorCode('MISSING_IDENTIFIER', "Expected an identifier"); 9566 const ParserErrorCode('MISSING_IDENTIFIER', "Expected an identifier");
10458 9567
10459 static const ParserErrorCode MISSING_INITIALIZER = 9568 static const ParserErrorCode MISSING_INITIALIZER =
10460 const ParserErrorCode('MISSING_INITIALIZER', "Expected an initializer"); 9569 const ParserErrorCode('MISSING_INITIALIZER', "Expected an initializer");
10461 9570
10462 static const ParserErrorCode MISSING_KEYWORD_OPERATOR = const ParserErrorCode( 9571 static const ParserErrorCode MISSING_KEYWORD_OPERATOR = const ParserErrorCode(
10463 'MISSING_KEYWORD_OPERATOR', 9572 'MISSING_KEYWORD_OPERATOR',
10464 "Operator declarations must be preceeded by the keyword 'operator'"); 9573 "Operator declarations must be preceeded by the keyword 'operator'");
10465 9574
10466 static const ParserErrorCode MISSING_NAME_IN_LIBRARY_DIRECTIVE = 9575 static const ParserErrorCode MISSING_NAME_IN_LIBRARY_DIRECTIVE =
10467 const ParserErrorCode( 9576 const ParserErrorCode('MISSING_NAME_IN_LIBRARY_DIRECTIVE',
10468 'MISSING_NAME_IN_LIBRARY_DIRECTIVE',
10469 "Library directives must include a library name"); 9577 "Library directives must include a library name");
10470 9578
10471 static const ParserErrorCode MISSING_NAME_IN_PART_OF_DIRECTIVE = 9579 static const ParserErrorCode MISSING_NAME_IN_PART_OF_DIRECTIVE =
10472 const ParserErrorCode( 9580 const ParserErrorCode('MISSING_NAME_IN_PART_OF_DIRECTIVE',
10473 'MISSING_NAME_IN_PART_OF_DIRECTIVE',
10474 "Library directives must include a library name"); 9581 "Library directives must include a library name");
10475 9582
10476 static const ParserErrorCode MISSING_PREFIX_IN_DEFERRED_IMPORT = 9583 static const ParserErrorCode MISSING_PREFIX_IN_DEFERRED_IMPORT =
10477 const ParserErrorCode( 9584 const ParserErrorCode('MISSING_PREFIX_IN_DEFERRED_IMPORT',
10478 'MISSING_PREFIX_IN_DEFERRED_IMPORT',
10479 "Deferred imports must have a prefix"); 9585 "Deferred imports must have a prefix");
10480 9586
10481 static const ParserErrorCode MISSING_STAR_AFTER_SYNC = const ParserErrorCode( 9587 static const ParserErrorCode MISSING_STAR_AFTER_SYNC = const ParserErrorCode(
10482 'MISSING_STAR_AFTER_SYNC', 9588 'MISSING_STAR_AFTER_SYNC',
10483 "The modifier 'sync' must be followed by a star ('*')", 9589 "The modifier 'sync' must be followed by a star ('*')",
10484 "Remove the modifier or add a star."); 9590 "Remove the modifier or add a star.");
10485 9591
10486 static const ParserErrorCode MISSING_STATEMENT = 9592 static const ParserErrorCode MISSING_STATEMENT =
10487 const ParserErrorCode('MISSING_STATEMENT', "Expected a statement"); 9593 const ParserErrorCode('MISSING_STATEMENT', "Expected a statement");
10488 9594
10489 static const ParserErrorCode MISSING_TERMINATOR_FOR_PARAMETER_GROUP = 9595 static const ParserErrorCode MISSING_TERMINATOR_FOR_PARAMETER_GROUP =
10490 const ParserErrorCode( 9596 const ParserErrorCode('MISSING_TERMINATOR_FOR_PARAMETER_GROUP',
10491 'MISSING_TERMINATOR_FOR_PARAMETER_GROUP',
10492 "There is no '{0}' to close the parameter group"); 9597 "There is no '{0}' to close the parameter group");
10493 9598
10494 static const ParserErrorCode MISSING_TYPEDEF_PARAMETERS = 9599 static const ParserErrorCode MISSING_TYPEDEF_PARAMETERS =
10495 const ParserErrorCode( 9600 const ParserErrorCode('MISSING_TYPEDEF_PARAMETERS',
10496 'MISSING_TYPEDEF_PARAMETERS',
10497 "Type aliases for functions must have an explicit list of parameters") ; 9601 "Type aliases for functions must have an explicit list of parameters") ;
10498 9602
10499 static const ParserErrorCode MISSING_VARIABLE_IN_FOR_EACH = 9603 static const ParserErrorCode MISSING_VARIABLE_IN_FOR_EACH = const ParserErrorC ode(
10500 const ParserErrorCode( 9604 'MISSING_VARIABLE_IN_FOR_EACH',
10501 'MISSING_VARIABLE_IN_FOR_EACH', 9605 "A loop variable must be declared in a for-each loop before the 'in', but none were found");
10502 "A loop variable must be declared in a for-each loop before the 'in', but none were found");
10503 9606
10504 static const ParserErrorCode MIXED_PARAMETER_GROUPS = const ParserErrorCode( 9607 static const ParserErrorCode MIXED_PARAMETER_GROUPS = const ParserErrorCode(
10505 'MIXED_PARAMETER_GROUPS', 9608 'MIXED_PARAMETER_GROUPS',
10506 "Cannot have both positional and named parameters in a single parameter li st"); 9609 "Cannot have both positional and named parameters in a single parameter li st");
10507 9610
10508 static const ParserErrorCode MULTIPLE_EXTENDS_CLAUSES = const ParserErrorCode( 9611 static const ParserErrorCode MULTIPLE_EXTENDS_CLAUSES = const ParserErrorCode(
10509 'MULTIPLE_EXTENDS_CLAUSES', 9612 'MULTIPLE_EXTENDS_CLAUSES',
10510 "Each class definition can have at most one extends clause"); 9613 "Each class definition can have at most one extends clause");
10511 9614
10512 static const ParserErrorCode MULTIPLE_IMPLEMENTS_CLAUSES = 9615 static const ParserErrorCode MULTIPLE_IMPLEMENTS_CLAUSES =
10513 const ParserErrorCode( 9616 const ParserErrorCode('MULTIPLE_IMPLEMENTS_CLAUSES',
10514 'MULTIPLE_IMPLEMENTS_CLAUSES',
10515 "Each class definition can have at most one implements clause"); 9617 "Each class definition can have at most one implements clause");
10516 9618
10517 static const ParserErrorCode MULTIPLE_LIBRARY_DIRECTIVES = 9619 static const ParserErrorCode MULTIPLE_LIBRARY_DIRECTIVES =
10518 const ParserErrorCode( 9620 const ParserErrorCode('MULTIPLE_LIBRARY_DIRECTIVES',
10519 'MULTIPLE_LIBRARY_DIRECTIVES',
10520 "Only one library directive may be declared in a file"); 9621 "Only one library directive may be declared in a file");
10521 9622
10522 static const ParserErrorCode MULTIPLE_NAMED_PARAMETER_GROUPS = 9623 static const ParserErrorCode MULTIPLE_NAMED_PARAMETER_GROUPS =
10523 const ParserErrorCode( 9624 const ParserErrorCode('MULTIPLE_NAMED_PARAMETER_GROUPS',
10524 'MULTIPLE_NAMED_PARAMETER_GROUPS',
10525 "Cannot have multiple groups of named parameters in a single parameter list"); 9625 "Cannot have multiple groups of named parameters in a single parameter list");
10526 9626
10527 static const ParserErrorCode MULTIPLE_PART_OF_DIRECTIVES = 9627 static const ParserErrorCode MULTIPLE_PART_OF_DIRECTIVES =
10528 const ParserErrorCode( 9628 const ParserErrorCode('MULTIPLE_PART_OF_DIRECTIVES',
10529 'MULTIPLE_PART_OF_DIRECTIVES',
10530 "Only one part-of directive may be declared in a file"); 9629 "Only one part-of directive may be declared in a file");
10531 9630
10532 static const ParserErrorCode MULTIPLE_POSITIONAL_PARAMETER_GROUPS = 9631 static const ParserErrorCode MULTIPLE_POSITIONAL_PARAMETER_GROUPS =
10533 const ParserErrorCode( 9632 const ParserErrorCode('MULTIPLE_POSITIONAL_PARAMETER_GROUPS',
10534 'MULTIPLE_POSITIONAL_PARAMETER_GROUPS',
10535 "Cannot have multiple groups of positional parameters in a single para meter list"); 9633 "Cannot have multiple groups of positional parameters in a single para meter list");
10536 9634
10537 static const ParserErrorCode MULTIPLE_VARIABLES_IN_FOR_EACH = 9635 static const ParserErrorCode MULTIPLE_VARIABLES_IN_FOR_EACH =
10538 const ParserErrorCode( 9636 const ParserErrorCode('MULTIPLE_VARIABLES_IN_FOR_EACH',
10539 'MULTIPLE_VARIABLES_IN_FOR_EACH',
10540 "A single loop variable must be declared in a for-each loop before the 'in', but {0} were found"); 9637 "A single loop variable must be declared in a for-each loop before the 'in', but {0} were found");
10541 9638
10542 static const ParserErrorCode MULTIPLE_WITH_CLAUSES = const ParserErrorCode( 9639 static const ParserErrorCode MULTIPLE_WITH_CLAUSES = const ParserErrorCode(
10543 'MULTIPLE_WITH_CLAUSES', 9640 'MULTIPLE_WITH_CLAUSES',
10544 "Each class definition can have at most one with clause"); 9641 "Each class definition can have at most one with clause");
10545 9642
10546 static const ParserErrorCode NAMED_FUNCTION_EXPRESSION = 9643 static const ParserErrorCode NAMED_FUNCTION_EXPRESSION =
10547 const ParserErrorCode( 9644 const ParserErrorCode(
10548 'NAMED_FUNCTION_EXPRESSION', 9645 'NAMED_FUNCTION_EXPRESSION', "Function expressions cannot be named");
10549 "Function expressions cannot be named");
10550 9646
10551 static const ParserErrorCode NAMED_PARAMETER_OUTSIDE_GROUP = 9647 static const ParserErrorCode NAMED_PARAMETER_OUTSIDE_GROUP =
10552 const ParserErrorCode( 9648 const ParserErrorCode('NAMED_PARAMETER_OUTSIDE_GROUP',
10553 'NAMED_PARAMETER_OUTSIDE_GROUP',
10554 "Named parameters must be enclosed in curly braces ('{' and '}')"); 9649 "Named parameters must be enclosed in curly braces ('{' and '}')");
10555 9650
10556 static const ParserErrorCode NATIVE_CLAUSE_IN_NON_SDK_CODE = 9651 static const ParserErrorCode NATIVE_CLAUSE_IN_NON_SDK_CODE =
10557 const ParserErrorCode( 9652 const ParserErrorCode('NATIVE_CLAUSE_IN_NON_SDK_CODE',
10558 'NATIVE_CLAUSE_IN_NON_SDK_CODE',
10559 "Native clause can only be used in the SDK and code that is loaded thr ough native extensions"); 9653 "Native clause can only be used in the SDK and code that is loaded thr ough native extensions");
10560 9654
10561 static const ParserErrorCode NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE = 9655 static const ParserErrorCode NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE =
10562 const ParserErrorCode( 9656 const ParserErrorCode('NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE',
10563 'NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE',
10564 "Native functions can only be declared in the SDK and code that is loa ded through native extensions"); 9657 "Native functions can only be declared in the SDK and code that is loa ded through native extensions");
10565 9658
10566 static const ParserErrorCode NON_CONSTRUCTOR_FACTORY = const ParserErrorCode( 9659 static const ParserErrorCode NON_CONSTRUCTOR_FACTORY = const ParserErrorCode(
10567 'NON_CONSTRUCTOR_FACTORY', 9660 'NON_CONSTRUCTOR_FACTORY',
10568 "Only constructors can be declared to be a 'factory'"); 9661 "Only constructors can be declared to be a 'factory'");
10569 9662
10570 static const ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME = 9663 static const ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME =
10571 const ParserErrorCode( 9664 const ParserErrorCode('NON_IDENTIFIER_LIBRARY_NAME',
10572 'NON_IDENTIFIER_LIBRARY_NAME',
10573 "The name of a library must be an identifier"); 9665 "The name of a library must be an identifier");
10574 9666
10575 static const ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART = 9667 static const ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART =
10576 const ParserErrorCode( 9668 const ParserErrorCode('NON_PART_OF_DIRECTIVE_IN_PART',
10577 'NON_PART_OF_DIRECTIVE_IN_PART',
10578 "The part-of directive must be the only directive in a part"); 9669 "The part-of directive must be the only directive in a part");
10579 9670
10580 static const ParserErrorCode NON_STRING_LITERAL_AS_URI = 9671 static const ParserErrorCode NON_STRING_LITERAL_AS_URI =
10581 const ParserErrorCode( 9672 const ParserErrorCode('NON_STRING_LITERAL_AS_URI',
10582 'NON_STRING_LITERAL_AS_URI',
10583 "The URI must be a string literal", 9673 "The URI must be a string literal",
10584 "Enclose the URI in either single or double quotes."); 9674 "Enclose the URI in either single or double quotes.");
10585 9675
10586 static const ParserErrorCode NON_USER_DEFINABLE_OPERATOR = 9676 static const ParserErrorCode NON_USER_DEFINABLE_OPERATOR =
10587 const ParserErrorCode( 9677 const ParserErrorCode('NON_USER_DEFINABLE_OPERATOR',
10588 'NON_USER_DEFINABLE_OPERATOR',
10589 "The operator '{0}' is not user definable"); 9678 "The operator '{0}' is not user definable");
10590 9679
10591 static const ParserErrorCode NORMAL_BEFORE_OPTIONAL_PARAMETERS = 9680 static const ParserErrorCode NORMAL_BEFORE_OPTIONAL_PARAMETERS =
10592 const ParserErrorCode( 9681 const ParserErrorCode('NORMAL_BEFORE_OPTIONAL_PARAMETERS',
10593 'NORMAL_BEFORE_OPTIONAL_PARAMETERS',
10594 "Normal parameters must occur before optional parameters"); 9682 "Normal parameters must occur before optional parameters");
10595 9683
10596 static const ParserErrorCode POSITIONAL_AFTER_NAMED_ARGUMENT = 9684 static const ParserErrorCode POSITIONAL_AFTER_NAMED_ARGUMENT =
10597 const ParserErrorCode( 9685 const ParserErrorCode('POSITIONAL_AFTER_NAMED_ARGUMENT',
10598 'POSITIONAL_AFTER_NAMED_ARGUMENT',
10599 "Positional arguments must occur before named arguments"); 9686 "Positional arguments must occur before named arguments");
10600 9687
10601 static const ParserErrorCode POSITIONAL_PARAMETER_OUTSIDE_GROUP = 9688 static const ParserErrorCode POSITIONAL_PARAMETER_OUTSIDE_GROUP =
10602 const ParserErrorCode( 9689 const ParserErrorCode('POSITIONAL_PARAMETER_OUTSIDE_GROUP',
10603 'POSITIONAL_PARAMETER_OUTSIDE_GROUP',
10604 "Positional parameters must be enclosed in square brackets ('[' and '] ')"); 9690 "Positional parameters must be enclosed in square brackets ('[' and '] ')");
10605 9691
10606 static const ParserErrorCode REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR = 9692 static const ParserErrorCode REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR =
10607 const ParserErrorCode( 9693 const ParserErrorCode('REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR',
10608 'REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR',
10609 "Only factory constructor can specify '=' redirection."); 9694 "Only factory constructor can specify '=' redirection.");
10610 9695
10611 static const ParserErrorCode SETTER_IN_FUNCTION = const ParserErrorCode( 9696 static const ParserErrorCode SETTER_IN_FUNCTION = const ParserErrorCode(
10612 'SETTER_IN_FUNCTION', 9697 'SETTER_IN_FUNCTION',
10613 "Setters cannot be defined within methods or functions"); 9698 "Setters cannot be defined within methods or functions");
10614 9699
10615 static const ParserErrorCode STATIC_AFTER_CONST = const ParserErrorCode( 9700 static const ParserErrorCode STATIC_AFTER_CONST = const ParserErrorCode(
10616 'STATIC_AFTER_CONST', 9701 'STATIC_AFTER_CONST',
10617 "The modifier 'static' should be before the modifier 'const'"); 9702 "The modifier 'static' should be before the modifier 'const'");
10618 9703
10619 static const ParserErrorCode STATIC_AFTER_FINAL = const ParserErrorCode( 9704 static const ParserErrorCode STATIC_AFTER_FINAL = const ParserErrorCode(
10620 'STATIC_AFTER_FINAL', 9705 'STATIC_AFTER_FINAL',
10621 "The modifier 'static' should be before the modifier 'final'"); 9706 "The modifier 'static' should be before the modifier 'final'");
10622 9707
10623 static const ParserErrorCode STATIC_AFTER_VAR = const ParserErrorCode( 9708 static const ParserErrorCode STATIC_AFTER_VAR = const ParserErrorCode(
10624 'STATIC_AFTER_VAR', 9709 'STATIC_AFTER_VAR',
10625 "The modifier 'static' should be before the modifier 'var'"); 9710 "The modifier 'static' should be before the modifier 'var'");
10626 9711
10627 static const ParserErrorCode STATIC_CONSTRUCTOR = 9712 static const ParserErrorCode STATIC_CONSTRUCTOR = const ParserErrorCode(
10628 const ParserErrorCode('STATIC_CONSTRUCTOR', "Constructors cannot be static "); 9713 'STATIC_CONSTRUCTOR', "Constructors cannot be static");
10629 9714
10630 static const ParserErrorCode STATIC_GETTER_WITHOUT_BODY = 9715 static const ParserErrorCode STATIC_GETTER_WITHOUT_BODY =
10631 const ParserErrorCode( 9716 const ParserErrorCode(
10632 'STATIC_GETTER_WITHOUT_BODY', 9717 'STATIC_GETTER_WITHOUT_BODY', "A 'static' getter must have a body");
10633 "A 'static' getter must have a body");
10634 9718
10635 static const ParserErrorCode STATIC_OPERATOR = 9719 static const ParserErrorCode STATIC_OPERATOR =
10636 const ParserErrorCode('STATIC_OPERATOR', "Operators cannot be static"); 9720 const ParserErrorCode('STATIC_OPERATOR', "Operators cannot be static");
10637 9721
10638 static const ParserErrorCode STATIC_SETTER_WITHOUT_BODY = 9722 static const ParserErrorCode STATIC_SETTER_WITHOUT_BODY =
10639 const ParserErrorCode( 9723 const ParserErrorCode(
10640 'STATIC_SETTER_WITHOUT_BODY', 9724 'STATIC_SETTER_WITHOUT_BODY', "A 'static' setter must have a body");
10641 "A 'static' setter must have a body");
10642 9725
10643 static const ParserErrorCode STATIC_TOP_LEVEL_DECLARATION = 9726 static const ParserErrorCode STATIC_TOP_LEVEL_DECLARATION =
10644 const ParserErrorCode( 9727 const ParserErrorCode('STATIC_TOP_LEVEL_DECLARATION',
10645 'STATIC_TOP_LEVEL_DECLARATION',
10646 "Top-level declarations cannot be declared to be 'static'"); 9728 "Top-level declarations cannot be declared to be 'static'");
10647 9729
10648 static const ParserErrorCode SWITCH_HAS_CASE_AFTER_DEFAULT_CASE = 9730 static const ParserErrorCode SWITCH_HAS_CASE_AFTER_DEFAULT_CASE =
10649 const ParserErrorCode( 9731 const ParserErrorCode('SWITCH_HAS_CASE_AFTER_DEFAULT_CASE',
10650 'SWITCH_HAS_CASE_AFTER_DEFAULT_CASE',
10651 "The 'default' case should be the last case in a switch statement"); 9732 "The 'default' case should be the last case in a switch statement");
10652 9733
10653 static const ParserErrorCode SWITCH_HAS_MULTIPLE_DEFAULT_CASES = 9734 static const ParserErrorCode SWITCH_HAS_MULTIPLE_DEFAULT_CASES =
10654 const ParserErrorCode( 9735 const ParserErrorCode('SWITCH_HAS_MULTIPLE_DEFAULT_CASES',
10655 'SWITCH_HAS_MULTIPLE_DEFAULT_CASES',
10656 "The 'default' case can only be declared once"); 9736 "The 'default' case can only be declared once");
10657 9737
10658 static const ParserErrorCode TOP_LEVEL_OPERATOR = const ParserErrorCode( 9738 static const ParserErrorCode TOP_LEVEL_OPERATOR = const ParserErrorCode(
10659 'TOP_LEVEL_OPERATOR', 9739 'TOP_LEVEL_OPERATOR', "Operators must be declared within a class");
10660 "Operators must be declared within a class");
10661 9740
10662 static const ParserErrorCode TYPEDEF_IN_CLASS = const ParserErrorCode( 9741 static const ParserErrorCode TYPEDEF_IN_CLASS = const ParserErrorCode(
10663 'TYPEDEF_IN_CLASS', 9742 'TYPEDEF_IN_CLASS',
10664 "Function type aliases cannot be declared inside classes"); 9743 "Function type aliases cannot be declared inside classes");
10665 9744
10666 static const ParserErrorCode UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP = 9745 static const ParserErrorCode UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP =
10667 const ParserErrorCode( 9746 const ParserErrorCode('UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP',
10668 'UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP',
10669 "There is no '{0}' to open a parameter group"); 9747 "There is no '{0}' to open a parameter group");
10670 9748
10671 static const ParserErrorCode UNEXPECTED_TOKEN = 9749 static const ParserErrorCode UNEXPECTED_TOKEN =
10672 const ParserErrorCode('UNEXPECTED_TOKEN', "Unexpected token '{0}'"); 9750 const ParserErrorCode('UNEXPECTED_TOKEN', "Unexpected token '{0}'");
10673 9751
10674 static const ParserErrorCode WITH_BEFORE_EXTENDS = const ParserErrorCode( 9752 static const ParserErrorCode WITH_BEFORE_EXTENDS = const ParserErrorCode(
10675 'WITH_BEFORE_EXTENDS', 9753 'WITH_BEFORE_EXTENDS',
10676 "The extends clause must be before the with clause"); 9754 "The extends clause must be before the with clause");
10677 9755
10678 static const ParserErrorCode WITH_WITHOUT_EXTENDS = const ParserErrorCode( 9756 static const ParserErrorCode WITH_WITHOUT_EXTENDS = const ParserErrorCode(
10679 'WITH_WITHOUT_EXTENDS', 9757 'WITH_WITHOUT_EXTENDS',
10680 "The with clause cannot be used without an extends clause"); 9758 "The with clause cannot be used without an extends clause");
10681 9759
10682 static const ParserErrorCode WRONG_SEPARATOR_FOR_NAMED_PARAMETER = 9760 static const ParserErrorCode WRONG_SEPARATOR_FOR_NAMED_PARAMETER =
10683 const ParserErrorCode( 9761 const ParserErrorCode('WRONG_SEPARATOR_FOR_NAMED_PARAMETER',
10684 'WRONG_SEPARATOR_FOR_NAMED_PARAMETER',
10685 "The default value of a named parameter should be preceeded by ':'"); 9762 "The default value of a named parameter should be preceeded by ':'");
10686 9763
10687 static const ParserErrorCode WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER = 9764 static const ParserErrorCode WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER =
10688 const ParserErrorCode( 9765 const ParserErrorCode('WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER',
10689 'WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER',
10690 "The default value of a positional parameter should be preceeded by '= '"); 9766 "The default value of a positional parameter should be preceeded by '= '");
10691 9767
10692 static const ParserErrorCode WRONG_TERMINATOR_FOR_PARAMETER_GROUP = 9768 static const ParserErrorCode WRONG_TERMINATOR_FOR_PARAMETER_GROUP =
10693 const ParserErrorCode( 9769 const ParserErrorCode('WRONG_TERMINATOR_FOR_PARAMETER_GROUP',
10694 'WRONG_TERMINATOR_FOR_PARAMETER_GROUP',
10695 "Expected '{0}' to close parameter group"); 9770 "Expected '{0}' to close parameter group");
10696 9771
10697 static const ParserErrorCode VAR_AND_TYPE = const ParserErrorCode( 9772 static const ParserErrorCode VAR_AND_TYPE = const ParserErrorCode(
10698 'VAR_AND_TYPE', 9773 'VAR_AND_TYPE',
10699 "Variables cannot be declared using both 'var' and a type name; remove the 'var'"); 9774 "Variables cannot be declared using both 'var' and a type name; remove the 'var'");
10700 9775
10701 static const ParserErrorCode VAR_AS_TYPE_NAME = const ParserErrorCode( 9776 static const ParserErrorCode VAR_AS_TYPE_NAME = const ParserErrorCode(
10702 'VAR_AS_TYPE_NAME', 9777 'VAR_AS_TYPE_NAME', "The keyword 'var' cannot be used as a type name");
10703 "The keyword 'var' cannot be used as a type name");
10704 9778
10705 static const ParserErrorCode VAR_CLASS = 9779 static const ParserErrorCode VAR_CLASS = const ParserErrorCode(
10706 const ParserErrorCode('VAR_CLASS', "Classes cannot be declared to be 'var' "); 9780 'VAR_CLASS', "Classes cannot be declared to be 'var'");
10707 9781
10708 static const ParserErrorCode VAR_ENUM = 9782 static const ParserErrorCode VAR_ENUM =
10709 const ParserErrorCode('VAR_ENUM', "Enums cannot be declared to be 'var'"); 9783 const ParserErrorCode('VAR_ENUM', "Enums cannot be declared to be 'var'");
10710 9784
10711 static const ParserErrorCode VAR_RETURN_TYPE = 9785 static const ParserErrorCode VAR_RETURN_TYPE = const ParserErrorCode(
10712 const ParserErrorCode('VAR_RETURN_TYPE', "The return type cannot be 'var'" ); 9786 'VAR_RETURN_TYPE', "The return type cannot be 'var'");
10713 9787
10714 static const ParserErrorCode VAR_TYPEDEF = const ParserErrorCode( 9788 static const ParserErrorCode VAR_TYPEDEF = const ParserErrorCode(
10715 'VAR_TYPEDEF', 9789 'VAR_TYPEDEF', "Type aliases cannot be declared to be 'var'");
10716 "Type aliases cannot be declared to be 'var'");
10717 9790
10718 static const ParserErrorCode VOID_PARAMETER = const ParserErrorCode( 9791 static const ParserErrorCode VOID_PARAMETER = const ParserErrorCode(
10719 'VOID_PARAMETER', 9792 'VOID_PARAMETER', "Parameters cannot have a type of 'void'");
10720 "Parameters cannot have a type of 'void'");
10721 9793
10722 static const ParserErrorCode VOID_VARIABLE = const ParserErrorCode( 9794 static const ParserErrorCode VOID_VARIABLE = const ParserErrorCode(
10723 'VOID_VARIABLE', 9795 'VOID_VARIABLE', "Variables cannot have a type of 'void'");
10724 "Variables cannot have a type of 'void'");
10725 9796
10726 /** 9797 /**
10727 * Initialize a newly created error code to have the given [name]. The message 9798 * Initialize a newly created error code to have the given [name]. The message
10728 * associated with the error will be created from the given [message] 9799 * associated with the error will be created from the given [message]
10729 * template. The correction associated with the error will be created from the 9800 * template. The correction associated with the error will be created from the
10730 * given [correction] template. 9801 * given [correction] template.
10731 */ 9802 */
10732 const ParserErrorCode(String name, String message, [String correction]) 9803 const ParserErrorCode(String name, String message, [String correction])
10733 : super(name, message, correction); 9804 : super(name, message, correction);
10734 9805
10735 @override 9806 @override
10736 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; 9807 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
10737 9808
10738 @override 9809 @override
10739 ErrorType get type => ErrorType.SYNTACTIC_ERROR; 9810 ErrorType get type => ErrorType.SYNTACTIC_ERROR;
10740 } 9811 }
10741 9812
10742
10743 /** 9813 /**
10744 * Instances of the class `ResolutionCopier` copies resolution information from one AST 9814 * Instances of the class `ResolutionCopier` copies resolution information from one AST
10745 * structure to another as long as the structures of the corresponding children of a pair of nodes 9815 * structure to another as long as the structures of the corresponding children of a pair of nodes
10746 * are the same. 9816 * are the same.
10747 */ 9817 */
10748 class ResolutionCopier implements AstVisitor<bool> { 9818 class ResolutionCopier implements AstVisitor<bool> {
10749 /** 9819 /**
10750 * The AST node with which the node being visited is to be compared. This is o nly valid at the 9820 * The AST node with which the node being visited is to be compared. This is o nly valid at the
10751 * beginning of each visit method (until [isEqualNodes] is invoked). 9821 * beginning of each visit method (until [isEqualNodes] is invoked).
10752 */ 9822 */
10753 AstNode _toNode; 9823 AstNode _toNode;
10754 9824
10755 @override 9825 @override
10756 bool visitAdjacentStrings(AdjacentStrings node) { 9826 bool visitAdjacentStrings(AdjacentStrings node) {
10757 AdjacentStrings toNode = this._toNode as AdjacentStrings; 9827 AdjacentStrings toNode = this._toNode as AdjacentStrings;
10758 return _isEqualNodeLists(node.strings, toNode.strings); 9828 return _isEqualNodeLists(node.strings, toNode.strings);
10759 } 9829 }
10760 9830
10761 @override 9831 @override
10762 bool visitAnnotation(Annotation node) { 9832 bool visitAnnotation(Annotation node) {
10763 Annotation toNode = this._toNode as Annotation; 9833 Annotation toNode = this._toNode as Annotation;
10764 if (_and( 9834 if (_and(_isEqualTokens(node.atSign, toNode.atSign),
10765 _isEqualTokens(node.atSign, toNode.atSign),
10766 _isEqualNodes(node.name, toNode.name), 9835 _isEqualNodes(node.name, toNode.name),
10767 _isEqualTokens(node.period, toNode.period), 9836 _isEqualTokens(node.period, toNode.period),
10768 _isEqualNodes(node.constructorName, toNode.constructorName), 9837 _isEqualNodes(node.constructorName, toNode.constructorName),
10769 _isEqualNodes(node.arguments, toNode.arguments))) { 9838 _isEqualNodes(node.arguments, toNode.arguments))) {
10770 toNode.element = node.element; 9839 toNode.element = node.element;
10771 return true; 9840 return true;
10772 } 9841 }
10773 return false; 9842 return false;
10774 } 9843 }
10775 9844
10776 @override 9845 @override
10777 bool visitArgumentList(ArgumentList node) { 9846 bool visitArgumentList(ArgumentList node) {
10778 ArgumentList toNode = this._toNode as ArgumentList; 9847 ArgumentList toNode = this._toNode as ArgumentList;
10779 return _and( 9848 return _and(_isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
10780 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
10781 _isEqualNodeLists(node.arguments, toNode.arguments), 9849 _isEqualNodeLists(node.arguments, toNode.arguments),
10782 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis)); 9850 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis));
10783 } 9851 }
10784 9852
10785 @override 9853 @override
10786 bool visitAsExpression(AsExpression node) { 9854 bool visitAsExpression(AsExpression node) {
10787 AsExpression toNode = this._toNode as AsExpression; 9855 AsExpression toNode = this._toNode as AsExpression;
10788 if (_and( 9856 if (_and(_isEqualNodes(node.expression, toNode.expression),
10789 _isEqualNodes(node.expression, toNode.expression),
10790 _isEqualTokens(node.asOperator, toNode.asOperator), 9857 _isEqualTokens(node.asOperator, toNode.asOperator),
10791 _isEqualNodes(node.type, toNode.type))) { 9858 _isEqualNodes(node.type, toNode.type))) {
10792 toNode.propagatedType = node.propagatedType; 9859 toNode.propagatedType = node.propagatedType;
10793 toNode.staticType = node.staticType; 9860 toNode.staticType = node.staticType;
10794 return true; 9861 return true;
10795 } 9862 }
10796 return false; 9863 return false;
10797 } 9864 }
10798 9865
10799 @override 9866 @override
10800 bool visitAssertStatement(AssertStatement node) { 9867 bool visitAssertStatement(AssertStatement node) {
10801 AssertStatement toNode = this._toNode as AssertStatement; 9868 AssertStatement toNode = this._toNode as AssertStatement;
10802 return _and( 9869 return _and(_isEqualTokens(node.assertKeyword, toNode.assertKeyword),
10803 _isEqualTokens(node.assertKeyword, toNode.assertKeyword),
10804 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), 9870 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
10805 _isEqualNodes(node.condition, toNode.condition), 9871 _isEqualNodes(node.condition, toNode.condition),
10806 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), 9872 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
10807 _isEqualTokens(node.semicolon, toNode.semicolon)); 9873 _isEqualTokens(node.semicolon, toNode.semicolon));
10808 } 9874 }
10809 9875
10810 @override 9876 @override
10811 bool visitAssignmentExpression(AssignmentExpression node) { 9877 bool visitAssignmentExpression(AssignmentExpression node) {
10812 AssignmentExpression toNode = this._toNode as AssignmentExpression; 9878 AssignmentExpression toNode = this._toNode as AssignmentExpression;
10813 if (_and( 9879 if (_and(_isEqualNodes(node.leftHandSide, toNode.leftHandSide),
10814 _isEqualNodes(node.leftHandSide, toNode.leftHandSide),
10815 _isEqualTokens(node.operator, toNode.operator), 9880 _isEqualTokens(node.operator, toNode.operator),
10816 _isEqualNodes(node.rightHandSide, toNode.rightHandSide))) { 9881 _isEqualNodes(node.rightHandSide, toNode.rightHandSide))) {
10817 toNode.propagatedElement = node.propagatedElement; 9882 toNode.propagatedElement = node.propagatedElement;
10818 toNode.propagatedType = node.propagatedType; 9883 toNode.propagatedType = node.propagatedType;
10819 toNode.staticElement = node.staticElement; 9884 toNode.staticElement = node.staticElement;
10820 toNode.staticType = node.staticType; 9885 toNode.staticType = node.staticType;
10821 return true; 9886 return true;
10822 } 9887 }
10823 return false; 9888 return false;
10824 } 9889 }
10825 9890
10826 @override 9891 @override
10827 bool visitAwaitExpression(AwaitExpression node) { 9892 bool visitAwaitExpression(AwaitExpression node) {
10828 AwaitExpression toNode = this._toNode as AwaitExpression; 9893 AwaitExpression toNode = this._toNode as AwaitExpression;
10829 return _and( 9894 return _and(_isEqualTokens(node.awaitKeyword, toNode.awaitKeyword),
10830 _isEqualTokens(node.awaitKeyword, toNode.awaitKeyword),
10831 _isEqualNodes(node.expression, toNode.expression)); 9895 _isEqualNodes(node.expression, toNode.expression));
10832 } 9896 }
10833 9897
10834 @override 9898 @override
10835 bool visitBinaryExpression(BinaryExpression node) { 9899 bool visitBinaryExpression(BinaryExpression node) {
10836 BinaryExpression toNode = this._toNode as BinaryExpression; 9900 BinaryExpression toNode = this._toNode as BinaryExpression;
10837 if (_and( 9901 if (_and(_isEqualNodes(node.leftOperand, toNode.leftOperand),
10838 _isEqualNodes(node.leftOperand, toNode.leftOperand),
10839 _isEqualTokens(node.operator, toNode.operator), 9902 _isEqualTokens(node.operator, toNode.operator),
10840 _isEqualNodes(node.rightOperand, toNode.rightOperand))) { 9903 _isEqualNodes(node.rightOperand, toNode.rightOperand))) {
10841 toNode.propagatedElement = node.propagatedElement; 9904 toNode.propagatedElement = node.propagatedElement;
10842 toNode.propagatedType = node.propagatedType; 9905 toNode.propagatedType = node.propagatedType;
10843 toNode.staticElement = node.staticElement; 9906 toNode.staticElement = node.staticElement;
10844 toNode.staticType = node.staticType; 9907 toNode.staticType = node.staticType;
10845 return true; 9908 return true;
10846 } 9909 }
10847 return false; 9910 return false;
10848 } 9911 }
10849 9912
10850 @override 9913 @override
10851 bool visitBlock(Block node) { 9914 bool visitBlock(Block node) {
10852 Block toNode = this._toNode as Block; 9915 Block toNode = this._toNode as Block;
10853 return _and( 9916 return _and(_isEqualTokens(node.leftBracket, toNode.leftBracket),
10854 _isEqualTokens(node.leftBracket, toNode.leftBracket),
10855 _isEqualNodeLists(node.statements, toNode.statements), 9917 _isEqualNodeLists(node.statements, toNode.statements),
10856 _isEqualTokens(node.rightBracket, toNode.rightBracket)); 9918 _isEqualTokens(node.rightBracket, toNode.rightBracket));
10857 } 9919 }
10858 9920
10859 @override 9921 @override
10860 bool visitBlockFunctionBody(BlockFunctionBody node) { 9922 bool visitBlockFunctionBody(BlockFunctionBody node) {
10861 BlockFunctionBody toNode = this._toNode as BlockFunctionBody; 9923 BlockFunctionBody toNode = this._toNode as BlockFunctionBody;
10862 return _isEqualNodes(node.block, toNode.block); 9924 return _isEqualNodes(node.block, toNode.block);
10863 } 9925 }
10864 9926
10865 @override 9927 @override
10866 bool visitBooleanLiteral(BooleanLiteral node) { 9928 bool visitBooleanLiteral(BooleanLiteral node) {
10867 BooleanLiteral toNode = this._toNode as BooleanLiteral; 9929 BooleanLiteral toNode = this._toNode as BooleanLiteral;
10868 if (_and( 9930 if (_and(_isEqualTokens(node.literal, toNode.literal),
10869 _isEqualTokens(node.literal, toNode.literal),
10870 node.value == toNode.value)) { 9931 node.value == toNode.value)) {
10871 toNode.propagatedType = node.propagatedType; 9932 toNode.propagatedType = node.propagatedType;
10872 toNode.staticType = node.staticType; 9933 toNode.staticType = node.staticType;
10873 return true; 9934 return true;
10874 } 9935 }
10875 return false; 9936 return false;
10876 } 9937 }
10877 9938
10878 @override 9939 @override
10879 bool visitBreakStatement(BreakStatement node) { 9940 bool visitBreakStatement(BreakStatement node) {
10880 BreakStatement toNode = this._toNode as BreakStatement; 9941 BreakStatement toNode = this._toNode as BreakStatement;
10881 if (_and( 9942 if (_and(_isEqualTokens(node.breakKeyword, toNode.breakKeyword),
10882 _isEqualTokens(node.breakKeyword, toNode.breakKeyword),
10883 _isEqualNodes(node.label, toNode.label), 9943 _isEqualNodes(node.label, toNode.label),
10884 _isEqualTokens(node.semicolon, toNode.semicolon))) { 9944 _isEqualTokens(node.semicolon, toNode.semicolon))) {
10885 // TODO(paulberry): map node.target to toNode.target. 9945 // TODO(paulberry): map node.target to toNode.target.
10886 return true; 9946 return true;
10887 } 9947 }
10888 return false; 9948 return false;
10889 } 9949 }
10890 9950
10891 @override 9951 @override
10892 bool visitCascadeExpression(CascadeExpression node) { 9952 bool visitCascadeExpression(CascadeExpression node) {
10893 CascadeExpression toNode = this._toNode as CascadeExpression; 9953 CascadeExpression toNode = this._toNode as CascadeExpression;
10894 if (_and( 9954 if (_and(_isEqualNodes(node.target, toNode.target),
10895 _isEqualNodes(node.target, toNode.target),
10896 _isEqualNodeLists(node.cascadeSections, toNode.cascadeSections))) { 9955 _isEqualNodeLists(node.cascadeSections, toNode.cascadeSections))) {
10897 toNode.propagatedType = node.propagatedType; 9956 toNode.propagatedType = node.propagatedType;
10898 toNode.staticType = node.staticType; 9957 toNode.staticType = node.staticType;
10899 return true; 9958 return true;
10900 } 9959 }
10901 return false; 9960 return false;
10902 } 9961 }
10903 9962
10904 @override 9963 @override
10905 bool visitCatchClause(CatchClause node) { 9964 bool visitCatchClause(CatchClause node) {
10906 CatchClause toNode = this._toNode as CatchClause; 9965 CatchClause toNode = this._toNode as CatchClause;
10907 return _and( 9966 return _and(_isEqualTokens(node.onKeyword, toNode.onKeyword),
10908 _isEqualTokens(node.onKeyword, toNode.onKeyword),
10909 _isEqualNodes(node.exceptionType, toNode.exceptionType), 9967 _isEqualNodes(node.exceptionType, toNode.exceptionType),
10910 _isEqualTokens(node.catchKeyword, toNode.catchKeyword), 9968 _isEqualTokens(node.catchKeyword, toNode.catchKeyword),
10911 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), 9969 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
10912 _isEqualNodes(node.exceptionParameter, toNode.exceptionParameter), 9970 _isEqualNodes(node.exceptionParameter, toNode.exceptionParameter),
10913 _isEqualTokens(node.comma, toNode.comma), 9971 _isEqualTokens(node.comma, toNode.comma),
10914 _isEqualNodes(node.stackTraceParameter, toNode.stackTraceParameter), 9972 _isEqualNodes(node.stackTraceParameter, toNode.stackTraceParameter),
10915 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), 9973 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
10916 _isEqualNodes(node.body, toNode.body)); 9974 _isEqualNodes(node.body, toNode.body));
10917 } 9975 }
10918 9976
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
10953 10011
10954 @override 10012 @override
10955 bool visitComment(Comment node) { 10013 bool visitComment(Comment node) {
10956 Comment toNode = this._toNode as Comment; 10014 Comment toNode = this._toNode as Comment;
10957 return _isEqualNodeLists(node.references, toNode.references); 10015 return _isEqualNodeLists(node.references, toNode.references);
10958 } 10016 }
10959 10017
10960 @override 10018 @override
10961 bool visitCommentReference(CommentReference node) { 10019 bool visitCommentReference(CommentReference node) {
10962 CommentReference toNode = this._toNode as CommentReference; 10020 CommentReference toNode = this._toNode as CommentReference;
10963 return _and( 10021 return _and(_isEqualTokens(node.newKeyword, toNode.newKeyword),
10964 _isEqualTokens(node.newKeyword, toNode.newKeyword),
10965 _isEqualNodes(node.identifier, toNode.identifier)); 10022 _isEqualNodes(node.identifier, toNode.identifier));
10966 } 10023 }
10967 10024
10968 @override 10025 @override
10969 bool visitCompilationUnit(CompilationUnit node) { 10026 bool visitCompilationUnit(CompilationUnit node) {
10970 CompilationUnit toNode = this._toNode as CompilationUnit; 10027 CompilationUnit toNode = this._toNode as CompilationUnit;
10971 if (_and( 10028 if (_and(_isEqualTokens(node.beginToken, toNode.beginToken),
10972 _isEqualTokens(node.beginToken, toNode.beginToken),
10973 _isEqualNodes(node.scriptTag, toNode.scriptTag), 10029 _isEqualNodes(node.scriptTag, toNode.scriptTag),
10974 _isEqualNodeLists(node.directives, toNode.directives), 10030 _isEqualNodeLists(node.directives, toNode.directives),
10975 _isEqualNodeLists(node.declarations, toNode.declarations), 10031 _isEqualNodeLists(node.declarations, toNode.declarations),
10976 _isEqualTokens(node.endToken, toNode.endToken))) { 10032 _isEqualTokens(node.endToken, toNode.endToken))) {
10977 toNode.element = node.element; 10033 toNode.element = node.element;
10978 return true; 10034 return true;
10979 } 10035 }
10980 return false; 10036 return false;
10981 } 10037 }
10982 10038
10983 @override 10039 @override
10984 bool visitConditionalExpression(ConditionalExpression node) { 10040 bool visitConditionalExpression(ConditionalExpression node) {
10985 ConditionalExpression toNode = this._toNode as ConditionalExpression; 10041 ConditionalExpression toNode = this._toNode as ConditionalExpression;
10986 if (_and( 10042 if (_and(_isEqualNodes(node.condition, toNode.condition),
10987 _isEqualNodes(node.condition, toNode.condition),
10988 _isEqualTokens(node.question, toNode.question), 10043 _isEqualTokens(node.question, toNode.question),
10989 _isEqualNodes(node.thenExpression, toNode.thenExpression), 10044 _isEqualNodes(node.thenExpression, toNode.thenExpression),
10990 _isEqualTokens(node.colon, toNode.colon), 10045 _isEqualTokens(node.colon, toNode.colon),
10991 _isEqualNodes(node.elseExpression, toNode.elseExpression))) { 10046 _isEqualNodes(node.elseExpression, toNode.elseExpression))) {
10992 toNode.propagatedType = node.propagatedType; 10047 toNode.propagatedType = node.propagatedType;
10993 toNode.staticType = node.staticType; 10048 toNode.staticType = node.staticType;
10994 return true; 10049 return true;
10995 } 10050 }
10996 return false; 10051 return false;
10997 } 10052 }
(...skipping 18 matching lines...) Expand all
11016 toNode.element = node.element; 10071 toNode.element = node.element;
11017 return true; 10072 return true;
11018 } 10073 }
11019 return false; 10074 return false;
11020 } 10075 }
11021 10076
11022 @override 10077 @override
11023 bool visitConstructorFieldInitializer(ConstructorFieldInitializer node) { 10078 bool visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
11024 ConstructorFieldInitializer toNode = 10079 ConstructorFieldInitializer toNode =
11025 this._toNode as ConstructorFieldInitializer; 10080 this._toNode as ConstructorFieldInitializer;
11026 return _and( 10081 return _and(_isEqualTokens(node.thisKeyword, toNode.thisKeyword),
11027 _isEqualTokens(node.thisKeyword, toNode.thisKeyword),
11028 _isEqualTokens(node.period, toNode.period), 10082 _isEqualTokens(node.period, toNode.period),
11029 _isEqualNodes(node.fieldName, toNode.fieldName), 10083 _isEqualNodes(node.fieldName, toNode.fieldName),
11030 _isEqualTokens(node.equals, toNode.equals), 10084 _isEqualTokens(node.equals, toNode.equals),
11031 _isEqualNodes(node.expression, toNode.expression)); 10085 _isEqualNodes(node.expression, toNode.expression));
11032 } 10086 }
11033 10087
11034 @override 10088 @override
11035 bool visitConstructorName(ConstructorName node) { 10089 bool visitConstructorName(ConstructorName node) {
11036 ConstructorName toNode = this._toNode as ConstructorName; 10090 ConstructorName toNode = this._toNode as ConstructorName;
11037 if (_and( 10091 if (_and(_isEqualNodes(node.type, toNode.type),
11038 _isEqualNodes(node.type, toNode.type),
11039 _isEqualTokens(node.period, toNode.period), 10092 _isEqualTokens(node.period, toNode.period),
11040 _isEqualNodes(node.name, toNode.name))) { 10093 _isEqualNodes(node.name, toNode.name))) {
11041 toNode.staticElement = node.staticElement; 10094 toNode.staticElement = node.staticElement;
11042 return true; 10095 return true;
11043 } 10096 }
11044 return false; 10097 return false;
11045 } 10098 }
11046 10099
11047 @override 10100 @override
11048 bool visitContinueStatement(ContinueStatement node) { 10101 bool visitContinueStatement(ContinueStatement node) {
11049 ContinueStatement toNode = this._toNode as ContinueStatement; 10102 ContinueStatement toNode = this._toNode as ContinueStatement;
11050 if (_and( 10103 if (_and(_isEqualTokens(node.continueKeyword, toNode.continueKeyword),
11051 _isEqualTokens(node.continueKeyword, toNode.continueKeyword),
11052 _isEqualNodes(node.label, toNode.label), 10104 _isEqualNodes(node.label, toNode.label),
11053 _isEqualTokens(node.semicolon, toNode.semicolon))) { 10105 _isEqualTokens(node.semicolon, toNode.semicolon))) {
11054 // TODO(paulberry): map node.target to toNode.target. 10106 // TODO(paulberry): map node.target to toNode.target.
11055 return true; 10107 return true;
11056 } 10108 }
11057 return false; 10109 return false;
11058 } 10110 }
11059 10111
11060 @override 10112 @override
11061 bool visitDeclaredIdentifier(DeclaredIdentifier node) { 10113 bool visitDeclaredIdentifier(DeclaredIdentifier node) {
11062 DeclaredIdentifier toNode = this._toNode as DeclaredIdentifier; 10114 DeclaredIdentifier toNode = this._toNode as DeclaredIdentifier;
11063 return _and( 10115 return _and(
11064 _isEqualNodes(node.documentationComment, toNode.documentationComment), 10116 _isEqualNodes(node.documentationComment, toNode.documentationComment),
11065 _isEqualNodeLists(node.metadata, toNode.metadata), 10117 _isEqualNodeLists(node.metadata, toNode.metadata),
11066 _isEqualTokens(node.keyword, toNode.keyword), 10118 _isEqualTokens(node.keyword, toNode.keyword),
11067 _isEqualNodes(node.type, toNode.type), 10119 _isEqualNodes(node.type, toNode.type),
11068 _isEqualNodes(node.identifier, toNode.identifier)); 10120 _isEqualNodes(node.identifier, toNode.identifier));
11069 } 10121 }
11070 10122
11071 @override 10123 @override
11072 bool visitDefaultFormalParameter(DefaultFormalParameter node) { 10124 bool visitDefaultFormalParameter(DefaultFormalParameter node) {
11073 DefaultFormalParameter toNode = this._toNode as DefaultFormalParameter; 10125 DefaultFormalParameter toNode = this._toNode as DefaultFormalParameter;
11074 return _and( 10126 return _and(_isEqualNodes(node.parameter, toNode.parameter),
11075 _isEqualNodes(node.parameter, toNode.parameter),
11076 node.kind == toNode.kind, 10127 node.kind == toNode.kind,
11077 _isEqualTokens(node.separator, toNode.separator), 10128 _isEqualTokens(node.separator, toNode.separator),
11078 _isEqualNodes(node.defaultValue, toNode.defaultValue)); 10129 _isEqualNodes(node.defaultValue, toNode.defaultValue));
11079 } 10130 }
11080 10131
11081 @override 10132 @override
11082 bool visitDoStatement(DoStatement node) { 10133 bool visitDoStatement(DoStatement node) {
11083 DoStatement toNode = this._toNode as DoStatement; 10134 DoStatement toNode = this._toNode as DoStatement;
11084 return _and( 10135 return _and(_isEqualTokens(node.doKeyword, toNode.doKeyword),
11085 _isEqualTokens(node.doKeyword, toNode.doKeyword),
11086 _isEqualNodes(node.body, toNode.body), 10136 _isEqualNodes(node.body, toNode.body),
11087 _isEqualTokens(node.whileKeyword, toNode.whileKeyword), 10137 _isEqualTokens(node.whileKeyword, toNode.whileKeyword),
11088 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), 10138 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11089 _isEqualNodes(node.condition, toNode.condition), 10139 _isEqualNodes(node.condition, toNode.condition),
11090 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), 10140 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
11091 _isEqualTokens(node.semicolon, toNode.semicolon)); 10141 _isEqualTokens(node.semicolon, toNode.semicolon));
11092 } 10142 }
11093 10143
11094 @override 10144 @override
11095 bool visitDoubleLiteral(DoubleLiteral node) { 10145 bool visitDoubleLiteral(DoubleLiteral node) {
11096 DoubleLiteral toNode = this._toNode as DoubleLiteral; 10146 DoubleLiteral toNode = this._toNode as DoubleLiteral;
11097 if (_and( 10147 if (_and(_isEqualTokens(node.literal, toNode.literal),
11098 _isEqualTokens(node.literal, toNode.literal),
11099 node.value == toNode.value)) { 10148 node.value == toNode.value)) {
11100 toNode.propagatedType = node.propagatedType; 10149 toNode.propagatedType = node.propagatedType;
11101 toNode.staticType = node.staticType; 10150 toNode.staticType = node.staticType;
11102 return true; 10151 return true;
11103 } 10152 }
11104 return false; 10153 return false;
11105 } 10154 }
11106 10155
11107 @override 10156 @override
11108 bool visitEmptyFunctionBody(EmptyFunctionBody node) { 10157 bool visitEmptyFunctionBody(EmptyFunctionBody node) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
11159 ExpressionFunctionBody toNode = this._toNode as ExpressionFunctionBody; 10208 ExpressionFunctionBody toNode = this._toNode as ExpressionFunctionBody;
11160 return _and( 10209 return _and(
11161 _isEqualTokens(node.functionDefinition, toNode.functionDefinition), 10210 _isEqualTokens(node.functionDefinition, toNode.functionDefinition),
11162 _isEqualNodes(node.expression, toNode.expression), 10211 _isEqualNodes(node.expression, toNode.expression),
11163 _isEqualTokens(node.semicolon, toNode.semicolon)); 10212 _isEqualTokens(node.semicolon, toNode.semicolon));
11164 } 10213 }
11165 10214
11166 @override 10215 @override
11167 bool visitExpressionStatement(ExpressionStatement node) { 10216 bool visitExpressionStatement(ExpressionStatement node) {
11168 ExpressionStatement toNode = this._toNode as ExpressionStatement; 10217 ExpressionStatement toNode = this._toNode as ExpressionStatement;
11169 return _and( 10218 return _and(_isEqualNodes(node.expression, toNode.expression),
11170 _isEqualNodes(node.expression, toNode.expression),
11171 _isEqualTokens(node.semicolon, toNode.semicolon)); 10219 _isEqualTokens(node.semicolon, toNode.semicolon));
11172 } 10220 }
11173 10221
11174 @override 10222 @override
11175 bool visitExtendsClause(ExtendsClause node) { 10223 bool visitExtendsClause(ExtendsClause node) {
11176 ExtendsClause toNode = this._toNode as ExtendsClause; 10224 ExtendsClause toNode = this._toNode as ExtendsClause;
11177 return _and( 10225 return _and(_isEqualTokens(node.extendsKeyword, toNode.extendsKeyword),
11178 _isEqualTokens(node.extendsKeyword, toNode.extendsKeyword),
11179 _isEqualNodes(node.superclass, toNode.superclass)); 10226 _isEqualNodes(node.superclass, toNode.superclass));
11180 } 10227 }
11181 10228
11182 @override 10229 @override
11183 bool visitFieldDeclaration(FieldDeclaration node) { 10230 bool visitFieldDeclaration(FieldDeclaration node) {
11184 FieldDeclaration toNode = this._toNode as FieldDeclaration; 10231 FieldDeclaration toNode = this._toNode as FieldDeclaration;
11185 return _and( 10232 return _and(
11186 _isEqualNodes(node.documentationComment, toNode.documentationComment), 10233 _isEqualNodes(node.documentationComment, toNode.documentationComment),
11187 _isEqualNodeLists(node.metadata, toNode.metadata), 10234 _isEqualNodeLists(node.metadata, toNode.metadata),
11188 _isEqualTokens(node.staticKeyword, toNode.staticKeyword), 10235 _isEqualTokens(node.staticKeyword, toNode.staticKeyword),
(...skipping 10 matching lines...) Expand all
11199 _isEqualTokens(node.keyword, toNode.keyword), 10246 _isEqualTokens(node.keyword, toNode.keyword),
11200 _isEqualNodes(node.type, toNode.type), 10247 _isEqualNodes(node.type, toNode.type),
11201 _isEqualTokens(node.thisKeyword, toNode.thisKeyword), 10248 _isEqualTokens(node.thisKeyword, toNode.thisKeyword),
11202 _isEqualTokens(node.period, toNode.period), 10249 _isEqualTokens(node.period, toNode.period),
11203 _isEqualNodes(node.identifier, toNode.identifier)); 10250 _isEqualNodes(node.identifier, toNode.identifier));
11204 } 10251 }
11205 10252
11206 @override 10253 @override
11207 bool visitForEachStatement(ForEachStatement node) { 10254 bool visitForEachStatement(ForEachStatement node) {
11208 ForEachStatement toNode = this._toNode as ForEachStatement; 10255 ForEachStatement toNode = this._toNode as ForEachStatement;
11209 return _and( 10256 return _and(_isEqualTokens(node.forKeyword, toNode.forKeyword),
11210 _isEqualTokens(node.forKeyword, toNode.forKeyword),
11211 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), 10257 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11212 _isEqualNodes(node.loopVariable, toNode.loopVariable), 10258 _isEqualNodes(node.loopVariable, toNode.loopVariable),
11213 _isEqualTokens(node.inKeyword, toNode.inKeyword), 10259 _isEqualTokens(node.inKeyword, toNode.inKeyword),
11214 _isEqualNodes(node.iterable, toNode.iterable), 10260 _isEqualNodes(node.iterable, toNode.iterable),
11215 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), 10261 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
11216 _isEqualNodes(node.body, toNode.body)); 10262 _isEqualNodes(node.body, toNode.body));
11217 } 10263 }
11218 10264
11219 @override 10265 @override
11220 bool visitFormalParameterList(FormalParameterList node) { 10266 bool visitFormalParameterList(FormalParameterList node) {
11221 FormalParameterList toNode = this._toNode as FormalParameterList; 10267 FormalParameterList toNode = this._toNode as FormalParameterList;
11222 return _and( 10268 return _and(_isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11223 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11224 _isEqualNodeLists(node.parameters, toNode.parameters), 10269 _isEqualNodeLists(node.parameters, toNode.parameters),
11225 _isEqualTokens(node.leftDelimiter, toNode.leftDelimiter), 10270 _isEqualTokens(node.leftDelimiter, toNode.leftDelimiter),
11226 _isEqualTokens(node.rightDelimiter, toNode.rightDelimiter), 10271 _isEqualTokens(node.rightDelimiter, toNode.rightDelimiter),
11227 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis)); 10272 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis));
11228 } 10273 }
11229 10274
11230 @override 10275 @override
11231 bool visitForStatement(ForStatement node) { 10276 bool visitForStatement(ForStatement node) {
11232 ForStatement toNode = this._toNode as ForStatement; 10277 ForStatement toNode = this._toNode as ForStatement;
11233 return _and( 10278 return _and(_isEqualTokens(node.forKeyword, toNode.forKeyword),
11234 _isEqualTokens(node.forKeyword, toNode.forKeyword),
11235 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), 10279 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11236 _isEqualNodes(node.variables, toNode.variables), 10280 _isEqualNodes(node.variables, toNode.variables),
11237 _isEqualNodes(node.initialization, toNode.initialization), 10281 _isEqualNodes(node.initialization, toNode.initialization),
11238 _isEqualTokens(node.leftSeparator, toNode.leftSeparator), 10282 _isEqualTokens(node.leftSeparator, toNode.leftSeparator),
11239 _isEqualNodes(node.condition, toNode.condition), 10283 _isEqualNodes(node.condition, toNode.condition),
11240 _isEqualTokens(node.rightSeparator, toNode.rightSeparator), 10284 _isEqualTokens(node.rightSeparator, toNode.rightSeparator),
11241 _isEqualNodeLists(node.updaters, toNode.updaters), 10285 _isEqualNodeLists(node.updaters, toNode.updaters),
11242 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), 10286 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
11243 _isEqualNodes(node.body, toNode.body)); 10287 _isEqualNodes(node.body, toNode.body));
11244 } 10288 }
(...skipping 14 matching lines...) Expand all
11259 @override 10303 @override
11260 bool visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { 10304 bool visitFunctionDeclarationStatement(FunctionDeclarationStatement node) {
11261 FunctionDeclarationStatement toNode = 10305 FunctionDeclarationStatement toNode =
11262 this._toNode as FunctionDeclarationStatement; 10306 this._toNode as FunctionDeclarationStatement;
11263 return _isEqualNodes(node.functionDeclaration, toNode.functionDeclaration); 10307 return _isEqualNodes(node.functionDeclaration, toNode.functionDeclaration);
11264 } 10308 }
11265 10309
11266 @override 10310 @override
11267 bool visitFunctionExpression(FunctionExpression node) { 10311 bool visitFunctionExpression(FunctionExpression node) {
11268 FunctionExpression toNode = this._toNode as FunctionExpression; 10312 FunctionExpression toNode = this._toNode as FunctionExpression;
11269 if (_and( 10313 if (_and(_isEqualNodes(node.parameters, toNode.parameters),
11270 _isEqualNodes(node.parameters, toNode.parameters),
11271 _isEqualNodes(node.body, toNode.body))) { 10314 _isEqualNodes(node.body, toNode.body))) {
11272 toNode.element = node.element; 10315 toNode.element = node.element;
11273 toNode.propagatedType = node.propagatedType; 10316 toNode.propagatedType = node.propagatedType;
11274 toNode.staticType = node.staticType; 10317 toNode.staticType = node.staticType;
11275 return true; 10318 return true;
11276 } 10319 }
11277 return false; 10320 return false;
11278 } 10321 }
11279 10322
11280 @override 10323 @override
11281 bool visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { 10324 bool visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
11282 FunctionExpressionInvocation toNode = 10325 FunctionExpressionInvocation toNode =
11283 this._toNode as FunctionExpressionInvocation; 10326 this._toNode as FunctionExpressionInvocation;
11284 if (_and( 10327 if (_and(_isEqualNodes(node.function, toNode.function),
11285 _isEqualNodes(node.function, toNode.function),
11286 _isEqualNodes(node.argumentList, toNode.argumentList))) { 10328 _isEqualNodes(node.argumentList, toNode.argumentList))) {
11287 toNode.propagatedElement = node.propagatedElement; 10329 toNode.propagatedElement = node.propagatedElement;
11288 toNode.propagatedType = node.propagatedType; 10330 toNode.propagatedType = node.propagatedType;
11289 toNode.staticElement = node.staticElement; 10331 toNode.staticElement = node.staticElement;
11290 toNode.staticType = node.staticType; 10332 toNode.staticType = node.staticType;
11291 return true; 10333 return true;
11292 } 10334 }
11293 return false; 10335 return false;
11294 } 10336 }
11295 10337
(...skipping 19 matching lines...) Expand all
11315 _isEqualNodes(node.documentationComment, toNode.documentationComment), 10357 _isEqualNodes(node.documentationComment, toNode.documentationComment),
11316 _isEqualNodeLists(node.metadata, toNode.metadata), 10358 _isEqualNodeLists(node.metadata, toNode.metadata),
11317 _isEqualNodes(node.returnType, toNode.returnType), 10359 _isEqualNodes(node.returnType, toNode.returnType),
11318 _isEqualNodes(node.identifier, toNode.identifier), 10360 _isEqualNodes(node.identifier, toNode.identifier),
11319 _isEqualNodes(node.parameters, toNode.parameters)); 10361 _isEqualNodes(node.parameters, toNode.parameters));
11320 } 10362 }
11321 10363
11322 @override 10364 @override
11323 bool visitHideCombinator(HideCombinator node) { 10365 bool visitHideCombinator(HideCombinator node) {
11324 HideCombinator toNode = this._toNode as HideCombinator; 10366 HideCombinator toNode = this._toNode as HideCombinator;
11325 return _and( 10367 return _and(_isEqualTokens(node.keyword, toNode.keyword),
11326 _isEqualTokens(node.keyword, toNode.keyword),
11327 _isEqualNodeLists(node.hiddenNames, toNode.hiddenNames)); 10368 _isEqualNodeLists(node.hiddenNames, toNode.hiddenNames));
11328 } 10369 }
11329 10370
11330 @override 10371 @override
11331 bool visitIfStatement(IfStatement node) { 10372 bool visitIfStatement(IfStatement node) {
11332 IfStatement toNode = this._toNode as IfStatement; 10373 IfStatement toNode = this._toNode as IfStatement;
11333 return _and( 10374 return _and(_isEqualTokens(node.ifKeyword, toNode.ifKeyword),
11334 _isEqualTokens(node.ifKeyword, toNode.ifKeyword),
11335 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), 10375 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11336 _isEqualNodes(node.condition, toNode.condition), 10376 _isEqualNodes(node.condition, toNode.condition),
11337 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), 10377 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
11338 _isEqualNodes(node.thenStatement, toNode.thenStatement), 10378 _isEqualNodes(node.thenStatement, toNode.thenStatement),
11339 _isEqualTokens(node.elseKeyword, toNode.elseKeyword), 10379 _isEqualTokens(node.elseKeyword, toNode.elseKeyword),
11340 _isEqualNodes(node.elseStatement, toNode.elseStatement)); 10380 _isEqualNodes(node.elseStatement, toNode.elseStatement));
11341 } 10381 }
11342 10382
11343 @override 10383 @override
11344 bool visitImplementsClause(ImplementsClause node) { 10384 bool visitImplementsClause(ImplementsClause node) {
(...skipping 17 matching lines...) Expand all
11362 _isEqualTokens(node.semicolon, toNode.semicolon))) { 10402 _isEqualTokens(node.semicolon, toNode.semicolon))) {
11363 toNode.element = node.element; 10403 toNode.element = node.element;
11364 return true; 10404 return true;
11365 } 10405 }
11366 return false; 10406 return false;
11367 } 10407 }
11368 10408
11369 @override 10409 @override
11370 bool visitIndexExpression(IndexExpression node) { 10410 bool visitIndexExpression(IndexExpression node) {
11371 IndexExpression toNode = this._toNode as IndexExpression; 10411 IndexExpression toNode = this._toNode as IndexExpression;
11372 if (_and( 10412 if (_and(_isEqualNodes(node.target, toNode.target),
11373 _isEqualNodes(node.target, toNode.target),
11374 _isEqualTokens(node.leftBracket, toNode.leftBracket), 10413 _isEqualTokens(node.leftBracket, toNode.leftBracket),
11375 _isEqualNodes(node.index, toNode.index), 10414 _isEqualNodes(node.index, toNode.index),
11376 _isEqualTokens(node.rightBracket, toNode.rightBracket))) { 10415 _isEqualTokens(node.rightBracket, toNode.rightBracket))) {
11377 toNode.auxiliaryElements = node.auxiliaryElements; 10416 toNode.auxiliaryElements = node.auxiliaryElements;
11378 toNode.propagatedElement = node.propagatedElement; 10417 toNode.propagatedElement = node.propagatedElement;
11379 toNode.propagatedType = node.propagatedType; 10418 toNode.propagatedType = node.propagatedType;
11380 toNode.staticElement = node.staticElement; 10419 toNode.staticElement = node.staticElement;
11381 toNode.staticType = node.staticType; 10420 toNode.staticType = node.staticType;
11382 return true; 10421 return true;
11383 } 10422 }
11384 return false; 10423 return false;
11385 } 10424 }
11386 10425
11387 @override 10426 @override
11388 bool visitInstanceCreationExpression(InstanceCreationExpression node) { 10427 bool visitInstanceCreationExpression(InstanceCreationExpression node) {
11389 InstanceCreationExpression toNode = 10428 InstanceCreationExpression toNode =
11390 this._toNode as InstanceCreationExpression; 10429 this._toNode as InstanceCreationExpression;
11391 if (_and( 10430 if (_and(_isEqualTokens(node.keyword, toNode.keyword),
11392 _isEqualTokens(node.keyword, toNode.keyword),
11393 _isEqualNodes(node.constructorName, toNode.constructorName), 10431 _isEqualNodes(node.constructorName, toNode.constructorName),
11394 _isEqualNodes(node.argumentList, toNode.argumentList))) { 10432 _isEqualNodes(node.argumentList, toNode.argumentList))) {
11395 toNode.propagatedType = node.propagatedType; 10433 toNode.propagatedType = node.propagatedType;
11396 toNode.staticElement = node.staticElement; 10434 toNode.staticElement = node.staticElement;
11397 toNode.staticType = node.staticType; 10435 toNode.staticType = node.staticType;
11398 return true; 10436 return true;
11399 } 10437 }
11400 return false; 10438 return false;
11401 } 10439 }
11402 10440
11403 @override 10441 @override
11404 bool visitIntegerLiteral(IntegerLiteral node) { 10442 bool visitIntegerLiteral(IntegerLiteral node) {
11405 IntegerLiteral toNode = this._toNode as IntegerLiteral; 10443 IntegerLiteral toNode = this._toNode as IntegerLiteral;
11406 if (_and( 10444 if (_and(_isEqualTokens(node.literal, toNode.literal),
11407 _isEqualTokens(node.literal, toNode.literal),
11408 node.value == toNode.value)) { 10445 node.value == toNode.value)) {
11409 toNode.propagatedType = node.propagatedType; 10446 toNode.propagatedType = node.propagatedType;
11410 toNode.staticType = node.staticType; 10447 toNode.staticType = node.staticType;
11411 return true; 10448 return true;
11412 } 10449 }
11413 return false; 10450 return false;
11414 } 10451 }
11415 10452
11416 @override 10453 @override
11417 bool visitInterpolationExpression(InterpolationExpression node) { 10454 bool visitInterpolationExpression(InterpolationExpression node) {
11418 InterpolationExpression toNode = this._toNode as InterpolationExpression; 10455 InterpolationExpression toNode = this._toNode as InterpolationExpression;
11419 return _and( 10456 return _and(_isEqualTokens(node.leftBracket, toNode.leftBracket),
11420 _isEqualTokens(node.leftBracket, toNode.leftBracket),
11421 _isEqualNodes(node.expression, toNode.expression), 10457 _isEqualNodes(node.expression, toNode.expression),
11422 _isEqualTokens(node.rightBracket, toNode.rightBracket)); 10458 _isEqualTokens(node.rightBracket, toNode.rightBracket));
11423 } 10459 }
11424 10460
11425 @override 10461 @override
11426 bool visitInterpolationString(InterpolationString node) { 10462 bool visitInterpolationString(InterpolationString node) {
11427 InterpolationString toNode = this._toNode as InterpolationString; 10463 InterpolationString toNode = this._toNode as InterpolationString;
11428 return _and( 10464 return _and(_isEqualTokens(node.contents, toNode.contents),
11429 _isEqualTokens(node.contents, toNode.contents),
11430 node.value == toNode.value); 10465 node.value == toNode.value);
11431 } 10466 }
11432 10467
11433 @override 10468 @override
11434 bool visitIsExpression(IsExpression node) { 10469 bool visitIsExpression(IsExpression node) {
11435 IsExpression toNode = this._toNode as IsExpression; 10470 IsExpression toNode = this._toNode as IsExpression;
11436 if (_and( 10471 if (_and(_isEqualNodes(node.expression, toNode.expression),
11437 _isEqualNodes(node.expression, toNode.expression),
11438 _isEqualTokens(node.isOperator, toNode.isOperator), 10472 _isEqualTokens(node.isOperator, toNode.isOperator),
11439 _isEqualTokens(node.notOperator, toNode.notOperator), 10473 _isEqualTokens(node.notOperator, toNode.notOperator),
11440 _isEqualNodes(node.type, toNode.type))) { 10474 _isEqualNodes(node.type, toNode.type))) {
11441 toNode.propagatedType = node.propagatedType; 10475 toNode.propagatedType = node.propagatedType;
11442 toNode.staticType = node.staticType; 10476 toNode.staticType = node.staticType;
11443 return true; 10477 return true;
11444 } 10478 }
11445 return false; 10479 return false;
11446 } 10480 }
11447 10481
11448 @override 10482 @override
11449 bool visitLabel(Label node) { 10483 bool visitLabel(Label node) {
11450 Label toNode = this._toNode as Label; 10484 Label toNode = this._toNode as Label;
11451 return _and( 10485 return _and(_isEqualNodes(node.label, toNode.label),
11452 _isEqualNodes(node.label, toNode.label),
11453 _isEqualTokens(node.colon, toNode.colon)); 10486 _isEqualTokens(node.colon, toNode.colon));
11454 } 10487 }
11455 10488
11456 @override 10489 @override
11457 bool visitLabeledStatement(LabeledStatement node) { 10490 bool visitLabeledStatement(LabeledStatement node) {
11458 LabeledStatement toNode = this._toNode as LabeledStatement; 10491 LabeledStatement toNode = this._toNode as LabeledStatement;
11459 return _and( 10492 return _and(_isEqualNodeLists(node.labels, toNode.labels),
11460 _isEqualNodeLists(node.labels, toNode.labels),
11461 _isEqualNodes(node.statement, toNode.statement)); 10493 _isEqualNodes(node.statement, toNode.statement));
11462 } 10494 }
11463 10495
11464 @override 10496 @override
11465 bool visitLibraryDirective(LibraryDirective node) { 10497 bool visitLibraryDirective(LibraryDirective node) {
11466 LibraryDirective toNode = this._toNode as LibraryDirective; 10498 LibraryDirective toNode = this._toNode as LibraryDirective;
11467 return _and( 10499 return _and(
11468 _isEqualNodes(node.documentationComment, toNode.documentationComment), 10500 _isEqualNodes(node.documentationComment, toNode.documentationComment),
11469 _isEqualNodeLists(node.metadata, toNode.metadata), 10501 _isEqualNodeLists(node.metadata, toNode.metadata),
11470 _isEqualTokens(node.libraryKeyword, toNode.libraryKeyword), 10502 _isEqualTokens(node.libraryKeyword, toNode.libraryKeyword),
11471 _isEqualNodes(node.name, toNode.name), 10503 _isEqualNodes(node.name, toNode.name),
11472 _isEqualTokens(node.semicolon, toNode.semicolon)); 10504 _isEqualTokens(node.semicolon, toNode.semicolon));
11473 } 10505 }
11474 10506
11475 @override 10507 @override
11476 bool visitLibraryIdentifier(LibraryIdentifier node) { 10508 bool visitLibraryIdentifier(LibraryIdentifier node) {
11477 LibraryIdentifier toNode = this._toNode as LibraryIdentifier; 10509 LibraryIdentifier toNode = this._toNode as LibraryIdentifier;
11478 if (_isEqualNodeLists(node.components, toNode.components)) { 10510 if (_isEqualNodeLists(node.components, toNode.components)) {
11479 toNode.propagatedType = node.propagatedType; 10511 toNode.propagatedType = node.propagatedType;
11480 toNode.staticType = node.staticType; 10512 toNode.staticType = node.staticType;
11481 return true; 10513 return true;
11482 } 10514 }
11483 return false; 10515 return false;
11484 } 10516 }
11485 10517
11486 @override 10518 @override
11487 bool visitListLiteral(ListLiteral node) { 10519 bool visitListLiteral(ListLiteral node) {
11488 ListLiteral toNode = this._toNode as ListLiteral; 10520 ListLiteral toNode = this._toNode as ListLiteral;
11489 if (_and( 10521 if (_and(_isEqualTokens(node.constKeyword, toNode.constKeyword),
11490 _isEqualTokens(node.constKeyword, toNode.constKeyword),
11491 _isEqualNodes(node.typeArguments, toNode.typeArguments), 10522 _isEqualNodes(node.typeArguments, toNode.typeArguments),
11492 _isEqualTokens(node.leftBracket, toNode.leftBracket), 10523 _isEqualTokens(node.leftBracket, toNode.leftBracket),
11493 _isEqualNodeLists(node.elements, toNode.elements), 10524 _isEqualNodeLists(node.elements, toNode.elements),
11494 _isEqualTokens(node.rightBracket, toNode.rightBracket))) { 10525 _isEqualTokens(node.rightBracket, toNode.rightBracket))) {
11495 toNode.propagatedType = node.propagatedType; 10526 toNode.propagatedType = node.propagatedType;
11496 toNode.staticType = node.staticType; 10527 toNode.staticType = node.staticType;
11497 return true; 10528 return true;
11498 } 10529 }
11499 return false; 10530 return false;
11500 } 10531 }
11501 10532
11502 @override 10533 @override
11503 bool visitMapLiteral(MapLiteral node) { 10534 bool visitMapLiteral(MapLiteral node) {
11504 MapLiteral toNode = this._toNode as MapLiteral; 10535 MapLiteral toNode = this._toNode as MapLiteral;
11505 if (_and( 10536 if (_and(_isEqualTokens(node.constKeyword, toNode.constKeyword),
11506 _isEqualTokens(node.constKeyword, toNode.constKeyword),
11507 _isEqualNodes(node.typeArguments, toNode.typeArguments), 10537 _isEqualNodes(node.typeArguments, toNode.typeArguments),
11508 _isEqualTokens(node.leftBracket, toNode.leftBracket), 10538 _isEqualTokens(node.leftBracket, toNode.leftBracket),
11509 _isEqualNodeLists(node.entries, toNode.entries), 10539 _isEqualNodeLists(node.entries, toNode.entries),
11510 _isEqualTokens(node.rightBracket, toNode.rightBracket))) { 10540 _isEqualTokens(node.rightBracket, toNode.rightBracket))) {
11511 toNode.propagatedType = node.propagatedType; 10541 toNode.propagatedType = node.propagatedType;
11512 toNode.staticType = node.staticType; 10542 toNode.staticType = node.staticType;
11513 return true; 10543 return true;
11514 } 10544 }
11515 return false; 10545 return false;
11516 } 10546 }
11517 10547
11518 @override 10548 @override
11519 bool visitMapLiteralEntry(MapLiteralEntry node) { 10549 bool visitMapLiteralEntry(MapLiteralEntry node) {
11520 MapLiteralEntry toNode = this._toNode as MapLiteralEntry; 10550 MapLiteralEntry toNode = this._toNode as MapLiteralEntry;
11521 return _and( 10551 return _and(_isEqualNodes(node.key, toNode.key),
11522 _isEqualNodes(node.key, toNode.key),
11523 _isEqualTokens(node.separator, toNode.separator), 10552 _isEqualTokens(node.separator, toNode.separator),
11524 _isEqualNodes(node.value, toNode.value)); 10553 _isEqualNodes(node.value, toNode.value));
11525 } 10554 }
11526 10555
11527 @override 10556 @override
11528 bool visitMethodDeclaration(MethodDeclaration node) { 10557 bool visitMethodDeclaration(MethodDeclaration node) {
11529 MethodDeclaration toNode = this._toNode as MethodDeclaration; 10558 MethodDeclaration toNode = this._toNode as MethodDeclaration;
11530 return _and( 10559 return _and(
11531 _isEqualNodes(node.documentationComment, toNode.documentationComment), 10560 _isEqualNodes(node.documentationComment, toNode.documentationComment),
11532 _isEqualNodeLists(node.metadata, toNode.metadata), 10561 _isEqualNodeLists(node.metadata, toNode.metadata),
11533 _isEqualTokens(node.externalKeyword, toNode.externalKeyword), 10562 _isEqualTokens(node.externalKeyword, toNode.externalKeyword),
11534 _isEqualTokens(node.modifierKeyword, toNode.modifierKeyword), 10563 _isEqualTokens(node.modifierKeyword, toNode.modifierKeyword),
11535 _isEqualNodes(node.returnType, toNode.returnType), 10564 _isEqualNodes(node.returnType, toNode.returnType),
11536 _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword), 10565 _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword),
11537 _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword), 10566 _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword),
11538 _isEqualNodes(node.name, toNode.name), 10567 _isEqualNodes(node.name, toNode.name),
11539 _isEqualNodes(node.parameters, toNode.parameters), 10568 _isEqualNodes(node.parameters, toNode.parameters),
11540 _isEqualNodes(node.body, toNode.body)); 10569 _isEqualNodes(node.body, toNode.body));
11541 } 10570 }
11542 10571
11543 @override 10572 @override
11544 bool visitMethodInvocation(MethodInvocation node) { 10573 bool visitMethodInvocation(MethodInvocation node) {
11545 MethodInvocation toNode = this._toNode as MethodInvocation; 10574 MethodInvocation toNode = this._toNode as MethodInvocation;
11546 if (_and( 10575 if (_and(_isEqualNodes(node.target, toNode.target),
11547 _isEqualNodes(node.target, toNode.target),
11548 _isEqualTokens(node.period, toNode.period), 10576 _isEqualTokens(node.period, toNode.period),
11549 _isEqualNodes(node.methodName, toNode.methodName), 10577 _isEqualNodes(node.methodName, toNode.methodName),
11550 _isEqualNodes(node.argumentList, toNode.argumentList))) { 10578 _isEqualNodes(node.argumentList, toNode.argumentList))) {
11551 toNode.propagatedType = node.propagatedType; 10579 toNode.propagatedType = node.propagatedType;
11552 toNode.staticType = node.staticType; 10580 toNode.staticType = node.staticType;
11553 return true; 10581 return true;
11554 } 10582 }
11555 return false; 10583 return false;
11556 } 10584 }
11557 10585
11558 @override 10586 @override
11559 bool visitNamedExpression(NamedExpression node) { 10587 bool visitNamedExpression(NamedExpression node) {
11560 NamedExpression toNode = this._toNode as NamedExpression; 10588 NamedExpression toNode = this._toNode as NamedExpression;
11561 if (_and( 10589 if (_and(_isEqualNodes(node.name, toNode.name),
11562 _isEqualNodes(node.name, toNode.name),
11563 _isEqualNodes(node.expression, toNode.expression))) { 10590 _isEqualNodes(node.expression, toNode.expression))) {
11564 toNode.propagatedType = node.propagatedType; 10591 toNode.propagatedType = node.propagatedType;
11565 toNode.staticType = node.staticType; 10592 toNode.staticType = node.staticType;
11566 return true; 10593 return true;
11567 } 10594 }
11568 return false; 10595 return false;
11569 } 10596 }
11570 10597
11571 @override 10598 @override
11572 bool visitNativeClause(NativeClause node) { 10599 bool visitNativeClause(NativeClause node) {
11573 NativeClause toNode = this._toNode as NativeClause; 10600 NativeClause toNode = this._toNode as NativeClause;
11574 return _and( 10601 return _and(_isEqualTokens(node.nativeKeyword, toNode.nativeKeyword),
11575 _isEqualTokens(node.nativeKeyword, toNode.nativeKeyword),
11576 _isEqualNodes(node.name, toNode.name)); 10602 _isEqualNodes(node.name, toNode.name));
11577 } 10603 }
11578 10604
11579 @override 10605 @override
11580 bool visitNativeFunctionBody(NativeFunctionBody node) { 10606 bool visitNativeFunctionBody(NativeFunctionBody node) {
11581 NativeFunctionBody toNode = this._toNode as NativeFunctionBody; 10607 NativeFunctionBody toNode = this._toNode as NativeFunctionBody;
11582 return _and( 10608 return _and(_isEqualTokens(node.nativeKeyword, toNode.nativeKeyword),
11583 _isEqualTokens(node.nativeKeyword, toNode.nativeKeyword),
11584 _isEqualNodes(node.stringLiteral, toNode.stringLiteral), 10609 _isEqualNodes(node.stringLiteral, toNode.stringLiteral),
11585 _isEqualTokens(node.semicolon, toNode.semicolon)); 10610 _isEqualTokens(node.semicolon, toNode.semicolon));
11586 } 10611 }
11587 10612
11588 @override 10613 @override
11589 bool visitNullLiteral(NullLiteral node) { 10614 bool visitNullLiteral(NullLiteral node) {
11590 NullLiteral toNode = this._toNode as NullLiteral; 10615 NullLiteral toNode = this._toNode as NullLiteral;
11591 if (_isEqualTokens(node.literal, toNode.literal)) { 10616 if (_isEqualTokens(node.literal, toNode.literal)) {
11592 toNode.propagatedType = node.propagatedType; 10617 toNode.propagatedType = node.propagatedType;
11593 toNode.staticType = node.staticType; 10618 toNode.staticType = node.staticType;
11594 return true; 10619 return true;
11595 } 10620 }
11596 return false; 10621 return false;
11597 } 10622 }
11598 10623
11599 @override 10624 @override
11600 bool visitParenthesizedExpression(ParenthesizedExpression node) { 10625 bool visitParenthesizedExpression(ParenthesizedExpression node) {
11601 ParenthesizedExpression toNode = this._toNode as ParenthesizedExpression; 10626 ParenthesizedExpression toNode = this._toNode as ParenthesizedExpression;
11602 if (_and( 10627 if (_and(_isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11603 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11604 _isEqualNodes(node.expression, toNode.expression), 10628 _isEqualNodes(node.expression, toNode.expression),
11605 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis))) { 10629 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis))) {
11606 toNode.propagatedType = node.propagatedType; 10630 toNode.propagatedType = node.propagatedType;
11607 toNode.staticType = node.staticType; 10631 toNode.staticType = node.staticType;
11608 return true; 10632 return true;
11609 } 10633 }
11610 return false; 10634 return false;
11611 } 10635 }
11612 10636
11613 @override 10637 @override
(...skipping 23 matching lines...) Expand all
11637 _isEqualTokens(node.semicolon, toNode.semicolon))) { 10661 _isEqualTokens(node.semicolon, toNode.semicolon))) {
11638 toNode.element = node.element; 10662 toNode.element = node.element;
11639 return true; 10663 return true;
11640 } 10664 }
11641 return false; 10665 return false;
11642 } 10666 }
11643 10667
11644 @override 10668 @override
11645 bool visitPostfixExpression(PostfixExpression node) { 10669 bool visitPostfixExpression(PostfixExpression node) {
11646 PostfixExpression toNode = this._toNode as PostfixExpression; 10670 PostfixExpression toNode = this._toNode as PostfixExpression;
11647 if (_and( 10671 if (_and(_isEqualNodes(node.operand, toNode.operand),
11648 _isEqualNodes(node.operand, toNode.operand),
11649 _isEqualTokens(node.operator, toNode.operator))) { 10672 _isEqualTokens(node.operator, toNode.operator))) {
11650 toNode.propagatedElement = node.propagatedElement; 10673 toNode.propagatedElement = node.propagatedElement;
11651 toNode.propagatedType = node.propagatedType; 10674 toNode.propagatedType = node.propagatedType;
11652 toNode.staticElement = node.staticElement; 10675 toNode.staticElement = node.staticElement;
11653 toNode.staticType = node.staticType; 10676 toNode.staticType = node.staticType;
11654 return true; 10677 return true;
11655 } 10678 }
11656 return false; 10679 return false;
11657 } 10680 }
11658 10681
11659 @override 10682 @override
11660 bool visitPrefixedIdentifier(PrefixedIdentifier node) { 10683 bool visitPrefixedIdentifier(PrefixedIdentifier node) {
11661 PrefixedIdentifier toNode = this._toNode as PrefixedIdentifier; 10684 PrefixedIdentifier toNode = this._toNode as PrefixedIdentifier;
11662 if (_and( 10685 if (_and(_isEqualNodes(node.prefix, toNode.prefix),
11663 _isEqualNodes(node.prefix, toNode.prefix),
11664 _isEqualTokens(node.period, toNode.period), 10686 _isEqualTokens(node.period, toNode.period),
11665 _isEqualNodes(node.identifier, toNode.identifier))) { 10687 _isEqualNodes(node.identifier, toNode.identifier))) {
11666 toNode.propagatedType = node.propagatedType; 10688 toNode.propagatedType = node.propagatedType;
11667 toNode.staticType = node.staticType; 10689 toNode.staticType = node.staticType;
11668 return true; 10690 return true;
11669 } 10691 }
11670 return false; 10692 return false;
11671 } 10693 }
11672 10694
11673 @override 10695 @override
11674 bool visitPrefixExpression(PrefixExpression node) { 10696 bool visitPrefixExpression(PrefixExpression node) {
11675 PrefixExpression toNode = this._toNode as PrefixExpression; 10697 PrefixExpression toNode = this._toNode as PrefixExpression;
11676 if (_and( 10698 if (_and(_isEqualTokens(node.operator, toNode.operator),
11677 _isEqualTokens(node.operator, toNode.operator),
11678 _isEqualNodes(node.operand, toNode.operand))) { 10699 _isEqualNodes(node.operand, toNode.operand))) {
11679 toNode.propagatedElement = node.propagatedElement; 10700 toNode.propagatedElement = node.propagatedElement;
11680 toNode.propagatedType = node.propagatedType; 10701 toNode.propagatedType = node.propagatedType;
11681 toNode.staticElement = node.staticElement; 10702 toNode.staticElement = node.staticElement;
11682 toNode.staticType = node.staticType; 10703 toNode.staticType = node.staticType;
11683 return true; 10704 return true;
11684 } 10705 }
11685 return false; 10706 return false;
11686 } 10707 }
11687 10708
11688 @override 10709 @override
11689 bool visitPropertyAccess(PropertyAccess node) { 10710 bool visitPropertyAccess(PropertyAccess node) {
11690 PropertyAccess toNode = this._toNode as PropertyAccess; 10711 PropertyAccess toNode = this._toNode as PropertyAccess;
11691 if (_and( 10712 if (_and(_isEqualNodes(node.target, toNode.target),
11692 _isEqualNodes(node.target, toNode.target),
11693 _isEqualTokens(node.operator, toNode.operator), 10713 _isEqualTokens(node.operator, toNode.operator),
11694 _isEqualNodes(node.propertyName, toNode.propertyName))) { 10714 _isEqualNodes(node.propertyName, toNode.propertyName))) {
11695 toNode.propagatedType = node.propagatedType; 10715 toNode.propagatedType = node.propagatedType;
11696 toNode.staticType = node.staticType; 10716 toNode.staticType = node.staticType;
11697 return true; 10717 return true;
11698 } 10718 }
11699 return false; 10719 return false;
11700 } 10720 }
11701 10721
11702 @override 10722 @override
11703 bool 10723 bool visitRedirectingConstructorInvocation(
11704 visitRedirectingConstructorInvocation(RedirectingConstructorInvocation nod e) { 10724 RedirectingConstructorInvocation node) {
11705 RedirectingConstructorInvocation toNode = 10725 RedirectingConstructorInvocation toNode =
11706 this._toNode as RedirectingConstructorInvocation; 10726 this._toNode as RedirectingConstructorInvocation;
11707 if (_and( 10727 if (_and(_isEqualTokens(node.thisKeyword, toNode.thisKeyword),
11708 _isEqualTokens(node.thisKeyword, toNode.thisKeyword),
11709 _isEqualTokens(node.period, toNode.period), 10728 _isEqualTokens(node.period, toNode.period),
11710 _isEqualNodes(node.constructorName, toNode.constructorName), 10729 _isEqualNodes(node.constructorName, toNode.constructorName),
11711 _isEqualNodes(node.argumentList, toNode.argumentList))) { 10730 _isEqualNodes(node.argumentList, toNode.argumentList))) {
11712 toNode.staticElement = node.staticElement; 10731 toNode.staticElement = node.staticElement;
11713 return true; 10732 return true;
11714 } 10733 }
11715 return false; 10734 return false;
11716 } 10735 }
11717 10736
11718 @override 10737 @override
11719 bool visitRethrowExpression(RethrowExpression node) { 10738 bool visitRethrowExpression(RethrowExpression node) {
11720 RethrowExpression toNode = this._toNode as RethrowExpression; 10739 RethrowExpression toNode = this._toNode as RethrowExpression;
11721 if (_isEqualTokens(node.rethrowKeyword, toNode.rethrowKeyword)) { 10740 if (_isEqualTokens(node.rethrowKeyword, toNode.rethrowKeyword)) {
11722 toNode.propagatedType = node.propagatedType; 10741 toNode.propagatedType = node.propagatedType;
11723 toNode.staticType = node.staticType; 10742 toNode.staticType = node.staticType;
11724 return true; 10743 return true;
11725 } 10744 }
11726 return false; 10745 return false;
11727 } 10746 }
11728 10747
11729 @override 10748 @override
11730 bool visitReturnStatement(ReturnStatement node) { 10749 bool visitReturnStatement(ReturnStatement node) {
11731 ReturnStatement toNode = this._toNode as ReturnStatement; 10750 ReturnStatement toNode = this._toNode as ReturnStatement;
11732 return _and( 10751 return _and(_isEqualTokens(node.returnKeyword, toNode.returnKeyword),
11733 _isEqualTokens(node.returnKeyword, toNode.returnKeyword),
11734 _isEqualNodes(node.expression, toNode.expression), 10752 _isEqualNodes(node.expression, toNode.expression),
11735 _isEqualTokens(node.semicolon, toNode.semicolon)); 10753 _isEqualTokens(node.semicolon, toNode.semicolon));
11736 } 10754 }
11737 10755
11738 @override 10756 @override
11739 bool visitScriptTag(ScriptTag node) { 10757 bool visitScriptTag(ScriptTag node) {
11740 ScriptTag toNode = this._toNode as ScriptTag; 10758 ScriptTag toNode = this._toNode as ScriptTag;
11741 return _isEqualTokens(node.scriptTag, toNode.scriptTag); 10759 return _isEqualTokens(node.scriptTag, toNode.scriptTag);
11742 } 10760 }
11743 10761
11744 @override 10762 @override
11745 bool visitShowCombinator(ShowCombinator node) { 10763 bool visitShowCombinator(ShowCombinator node) {
11746 ShowCombinator toNode = this._toNode as ShowCombinator; 10764 ShowCombinator toNode = this._toNode as ShowCombinator;
11747 return _and( 10765 return _and(_isEqualTokens(node.keyword, toNode.keyword),
11748 _isEqualTokens(node.keyword, toNode.keyword),
11749 _isEqualNodeLists(node.shownNames, toNode.shownNames)); 10766 _isEqualNodeLists(node.shownNames, toNode.shownNames));
11750 } 10767 }
11751 10768
11752 @override 10769 @override
11753 bool visitSimpleFormalParameter(SimpleFormalParameter node) { 10770 bool visitSimpleFormalParameter(SimpleFormalParameter node) {
11754 SimpleFormalParameter toNode = this._toNode as SimpleFormalParameter; 10771 SimpleFormalParameter toNode = this._toNode as SimpleFormalParameter;
11755 return _and( 10772 return _and(
11756 _isEqualNodes(node.documentationComment, toNode.documentationComment), 10773 _isEqualNodes(node.documentationComment, toNode.documentationComment),
11757 _isEqualNodeLists(node.metadata, toNode.metadata), 10774 _isEqualNodeLists(node.metadata, toNode.metadata),
11758 _isEqualTokens(node.keyword, toNode.keyword), 10775 _isEqualTokens(node.keyword, toNode.keyword),
(...skipping 11 matching lines...) Expand all
11770 toNode.propagatedType = node.propagatedType; 10787 toNode.propagatedType = node.propagatedType;
11771 toNode.auxiliaryElements = node.auxiliaryElements; 10788 toNode.auxiliaryElements = node.auxiliaryElements;
11772 return true; 10789 return true;
11773 } 10790 }
11774 return false; 10791 return false;
11775 } 10792 }
11776 10793
11777 @override 10794 @override
11778 bool visitSimpleStringLiteral(SimpleStringLiteral node) { 10795 bool visitSimpleStringLiteral(SimpleStringLiteral node) {
11779 SimpleStringLiteral toNode = this._toNode as SimpleStringLiteral; 10796 SimpleStringLiteral toNode = this._toNode as SimpleStringLiteral;
11780 if (_and( 10797 if (_and(_isEqualTokens(node.literal, toNode.literal),
11781 _isEqualTokens(node.literal, toNode.literal),
11782 node.value == toNode.value)) { 10798 node.value == toNode.value)) {
11783 toNode.propagatedType = node.propagatedType; 10799 toNode.propagatedType = node.propagatedType;
11784 toNode.staticType = node.staticType; 10800 toNode.staticType = node.staticType;
11785 return true; 10801 return true;
11786 } 10802 }
11787 return false; 10803 return false;
11788 } 10804 }
11789 10805
11790 @override 10806 @override
11791 bool visitStringInterpolation(StringInterpolation node) { 10807 bool visitStringInterpolation(StringInterpolation node) {
11792 StringInterpolation toNode = this._toNode as StringInterpolation; 10808 StringInterpolation toNode = this._toNode as StringInterpolation;
11793 if (_isEqualNodeLists(node.elements, toNode.elements)) { 10809 if (_isEqualNodeLists(node.elements, toNode.elements)) {
11794 toNode.propagatedType = node.propagatedType; 10810 toNode.propagatedType = node.propagatedType;
11795 toNode.staticType = node.staticType; 10811 toNode.staticType = node.staticType;
11796 return true; 10812 return true;
11797 } 10813 }
11798 return false; 10814 return false;
11799 } 10815 }
11800 10816
11801 @override 10817 @override
11802 bool visitSuperConstructorInvocation(SuperConstructorInvocation node) { 10818 bool visitSuperConstructorInvocation(SuperConstructorInvocation node) {
11803 SuperConstructorInvocation toNode = 10819 SuperConstructorInvocation toNode =
11804 this._toNode as SuperConstructorInvocation; 10820 this._toNode as SuperConstructorInvocation;
11805 if (_and( 10821 if (_and(_isEqualTokens(node.superKeyword, toNode.superKeyword),
11806 _isEqualTokens(node.superKeyword, toNode.superKeyword),
11807 _isEqualTokens(node.period, toNode.period), 10822 _isEqualTokens(node.period, toNode.period),
11808 _isEqualNodes(node.constructorName, toNode.constructorName), 10823 _isEqualNodes(node.constructorName, toNode.constructorName),
11809 _isEqualNodes(node.argumentList, toNode.argumentList))) { 10824 _isEqualNodes(node.argumentList, toNode.argumentList))) {
11810 toNode.staticElement = node.staticElement; 10825 toNode.staticElement = node.staticElement;
11811 return true; 10826 return true;
11812 } 10827 }
11813 return false; 10828 return false;
11814 } 10829 }
11815 10830
11816 @override 10831 @override
11817 bool visitSuperExpression(SuperExpression node) { 10832 bool visitSuperExpression(SuperExpression node) {
11818 SuperExpression toNode = this._toNode as SuperExpression; 10833 SuperExpression toNode = this._toNode as SuperExpression;
11819 if (_isEqualTokens(node.superKeyword, toNode.superKeyword)) { 10834 if (_isEqualTokens(node.superKeyword, toNode.superKeyword)) {
11820 toNode.propagatedType = node.propagatedType; 10835 toNode.propagatedType = node.propagatedType;
11821 toNode.staticType = node.staticType; 10836 toNode.staticType = node.staticType;
11822 return true; 10837 return true;
11823 } 10838 }
11824 return false; 10839 return false;
11825 } 10840 }
11826 10841
11827 @override 10842 @override
11828 bool visitSwitchCase(SwitchCase node) { 10843 bool visitSwitchCase(SwitchCase node) {
11829 SwitchCase toNode = this._toNode as SwitchCase; 10844 SwitchCase toNode = this._toNode as SwitchCase;
11830 return _and( 10845 return _and(_isEqualNodeLists(node.labels, toNode.labels),
11831 _isEqualNodeLists(node.labels, toNode.labels),
11832 _isEqualTokens(node.keyword, toNode.keyword), 10846 _isEqualTokens(node.keyword, toNode.keyword),
11833 _isEqualNodes(node.expression, toNode.expression), 10847 _isEqualNodes(node.expression, toNode.expression),
11834 _isEqualTokens(node.colon, toNode.colon), 10848 _isEqualTokens(node.colon, toNode.colon),
11835 _isEqualNodeLists(node.statements, toNode.statements)); 10849 _isEqualNodeLists(node.statements, toNode.statements));
11836 } 10850 }
11837 10851
11838 @override 10852 @override
11839 bool visitSwitchDefault(SwitchDefault node) { 10853 bool visitSwitchDefault(SwitchDefault node) {
11840 SwitchDefault toNode = this._toNode as SwitchDefault; 10854 SwitchDefault toNode = this._toNode as SwitchDefault;
11841 return _and( 10855 return _and(_isEqualNodeLists(node.labels, toNode.labels),
11842 _isEqualNodeLists(node.labels, toNode.labels),
11843 _isEqualTokens(node.keyword, toNode.keyword), 10856 _isEqualTokens(node.keyword, toNode.keyword),
11844 _isEqualTokens(node.colon, toNode.colon), 10857 _isEqualTokens(node.colon, toNode.colon),
11845 _isEqualNodeLists(node.statements, toNode.statements)); 10858 _isEqualNodeLists(node.statements, toNode.statements));
11846 } 10859 }
11847 10860
11848 @override 10861 @override
11849 bool visitSwitchStatement(SwitchStatement node) { 10862 bool visitSwitchStatement(SwitchStatement node) {
11850 SwitchStatement toNode = this._toNode as SwitchStatement; 10863 SwitchStatement toNode = this._toNode as SwitchStatement;
11851 return _and( 10864 return _and(_isEqualTokens(node.switchKeyword, toNode.switchKeyword),
11852 _isEqualTokens(node.switchKeyword, toNode.switchKeyword),
11853 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), 10865 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11854 _isEqualNodes(node.expression, toNode.expression), 10866 _isEqualNodes(node.expression, toNode.expression),
11855 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), 10867 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
11856 _isEqualTokens(node.leftBracket, toNode.leftBracket), 10868 _isEqualTokens(node.leftBracket, toNode.leftBracket),
11857 _isEqualNodeLists(node.members, toNode.members), 10869 _isEqualNodeLists(node.members, toNode.members),
11858 _isEqualTokens(node.rightBracket, toNode.rightBracket)); 10870 _isEqualTokens(node.rightBracket, toNode.rightBracket));
11859 } 10871 }
11860 10872
11861 @override 10873 @override
11862 bool visitSymbolLiteral(SymbolLiteral node) { 10874 bool visitSymbolLiteral(SymbolLiteral node) {
11863 SymbolLiteral toNode = this._toNode as SymbolLiteral; 10875 SymbolLiteral toNode = this._toNode as SymbolLiteral;
11864 if (_and( 10876 if (_and(_isEqualTokens(node.poundSign, toNode.poundSign),
11865 _isEqualTokens(node.poundSign, toNode.poundSign),
11866 _isEqualTokenLists(node.components, toNode.components))) { 10877 _isEqualTokenLists(node.components, toNode.components))) {
11867 toNode.propagatedType = node.propagatedType; 10878 toNode.propagatedType = node.propagatedType;
11868 toNode.staticType = node.staticType; 10879 toNode.staticType = node.staticType;
11869 return true; 10880 return true;
11870 } 10881 }
11871 return false; 10882 return false;
11872 } 10883 }
11873 10884
11874 @override 10885 @override
11875 bool visitThisExpression(ThisExpression node) { 10886 bool visitThisExpression(ThisExpression node) {
11876 ThisExpression toNode = this._toNode as ThisExpression; 10887 ThisExpression toNode = this._toNode as ThisExpression;
11877 if (_isEqualTokens(node.thisKeyword, toNode.thisKeyword)) { 10888 if (_isEqualTokens(node.thisKeyword, toNode.thisKeyword)) {
11878 toNode.propagatedType = node.propagatedType; 10889 toNode.propagatedType = node.propagatedType;
11879 toNode.staticType = node.staticType; 10890 toNode.staticType = node.staticType;
11880 return true; 10891 return true;
11881 } 10892 }
11882 return false; 10893 return false;
11883 } 10894 }
11884 10895
11885 @override 10896 @override
11886 bool visitThrowExpression(ThrowExpression node) { 10897 bool visitThrowExpression(ThrowExpression node) {
11887 ThrowExpression toNode = this._toNode as ThrowExpression; 10898 ThrowExpression toNode = this._toNode as ThrowExpression;
11888 if (_and( 10899 if (_and(_isEqualTokens(node.throwKeyword, toNode.throwKeyword),
11889 _isEqualTokens(node.throwKeyword, toNode.throwKeyword),
11890 _isEqualNodes(node.expression, toNode.expression))) { 10900 _isEqualNodes(node.expression, toNode.expression))) {
11891 toNode.propagatedType = node.propagatedType; 10901 toNode.propagatedType = node.propagatedType;
11892 toNode.staticType = node.staticType; 10902 toNode.staticType = node.staticType;
11893 return true; 10903 return true;
11894 } 10904 }
11895 return false; 10905 return false;
11896 } 10906 }
11897 10907
11898 @override 10908 @override
11899 bool visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { 10909 bool visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
11900 TopLevelVariableDeclaration toNode = 10910 TopLevelVariableDeclaration toNode =
11901 this._toNode as TopLevelVariableDeclaration; 10911 this._toNode as TopLevelVariableDeclaration;
11902 return _and( 10912 return _and(
11903 _isEqualNodes(node.documentationComment, toNode.documentationComment), 10913 _isEqualNodes(node.documentationComment, toNode.documentationComment),
11904 _isEqualNodeLists(node.metadata, toNode.metadata), 10914 _isEqualNodeLists(node.metadata, toNode.metadata),
11905 _isEqualNodes(node.variables, toNode.variables), 10915 _isEqualNodes(node.variables, toNode.variables),
11906 _isEqualTokens(node.semicolon, toNode.semicolon)); 10916 _isEqualTokens(node.semicolon, toNode.semicolon));
11907 } 10917 }
11908 10918
11909 @override 10919 @override
11910 bool visitTryStatement(TryStatement node) { 10920 bool visitTryStatement(TryStatement node) {
11911 TryStatement toNode = this._toNode as TryStatement; 10921 TryStatement toNode = this._toNode as TryStatement;
11912 return _and( 10922 return _and(_isEqualTokens(node.tryKeyword, toNode.tryKeyword),
11913 _isEqualTokens(node.tryKeyword, toNode.tryKeyword),
11914 _isEqualNodes(node.body, toNode.body), 10923 _isEqualNodes(node.body, toNode.body),
11915 _isEqualNodeLists(node.catchClauses, toNode.catchClauses), 10924 _isEqualNodeLists(node.catchClauses, toNode.catchClauses),
11916 _isEqualTokens(node.finallyKeyword, toNode.finallyKeyword), 10925 _isEqualTokens(node.finallyKeyword, toNode.finallyKeyword),
11917 _isEqualNodes(node.finallyBlock, toNode.finallyBlock)); 10926 _isEqualNodes(node.finallyBlock, toNode.finallyBlock));
11918 } 10927 }
11919 10928
11920 @override 10929 @override
11921 bool visitTypeArgumentList(TypeArgumentList node) { 10930 bool visitTypeArgumentList(TypeArgumentList node) {
11922 TypeArgumentList toNode = this._toNode as TypeArgumentList; 10931 TypeArgumentList toNode = this._toNode as TypeArgumentList;
11923 return _and( 10932 return _and(_isEqualTokens(node.leftBracket, toNode.leftBracket),
11924 _isEqualTokens(node.leftBracket, toNode.leftBracket),
11925 _isEqualNodeLists(node.arguments, toNode.arguments), 10933 _isEqualNodeLists(node.arguments, toNode.arguments),
11926 _isEqualTokens(node.rightBracket, toNode.rightBracket)); 10934 _isEqualTokens(node.rightBracket, toNode.rightBracket));
11927 } 10935 }
11928 10936
11929 @override 10937 @override
11930 bool visitTypeName(TypeName node) { 10938 bool visitTypeName(TypeName node) {
11931 TypeName toNode = this._toNode as TypeName; 10939 TypeName toNode = this._toNode as TypeName;
11932 if (_and( 10940 if (_and(_isEqualNodes(node.name, toNode.name),
11933 _isEqualNodes(node.name, toNode.name),
11934 _isEqualNodes(node.typeArguments, toNode.typeArguments))) { 10941 _isEqualNodes(node.typeArguments, toNode.typeArguments))) {
11935 toNode.type = node.type; 10942 toNode.type = node.type;
11936 return true; 10943 return true;
11937 } 10944 }
11938 return false; 10945 return false;
11939 } 10946 }
11940 10947
11941 @override 10948 @override
11942 bool visitTypeParameter(TypeParameter node) { 10949 bool visitTypeParameter(TypeParameter node) {
11943 TypeParameter toNode = this._toNode as TypeParameter; 10950 TypeParameter toNode = this._toNode as TypeParameter;
11944 return _and( 10951 return _and(
11945 _isEqualNodes(node.documentationComment, toNode.documentationComment), 10952 _isEqualNodes(node.documentationComment, toNode.documentationComment),
11946 _isEqualNodeLists(node.metadata, toNode.metadata), 10953 _isEqualNodeLists(node.metadata, toNode.metadata),
11947 _isEqualNodes(node.name, toNode.name), 10954 _isEqualNodes(node.name, toNode.name),
11948 _isEqualTokens(node.extendsKeyword, toNode.extendsKeyword), 10955 _isEqualTokens(node.extendsKeyword, toNode.extendsKeyword),
11949 _isEqualNodes(node.bound, toNode.bound)); 10956 _isEqualNodes(node.bound, toNode.bound));
11950 } 10957 }
11951 10958
11952 @override 10959 @override
11953 bool visitTypeParameterList(TypeParameterList node) { 10960 bool visitTypeParameterList(TypeParameterList node) {
11954 TypeParameterList toNode = this._toNode as TypeParameterList; 10961 TypeParameterList toNode = this._toNode as TypeParameterList;
11955 return _and( 10962 return _and(_isEqualTokens(node.leftBracket, toNode.leftBracket),
11956 _isEqualTokens(node.leftBracket, toNode.leftBracket),
11957 _isEqualNodeLists(node.typeParameters, toNode.typeParameters), 10963 _isEqualNodeLists(node.typeParameters, toNode.typeParameters),
11958 _isEqualTokens(node.rightBracket, toNode.rightBracket)); 10964 _isEqualTokens(node.rightBracket, toNode.rightBracket));
11959 } 10965 }
11960 10966
11961 @override 10967 @override
11962 bool visitVariableDeclaration(VariableDeclaration node) { 10968 bool visitVariableDeclaration(VariableDeclaration node) {
11963 VariableDeclaration toNode = this._toNode as VariableDeclaration; 10969 VariableDeclaration toNode = this._toNode as VariableDeclaration;
11964 return _and( 10970 return _and(
11965 _isEqualNodes(node.documentationComment, toNode.documentationComment), 10971 _isEqualNodes(node.documentationComment, toNode.documentationComment),
11966 _isEqualNodeLists(node.metadata, toNode.metadata), 10972 _isEqualNodeLists(node.metadata, toNode.metadata),
(...skipping 10 matching lines...) Expand all
11977 _isEqualNodeLists(node.metadata, toNode.metadata), 10983 _isEqualNodeLists(node.metadata, toNode.metadata),
11978 _isEqualTokens(node.keyword, toNode.keyword), 10984 _isEqualTokens(node.keyword, toNode.keyword),
11979 _isEqualNodes(node.type, toNode.type), 10985 _isEqualNodes(node.type, toNode.type),
11980 _isEqualNodeLists(node.variables, toNode.variables)); 10986 _isEqualNodeLists(node.variables, toNode.variables));
11981 } 10987 }
11982 10988
11983 @override 10989 @override
11984 bool visitVariableDeclarationStatement(VariableDeclarationStatement node) { 10990 bool visitVariableDeclarationStatement(VariableDeclarationStatement node) {
11985 VariableDeclarationStatement toNode = 10991 VariableDeclarationStatement toNode =
11986 this._toNode as VariableDeclarationStatement; 10992 this._toNode as VariableDeclarationStatement;
11987 return _and( 10993 return _and(_isEqualNodes(node.variables, toNode.variables),
11988 _isEqualNodes(node.variables, toNode.variables),
11989 _isEqualTokens(node.semicolon, toNode.semicolon)); 10994 _isEqualTokens(node.semicolon, toNode.semicolon));
11990 } 10995 }
11991 10996
11992 @override 10997 @override
11993 bool visitWhileStatement(WhileStatement node) { 10998 bool visitWhileStatement(WhileStatement node) {
11994 WhileStatement toNode = this._toNode as WhileStatement; 10999 WhileStatement toNode = this._toNode as WhileStatement;
11995 return _and( 11000 return _and(_isEqualTokens(node.whileKeyword, toNode.whileKeyword),
11996 _isEqualTokens(node.whileKeyword, toNode.whileKeyword),
11997 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), 11001 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11998 _isEqualNodes(node.condition, toNode.condition), 11002 _isEqualNodes(node.condition, toNode.condition),
11999 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), 11003 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
12000 _isEqualNodes(node.body, toNode.body)); 11004 _isEqualNodes(node.body, toNode.body));
12001 } 11005 }
12002 11006
12003 @override 11007 @override
12004 bool visitWithClause(WithClause node) { 11008 bool visitWithClause(WithClause node) {
12005 WithClause toNode = this._toNode as WithClause; 11009 WithClause toNode = this._toNode as WithClause;
12006 return _and( 11010 return _and(_isEqualTokens(node.withKeyword, toNode.withKeyword),
12007 _isEqualTokens(node.withKeyword, toNode.withKeyword),
12008 _isEqualNodeLists(node.mixinTypes, toNode.mixinTypes)); 11011 _isEqualNodeLists(node.mixinTypes, toNode.mixinTypes));
12009 } 11012 }
12010 11013
12011 @override 11014 @override
12012 bool visitYieldStatement(YieldStatement node) { 11015 bool visitYieldStatement(YieldStatement node) {
12013 YieldStatement toNode = this._toNode as YieldStatement; 11016 YieldStatement toNode = this._toNode as YieldStatement;
12014 return _and( 11017 return _and(_isEqualTokens(node.yieldKeyword, toNode.yieldKeyword),
12015 _isEqualTokens(node.yieldKeyword, toNode.yieldKeyword),
12016 _isEqualNodes(node.expression, toNode.expression), 11018 _isEqualNodes(node.expression, toNode.expression),
12017 _isEqualTokens(node.semicolon, toNode.semicolon)); 11019 _isEqualTokens(node.semicolon, toNode.semicolon));
12018 } 11020 }
12019 11021
12020 /** 11022 /**
12021 * Return `true` if all of the parameters are `true`. 11023 * Return `true` if all of the parameters are `true`.
12022 */ 11024 */
12023 bool _and(bool b1, bool b2, [bool b3 = true, bool b4 = true, bool b5 = true, 11025 bool _and(bool b1, bool b2, [bool b3 = true, bool b4 = true, bool b5 = true,
12024 bool b6 = true, bool b7 = true, bool b8 = true, bool b9 = true, bool b10 = true, 11026 bool b6 = true, bool b7 = true, bool b8 = true, bool b9 = true,
12025 bool b11 = true, bool b12 = true, bool b13 = true]) { 11027 bool b10 = true, bool b11 = true, bool b12 = true, bool b13 = true]) {
12026 return b1 && 11028 return b1 &&
12027 b2 && 11029 b2 &&
12028 b3 && 11030 b3 &&
12029 b4 && 11031 b4 &&
12030 b5 && 11032 b5 &&
12031 b6 && 11033 b6 &&
12032 b7 && 11034 b7 &&
12033 b8 && 11035 b8 &&
12034 b9 && 11036 b9 &&
12035 b10 && 11037 b10 &&
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
12145 * Copy resolution data from one node to another. 11147 * Copy resolution data from one node to another.
12146 * 11148 *
12147 * @param fromNode the node from which resolution information will be copied 11149 * @param fromNode the node from which resolution information will be copied
12148 * @param toNode the node to which resolution information will be copied 11150 * @param toNode the node to which resolution information will be copied
12149 */ 11151 */
12150 static void copyResolutionData(AstNode fromNode, AstNode toNode) { 11152 static void copyResolutionData(AstNode fromNode, AstNode toNode) {
12151 ResolutionCopier copier = new ResolutionCopier(); 11153 ResolutionCopier copier = new ResolutionCopier();
12152 copier._isEqualNodes(fromNode, toNode); 11154 copier._isEqualNodes(fromNode, toNode);
12153 } 11155 }
12154 } 11156 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/java_engine_io.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698