OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /** | 5 /** |
6 * Defines the tokens that are produced by the scanner, used by the parser, and | 6 * Defines the tokens that are produced by the scanner, used by the parser, and |
7 * referenced from the [AST structure](ast.dart). | 7 * referenced from the [AST structure](ast.dart). |
8 */ | 8 */ |
9 import 'dart:collection'; | 9 import 'dart:collection'; |
10 | 10 |
11 import 'package:front_end/src/base/syntactic_entity.dart'; | 11 import 'package:front_end/src/base/syntactic_entity.dart'; |
12 import 'package:front_end/src/scanner/string_utilities.dart'; | 12 import 'package:front_end/src/scanner/string_utilities.dart'; |
13 import 'package:front_end/src/fasta/scanner/keyword.dart' as fasta; | |
14 import 'package:front_end/src/fasta/scanner/precedence.dart' as fasta; | 13 import 'package:front_end/src/fasta/scanner/precedence.dart' as fasta; |
15 | 14 |
16 /** | 15 /** |
17 * The opening half of a grouping pair of tokens. This is used for curly | 16 * The opening half of a grouping pair of tokens. This is used for curly |
18 * brackets ('{'), parentheses ('('), and square brackets ('['). | 17 * brackets ('{'), parentheses ('('), and square brackets ('['). |
19 */ | 18 */ |
20 class BeginToken extends SimpleToken { | 19 class BeginToken extends SimpleToken { |
21 /** | 20 /** |
22 * The token that corresponds to this token. | 21 * The token that corresponds to this token. |
23 */ | 22 */ |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 references.forEach((ref) => copy.references.add(ref.copy())); | 141 references.forEach((ref) => copy.references.add(ref.copy())); |
143 return copy; | 142 return copy; |
144 } | 143 } |
145 } | 144 } |
146 | 145 |
147 /** | 146 /** |
148 * The keywords in the Dart programming language. | 147 * The keywords in the Dart programming language. |
149 * | 148 * |
150 * Clients may not extend, implement or mix-in this class. | 149 * Clients may not extend, implement or mix-in this class. |
151 */ | 150 */ |
152 abstract class Keyword { | 151 class Keyword { |
153 static const Keyword ABSTRACT = fasta.Keyword.ABSTRACT; | 152 static const Keyword ABSTRACT = const Keyword("abstract", isBuiltIn: true); |
154 | 153 |
155 static const Keyword AS = fasta.Keyword.AS; | 154 static const Keyword AS = |
| 155 const Keyword("as", info: fasta.AS_INFO, isBuiltIn: true); |
156 | 156 |
157 static const Keyword ASSERT = fasta.Keyword.ASSERT; | 157 static const Keyword ASSERT = const Keyword("assert"); |
158 | 158 |
159 static const Keyword ASYNC = fasta.Keyword.ASYNC; | 159 static const Keyword ASYNC = const Keyword("async", isPseudo: true); |
160 | 160 |
161 static const Keyword AWAIT = fasta.Keyword.AWAIT; | 161 static const Keyword AWAIT = const Keyword("await", isPseudo: true); |
162 | 162 |
163 static const Keyword BREAK = fasta.Keyword.BREAK; | 163 static const Keyword BREAK = const Keyword("break"); |
164 | 164 |
165 static const Keyword CASE = fasta.Keyword.CASE; | 165 static const Keyword CASE = const Keyword("case"); |
166 | 166 |
167 static const Keyword CATCH = fasta.Keyword.CATCH; | 167 static const Keyword CATCH = const Keyword("catch"); |
168 | 168 |
169 static const Keyword CLASS = fasta.Keyword.CLASS; | 169 static const Keyword CLASS = const Keyword("class"); |
170 | 170 |
171 static const Keyword CONST = fasta.Keyword.CONST; | 171 static const Keyword CONST = const Keyword("const"); |
172 | 172 |
173 static const Keyword CONTINUE = fasta.Keyword.CONTINUE; | 173 static const Keyword CONTINUE = const Keyword("continue"); |
174 | 174 |
175 static const Keyword COVARIANT = fasta.Keyword.COVARIANT; | 175 static const Keyword COVARIANT = const Keyword("covariant", isBuiltIn: true); |
176 | 176 |
177 static const Keyword DEFAULT = fasta.Keyword.DEFAULT; | 177 static const Keyword DEFAULT = const Keyword("default"); |
178 | 178 |
179 static const Keyword DEFERRED = fasta.Keyword.DEFERRED; | 179 static const Keyword DEFERRED = const Keyword("deferred", isBuiltIn: true); |
180 | 180 |
181 static const Keyword DO = fasta.Keyword.DO; | 181 static const Keyword DO = const Keyword("do"); |
182 | 182 |
183 static const Keyword DYNAMIC = fasta.Keyword.DYNAMIC; | 183 static const Keyword DYNAMIC = const Keyword("dynamic", isBuiltIn: true); |
184 | 184 |
185 static const Keyword ELSE = fasta.Keyword.ELSE; | 185 static const Keyword ELSE = const Keyword("else"); |
186 | 186 |
187 static const Keyword ENUM = fasta.Keyword.ENUM; | 187 static const Keyword ENUM = const Keyword("enum"); |
188 | 188 |
189 static const Keyword EXPORT = fasta.Keyword.EXPORT; | 189 static const Keyword EXPORT = const Keyword("export", isBuiltIn: true); |
190 | 190 |
191 static const Keyword EXTENDS = fasta.Keyword.EXTENDS; | 191 static const Keyword EXTENDS = const Keyword("extends"); |
192 | 192 |
193 static const Keyword EXTERNAL = fasta.Keyword.EXTERNAL; | 193 static const Keyword EXTERNAL = const Keyword("external", isBuiltIn: true); |
194 | 194 |
195 static const Keyword FACTORY = fasta.Keyword.FACTORY; | 195 static const Keyword FACTORY = const Keyword("factory", isBuiltIn: true); |
196 | 196 |
197 static const Keyword FALSE = fasta.Keyword.FALSE; | 197 static const Keyword FALSE = const Keyword("false"); |
198 | 198 |
199 static const Keyword FINAL = fasta.Keyword.FINAL; | 199 static const Keyword FINAL = const Keyword("final"); |
200 | 200 |
201 static const Keyword FINALLY = fasta.Keyword.FINALLY; | 201 static const Keyword FINALLY = const Keyword("finally"); |
202 | 202 |
203 static const Keyword FOR = fasta.Keyword.FOR; | 203 static const Keyword FOR = const Keyword("for"); |
204 | 204 |
205 static const Keyword FUNCTION = fasta.Keyword.FUNCTION; | 205 static const Keyword FUNCTION = const Keyword("Function", isPseudo: true); |
206 | 206 |
207 static const Keyword GET = fasta.Keyword.GET; | 207 static const Keyword GET = const Keyword("get", isBuiltIn: true); |
208 | 208 |
209 static const Keyword HIDE = fasta.Keyword.HIDE; | 209 static const Keyword HIDE = const Keyword("hide", isPseudo: true); |
210 | 210 |
211 static const Keyword IF = fasta.Keyword.IF; | 211 static const Keyword IF = const Keyword("if"); |
212 | 212 |
213 static const Keyword IMPLEMENTS = fasta.Keyword.IMPLEMENTS; | 213 static const Keyword IMPLEMENTS = |
| 214 const Keyword("implements", isBuiltIn: true); |
214 | 215 |
215 static const Keyword IMPORT = fasta.Keyword.IMPORT; | 216 static const Keyword IMPORT = const Keyword("import", isBuiltIn: true); |
216 | 217 |
217 static const Keyword IN = fasta.Keyword.IN; | 218 static const Keyword IN = const Keyword("in"); |
218 | 219 |
219 static const Keyword IS = fasta.Keyword.IS; | 220 static const Keyword IS = const Keyword("is", info: fasta.IS_INFO); |
220 | 221 |
221 static const Keyword LIBRARY = fasta.Keyword.LIBRARY; | 222 static const Keyword LIBRARY = const Keyword("library", isBuiltIn: true); |
222 | 223 |
223 static const Keyword NATIVE = fasta.Keyword.NATIVE; | 224 static const Keyword NATIVE = const Keyword("native", isPseudo: true); |
224 | 225 |
225 static const Keyword NEW = fasta.Keyword.NEW; | 226 static const Keyword NEW = const Keyword("new"); |
226 | 227 |
227 static const Keyword NULL = fasta.Keyword.NULL; | 228 static const Keyword NULL = const Keyword("null"); |
228 | 229 |
229 static const Keyword OF = fasta.Keyword.OF; | 230 static const Keyword OF = const Keyword("of", isPseudo: true); |
230 | 231 |
231 static const Keyword ON = fasta.Keyword.ON; | 232 static const Keyword ON = const Keyword("on", isPseudo: true); |
232 | 233 |
233 static const Keyword OPERATOR = fasta.Keyword.OPERATOR; | 234 static const Keyword OPERATOR = const Keyword("operator", isBuiltIn: true); |
234 | 235 |
235 static const Keyword PART = fasta.Keyword.PART; | 236 static const Keyword PART = const Keyword("part", isBuiltIn: true); |
236 | 237 |
237 static const Keyword PATCH = fasta.Keyword.PATCH; | 238 static const Keyword PATCH = const Keyword("patch", isPseudo: true); |
238 | 239 |
239 static const Keyword RETHROW = fasta.Keyword.RETHROW; | 240 static const Keyword RETHROW = const Keyword("rethrow"); |
240 | 241 |
241 static const Keyword RETURN = fasta.Keyword.RETURN; | 242 static const Keyword RETURN = const Keyword("return"); |
242 | 243 |
243 static const Keyword SET = fasta.Keyword.SET; | 244 static const Keyword SET = const Keyword("set", isBuiltIn: true); |
244 | 245 |
245 static const Keyword SHOW = fasta.Keyword.SHOW; | 246 static const Keyword SHOW = const Keyword("show", isPseudo: true); |
246 | 247 |
247 static const Keyword SOURCE = fasta.Keyword.SOURCE; | 248 static const Keyword SOURCE = const Keyword("source", isPseudo: true); |
248 | 249 |
249 static const Keyword STATIC = fasta.Keyword.STATIC; | 250 static const Keyword STATIC = const Keyword("static", isBuiltIn: true); |
250 | 251 |
251 static const Keyword SUPER = fasta.Keyword.SUPER; | 252 static const Keyword SUPER = const Keyword("super"); |
252 | 253 |
253 static const Keyword SWITCH = fasta.Keyword.SWITCH; | 254 static const Keyword SWITCH = const Keyword("switch"); |
254 | 255 |
255 static const Keyword SYNC = fasta.Keyword.SYNC; | 256 static const Keyword SYNC = const Keyword("sync", isPseudo: true); |
256 | 257 |
257 static const Keyword THIS = fasta.Keyword.THIS; | 258 static const Keyword THIS = const Keyword("this"); |
258 | 259 |
259 static const Keyword THROW = fasta.Keyword.THROW; | 260 static const Keyword THROW = const Keyword("throw"); |
260 | 261 |
261 static const Keyword TRUE = fasta.Keyword.TRUE; | 262 static const Keyword TRUE = const Keyword("true"); |
262 | 263 |
263 static const Keyword TRY = fasta.Keyword.TRY; | 264 static const Keyword TRY = const Keyword("try"); |
264 | 265 |
265 static const Keyword TYPEDEF = fasta.Keyword.TYPEDEF; | 266 static const Keyword TYPEDEF = const Keyword("typedef", isBuiltIn: true); |
266 | 267 |
267 static const Keyword VAR = fasta.Keyword.VAR; | 268 static const Keyword VAR = const Keyword("var"); |
268 | 269 |
269 static const Keyword VOID = fasta.Keyword.VOID; | 270 static const Keyword VOID = const Keyword("void"); |
270 | 271 |
271 static const Keyword WHILE = fasta.Keyword.WHILE; | 272 static const Keyword WHILE = const Keyword("while"); |
272 | 273 |
273 static const Keyword WITH = fasta.Keyword.WITH; | 274 static const Keyword WITH = const Keyword("with"); |
274 | 275 |
275 static const Keyword YIELD = fasta.Keyword.YIELD; | 276 static const Keyword YIELD = const Keyword("yield", isPseudo: true); |
276 | 277 |
277 static const List<Keyword> values = const <Keyword>[ | 278 static const List<Keyword> values = const <Keyword>[ |
278 ABSTRACT, | 279 ABSTRACT, |
279 AS, | 280 AS, |
280 ASSERT, | 281 ASSERT, |
281 ASYNC, | 282 ASYNC, |
282 AWAIT, | 283 AWAIT, |
283 BREAK, | 284 BREAK, |
284 CASE, | 285 CASE, |
285 CATCH, | 286 CATCH, |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 | 1255 |
1255 void set precedingComments(CommentToken comment) { | 1256 void set precedingComments(CommentToken comment) { |
1256 _precedingComment = comment; | 1257 _precedingComment = comment; |
1257 _setCommentParent(_precedingComment); | 1258 _setCommentParent(_precedingComment); |
1258 } | 1259 } |
1259 | 1260 |
1260 @override | 1261 @override |
1261 Token copy() => | 1262 Token copy() => |
1262 new TokenWithComment(type, offset, copyComments(precedingComments)); | 1263 new TokenWithComment(type, offset, copyComments(precedingComments)); |
1263 } | 1264 } |
OLD | NEW |