SHOW:
|
|
- or go back to the newest paste.
1 | /** | |
2 | * Adding support for Inform 6 language. | |
3 | * | |
4 | * Douglas "logicmoo" Miles 02/2014 | |
5 | * =================================================================== | |
6 | * Added support for Java 8 language constructs. | |
7 | * | |
8 | * Andreas Dangel 01/2014 | |
9 | * =================================================================== | |
10 | * Fix ForStatement to allow Annotations within the initializer. | |
11 | * | |
12 | * Andreas Dangel 01/2013 | |
13 | * =================================================================== | |
14 | * Fix wrong consumption of modifiers (e.g. "final") in a for-each loop. | |
15 | * Check for wrong java usage when catching multiple exceptions. | |
16 | * | |
17 | * Andreas Dangel 12/2012 | |
18 | * =================================================================== | |
19 | * Enhance grammar to use LocalVariableDeclaration in a for-each loop. | |
20 | * This enhances the symbol table to recognize variables declared in such | |
21 | * a for-each loop. | |
22 | * | |
23 | * Andreas Dangel 10/2012 | |
24 | * =================================================================== | |
25 | * Fix parser problem #3530124 with generics | |
26 | * | |
27 | * Modified the grammar, so that the different usages of generics work. | |
28 | * Adjusted the rules, that use "super", as super is no longer a PrimarySuffix. | |
29 | * It's now either a ExplicitConstructorInvocation or a PrimaryPrefix. | |
30 | * See also test case ParserCornersTest/testParsersCases | |
31 | * | |
32 | * Andreas Dangel 05/2012 | |
33 | * =================================================================== | |
34 | * Added support for Java 7 language constructs | |
35 | * | |
36 | * Dinesh Bolkensteyn (SonarSource), 10/2011 | |
37 | * =================================================================== | |
38 | * Changed the CastLookahead production to use 3 lookaheads for primitive types as suggested by Andreas Dangel | |
39 | * | |
40 | * Brian Remedios 07/2011 | |
41 | * =================================================================== | |
42 | * Added in support for assert as a name using lookaheads | |
43 | * | |
44 | * Tom Copeland, 09/03 | |
45 | * =================================================================== | |
46 | * Copied over the changes made by Andrea Gini and Marco Savard to | |
47 | * support JDK 1.4 language constructs, i.e., asserts. | |
48 | * See the java1_4c.jj distributed in the javacc2.1/examples/JavaGrammers directory. | |
49 | * Made numerous other modifications to support PMD. | |
50 | * | |
51 | * Tom Copeland, 6/02 | |
52 | * =================================================================== | |
53 | * This file is a modified version of one originally found in the | |
54 | * VTransformer Examples directory of JavaCC1_1. It has been | |
55 | * modified to accept Java source code for Java 1.2. Basically, | |
56 | * this means a new key word was added, 'strictfp', and that keyword | |
57 | * added to the appropriate productions and LOOKAHEADs (where other, | |
58 | * similar keywords are listed as possible choices). This involved | |
59 | * changing 11 lines. | |
60 | * | |
61 | * Some other minor changes were made, which can be found by doing | |
62 | * a search on 'DW, 7/99'. | |
63 | * | |
64 | * The goal of this effort was for the grammar to be able to parse | |
65 | * any legal Java 1.2 source code. It does not reject all illegal | |
66 | * cases, but neither did the original. Plus, when it comes to | |
67 | * the new 'strictfp' keyword, the Java Compiler from Sun (JDK1.2.1) | |
68 | * also does not reject all illegal cases, as defined by the | |
69 | * "Updates" document found at | |
70 | * http://java.sun.com/docs/books/jls/strictfp-changes.pdf | |
71 | * (see the testcases.txt file for details). | |
72 | * | |
73 | * David Williams, 7/99 | |
74 | * =================================================================== | |
75 | * | |
76 | * | |
77 | * Copyright (C) 1996, 1997 Sun Microsystems Inc. | |
78 | * | |
79 | * Use of this file and the system it is part of is constrained by the | |
80 | * file COPYRIGHT in the root directory of this system. You may, however, | |
81 | * make any modifications you wish to this file. | |
82 | * | |
83 | * Java files generated by running JavaCC on this file (or modified versions | |
84 | * of this file) may be used in exactly the same manner as Java files | |
85 | * generated from any grammar developed by you. | |
86 | * | |
87 | * Author: Sriram Sankar | |
88 | * Date: 3/5/97 | |
89 | * | |
90 | * This file contains a Java grammar and actions that implement a front-end. | |
91 | */ | |
92 | ||
93 | options { | |
94 | JAVA_UNICODE_ESCAPE = true; | |
95 | CACHE_TOKENS = true; | |
96 | STATIC = false; | |
97 | USER_CHAR_STREAM = true; | |
98 | JDK_VERSION = "1.5"; | |
99 | ||
100 | MULTI = true; | |
101 | VISITOR = true; | |
102 | NODE_USES_PARSER = true; | |
103 | NODE_PACKAGE="net.sourceforge.pmd.lang.java.ast"; | |
104 | ||
105 | DEBUG_PARSER = true; | |
106 | DEBUG_LOOKAHEAD = true; | |
107 | } | |
108 | PARSER_BEGIN(JavaParser) | |
109 | package net.sourceforge.pmd.lang.java.ast; | |
110 | import java.util.ArrayList; | |
111 | import java.util.List; | |
112 | import java.util.Map; | |
113 | //extends net.sourceforge.pmd.lang.ast.AbstractTokenManager | |
114 | import net.sourceforge.pmd.lang.ast.AbstractTokenManager; | |
115 | import net.sourceforge.pmd.lang.ast.CharStream; | |
116 | import net.sourceforge.pmd.lang.ast.TokenMgrError; | |
117 | import net.sourceforge.pmd.lang.ast.Node; | |
118 | ||
119 | public class JavaParser { | |
120 | ||
121 | private int jdkVersion = 0; | |
122 | ||
123 | public void setJdkVersion(int jdkVersion) { | |
124 | this.jdkVersion = jdkVersion; | |
125 | } | |
126 | ||
127 | private void throwParseException(String message) { | |
128 | int line = -1; | |
129 | int col = -1; | |
130 | if (jj_lastpos != null) { | |
131 | line = jj_lastpos.beginLine; | |
132 | col = jj_lastpos.beginColumn; | |
133 | } | |
134 | throw new ParseException("Line " + line + ", Column " + col + ": " + message); | |
135 | } | |
136 | ||
137 | private void checkForBadAssertUsage(String in, String usage) { | |
138 | if (jdkVersion > 3 && in.equals("assert")) { | |
139 | throwParseException("Can't use 'assert' as " + usage + " when running in JDK 1.4 mode!"); | |
140 | } | |
141 | } | |
142 | ||
143 | private void checkForBadStaticImportUsage() { | |
144 | if (jdkVersion < 5) { | |
145 | throwParseException("Can't use static imports when running in JDK 1.4 mode!"); | |
146 | } | |
147 | } | |
148 | ||
149 | private void checkForBadAnnotationUsage() { | |
150 | if (jdkVersion < 5) { | |
151 | throwParseException("Can't use annotations when running in JDK 1.4 mode!"); | |
152 | } | |
153 | } | |
154 | ||
155 | private void checkForBadGenericsUsage() { | |
156 | if (jdkVersion < 5) { | |
157 | throwParseException("Can't use generics unless running in JDK 1.5 mode!"); | |
158 | } | |
159 | } | |
160 | ||
161 | private void checkForBadVariableArgumentsUsage() { | |
162 | if (jdkVersion < 5) { | |
163 | throwParseException("Can't use variable arguments (varargs) when running in JDK 1.4 mode!"); | |
164 | } | |
165 | } | |
166 | ||
167 | private void checkForBadJDK15ForLoopSyntaxArgumentsUsage() { | |
168 | if (jdkVersion < 5) { | |
169 | throwParseException("Can't use JDK 1.5 for loop syntax when running in JDK 1.4 mode!"); | |
170 | } | |
171 | } | |
172 | ||
173 | private void checkForBadEnumUsage(String in, String usage) { | |
174 | if (jdkVersion >= 5 && in.equals("enum")) { | |
175 | throwParseException("Can't use 'enum' as " + usage + " when running in JDK 1.5 mode!"); | |
176 | } | |
177 | } | |
178 | ||
179 | private void checkForBadHexFloatingPointLiteral() { | |
180 | if (jdkVersion < 5) { | |
181 | throwParseException("Can't use hexadecimal floating point literals in pre-JDK 1.5 target"); | |
182 | } | |
183 | } | |
184 | ||
185 | private void checkForBadNumericalLiteralslUsage(Token token) { | |
186 | if (jdkVersion < 7) { | |
187 | if (token.image.contains("_")) { | |
188 | throwParseException("Can't use underscores in numerical literals when running in JDK inferior to 1.7 mode!"); | |
189 | } | |
190 | ||
191 | if (token.image.startsWith("0b") || token.image.startsWith("0B")) { | |
192 | throwParseException("Can't use binary numerical literals when running in JDK inferior to 1.7 mode!"); | |
193 | } | |
194 | } | |
195 | } | |
196 | ||
197 | private void checkForBadDiamondUsage() { | |
198 | if (jdkVersion < 7) { | |
199 | throwParseException("Cannot use the diamond generic notation when running in JDK inferior to 1.7 mode!"); | |
200 | } | |
201 | } | |
202 | ||
203 | private void checkForBadTryWithResourcesUsage() { | |
204 | if (jdkVersion < 7) { | |
205 | throwParseException("Cannot use the try-with-resources notation when running in JDK inferior to 1.7 mode!"); | |
206 | } | |
207 | } | |
208 | ||
209 | private void checkForBadMultipleExceptionsCatching() { | |
210 | if (jdkVersion < 7) { | |
211 | throwParseException("Cannot catch multiple exceptions when running in JDK inferior to 1.7 mode!"); | |
212 | } | |
213 | } | |
214 | ||
215 | private void checkForBadLambdaUsage() { | |
216 | if (jdkVersion < 8) { | |
217 | throwParseException("Cannot use lambda expressions when running in JDK inferior to 1.8 mode!"); | |
218 | } | |
219 | } | |
220 | private void checkForBadMethodReferenceUsage() { | |
221 | if (jdkVersion < 8) { | |
222 | throwParseException("Cannot use method references when running in JDK inferior to 1.8 mode!"); | |
223 | } | |
224 | } | |
225 | private void checkForBadDefaultImplementationUsage() { | |
226 | if (jdkVersion < 8) { | |
227 | throwParseException("Cannot use default implementations in interfaces when running in JDK inferior to 1.8 mode!"); | |
228 | } | |
229 | } | |
230 | private void checkForBadIntersectionTypesInCasts() { | |
231 | if (jdkVersion < 8) { | |
232 | throwParseException("Cannot use intersection types in casts when running in JDK inferior to 1.8 mode!"); | |
233 | } | |
234 | } | |
235 | private void checkForBadTypeAnnotations() { | |
236 | if (jdkVersion < 8) { | |
237 | throwParseException("Cannot use type annotations when running in JDK inferior to 1.8 mode!"); | |
238 | } | |
239 | } | |
240 | ||
241 | // This is a semantic LOOKAHEAD to determine if we're dealing with an assert | |
242 | // Note that this can't be replaced with a syntactic lookahead | |
243 | // since "assert" isn't a string literal token | |
244 | private boolean isNextTokenAnAssert() { | |
245 | boolean res = getToken(1).image.equals("assert"); | |
246 | if (res && jdkVersion <= 3 && getToken(2).image.equals("(")) { | |
247 | res = false; | |
248 | } | |
249 | return res; | |
250 | } | |
251 | ||
252 | private boolean isPrecededByComment(Token tok) { | |
253 | boolean res = false; | |
254 | while (!res && tok.specialToken != null) { | |
255 | tok = tok.specialToken; | |
256 | res = tok.kind == SINGLE_LINE_COMMENT || | |
257 | tok.kind == FORMAL_COMMENT || | |
258 | tok.kind == MULTI_LINE_COMMENT; | |
259 | } | |
260 | return res; | |
261 | } | |
262 | ||
263 | public Map<Integer, String> getSuppressMap() { | |
264 | return token_source.getSuppressMap(); | |
265 | } | |
266 | ||
267 | public void setSuppressMarker(String marker) { | |
268 | token_source.setSuppressMarker(marker); | |
269 | } | |
270 | ||
271 | ||
272 | } | |
273 | PARSER_END(JavaParser) | |
274 | ||
275 | TOKEN_MGR_DECLS : | |
276 | { | |
277 | ||
278 | ||
279 | // public class JavaParserTokenManager extends net.sourceforge.pmd.lang.ast.AbstractTokenManager implements JavaParserConstants { | |
280 | ||
281 | protected List<Comment> comments = new ArrayList<Comment>(); | |
282 | ||
283 | } | |
284 | ||
285 | /* WHITE SPACE */ | |
286 | ||
287 | SPECIAL_TOKEN : | |
288 | { | |
289 | " " | "\t" | "\n" | "\r" | "\f" | |
290 | } | |
291 | ||
292 | SPECIAL_TOKEN : /* ! = inform6 #! = beanshell */ | |
293 | { | |
294 | < SINGLE_LINE_COMMENT: ("//"|"! "|"#!")(~["\n","\r"])* ("\n"|"\r"|"\r\n")? > | |
295 | { | |
296 | int startOfNOPMD = matchedToken.image.indexOf(suppressMarker); | |
297 | if (startOfNOPMD != -1) { | |
298 | suppressMap.put(matchedToken.beginLine, matchedToken.image.substring(startOfNOPMD + suppressMarker.length())); | |
299 | } | |
300 | comments.add(new SingleLineComment(matchedToken)); | |
301 | } | |
302 | } | |
303 | ||
304 | /* COMMENTS */ | |
305 | ||
306 | MORE : | |
307 | { | |
308 | <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT | |
309 | | | |
310 | "/*" : IN_MULTI_LINE_COMMENT | |
311 | } | |
312 | ||
313 | <IN_FORMAL_COMMENT> | |
314 | SPECIAL_TOKEN : | |
315 | { | |
316 | <FORMAL_COMMENT: "*/" > { comments.add(new FormalComment(matchedToken)); } : DEFAULT | |
317 | } | |
318 | ||
319 | <IN_MULTI_LINE_COMMENT> | |
320 | SPECIAL_TOKEN : | |
321 | { | |
322 | <MULTI_LINE_COMMENT: "*/" > { comments.add(new MultiLineComment(matchedToken)); } : DEFAULT | |
323 | } | |
324 | ||
325 | <IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT> | |
326 | MORE : | |
327 | { | |
328 | < ~[] > | |
329 | } | |
330 | ||
331 | ||
332 | SKIP : | |
333 | { | |
334 | "\r\n" | |
335 | | | |
336 | "#" : PREPROCESSOR_OUTPUT | |
337 | } | |
338 | ||
339 | <IN_LINE_COMMENT> SKIP: | |
340 | { | |
341 | "\n" : DEFAULT | |
342 | } | |
343 | ||
344 | <IN_LINE_COMMENT> MORE: | |
345 | { | |
346 | < ~[] > | |
347 | } | |
348 | ||
349 | <IN_COMMENT> SKIP: | |
350 | { "*/" : DEFAULT } | |
351 | ||
352 | <IN_COMMENT,IN_PREPROCESSOR_OUTPUT_COMMENT> MORE: | |
353 | { < ~[] > } | |
354 | ||
355 | <IN_PREPROCESSOR_OUTPUT_COMMENT> SKIP: | |
356 | { "*/" : PREPROCESSOR_OUTPUT } | |
357 | ||
358 | <PREPROCESSOR_OUTPUT> SKIP: | |
359 | { | |
360 | "\n" : DEFAULT | |
361 | | "/*" : IN_PREPROCESSOR_OUTPUT_COMMENT | |
362 | } | |
363 | ||
364 | <PREPROCESSOR_OUTPUT> MORE: | |
365 | { | |
366 | "\\\n" | |
367 | | | |
368 | "\\\r\n" | |
369 | | | |
370 | < ~[] > | |
371 | } | |
372 | ||
373 | ||
374 | /* RESERVED WORDS AND LITERALS */ | |
375 | ||
376 | TOKEN : | |
377 | { | |
378 | < ABSTRACT: "abstract" > | |
379 | | < OR: "or" > | |
380 | | < PRINT: "print" > | |
381 | | < PRINT_RET: "print_ret" > | |
382 | | < H_INCLUDE: "#include" > | |
383 | | < H_INCLUDE_PC: "#Include" > | |
384 | | < INCLUDE: "include" > | |
385 | | < INCLUDE_PC: "Include" > | |
386 | | < SWITCHES: "switches" > | |
387 | | < SWITCHES_PC: "Switches" > | |
388 | | < RELEASE: "release" > | |
389 | | < RELEASE_PC: "Release" > | |
390 | | < VERSION: "version" > | |
391 | | < VERSION_PC: "Verson" > | |
392 | | < ARRAY_PC: "Array" > | |
393 | | < ARRAY: "array" > | |
394 | | < CONSTANT: "constant" > | |
395 | | < GLOBAL: "global" > | |
396 | | < GLOBAL_PC: "Global" > | |
397 | | < CONSTANT_PC: "Constant" > | |
398 | | < RTRUE: "rtrue" > | |
399 | | < RFALSE: "rfalse" > | |
400 | | < BOOLEAN: "boolean" > | |
401 | | < BREAK: "break" > | |
402 | | < BYTE: "byte" > | |
403 | | < CASE: "case" > | |
404 | | < CATCH: "catch" > | |
405 | | < CHAR: "char" > | |
406 | | < CLASS: "class" > | |
407 | | < CONST: "const" > | |
408 | | < CONTINUE: "continue" > | |
409 | | < _DEFAULT: "default" > | |
410 | | < DO: "do" > | |
411 | | < DOUBLE: "double" > | |
412 | | < ELSE: "else" > | |
413 | | < EXTENDS: "extends" > | |
414 | | < FALSE: "false" > | |
415 | | < FINAL: "final" > | |
416 | | < FINALLY: "finally" > | |
417 | | < FLOAT: "float" > | |
418 | | < FOR: "for" > | |
419 | | < GOTO: "goto" > | |
420 | | < IF: "if" > | |
421 | | < IMPLEMENTS: "implements" > | |
422 | | < IMPORT: "import" > | |
423 | | < INSTANCEOF: "instanceof" > | |
424 | | < INT: "int" > | |
425 | | < INTERFACE: "interface" > | |
426 | | < LONG: "long" > | |
427 | | < NATIVE: "native" > | |
428 | | < NEW: "new" > | |
429 | | < NULL: "null" > | |
430 | | < PACKAGE: "package"> | |
431 | | < PRIVATE: "private" > | |
432 | | < PROTECTED: "protected" > | |
433 | | < PUBLIC: "public" > | |
434 | | < RETURN: "return" > | |
435 | | < SHORT: "short" > | |
436 | | < STATIC: "static" > | |
437 | | < SUPER: "super" > | |
438 | | < SWITCH: "switch" > | |
439 | | < SYNCHRONIZED: "synchronized" > | |
440 | | < THIS: "this" > | |
441 | | < THROW: "throw" > | |
442 | | < THROWS: "throws" > | |
443 | | < TRANSIENT: "transient" > | |
444 | | < TRUE: "true" > | |
445 | | < TRY: "try" > | |
446 | | < VOID: "void" > | |
447 | | < VOLATILE: "volatile" > | |
448 | | < WHILE: "while" > | |
449 | | < STRICTFP: "strictfp" > | |
450 | } | |
451 | ||
452 | /* LITERALS */ | |
453 | ||
454 | TOKEN : | |
455 | { | |
456 | < INTEGER_LITERAL: | |
457 | <DECIMAL_LITERAL> (["l","L"])? | |
458 | | <HEX_LITERAL> (["l","L"])? | |
459 | | <BINARY_LITERAL> (["l","L"])? | |
460 | | <OCTAL_LITERAL> (["l","L"])? | |
461 | > | |
462 | | | |
463 | < #DECIMAL_LITERAL: (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) > | |
464 | | | |
465 | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"]((["0"-"9","a"-"f","A"-"F","_"])*["0"-"9","a"-"f","A"-"F"])?) > | |
466 | | | |
467 | < #BINARY_LITERAL: "0" ["b","B"] (["0","1"]((["0","1","_"])*["0","1"])?) > | |
468 | | | |
469 | < #OCTAL_LITERAL: "0" (["0"-"7"]((["0"-"7","_"])*["0"-"7"])?) > | |
470 | | | |
471 | < FLOATING_POINT_LITERAL: | |
472 | (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) "." (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?)? (<EXPONENT>)? (["f","F","d","D"])? | |
473 | | "." (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) (<EXPONENT>)? (["f","F","d","D"])? | |
474 | | (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) <EXPONENT> (["f","F","d","D"])? | |
475 | | (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) (<EXPONENT>)? ["f","F","d","D"] | |
476 | > | |
477 | | | |
478 | < HEX_FLOATING_POINT_LITERAL: | |
479 | (<HEX_LITERAL> (".")? | "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"]((["0"-"9","a"-"f","A"-"F","_"])*["0"-"9","a"-"f","A"-"F"])?)? "." (["0"-"9","a"-"f","A"-"F"]((["0"-"9","a"-"f","A"-"F","_"])*["0"-"9","a"-"f","A"-"F"])?)) ["p","P"] (["+","-"])? (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) (["f","F","d","D"])? | |
480 | > | |
481 | | | |
482 | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) > | |
483 | | | |
484 | < CHARACTER_LITERAL: | |
485 | "'" | |
486 | ( (~["'","\\","\n","\r"]) | |
487 | | ("\\" | |
488 | ( ["n","t","b","r","f","\\","'","\""] | |
489 | | ["0"-"7"] ( ["0"-"7"] )? | |
490 | | ["0"-"3"] ["0"-"7"] ["0"-"7"] | |
491 | ) | |
492 | ) | |
493 | ) | |
494 | "'" | |
495 | > | |
496 | | | |
497 | < STRING_LITERAL: | |
498 | "\"" | |
499 | ( (~["\"","\\","\n","\r"]) | |
500 | | ("\\" | |
501 | ( ["n","t","b","r","f","\\","'","\""] | |
502 | | ["0"-"7"] ( ["0"-"7"] )? | |
503 | | ["0"-"3"] ["0"-"7"] ["0"-"7"] | |
504 | ) | |
505 | ) | |
506 | )* | |
507 | "\"" | |
508 | > | |
509 | | | |
510 | < STRING_LITERAL_SQ: | |
511 | "'" | |
512 | ( (~["'","\\","\n","\r"]) | |
513 | | ("\\" | |
514 | ( ["n","t","b","r","f","\\","'","\""] | |
515 | | ["0"-"7"] ( ["0"-"7"] )? | |
516 | | ["0"-"3"] ["0"-"7"] ["0"-"7"] | |
517 | ) | |
518 | ) | |
519 | )* | |
520 | "'" | |
521 | > | |
522 | } | |
523 | ||
524 | /* IDENTIFIERS */ | |
525 | ||
526 | ||
527 | TOKEN : | |
528 | { | |
529 | < ULXCODE: "@" <LETTER> (<PART_LETTER>)* > | |
530 | | | |
531 | < IDENTIFIER: <LETTER> (<PART_LETTER>)* > | |
532 | | | |
533 | < #LETTER: | |
534 | [ // all chars for which Character.isIdentifierStart is true | |
535 | "$", | |
536 | "A"-"Z", | |
537 | "_", | |
538 | "a"-"z", | |
539 | "\u00a2"-"\u00a5", | |
540 | "\u00aa", | |
541 | "\u00b5", | |
542 | "\u00ba", | |
543 | "\u00c0"-"\u00d6", | |
544 | "\u00d8"-"\u00f6", | |
545 | "\u00f8"-"\u021f", | |
546 | "\u0222"-"\u0233", | |
547 | "\u0250"-"\u02ad", | |
548 | "\u02b0"-"\u02b8", | |
549 | "\u02bb"-"\u02c1", | |
550 | "\u02d0"-"\u02d1", | |
551 | "\u02e0"-"\u02e4", | |
552 | "\u02ee", | |
553 | "\u037a", | |
554 | "\u0386", | |
555 | "\u0388"-"\u038a", | |
556 | "\u038c", | |
557 | "\u038e"-"\u03a1", | |
558 | "\u03a3"-"\u03ce", | |
559 | "\u03d0"-"\u03d7", | |
560 | "\u03da"-"\u03f3", | |
561 | "\u0400"-"\u0481", | |
562 | "\u048c"-"\u04c4", | |
563 | "\u04c7"-"\u04c8", | |
564 | "\u04cb"-"\u04cc", | |
565 | "\u04d0"-"\u04f5", | |
566 | "\u04f8"-"\u04f9", | |
567 | "\u0531"-"\u0556", | |
568 | "\u0559", | |
569 | "\u0561"-"\u0587", | |
570 | "\u05d0"-"\u05ea", | |
571 | "\u05f0"-"\u05f2", | |
572 | "\u0621"-"\u063a", | |
573 | "\u0640"-"\u064a", | |
574 | "\u0671"-"\u06d3", | |
575 | "\u06d5", | |
576 | "\u06e5"-"\u06e6", | |
577 | "\u06fa"-"\u06fc", | |
578 | "\u0710", | |
579 | "\u0712"-"\u072c", | |
580 | "\u0780"-"\u07a5", | |
581 | "\u0905"-"\u0939", | |
582 | "\u093d", | |
583 | "\u0950", | |
584 | "\u0958"-"\u0961", | |
585 | "\u0985"-"\u098c", | |
586 | "\u098f"-"\u0990", | |
587 | "\u0993"-"\u09a8", | |
588 | "\u09aa"-"\u09b0", | |
589 | "\u09b2", | |
590 | "\u09b6"-"\u09b9", | |
591 | "\u09dc"-"\u09dd", | |
592 | "\u09df"-"\u09e1", | |
593 | "\u09f0"-"\u09f3", | |
594 | "\u0a05"-"\u0a0a", | |
595 | "\u0a0f"-"\u0a10", | |
596 | "\u0a13"-"\u0a28", | |
597 | "\u0a2a"-"\u0a30", | |
598 | "\u0a32"-"\u0a33", | |
599 | "\u0a35"-"\u0a36", | |
600 | "\u0a38"-"\u0a39", | |
601 | "\u0a59"-"\u0a5c", | |
602 | "\u0a5e", | |
603 | "\u0a72"-"\u0a74", | |
604 | "\u0a85"-"\u0a8b", | |
605 | "\u0a8d", | |
606 | "\u0a8f"-"\u0a91", | |
607 | "\u0a93"-"\u0aa8", | |
608 | "\u0aaa"-"\u0ab0", | |
609 | "\u0ab2"-"\u0ab3", | |
610 | "\u0ab5"-"\u0ab9", | |
611 | "\u0abd", | |
612 | "\u0ad0", | |
613 | "\u0ae0", | |
614 | "\u0b05"-"\u0b0c", | |
615 | "\u0b0f"-"\u0b10", | |
616 | "\u0b13"-"\u0b28", | |
617 | "\u0b2a"-"\u0b30", | |
618 | "\u0b32"-"\u0b33", | |
619 | "\u0b36"-"\u0b39", | |
620 | "\u0b3d", | |
621 | "\u0b5c"-"\u0b5d", | |
622 | "\u0b5f"-"\u0b61", | |
623 | "\u0b85"-"\u0b8a", | |
624 | "\u0b8e"-"\u0b90", | |
625 | "\u0b92"-"\u0b95", | |
626 | "\u0b99"-"\u0b9a", | |
627 | "\u0b9c", | |
628 | "\u0b9e"-"\u0b9f", | |
629 | "\u0ba3"-"\u0ba4", | |
630 | "\u0ba8"-"\u0baa", | |
631 | "\u0bae"-"\u0bb5", | |
632 | "\u0bb7"-"\u0bb9", | |
633 | "\u0c05"-"\u0c0c", | |
634 | "\u0c0e"-"\u0c10", | |
635 | "\u0c12"-"\u0c28", | |
636 | "\u0c2a"-"\u0c33", | |
637 | "\u0c35"-"\u0c39", | |
638 | "\u0c60"-"\u0c61", | |
639 | "\u0c85"-"\u0c8c", | |
640 | "\u0c8e"-"\u0c90", | |
641 | "\u0c92"-"\u0ca8", | |
642 | "\u0caa"-"\u0cb3", | |
643 | "\u0cb5"-"\u0cb9", | |
644 | "\u0cde", | |
645 | "\u0ce0"-"\u0ce1", | |
646 | "\u0d05"-"\u0d0c", | |
647 | "\u0d0e"-"\u0d10", | |
648 | "\u0d12"-"\u0d28", | |
649 | "\u0d2a"-"\u0d39", | |
650 | "\u0d60"-"\u0d61", | |
651 | "\u0d85"-"\u0d96", | |
652 | "\u0d9a"-"\u0db1", | |
653 | "\u0db3"-"\u0dbb", | |
654 | "\u0dbd", | |
655 | "\u0dc0"-"\u0dc6", | |
656 | "\u0e01"-"\u0e30", | |
657 | "\u0e32"-"\u0e33", | |
658 | "\u0e3f"-"\u0e46", | |
659 | "\u0e81"-"\u0e82", | |
660 | "\u0e84", | |
661 | "\u0e87"-"\u0e88", | |
662 | "\u0e8a", | |
663 | "\u0e8d", | |
664 | "\u0e94"-"\u0e97", | |
665 | "\u0e99"-"\u0e9f", | |
666 | "\u0ea1"-"\u0ea3", | |
667 | "\u0ea5", | |
668 | "\u0ea7", | |
669 | "\u0eaa"-"\u0eab", | |
670 | "\u0ead"-"\u0eb0", | |
671 | "\u0eb2"-"\u0eb3", | |
672 | "\u0ebd", | |
673 | "\u0ec0"-"\u0ec4", | |
674 | "\u0ec6", | |
675 | "\u0edc"-"\u0edd", | |
676 | "\u0f00", | |
677 | "\u0f40"-"\u0f47", | |
678 | "\u0f49"-"\u0f6a", | |
679 | "\u0f88"-"\u0f8b", | |
680 | "\u1000"-"\u1021", | |
681 | "\u1023"-"\u1027", | |
682 | "\u1029"-"\u102a", | |
683 | "\u1050"-"\u1055", | |
684 | "\u10a0"-"\u10c5", | |
685 | "\u10d0"-"\u10f6", | |
686 | "\u1100"-"\u1159", | |
687 | "\u115f"-"\u11a2", | |
688 | "\u11a8"-"\u11f9", | |
689 | "\u1200"-"\u1206", | |
690 | "\u1208"-"\u1246", | |
691 | "\u1248", | |
692 | "\u124a"-"\u124d", | |
693 | "\u1250"-"\u1256", | |
694 | "\u1258", | |
695 | "\u125a"-"\u125d", | |
696 | "\u1260"-"\u1286", | |
697 | "\u1288", | |
698 | "\u128a"-"\u128d", | |
699 | "\u1290"-"\u12ae", | |
700 | "\u12b0", | |
701 | "\u12b2"-"\u12b5", | |
702 | "\u12b8"-"\u12be", | |
703 | "\u12c0", | |
704 | "\u12c2"-"\u12c5", | |
705 | "\u12c8"-"\u12ce", | |
706 | "\u12d0"-"\u12d6", | |
707 | "\u12d8"-"\u12ee", | |
708 | "\u12f0"-"\u130e", | |
709 | "\u1310", | |
710 | "\u1312"-"\u1315", | |
711 | "\u1318"-"\u131e", | |
712 | "\u1320"-"\u1346", | |
713 | "\u1348"-"\u135a", | |
714 | "\u13a0"-"\u13f4", | |
715 | "\u1401"-"\u166c", | |
716 | "\u166f"-"\u1676", | |
717 | "\u1681"-"\u169a", | |
718 | "\u16a0"-"\u16ea", | |
719 | "\u1780"-"\u17b3", | |
720 | "\u17db", | |
721 | "\u1820"-"\u1877", | |
722 | "\u1880"-"\u18a8", | |
723 | "\u1e00"-"\u1e9b", | |
724 | "\u1ea0"-"\u1ef9", | |
725 | "\u1f00"-"\u1f15", | |
726 | "\u1f18"-"\u1f1d", | |
727 | "\u1f20"-"\u1f45", | |
728 | "\u1f48"-"\u1f4d", | |
729 | "\u1f50"-"\u1f57", | |
730 | "\u1f59", | |
731 | "\u1f5b", | |
732 | "\u1f5d", | |
733 | "\u1f5f"-"\u1f7d", | |
734 | "\u1f80"-"\u1fb4", | |
735 | "\u1fb6"-"\u1fbc", | |
736 | "\u1fbe", | |
737 | "\u1fc2"-"\u1fc4", | |
738 | "\u1fc6"-"\u1fcc", | |
739 | "\u1fd0"-"\u1fd3", | |
740 | "\u1fd6"-"\u1fdb", | |
741 | "\u1fe0"-"\u1fec", | |
742 | "\u1ff2"-"\u1ff4", | |
743 | "\u1ff6"-"\u1ffc", | |
744 | "\u203f"-"\u2040", | |
745 | "\u207f", | |
746 | "\u20a0"-"\u20af", | |
747 | "\u2102", | |
748 | "\u2107", | |
749 | "\u210a"-"\u2113", | |
750 | "\u2115", | |
751 | "\u2119"-"\u211d", | |
752 | "\u2124", | |
753 | "\u2126", | |
754 | "\u2128", | |
755 | "\u212a"-"\u212d", | |
756 | "\u212f"-"\u2131", | |
757 | "\u2133"-"\u2139", | |
758 | "\u2160"-"\u2183", | |
759 | "\u3005"-"\u3007", | |
760 | "\u3021"-"\u3029", | |
761 | "\u3031"-"\u3035", | |
762 | "\u3038"-"\u303a", | |
763 | "\u3041"-"\u3094", | |
764 | "\u309d"-"\u309e", | |
765 | "\u30a1"-"\u30fe", | |
766 | "\u3105"-"\u312c", | |
767 | "\u3131"-"\u318e", | |
768 | "\u31a0"-"\u31b7", | |
769 | "\u3400"-"\u4db5", | |
770 | "\u4e00"-"\u9fa5", | |
771 | "\ua000"-"\ua48c", | |
772 | "\uac00"-"\ud7a3", | |
773 | "\uf900"-"\ufa2d", | |
774 | "\ufb00"-"\ufb06", | |
775 | "\ufb13"-"\ufb17", | |
776 | "\ufb1d", | |
777 | "\ufb1f"-"\ufb28", | |
778 | "\ufb2a"-"\ufb36", | |
779 | "\ufb38"-"\ufb3c", | |
780 | "\ufb3e", | |
781 | "\ufb40"-"\ufb41", | |
782 | "\ufb43"-"\ufb44", | |
783 | "\ufb46"-"\ufbb1", | |
784 | "\ufbd3"-"\ufd3d", | |
785 | "\ufd50"-"\ufd8f", | |
786 | "\ufd92"-"\ufdc7", | |
787 | "\ufdf0"-"\ufdfb", | |
788 | "\ufe33"-"\ufe34", | |
789 | "\ufe4d"-"\ufe4f", | |
790 | "\ufe69", | |
791 | "\ufe70"-"\ufe72", | |
792 | "\ufe74", | |
793 | "\ufe76"-"\ufefc", | |
794 | "\uff04", | |
795 | "\uff21"-"\uff3a", | |
796 | "\uff3f", | |
797 | "\uff41"-"\uff5a", | |
798 | "\uff65"-"\uffbe", | |
799 | "\uffc2"-"\uffc7", | |
800 | "\uffca"-"\uffcf", | |
801 | "\uffd2"-"\uffd7", | |
802 | "\uffda"-"\uffdc", | |
803 | "\uffe0"-"\uffe1", | |
804 | "\uffe5"-"\uffe6" | |
805 | ] | |
806 | > | |
807 | | | |
808 | < #PART_LETTER: | |
809 | [ // all chars for which Character.isIdentifierPart is true | |
810 | "\u0000"-"\u0008", | |
811 | "\u000e"-"\u001b", | |
812 | "$", | |
813 | "0"-"9", | |
814 | "A"-"Z", | |
815 | "_", | |
816 | "a"-"z", | |
817 | "\u007f"-"\u009f", | |
818 | "\u00a2"-"\u00a5", | |
819 | "\u00aa", | |
820 | "\u00b5", | |
821 | "\u00ba", | |
822 | "\u00c0"-"\u00d6", | |
823 | "\u00d8"-"\u00f6", | |
824 | "\u00f8"-"\u021f", | |
825 | "\u0222"-"\u0233", | |
826 | "\u0250"-"\u02ad", | |
827 | "\u02b0"-"\u02b8", | |
828 | "\u02bb"-"\u02c1", | |
829 | "\u02d0"-"\u02d1", | |
830 | "\u02e0"-"\u02e4", | |
831 | "\u02ee", | |
832 | "\u0300"-"\u034e", | |
833 | "\u0360"-"\u0362", | |
834 | "\u037a", | |
835 | "\u0386", | |
836 | "\u0388"-"\u038a", | |
837 | "\u038c", | |
838 | "\u038e"-"\u03a1", | |
839 | "\u03a3"-"\u03ce", | |
840 | "\u03d0"-"\u03d7", | |
841 | "\u03da"-"\u03f3", | |
842 | "\u0400"-"\u0481", | |
843 | "\u0483"-"\u0486", | |
844 | "\u048c"-"\u04c4", | |
845 | "\u04c7"-"\u04c8", | |
846 | "\u04cb"-"\u04cc", | |
847 | "\u04d0"-"\u04f5", | |
848 | "\u04f8"-"\u04f9", | |
849 | "\u0531"-"\u0556", | |
850 | "\u0559", | |
851 | "\u0561"-"\u0587", | |
852 | "\u0591"-"\u05a1", | |
853 | "\u05a3"-"\u05b9", | |
854 | "\u05bb"-"\u05bd", | |
855 | "\u05bf", | |
856 | "\u05c1"-"\u05c2", | |
857 | "\u05c4", | |
858 | "\u05d0"-"\u05ea", | |
859 | "\u05f0"-"\u05f2", | |
860 | "\u0621"-"\u063a", | |
861 | "\u0640"-"\u0655", | |
862 | "\u0660"-"\u0669", | |
863 | "\u0670"-"\u06d3", | |
864 | "\u06d5"-"\u06dc", | |
865 | "\u06df"-"\u06e8", | |
866 | "\u06ea"-"\u06ed", | |
867 | "\u06f0"-"\u06fc", | |
868 | "\u070f"-"\u072c", | |
869 | "\u0730"-"\u074a", | |
870 | "\u0780"-"\u07b0", | |
871 | "\u0901"-"\u0903", | |
872 | "\u0905"-"\u0939", | |
873 | "\u093c"-"\u094d", | |
874 | "\u0950"-"\u0954", | |
875 | "\u0958"-"\u0963", | |
876 | "\u0966"-"\u096f", | |
877 | "\u0981"-"\u0983", | |
878 | "\u0985"-"\u098c", | |
879 | "\u098f"-"\u0990", | |
880 | "\u0993"-"\u09a8", | |
881 | "\u09aa"-"\u09b0", | |
882 | "\u09b2", | |
883 | "\u09b6"-"\u09b9", | |
884 | "\u09bc", | |
885 | "\u09be"-"\u09c4", | |
886 | "\u09c7"-"\u09c8", | |
887 | "\u09cb"-"\u09cd", | |
888 | "\u09d7", | |
889 | "\u09dc"-"\u09dd", | |
890 | "\u09df"-"\u09e3", | |
891 | "\u09e6"-"\u09f3", | |
892 | "\u0a02", | |
893 | "\u0a05"-"\u0a0a", | |
894 | "\u0a0f"-"\u0a10", | |
895 | "\u0a13"-"\u0a28", | |
896 | "\u0a2a"-"\u0a30", | |
897 | "\u0a32"-"\u0a33", | |
898 | "\u0a35"-"\u0a36", | |
899 | "\u0a38"-"\u0a39", | |
900 | "\u0a3c", | |
901 | "\u0a3e"-"\u0a42", | |
902 | "\u0a47"-"\u0a48", | |
903 | "\u0a4b"-"\u0a4d", | |
904 | "\u0a59"-"\u0a5c", | |
905 | "\u0a5e", | |
906 | "\u0a66"-"\u0a74", | |
907 | "\u0a81"-"\u0a83", | |
908 | "\u0a85"-"\u0a8b", | |
909 | "\u0a8d", | |
910 | "\u0a8f"-"\u0a91", | |
911 | "\u0a93"-"\u0aa8", | |
912 | "\u0aaa"-"\u0ab0", | |
913 | "\u0ab2"-"\u0ab3", | |
914 | "\u0ab5"-"\u0ab9", | |
915 | "\u0abc"-"\u0ac5", | |
916 | "\u0ac7"-"\u0ac9", | |
917 | "\u0acb"-"\u0acd", | |
918 | "\u0ad0", | |
919 | "\u0ae0", | |
920 | "\u0ae6"-"\u0aef", | |
921 | "\u0b01"-"\u0b03", | |
922 | "\u0b05"-"\u0b0c", | |
923 | "\u0b0f"-"\u0b10", | |
924 | "\u0b13"-"\u0b28", | |
925 | "\u0b2a"-"\u0b30", | |
926 | "\u0b32"-"\u0b33", | |
927 | "\u0b36"-"\u0b39", | |
928 | "\u0b3c"-"\u0b43", | |
929 | "\u0b47"-"\u0b48", | |
930 | "\u0b4b"-"\u0b4d", | |
931 | "\u0b56"-"\u0b57", | |
932 | "\u0b5c"-"\u0b5d", | |
933 | "\u0b5f"-"\u0b61", | |
934 | "\u0b66"-"\u0b6f", | |
935 | "\u0b82"-"\u0b83", | |
936 | "\u0b85"-"\u0b8a", | |
937 | "\u0b8e"-"\u0b90", | |
938 | "\u0b92"-"\u0b95", | |
939 | "\u0b99"-"\u0b9a", | |
940 | "\u0b9c", | |
941 | "\u0b9e"-"\u0b9f", | |
942 | "\u0ba3"-"\u0ba4", | |
943 | "\u0ba8"-"\u0baa", | |
944 | "\u0bae"-"\u0bb5", | |
945 | "\u0bb7"-"\u0bb9", | |
946 | "\u0bbe"-"\u0bc2", | |
947 | "\u0bc6"-"\u0bc8", | |
948 | "\u0bca"-"\u0bcd", | |
949 | "\u0bd7", | |
950 | "\u0be7"-"\u0bef", | |
951 | "\u0c01"-"\u0c03", | |
952 | "\u0c05"-"\u0c0c", | |
953 | "\u0c0e"-"\u0c10", | |
954 | "\u0c12"-"\u0c28", | |
955 | "\u0c2a"-"\u0c33", | |
956 | "\u0c35"-"\u0c39", | |
957 | "\u0c3e"-"\u0c44", | |
958 | "\u0c46"-"\u0c48", | |
959 | "\u0c4a"-"\u0c4d", | |
960 | "\u0c55"-"\u0c56", | |
961 | "\u0c60"-"\u0c61", | |
962 | "\u0c66"-"\u0c6f", | |
963 | "\u0c82"-"\u0c83", | |
964 | "\u0c85"-"\u0c8c", | |
965 | "\u0c8e"-"\u0c90", | |
966 | "\u0c92"-"\u0ca8", | |
967 | "\u0caa"-"\u0cb3", | |
968 | "\u0cb5"-"\u0cb9", | |
969 | "\u0cbe"-"\u0cc4", | |
970 | "\u0cc6"-"\u0cc8", | |
971 | "\u0cca"-"\u0ccd", | |
972 | "\u0cd5"-"\u0cd6", | |
973 | "\u0cde", | |
974 | "\u0ce0"-"\u0ce1", | |
975 | "\u0ce6"-"\u0cef", | |
976 | "\u0d02"-"\u0d03", | |
977 | "\u0d05"-"\u0d0c", | |
978 | "\u0d0e"-"\u0d10", | |
979 | "\u0d12"-"\u0d28", | |
980 | "\u0d2a"-"\u0d39", | |
981 | "\u0d3e"-"\u0d43", | |
982 | "\u0d46"-"\u0d48", | |
983 | "\u0d4a"-"\u0d4d", | |
984 | "\u0d57", | |
985 | "\u0d60"-"\u0d61", | |
986 | "\u0d66"-"\u0d6f", | |
987 | "\u0d82"-"\u0d83", | |
988 | "\u0d85"-"\u0d96", | |
989 | "\u0d9a"-"\u0db1", | |
990 | "\u0db3"-"\u0dbb", | |
991 | "\u0dbd", | |
992 | "\u0dc0"-"\u0dc6", | |
993 | "\u0dca", | |
994 | "\u0dcf"-"\u0dd4", | |
995 | "\u0dd6", | |
996 | "\u0dd8"-"\u0ddf", | |
997 | "\u0df2"-"\u0df3", | |
998 | "\u0e01"-"\u0e3a", | |
999 | "\u0e3f"-"\u0e4e", | |
1000 | "\u0e50"-"\u0e59", | |
1001 | "\u0e81"-"\u0e82", | |
1002 | "\u0e84", | |
1003 | "\u0e87"-"\u0e88", | |
1004 | "\u0e8a", | |
1005 | "\u0e8d", | |
1006 | "\u0e94"-"\u0e97", | |
1007 | "\u0e99"-"\u0e9f", | |
1008 | "\u0ea1"-"\u0ea3", | |
1009 | "\u0ea5", | |
1010 | "\u0ea7", | |
1011 | "\u0eaa"-"\u0eab", | |
1012 | "\u0ead"-"\u0eb9", | |
1013 | "\u0ebb"-"\u0ebd", | |
1014 | "\u0ec0"-"\u0ec4", | |
1015 | "\u0ec6", | |
1016 | "\u0ec8"-"\u0ecd", | |
1017 | "\u0ed0"-"\u0ed9", | |
1018 | "\u0edc"-"\u0edd", | |
1019 | "\u0f00", | |
1020 | "\u0f18"-"\u0f19", | |
1021 | "\u0f20"-"\u0f29", | |
1022 | "\u0f35", | |
1023 | "\u0f37", | |
1024 | "\u0f39", | |
1025 | "\u0f3e"-"\u0f47", | |
1026 | "\u0f49"-"\u0f6a", | |
1027 | "\u0f71"-"\u0f84", | |
1028 | "\u0f86"-"\u0f8b", | |
1029 | "\u0f90"-"\u0f97", | |
1030 | "\u0f99"-"\u0fbc", | |
1031 | "\u0fc6", | |
1032 | "\u1000"-"\u1021", | |
1033 | "\u1023"-"\u1027", | |
1034 | "\u1029"-"\u102a", | |
1035 | "\u102c"-"\u1032", | |
1036 | "\u1036"-"\u1039", | |
1037 | "\u1040"-"\u1049", | |
1038 | "\u1050"-"\u1059", | |
1039 | "\u10a0"-"\u10c5", | |
1040 | "\u10d0"-"\u10f6", | |
1041 | "\u1100"-"\u1159", | |
1042 | "\u115f"-"\u11a2", | |
1043 | "\u11a8"-"\u11f9", | |
1044 | "\u1200"-"\u1206", | |
1045 | "\u1208"-"\u1246", | |
1046 | "\u1248", | |
1047 | "\u124a"-"\u124d", | |
1048 | "\u1250"-"\u1256", | |
1049 | "\u1258", | |
1050 | "\u125a"-"\u125d", | |
1051 | "\u1260"-"\u1286", | |
1052 | "\u1288", | |
1053 | "\u128a"-"\u128d", | |
1054 | "\u1290"-"\u12ae", | |
1055 | "\u12b0", | |
1056 | "\u12b2"-"\u12b5", | |
1057 | "\u12b8"-"\u12be", | |
1058 | "\u12c0", | |
1059 | "\u12c2"-"\u12c5", | |
1060 | "\u12c8"-"\u12ce", | |
1061 | "\u12d0"-"\u12d6", | |
1062 | "\u12d8"-"\u12ee", | |
1063 | "\u12f0"-"\u130e", | |
1064 | "\u1310", | |
1065 | "\u1312"-"\u1315", | |
1066 | "\u1318"-"\u131e", | |
1067 | "\u1320"-"\u1346", | |
1068 | "\u1348"-"\u135a", | |
1069 | "\u1369"-"\u1371", | |
1070 | "\u13a0"-"\u13f4", | |
1071 | "\u1401"-"\u166c", | |
1072 | "\u166f"-"\u1676", | |
1073 | "\u1681"-"\u169a", | |
1074 | "\u16a0"-"\u16ea", | |
1075 | "\u1780"-"\u17d3", | |
1076 | "\u17db", | |
1077 | "\u17e0"-"\u17e9", | |
1078 | "\u180b"-"\u180e", | |
1079 | "\u1810"-"\u1819", | |
1080 | "\u1820"-"\u1877", | |
1081 | "\u1880"-"\u18a9", | |
1082 | "\u1e00"-"\u1e9b", | |
1083 | "\u1ea0"-"\u1ef9", | |
1084 | "\u1f00"-"\u1f15", | |
1085 | "\u1f18"-"\u1f1d", | |
1086 | "\u1f20"-"\u1f45", | |
1087 | "\u1f48"-"\u1f4d", | |
1088 | "\u1f50"-"\u1f57", | |
1089 | "\u1f59", | |
1090 | "\u1f5b", | |
1091 | "\u1f5d", | |
1092 | "\u1f5f"-"\u1f7d", | |
1093 | "\u1f80"-"\u1fb4", | |
1094 | "\u1fb6"-"\u1fbc", | |
1095 | "\u1fbe", | |
1096 | "\u1fc2"-"\u1fc4", | |
1097 | "\u1fc6"-"\u1fcc", | |
1098 | "\u1fd0"-"\u1fd3", | |
1099 | "\u1fd6"-"\u1fdb", | |
1100 | "\u1fe0"-"\u1fec", | |
1101 | "\u1ff2"-"\u1ff4", | |
1102 | "\u1ff6"-"\u1ffc", | |
1103 | "\u200c"-"\u200f", | |
1104 | "\u202a"-"\u202e", | |
1105 | "\u203f"-"\u2040", | |
1106 | "\u206a"-"\u206f", | |
1107 | "\u207f", | |
1108 | "\u20a0"-"\u20af", | |
1109 | "\u20d0"-"\u20dc", | |
1110 | "\u20e1", | |
1111 | "\u2102", | |
1112 | "\u2107", | |
1113 | "\u210a"-"\u2113", | |
1114 | "\u2115", | |
1115 | "\u2119"-"\u211d", | |
1116 | "\u2124", | |
1117 | "\u2126", | |
1118 | "\u2128", | |
1119 | "\u212a"-"\u212d", | |
1120 | "\u212f"-"\u2131", | |
1121 | "\u2133"-"\u2139", | |
1122 | "\u2160"-"\u2183", | |
1123 | "\u3005"-"\u3007", | |
1124 | "\u3021"-"\u302f", | |
1125 | "\u3031"-"\u3035", | |
1126 | "\u3038"-"\u303a", | |
1127 | "\u3041"-"\u3094", | |
1128 | "\u3099"-"\u309a", | |
1129 | "\u309d"-"\u309e", | |
1130 | "\u30a1"-"\u30fe", | |
1131 | "\u3105"-"\u312c", | |
1132 | "\u3131"-"\u318e", | |
1133 | "\u31a0"-"\u31b7", | |
1134 | "\u3400"-"\u4db5", | |
1135 | "\u4e00"-"\u9fa5", | |
1136 | "\ua000"-"\ua48c", | |
1137 | "\uac00"-"\ud7a3", | |
1138 | "\uf900"-"\ufa2d", | |
1139 | "\ufb00"-"\ufb06", | |
1140 | "\ufb13"-"\ufb17", | |
1141 | "\ufb1d"-"\ufb28", | |
1142 | "\ufb2a"-"\ufb36", | |
1143 | "\ufb38"-"\ufb3c", | |
1144 | "\ufb3e", | |
1145 | "\ufb40"-"\ufb41", | |
1146 | "\ufb43"-"\ufb44", | |
1147 | "\ufb46"-"\ufbb1", | |
1148 | "\ufbd3"-"\ufd3d", | |
1149 | "\ufd50"-"\ufd8f", | |
1150 | "\ufd92"-"\ufdc7", | |
1151 | "\ufdf0"-"\ufdfb", | |
1152 | "\ufe20"-"\ufe23", | |
1153 | "\ufe33"-"\ufe34", | |
1154 | "\ufe4d"-"\ufe4f", | |
1155 | "\ufe69", | |
1156 | "\ufe70"-"\ufe72", | |
1157 | "\ufe74", | |
1158 | "\ufe76"-"\ufefc", | |
1159 | "\ufeff", | |
1160 | "\uff04", | |
1161 | "\uff10"-"\uff19", | |
1162 | "\uff21"-"\uff3a", | |
1163 | "\uff3f", | |
1164 | "\uff41"-"\uff5a", | |
1165 | "\uff65"-"\uffbe", | |
1166 | "\uffc2"-"\uffc7", | |
1167 | "\uffca"-"\uffcf", | |
1168 | "\uffd2"-"\uffd7", | |
1169 | "\uffda"-"\uffdc", | |
1170 | "\uffe0"-"\uffe1", | |
1171 | "\uffe5"-"\uffe6", | |
1172 | "\ufff9"-"\ufffb" | |
1173 | ] | |
1174 | > | |
1175 | } | |
1176 | ||
1177 | /* SEPARATORS */ | |
1178 | ||
1179 | TOKEN : | |
1180 | { | |
1181 | < LPAREN: "(" > | |
1182 | | < RPAREN: ")" > | |
1183 | | < LBRACE: "{" > | |
1184 | | < RBRACE: "}" > | |
1185 | | < LBRACKET: "[" > | |
1186 | | < RBRACKET: "]" > | |
1187 | | < SEMICOLON: ";" > | |
1188 | | < COMMA: "," > | |
1189 | | < DOT: "." > | |
1190 | | < AT: "@" > | |
1191 | } | |
1192 | ||
1193 | /* OPERATORS */ | |
1194 | ||
1195 | TOKEN : | |
1196 | { | |
1197 | < ASSIGN: "=" > | |
1198 | | < LT: "<" > | |
1199 | | < BANG: "!" > | |
1200 | | < TILDE: "~" > | |
1201 | | < HOOK: "?" > | |
1202 | | < COLON: ":" > | |
1203 | | < EQ: "==" > | |
1204 | | < LE: "<=" > | |
1205 | | < GE: ">=" > | |
1206 | | < NE: "!=" > | |
1207 | | < SC_OR: "||" > | |
1208 | | < SC_AND: "&&" > | |
1209 | | < INCR: "++" > | |
1210 | | < DECR: "--" > | |
1211 | | < PLUS: "+" > | |
1212 | | < MINUS: "-" > | |
1213 | | < STAR: "*" > | |
1214 | | < SLASH: "/" > | |
1215 | | < BIT_AND: "&" > | |
1216 | | < BIT_OR: "|" > | |
1217 | | < XOR: "^" > | |
1218 | | < REM: "%" > | |
1219 | | < LSHIFT: "<<" > | |
1220 | | < PLUSASSIGN: "+=" > | |
1221 | | < MINUSASSIGN: "-=" > | |
1222 | | < NOTASSIGN: "~=" > | |
1223 | | < STARASSIGN: "*=" > | |
1224 | | < SLASHASSIGN: "/=" > | |
1225 | | < ANDASSIGN: "&=" > | |
1226 | | < ORASSIGN: "|=" > | |
1227 | | < XORASSIGN: "^=" > | |
1228 | | < REMASSIGN: "%=" > | |
1229 | | < LSHIFTASSIGN: "<<=" > | |
1230 | | < RSIGNEDSHIFTASSIGN: ">>=" > | |
1231 | | < RUNSIGNEDSHIFTASSIGN: ">>>=" > | |
1232 | | < ELLIPSIS: "..." > | |
1233 | | < LAMBDA: "->" > | |
1234 | | < ARRAY_IDX: "-->" > | |
1235 | | < METHOD_REF: "::" > | |
1236 | } | |
1237 | ||
1238 | /* >'s need special attention due to generics syntax. */ | |
1239 | TOKEN : | |
1240 | { | |
1241 | < RUNSIGNEDSHIFT: ">>>" > | |
1242 | { | |
1243 | matchedToken.kind = GT; | |
1244 | ((Token.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT; | |
1245 | input_stream.backup(2); | |
1246 | matchedToken.image = ">"; | |
1247 | } | |
1248 | | < RSIGNEDSHIFT: ">>" > | |
1249 | { | |
1250 | matchedToken.kind = GT; | |
1251 | ((Token.GTToken)matchedToken).realKind = RSIGNEDSHIFT; | |
1252 | input_stream.backup(1); | |
1253 | matchedToken.image = ">"; | |
1254 | } | |
1255 | | < GT: ">" > | |
1256 | } | |
1257 | ||
1258 | /***************************************** | |
1259 | * THE JAVA LANGUAGE GRAMMAR STARTS HERE * | |
1260 | *****************************************/ | |
1261 | ||
1262 | /* | |
1263 | * Program structuring syntax follows. | |
1264 | */ | |
1265 | ||
1266 | ASTCompilationUnit CompilationUnit() : | |
1267 | {} | |
1268 | { | |
1269 | [ LOOKAHEAD( ( Annotation() )* "package" ) PackageDeclaration() ] | |
1270 | ( ImportDeclaration() )* | |
1271 | ( TypeDeclaration() )* | |
1272 | ( < "\u001a" > )? | |
1273 | ( < "~[]" > )? | |
1274 | <EOF> | |
1275 | { | |
1276 | jjtThis.setComments(token_source.comments); | |
1277 | return jjtThis; | |
1278 | } | |
1279 | } | |
1280 | ||
1281 | void PackageDeclaration() : | |
1282 | {} | |
1283 | { | |
1284 | ( Annotation() )* "package" Name() ";" | |
1285 | } | |
1286 | ||
1287 | void ImportDeclaration() : | |
1288 | {} | |
1289 | { | |
1290 | "import" [ "static" {checkForBadStaticImportUsage();jjtThis.setStatic();} ] Name() [ "." "*" {jjtThis.setImportOnDemand();} ] ";" | |
1291 | } | |
1292 | ||
1293 | /* | |
1294 | * Modifiers. We match all modifiers in a single rule to reduce the chances of | |
1295 | * syntax errors for simple modifier mistakes. It will also enable us to give | |
1296 | * better error messages. | |
1297 | */ | |
1298 | int Modifiers() #void: | |
1299 | { | |
1300 | int modifiers = 0; | |
1301 | } | |
1302 | { | |
1303 | ( | |
1304 | LOOKAHEAD(2) | |
1305 | ( | |
1306 | "public" { modifiers |= AccessNode.PUBLIC; } | |
1307 | | "static" { modifiers |= AccessNode.STATIC; } | |
1308 | | "protected" { modifiers |= AccessNode.PROTECTED; } | |
1309 | | "private" { modifiers |= AccessNode.PRIVATE; } | |
1310 | | "final" { modifiers |= AccessNode.FINAL; } | |
1311 | | "abstract" { modifiers |= AccessNode.ABSTRACT; } | |
1312 | | "synchronized" { modifiers |= AccessNode.SYNCHRONIZED; } | |
1313 | | "native" { modifiers |= AccessNode.NATIVE; } | |
1314 | | "transient" { modifiers |= AccessNode.TRANSIENT; } | |
1315 | | "volatile" { modifiers |= AccessNode.VOLATILE; } | |
1316 | | "strictfp" { modifiers |= AccessNode.STRICTFP; } | |
1317 | | "default" { modifiers |= AccessNode.DEFAULT; checkForBadDefaultImplementationUsage(); } | |
1318 | | Annotation() | |
1319 | ) | |
1320 | )* | |
1321 | { | |
1322 | return modifiers; | |
1323 | } | |
1324 | } | |
1325 | ||
1326 | /* | |
1327 | * Declaration syntax follows. | |
1328 | */ | |
1329 | void TypeDeclaration(): | |
1330 | { | |
1331 | int modifiers; | |
1332 | } | |
1333 | { | |
1334 | ";" | |
1335 | | | |
1336 | modifiers = Modifiers() | |
1337 | ( | |
1338 | ClassOrInterfaceDeclaration(modifiers) | |
1339 | | | |
1340 | EnumDeclaration(modifiers) | |
1341 | | | |
1342 | AnnotationTypeDeclaration(modifiers) | |
1343 | ) | |
1344 | } | |
1345 | ||
1346 | void ClassOrInterfaceDeclaration(int modifiers): | |
1347 | { | |
1348 | Token t = null; | |
1349 | jjtThis.setModifiers(modifiers); | |
1350 | } | |
1351 | { | |
1352 | ||
1353 | ( /* See note about this optional final modifier in BlockStatement */ ["final"|"abstract"] "class" | "interface" { jjtThis.setInterface(); } ) | |
1354 | t=<IDENTIFIER> { jjtThis.setImage(t.image); } | |
1355 | [ TypeParameters() ] | |
1356 | [ ExtendsList() ] | |
1357 | [ ImplementsList() ] | |
1358 | ClassOrInterfaceBody() | |
1359 | } | |
1360 | ||
1361 | void ExtendsList(): | |
1362 | { | |
1363 | boolean extendsMoreThanOne = false; | |
1364 | } | |
1365 | { | |
1366 | "extends" (Annotation() {checkForBadTypeAnnotations();})* ClassOrInterfaceType() | |
1367 | ( "," (Annotation() {checkForBadTypeAnnotations();})* ClassOrInterfaceType() { extendsMoreThanOne = true; } )* | |
1368 | } | |
1369 | ||
1370 | void ImplementsList(): | |
1371 | {} | |
1372 | { | |
1373 | "implements" (Annotation() {checkForBadTypeAnnotations();})* ClassOrInterfaceType() | |
1374 | ( "," (Annotation() {checkForBadTypeAnnotations();})* ClassOrInterfaceType() )* | |
1375 | } | |
1376 | ||
1377 | void EnumDeclaration(int modifiers): | |
1378 | { | |
1379 | ||
1380 | Token t; | |
1381 | jjtThis.setModifiers(modifiers); | |
1382 | } | |
1383 | { | |
1384 | t = <IDENTIFIER> { | |
1385 | if (!t.image.equals("enum")) { | |
1386 | throw new ParseException("ERROR: expecting enum"); | |
1387 | } | |
1388 | ||
1389 | if (jdkVersion < 5) { | |
1390 | throw new ParseException("ERROR: Can't use enum as a keyword in pre-JDK 1.5 target"); | |
1391 | } | |
1392 | } | |
1393 | t=<IDENTIFIER> {jjtThis.setImage(t.image);} | |
1394 | [ ImplementsList() ] | |
1395 | EnumBody() | |
1396 | } | |
1397 | ||
1398 | void EnumBody(): | |
1399 | {} | |
1400 | { | |
1401 | "{" | |
1402 | [( Annotation() )* EnumConstant() ( LOOKAHEAD(2) "," ( Annotation() )* EnumConstant() )* ] | |
1403 | [ "," ] | |
1404 | [ ";" ( ClassOrInterfaceBodyDeclaration() )* ] | |
1405 | "}" | |
1406 | } | |
1407 | ||
1408 | void EnumConstant(): | |
1409 | {Token t;} | |
1410 | { | |
1411 | t=<IDENTIFIER> {jjtThis.setImage(t.image);} [ Arguments() ] [ ClassOrInterfaceBody() ] | |
1412 | } | |
1413 | ||
1414 | void TypeParameters(): | |
1415 | {} | |
1416 | { | |
1417 | "<" {checkForBadGenericsUsage();} TypeParameter() ( "," TypeParameter() )* ">" | |
1418 | } | |
1419 | ||
1420 | void TypeParameter(): | |
1421 | {Token t;} | |
1422 | { | |
1423 | (Annotation() {checkForBadTypeAnnotations();})* | |
1424 | t=<IDENTIFIER> {jjtThis.setImage(t.image);} [ TypeBound() ] | |
1425 | } | |
1426 | ||
1427 | void TypeBound(): | |
1428 | {} | |
1429 | { | |
1430 | "extends" ClassOrInterfaceType() ( "&" ClassOrInterfaceType() )* | |
1431 | } | |
1432 | ||
1433 | void ClassOrInterfaceBody(): | |
1434 | {} | |
1435 | { | |
1436 | "{" ( ClassOrInterfaceBodyDeclaration() )* "}" | |
1437 | } | |
1438 | ||
1439 | void ClassOrInterfaceBodyDeclaration(): | |
1440 | { | |
1441 | int modifiers; | |
1442 | } | |
1443 | { LOOKAHEAD(["static"] "{" ) Initializer() | |
1444 | | modifiers = Modifiers() | |
1445 | ( LOOKAHEAD(3) ClassOrInterfaceDeclaration(modifiers) | |
1446 | | LOOKAHEAD(3) EnumDeclaration(modifiers) | |
1447 | | LOOKAHEAD( [ TypeParameters() ] <IDENTIFIER> "(" ) ConstructorDeclaration(modifiers) | |
1448 | | LOOKAHEAD( Type() <IDENTIFIER> ( "[" "]" )* ( "," | "=" | ";" | "->" | "-->" ) ) FieldDeclaration(modifiers) | |
1449 | | MethodDeclaration(modifiers) | |
1450 | | AnnotationTypeDeclaration(modifiers) | |
1451 | ) | |
1452 | | | |
1453 | ";" | |
1454 | } | |
1455 | ||
1456 | void FieldDeclaration(int modifiers) : | |
1457 | {jjtThis.setModifiers(modifiers);} | |
1458 | { | |
1459 | Type() VariableDeclarator() ( "," VariableDeclarator() )* ";" | |
1460 | } | |
1461 | ||
1462 | void VariableDeclarator() : | |
1463 | {} | |
1464 | { | |
1465 | VariableDeclaratorId() [ ( "=" | "-->" | "->" ) VariableInitializer() ] | |
1466 | } | |
1467 | ||
1468 | void VariableDeclaratorId() : | |
1469 | {Token t;} | |
1470 | { | |
1471 | t=<IDENTIFIER> | |
1472 | ( "[" "]" { jjtThis.bumpArrayDepth(); })* | |
1473 | { | |
1474 | checkForBadAssertUsage(t.image, "a variable name"); | |
1475 | checkForBadEnumUsage(t.image, "a variable name"); | |
1476 | jjtThis.setImage( t.image ); | |
1477 | } | |
1478 | } | |
1479 | ||
1480 | void VariableInitializer() : | |
1481 | {} | |
1482 | { | |
1483 | ArrayInitializer() | |
1484 | | Expression() | |
1485 | } | |
1486 | ||
1487 | void ArrayInitializer() : | |
1488 | {} | |
1489 | { | |
1490 | "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}" | |
1491 | } | |
1492 | ||
1493 | void MethodDeclaration(int modifiers) : | |
1494 | {jjtThis.setModifiers(modifiers);} | |
1495 | { | |
1496 | [ TypeParameters() ] | |
1497 | ResultType() MethodDeclarator() [ "throws" NameList() ] | |
1498 | ( Block() | ";" ) | |
1499 | } | |
1500 | ||
1501 | void MethodDeclarator() : | |
1502 | {Token t;} | |
1503 | { | |
1504 | t=<IDENTIFIER> | |
1505 | { | |
1506 | checkForBadAssertUsage(t.image, "a method name"); | |
1507 | checkForBadEnumUsage(t.image, "a method name"); | |
1508 | jjtThis.setImage( t.image ); | |
1509 | } | |
1510 | FormalParameters() ( "[" "]" )* | |
1511 | } | |
1512 | ||
1513 | ||
1514 | void FormalParameters() : | |
1515 | {} | |
1516 | { | |
1517 | "(" [ FormalParameter() ( "," FormalParameter() )* ] ")" | |
1518 | } | |
1519 | ||
1520 | void FormalParameter() : | |
1521 | { | |
1522 | } | |
1523 | { | |
1524 | ( "final" {jjtThis.setFinal(true);} | Annotation() )* | |
1525 | Type() ("|" {checkForBadMultipleExceptionsCatching();} Type())* | |
1526 | [ "..." {checkForBadVariableArgumentsUsage();} {jjtThis.setVarargs();} ] | |
1527 | VariableDeclaratorId() | |
1528 | } | |
1529 | ||
1530 | void ConstructorDeclaration(int modifiers) : | |
1531 | {jjtThis.setModifiers(modifiers); | |
1532 | Token t;} | |
1533 | { | |
1534 | [ TypeParameters() ] | |
1535 | <IDENTIFIER> FormalParameters() [ "throws" NameList() ] | |
1536 | "{" | |
1537 | [ LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() ] | |
1538 | ( BlockStatement() )* | |
1539 | t = "}" { if (isPrecededByComment(t)) { jjtThis.setContainsComment(); } } | |
1540 | } | |
1541 | ||
1542 | void ExplicitConstructorInvocation() : | |
1543 | {} | |
1544 | { | |
1545 | LOOKAHEAD("this" Arguments() ";") "this" {jjtThis.setIsThis();} Arguments() ";" | |
1546 | | | |
1547 | LOOKAHEAD(TypeArguments() "this" Arguments() ";") TypeArguments() "this" {jjtThis.setIsThis();} Arguments() ";" | |
1548 | | | |
1549 | [ LOOKAHEAD(PrimaryExpression() ".") PrimaryExpression() "." ] [ TypeArguments() ] "super" {jjtThis.setIsSuper();} Arguments() ";" | |
1550 | } | |
1551 | ||
1552 | void Initializer() : | |
1553 | {} | |
1554 | { | |
1555 | [ "static" {jjtThis.setStatic();} ] Block() | |
1556 | } | |
1557 | ||
1558 | ||
1559 | /* | |
1560 | * Type, name and expression syntax follows. | |
1561 | */ | |
1562 | void Type(): | |
1563 | {} | |
1564 | { | |
1565 | LOOKAHEAD(2) ReferenceType() | |
1566 | | | |
1567 | PrimitiveType() | |
1568 | } | |
1569 | ||
1570 | void ReferenceType(): | |
1571 | {} | |
1572 | { | |
1573 | PrimitiveType() ( LOOKAHEAD(2) "[" "]" { jjtThis.bumpArrayDepth(); })+ | |
1574 | | | |
1575 | ( ClassOrInterfaceType() ) ( LOOKAHEAD(2) "[" "]" { jjtThis.bumpArrayDepth(); })* | |
1576 | } | |
1577 | ||
1578 | void ClassOrInterfaceType(): | |
1579 | { | |
1580 | StringBuffer s = new StringBuffer(); | |
1581 | Token t; | |
1582 | } | |
1583 | { | |
1584 | t=<IDENTIFIER> {s.append(t.image);} | |
1585 | [ LOOKAHEAD(2) TypeArguments() ] | |
1586 | ( LOOKAHEAD(2) "." t=<IDENTIFIER> {s.append('.').append(t.image);} [ LOOKAHEAD(2) TypeArguments() ] )* | |
1587 | {jjtThis.setImage(s.toString());} | |
1588 | } | |
1589 | ||
1590 | void TypeArguments(): | |
1591 | {} | |
1592 | { | |
1593 | LOOKAHEAD(2) | |
1594 | "<" {checkForBadGenericsUsage();} TypeArgument() ( "," TypeArgument() )* ">" | |
1595 | | | |
1596 | "<" {checkForBadDiamondUsage();} ">" | |
1597 | } | |
1598 | ||
1599 | void TypeArgument(): | |
1600 | {} | |
1601 | { | |
1602 | (Annotation() {checkForBadTypeAnnotations();})* ReferenceType() | |
1603 | | | |
1604 | "?" [ WildcardBounds() ] | |
1605 | } | |
1606 | ||
1607 | void WildcardBounds(): | |
1608 | {} | |
1609 | { | |
1610 | "extends" (Annotation() {checkForBadTypeAnnotations();})* ReferenceType() | |
1611 | | | |
1612 | "super" (Annotation() {checkForBadTypeAnnotations();})* ReferenceType() | |
1613 | } | |
1614 | ||
1615 | void PrimitiveType() : | |
1616 | {} | |
1617 | { | |
1618 | "boolean" {jjtThis.setImage("boolean");} | |
1619 | | "char" {jjtThis.setImage("char");} | |
1620 | | "byte" {jjtThis.setImage("byte");} | |
1621 | | "short" {jjtThis.setImage("short");} | |
1622 | | "int" {jjtThis.setImage("int");} | |
1623 | | "long" {jjtThis.setImage("long");} | |
1624 | | "float" {jjtThis.setImage("float");} | |
1625 | | "double" {jjtThis.setImage("double");} | |
1626 | } | |
1627 | ||
1628 | ||
1629 | void ResultType() : | |
1630 | {} | |
1631 | { | |
1632 | "void" | Type() | |
1633 | } | |
1634 | ||
1635 | void Name() : | |
1636 | /* | |
1637 | * A lookahead of 2 is required below since "Name" can be followed | |
1638 | * by a ".*" when used in the context of an "ImportDeclaration". | |
1639 | */ | |
1640 | { | |
1641 | StringBuffer s = new StringBuffer(); | |
1642 | Token t; | |
1643 | } | |
1644 | { | |
1645 | t=<IDENTIFIER> | |
1646 | { | |
1647 | jjtThis.testingOnly__setBeginLine( t.beginLine); | |
1648 | jjtThis.testingOnly__setBeginColumn( t.beginColumn); | |
1649 | s.append(t.image); | |
1650 | } | |
1651 | ( LOOKAHEAD(2) "." t=<IDENTIFIER> | |
1652 | {s.append('.').append(t.image);} | |
1653 | )* | |
1654 | {jjtThis.setImage(s.toString());} | |
1655 | } | |
1656 | ||
1657 | void NameList() : | |
1658 | {} | |
1659 | { | |
1660 | (Annotation() {checkForBadTypeAnnotations();})* Name() | |
1661 | ( "," (Annotation() {checkForBadTypeAnnotations();})* Name() | |
1662 | )* | |
1663 | } | |
1664 | ||
1665 | ||
1666 | /* | |
1667 | * Expression syntax follows. | |
1668 | */ | |
1669 | ||
1670 | void Expression() : | |
1671 | /* | |
1672 | * This expansion has been written this way instead of: | |
1673 | * Assignment() | ConditionalExpression() | |
1674 | * for performance reasons. | |
1675 | * However, it is a weakening of the grammar for it allows the LHS of | |
1676 | * assignments to be any conditional expression whereas it can only be | |
1677 | * a primary expression. Consider adding a semantic predicate to work | |
1678 | * around this. | |
1679 | */ | |
1680 | {} | |
1681 | { | |
1682 | ConditionalExpression() | |
1683 | [ | |
1684 | LOOKAHEAD(2) AssignmentOperator() Expression() | |
1685 | ] | |
1686 | } | |
1687 | ||
1688 | void AssignmentOperator() : | |
1689 | {} | |
1690 | { | |
1691 | "=" {jjtThis.setImage("=");} | |
1692 | | "*=" {jjtThis.setImage("*="); jjtThis.setCompound();} | |
1693 | | "/=" {jjtThis.setImage("/="); jjtThis.setCompound();} | |
1694 | | "%=" {jjtThis.setImage("%="); jjtThis.setCompound();} | |
1695 | | "+=" {jjtThis.setImage("+="); jjtThis.setCompound();} | |
1696 | | "-=" {jjtThis.setImage("-="); jjtThis.setCompound();} | |
1697 | | "~=" {jjtThis.setImage("-="); jjtThis.setCompound();} | |
1698 | | "<<=" {jjtThis.setImage("<<="); jjtThis.setCompound();} | |
1699 | | ">>=" {jjtThis.setImage(">>="); jjtThis.setCompound();} | |
1700 | | ">>>=" {jjtThis.setImage(">>>="); jjtThis.setCompound();} | |
1701 | | "&=" {jjtThis.setImage("&="); jjtThis.setCompound();} | |
1702 | | "^=" {jjtThis.setImage("^="); jjtThis.setCompound();} | |
1703 | | "|=" {jjtThis.setImage("|="); jjtThis.setCompound();} | |
1704 | | "->" {jjtThis.setImage("-="); jjtThis.setCompound();} | |
1705 | | "-->" {jjtThis.setImage("-="); jjtThis.setCompound();} | |
1706 | } | |
1707 | ||
1708 | void ConditionalExpression() #ConditionalExpression(>1) : | |
1709 | {} | |
1710 | { | |
1711 | ConditionalOrExpression() [ LOOKAHEAD(2) "?" {jjtThis.setTernary();} Expression() ":" ConditionalExpression() ] | |
1712 | } | |
1713 | ||
1714 | void ConditionalOrExpression() #ConditionalOrExpression(>1): | |
1715 | {} | |
1716 | { | |
1717 | ConditionalAndExpression() ( LOOKAHEAD(2) "||" ConditionalAndExpression() )* | |
1718 | } | |
1719 | ||
1720 | void ConditionalAndExpression() #ConditionalAndExpression(>1): | |
1721 | {} | |
1722 | { | |
1723 | InclusiveOrExpression() ( LOOKAHEAD(2) "&&" InclusiveOrExpression() )* | |
1724 | } | |
1725 | ||
1726 | void InclusiveOrExpression() #InclusiveOrExpression(>1) : | |
1727 | {} | |
1728 | { | |
1729 | ExclusiveOrExpression() ( LOOKAHEAD(2) "|" ExclusiveOrExpression() )* | |
1730 | } | |
1731 | ||
1732 | void ExclusiveOrExpression() #ExclusiveOrExpression(>1) : | |
1733 | {} | |
1734 | { | |
1735 | AndExpression() ( LOOKAHEAD(2) "^" AndExpression() )* | |
1736 | } | |
1737 | ||
1738 | void AndExpression() #AndExpression(>1): | |
1739 | {} | |
1740 | { | |
1741 | EqualityExpression() ( LOOKAHEAD(2) "&" EqualityExpression() )* | |
1742 | } | |
1743 | ||
1744 | void EqualityExpression() #EqualityExpression(>1): | |
1745 | {} | |
1746 | { | |
1747 | InstanceOfExpression() ( LOOKAHEAD(2) ( "==" {jjtThis.setImage("==");} | "!=" {jjtThis.setImage("!=");} ) InstanceOfExpression() )* | |
1748 | } | |
1749 | ||
1750 | void InstanceOfExpression() #InstanceOfExpression(>1): | |
1751 | {} | |
1752 | { | |
1753 | RelationalExpression() [ LOOKAHEAD(2) "instanceof" Type() ] | |
1754 | } | |
1755 | ||
1756 | void RelationalExpression() #RelationalExpression(>1): | |
1757 | {} | |
1758 | { | |
1759 | ShiftExpression() | |
1760 | ( LOOKAHEAD(2) | |
1761 | ( "<" {jjtThis.setImage("<");} | |
1762 | | ">" {jjtThis.setImage(">");} | |
1763 | | "<=" {jjtThis.setImage("<=");} | |
1764 | | ">=" {jjtThis.setImage(">=");} | |
1765 | ) ShiftExpression() )* | |
1766 | } | |
1767 | ||
1768 | void ShiftExpression() #ShiftExpression(>1): | |
1769 | {} | |
1770 | { | |
1771 | AdditiveExpression() | |
1772 | ( LOOKAHEAD(2) | |
1773 | ( "<<" { jjtThis.setImage("<<");} | |
1774 | | RSIGNEDSHIFT() | |
1775 | | RUNSIGNEDSHIFT() | |
1776 | ) AdditiveExpression() )* | |
1777 | } | |
1778 | ||
1779 | void AdditiveExpression() #AdditiveExpression(>1): | |
1780 | {} | |
1781 | { | |
1782 | MultiplicativeExpression() ( LOOKAHEAD(2) ( "+" {jjtThis.setImage("+");} | "or" {jjtThis.setImage("or");} | "-" {jjtThis.setImage("-");} ) MultiplicativeExpression() )* | |
1783 | } | |
1784 | ||
1785 | void MultiplicativeExpression() #MultiplicativeExpression(>1): | |
1786 | {} | |
1787 | { | |
1788 | UnaryExpression() ( LOOKAHEAD(2) ( "*" {jjtThis.setImage("*");} | "/" {jjtThis.setImage("/");} | "%" {jjtThis.setImage("%");}) UnaryExpression() )* | |
1789 | } | |
1790 | ||
1791 | void UnaryExpression() #UnaryExpression((jjtn000.getImage() != null)): | |
1792 | {} | |
1793 | { | |
1794 | ("+" {jjtThis.setImage("+");} | "-" {jjtThis.setImage("-");}) UnaryExpression() | |
1795 | | PreIncrementExpression() | |
1796 | | PreDecrementExpression() | |
1797 | | UnaryExpressionNotPlusMinus() | |
1798 | } | |
1799 | ||
1800 | void PreIncrementExpression() : | |
1801 | {} | |
1802 | { | |
1803 | "++" PrimaryExpression() | |
1804 | } | |
1805 | ||
1806 | void PreDecrementExpression() : | |
1807 | {} | |
1808 | { | |
1809 | "--" PrimaryExpression() | |
1810 | } | |
1811 | ||
1812 | void UnaryExpressionNotPlusMinus() #UnaryExpressionNotPlusMinus((jjtn000.getImage() != null)): | |
1813 | {} | |
1814 | { | |
1815 | ( "~" {jjtThis.setImage("~");} | "!" {jjtThis.setImage("!");} ) UnaryExpression() | |
1816 | | LOOKAHEAD( CastExpression() ) CastExpression() | |
1817 | | PostfixExpression() | |
1818 | } | |
1819 | ||
1820 | void PostfixExpression() #PostfixExpression((jjtn000.getImage() != null)): | |
1821 | {} | |
1822 | { | |
1823 | PrimaryExpression() [ "++" {jjtThis.setImage("++");} | "--" {jjtThis.setImage("--");} ] | |
1824 | } | |
1825 | ||
1826 | void CastExpression() #CastExpression(>1): | |
1827 | {} | |
1828 | { | |
1829 | LOOKAHEAD("(" (Annotation())* Type() ")") "(" (Annotation() {checkForBadTypeAnnotations();})* Type() ")" UnaryExpression() | |
1830 | | LOOKAHEAD("(" (Annotation())* Type() "&") "(" (Annotation() {checkForBadTypeAnnotations();})* Type() ( "&" {checkForBadIntersectionTypesInCasts(); jjtThis.setIntersectionTypes(true);} ReferenceType() )+ ")" UnaryExpressionNotPlusMinus() | |
1831 | | "(" (Annotation() {checkForBadTypeAnnotations();})* Type() ")" UnaryExpressionNotPlusMinus() | |
1832 | } | |
1833 | ||
1834 | void PrimaryExpression() : | |
1835 | {} | |
1836 | { | |
1837 | PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )* | |
1838 | } | |
1839 | ||
1840 | void MemberSelector(): | |
1841 | { | |
1842 | Token t; | |
1843 | } | |
1844 | { | |
1845 | "." TypeArguments() t=<IDENTIFIER> {jjtThis.setImage(t.image);} | |
1846 | | MethodReference() | |
1847 | } | |
1848 | ||
1849 | void MethodReference() : | |
1850 | {Token t; checkForBadMethodReferenceUsage();} | |
1851 | { | |
1852 | "::" ("new" {jjtThis.setImage("new");} | t=<IDENTIFIER> {jjtThis.setImage(t.image);} ) | |
1853 | } | |
1854 | ||
1855 | void PrimaryPrefix() : | |
1856 | {Token t;} | |
1857 | { | |
1858 | Literal() | |
1859 | | "this" {jjtThis.setUsesThisModifier();} | |
1860 | | "super" {jjtThis.setUsesSuperModifier();} | |
1861 | | LOOKAHEAD( LambdaExpression() ) LambdaExpression() | |
1862 | | LOOKAHEAD( <IDENTIFIER> "->" ) LambdaExpression() | |
1863 | | LOOKAHEAD(3) "(" Expression() ")" | |
1864 | | AllocationExpression() | |
1865 | | LOOKAHEAD( ResultType() "." "class" ) ResultType() "." "class" | |
1866 | | LOOKAHEAD( ReferenceType() MethodReference() ) ReferenceType() MethodReference() | |
1867 | | Name() | |
1868 | } | |
1869 | ||
1870 | void LambdaExpression() : | |
1871 | { checkForBadLambdaUsage(); } | |
1872 | { | |
1873 | VariableDeclaratorId() "->" ( Expression() | Block() ) | |
1874 | | LOOKAHEAD(3) FormalParameters() "->" ( Expression() | Block() ) | |
1875 | | LOOKAHEAD(3) "(" VariableDeclaratorId() ( "," VariableDeclaratorId() )* ")" "->" ( Expression() | Block() ) | |
1876 | } | |
1877 | ||
1878 | void PrimarySuffix() : | |
1879 | {Token t;} | |
1880 | { LOOKAHEAD(2) "." "this" | |
1881 | | LOOKAHEAD(2) "." "super" | |
1882 | | LOOKAHEAD(2) "." AllocationExpression() | |
1883 | | LOOKAHEAD(3) MemberSelector() | |
1884 | | "[" Expression() "]" {jjtThis.setIsArrayDereference();} | |
1885 | | "." t=<IDENTIFIER> {jjtThis.setImage(t.image);} | |
1886 | | Arguments() {jjtThis.setIsArguments();} | |
1887 | } | |
1888 | ||
1889 | void Literal() : | |
1890 | {} | |
1891 | { | |
1892 | { Token t;} | |
1893 | t=<INTEGER_LITERAL> { checkForBadNumericalLiteralslUsage(t); jjtThis.setImage(t.image); jjtThis.setIntLiteral();} | |
1894 | | t=<FLOATING_POINT_LITERAL> { checkForBadNumericalLiteralslUsage(t); jjtThis.setImage(t.image); jjtThis.setFloatLiteral();} | |
1895 | | t=<HEX_FLOATING_POINT_LITERAL> { checkForBadHexFloatingPointLiteral(); checkForBadNumericalLiteralslUsage(t); jjtThis.setImage(t.image); jjtThis.setFloatLiteral();} | |
1896 | | t=<CHARACTER_LITERAL> {jjtThis.setImage(t.image); jjtThis.setCharLiteral();} | |
1897 | | t=<STRING_LITERAL> {jjtThis.setImage(t.image); jjtThis.setStringLiteral();} | |
1898 | | t=<STRING_LITERAL_SQ> {jjtThis.setImage(t.image); jjtThis.setStringLiteral();} | |
1899 | | BooleanLiteral() | |
1900 | | NullLiteral() | |
1901 | } | |
1902 | ||
1903 | void BooleanLiteral() : | |
1904 | {} | |
1905 | { | |
1906 | "true" { jjtThis.setTrue(); } | "false" | |
1907 | } | |
1908 | ||
1909 | void NullLiteral() : | |
1910 | {} | |
1911 | { "null" } | |
1912 | ||
1913 | void Arguments() : | |
1914 | {} | |
1915 | { | |
1916 | "(" [ ArgumentList() ] ")" | |
1917 | } | |
1918 | ||
1919 | void ArgumentList() : | |
1920 | {} | |
1921 | { | |
1922 | Expression() ( "," Expression() )* | |
1923 | } | |
1924 | ||
1925 | void AllocationExpression(): | |
1926 | {} | |
1927 | { | |
1928 | "new" (Annotation() {checkForBadTypeAnnotations();})* | |
1929 | (LOOKAHEAD(2) | |
1930 | PrimitiveType() ArrayDimsAndInits() | |
1931 | | | |
1932 | ClassOrInterfaceType() [ TypeArguments() ] | |
1933 | ( | |
1934 | ArrayDimsAndInits() | |
1935 | | | |
1936 | Arguments() [ ClassOrInterfaceBody() ] | |
1937 | ) | |
1938 | ) | |
1939 | } | |
1940 | ||
1941 | /* | |
1942 | * The second LOOKAHEAD specification below is to parse to PrimarySuffix | |
1943 | * if there is an expression between the "[...]". | |
1944 | */ | |
1945 | void ArrayDimsAndInits() : | |
1946 | {} | |
1947 | { | |
1948 | LOOKAHEAD(2) | |
1949 | ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )* | |
1950 | | | |
1951 | ( "[" "]" )+ ArrayInitializer() | |
1952 | } | |
1953 | ||
1954 | ||
1955 | /* | |
1956 | * Statement syntax follows. | |
1957 | */ | |
1958 | ||
1959 | void Statement() : | |
1960 | {} | |
1961 | { | |
1962 | LOOKAHEAD( { isNextTokenAnAssert() } ) AssertStatement() | |
1963 | | LOOKAHEAD(2) LabeledStatement() | |
1964 | | Block() | |
1965 | | EmptyStatement() | |
1966 | | I6ToplevelDeclaration() | |
1967 | | I6SpecificStatement() | |
1968 | | StatementExpression() ";" | |
1969 | | SwitchStatement() | |
1970 | | IfStatement() | |
1971 | | WhileStatement() | |
1972 | | DoStatement() | |
1973 | | ForStatement() | |
1974 | | BreakStatement() | |
1975 | | ContinueStatement() | |
1976 | | ReturnStatement() | |
1977 | | ThrowStatement() | |
1978 | | SynchronizedStatement() | |
1979 | | TryStatement() | |
1980 | } | |
1981 | ||
1982 | void LabeledStatement() : | |
1983 | {Token t;} | |
1984 | { | |
1985 | t=<IDENTIFIER> {jjtThis.setImage(t.image);} ":" Statement() | |
1986 | } | |
1987 | ||
1988 | void Block() : | |
1989 | {Token t;} | |
1990 | { | |
1991 | "{" | |
1992 | ||
1993 | ( BlockStatement() )* t = "}" { if (isPrecededByComment(t)) { jjtThis.setContainsComment(); } } | |
1994 | } | |
1995 | ||
1996 | void BlockStatement(): | |
1997 | {} | |
1998 | { | |
1999 | LOOKAHEAD( { isNextTokenAnAssert() } ) AssertStatement() | |
2000 | | | |
2001 | LOOKAHEAD(( "final" | Annotation() )* Type() <IDENTIFIER>) | |
2002 | LocalVariableDeclaration() ";" | |
2003 | | | |
2004 | Statement() | |
2005 | | | |
2006 | /* | |
2007 | TODO: Seems like we should be discarding the "final" | |
2008 | after using it in the lookahead; I added a ["final|abstract"] inside | |
2009 | ClassOrInterfaceDeclaration, but that seems like a hack that | |
2010 | could break other things... | |
2011 | */ | |
2012 | LOOKAHEAD( [Annotation()] ["final"|"abstract"] "class") [Annotation()] ClassOrInterfaceDeclaration(0) | |
2013 | } | |
2014 | ||
2015 | void LocalVariableDeclaration() : | |
2016 | {} | |
2017 | { | |
2018 | ( "final" {jjtThis.setFinal(true);} | Annotation() )* | |
2019 | Type() | |
2020 | VariableDeclarator() | |
2021 | ( "," VariableDeclarator() )* | |
2022 | } | |
2023 | ||
2024 | void EmptyStatement() : | |
2025 | {} | |
2026 | { | |
2027 | ";" | |
2028 | } | |
2029 | ||
2030 | void StatementExpression() : | |
2031 | {} | |
2032 | { | |
2033 | PreIncrementExpression() | |
2034 | | | |
2035 | PreDecrementExpression() | |
2036 | | | |
2037 | LOOKAHEAD( PrimaryExpression() ("++" | "--") ) PostfixExpression() | |
2038 | | | |
2039 | PrimaryExpression() | |
2040 | [ | |
2041 | AssignmentOperator() Expression() | |
2042 | ] | |
2043 | } | |
2044 | ||
2045 | void SwitchStatement() : | |
2046 | {} | |
2047 | { | |
2048 | "switch" "(" Expression() ")" "{" | |
2049 | ( SwitchLabel() ( BlockStatement() )* )* | |
2050 | "}" | |
2051 | } | |
2052 | ||
2053 | void SwitchLabel() : | |
2054 | {} | |
2055 | { | |
2056 | ["case"] Expression() ":" | |
2057 | | | |
2058 | "default" {jjtThis.setDefault();} ":" | |
2059 | } | |
2060 | ||
2061 | void IfStatement() : | |
2062 | /* | |
2063 | * The disambiguating algorithm of JavaCC automatically binds dangling | |
2064 | * else's to the innermost if statement. The LOOKAHEAD specification | |
2065 | * is to tell JavaCC that we know what we are doing. | |
2066 | */ | |
2067 | {} | |
2068 | { | |
2069 | "if" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" {jjtThis.setHasElse();} Statement() ] | |
2070 | {} | |
2071 | } | |
2072 | ||
2073 | void WhileStatement() : | |
2074 | {} | |
2075 | { | |
2076 | "while" "(" Expression() ")" Statement() | |
2077 | } | |
2078 | ||
2079 | void DoStatement() : | |
2080 | {} | |
2081 | { | |
2082 | "do" Statement() "while" "(" Expression() ")" ";" | |
2083 | } | |
2084 | ||
2085 | ||
2086 | void ForStatement() : | |
2087 | {} | |
2088 | { "for" "(" | |
2089 | ( | |
2090 | LOOKAHEAD(LocalVariableDeclaration() ":") {checkForBadJDK15ForLoopSyntaxArgumentsUsage();} LocalVariableDeclaration() ":" Expression() | |
2091 | | | |
2092 | [ ForInit() ] (";" | ":") [ Expression() ] (";" | ":") [ ForUpdate() ] | |
2093 | ) | |
2094 | ")" Statement() | |
2095 | } | |
2096 | ||
2097 | void ForInit() : | |
2098 | {} | |
2099 | { | |
2100 | LOOKAHEAD( LocalVariableDeclaration() ) | |
2101 | LocalVariableDeclaration() | |
2102 | | | |
2103 | StatementExpressionList() | |
2104 | } | |
2105 | ||
2106 | void StatementExpressionList() : | |
2107 | {} | |
2108 | { | |
2109 | StatementExpression() ( "," StatementExpression() )* | |
2110 | } | |
2111 | ||
2112 | void ForUpdate() : | |
2113 | {} | |
2114 | { | |
2115 | StatementExpressionList() | |
2116 | } | |
2117 | ||
2118 | void BreakStatement() : | |
2119 | {Token t;} | |
2120 | { | |
2121 | "break" [ t=<IDENTIFIER> {jjtThis.setImage(t.image);} ] ";" | |
2122 | } | |
2123 | ||
2124 | void ContinueStatement() : | |
2125 | {Token t;} | |
2126 | { | |
2127 | "continue" [ t=<IDENTIFIER> {jjtThis.setImage(t.image);} ] ";" | |
2128 | } | |
2129 | ||
2130 | void ReturnStatement() : | |
2131 | {} | |
2132 | { | |
2133 | "return" [ Expression() ] ";" | |
2134 | } | |
2135 | ||
2136 | void ThrowStatement() : | |
2137 | {} | |
2138 | { | |
2139 | "throw" Expression() ";" | |
2140 | } | |
2141 | ||
2142 | void SynchronizedStatement() : | |
2143 | {} | |
2144 | { | |
2145 | "synchronized" "(" Expression() ")" Block() | |
2146 | } | |
2147 | ||
2148 | void TryStatement() : | |
2149 | /* | |
2150 | * Semantic check required here to make sure that at least one | |
2151 | * resource/finally/catch is present. | |
2152 | */ | |
2153 | {} | |
2154 | { | |
2155 | "try" (ResourceSpecification())? Block() | |
2156 | ( CatchStatement() )* | |
2157 | [ FinallyStatement() ] | |
2158 | } | |
2159 | ||
2160 | void ResourceSpecification() : | |
2161 | {} | |
2162 | { | |
2163 | {checkForBadTryWithResourcesUsage();} | |
2164 | "(" | |
2165 | Resources() | |
2166 | (LOOKAHEAD(2) ";")? | |
2167 | ")" | |
2168 | } | |
2169 | ||
2170 | void Resources() : | |
2171 | {} | |
2172 | { | |
2173 | Resource() (LOOKAHEAD(2) ";" Resource())* | |
2174 | } | |
2175 | ||
2176 | void Resource() : | |
2177 | {} | |
2178 | { | |
2179 | ( "final" | Annotation() )* | |
2180 | Type() | |
2181 | VariableDeclaratorId() | |
2182 | "=" | |
2183 | Expression() | |
2184 | } | |
2185 | ||
2186 | void CatchStatement() : | |
2187 | {} | |
2188 | { | |
2189 | "catch" | |
2190 | "(" FormalParameter() ")" | |
2191 | Block() | |
2192 | } | |
2193 | ||
2194 | void FinallyStatement() : | |
2195 | {} | |
2196 | { | |
2197 | "finally" Block() | |
2198 | } | |
2199 | ||
2200 | void AssertStatement() : | |
2201 | { | |
2202 | if (jdkVersion <= 3) { | |
2203 | throw new ParseException("Can't use 'assert' as a keyword when running in JDK 1.3 mode!"); | |
2204 | } | |
2205 | } | |
2206 | { | |
2207 | <IDENTIFIER> Expression() [ ":" Expression() ] ";" | |
2208 | } | |
2209 | ||
2210 | /* We use productions to match >>>, >> and > so that we can keep the | |
2211 | * type declaration syntax with generics clean | |
2212 | */ | |
2213 | ||
2214 | void RUNSIGNEDSHIFT(): | |
2215 | {} | |
2216 | { | |
2217 | ( LOOKAHEAD({ getToken(1).kind == GT && | |
2218 | ((Token.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT} ) | |
2219 | ">" ">" ">" | |
2220 | ) | |
2221 | } | |
2222 | ||
2223 | void RSIGNEDSHIFT(): | |
2224 | {} | |
2225 | { | |
2226 | ( LOOKAHEAD({ getToken(1).kind == GT && | |
2227 | ((Token.GTToken)getToken(1)).realKind == RSIGNEDSHIFT} ) | |
2228 | ">" ">" | |
2229 | ) | |
2230 | } | |
2231 | ||
2232 | /* Annotation syntax follows. */ | |
2233 | ||
2234 | void Annotation(): | |
2235 | {} | |
2236 | { | |
2237 | LOOKAHEAD( "@" Name() "(" ( <IDENTIFIER> "=" | ")" )) | |
2238 | NormalAnnotation() | |
2239 | | | |
2240 | LOOKAHEAD( "@" Name() "(" ) | |
2241 | SingleMemberAnnotation() | |
2242 | | | |
2243 | MarkerAnnotation() | |
2244 | } | |
2245 | ||
2246 | void NormalAnnotation(): | |
2247 | {} | |
2248 | { | |
2249 | "@" Name() "(" [ MemberValuePairs() ] ")" {checkForBadAnnotationUsage();} | |
2250 | } | |
2251 | ||
2252 | void MarkerAnnotation(): | |
2253 | {} | |
2254 | { | |
2255 | "@" Name() {checkForBadAnnotationUsage();} | |
2256 | } | |
2257 | ||
2258 | void SingleMemberAnnotation(): | |
2259 | {} | |
2260 | { | |
2261 | "@" Name() "(" MemberValue() ")" {checkForBadAnnotationUsage();} | |
2262 | } | |
2263 | ||
2264 | void MemberValuePairs(): | |
2265 | {} | |
2266 | { | |
2267 | MemberValuePair() ( "," MemberValuePair() )* | |
2268 | } | |
2269 | ||
2270 | void MemberValuePair(): | |
2271 | {Token t;} | |
2272 | { | |
2273 | t=<IDENTIFIER> { jjtThis.setImage(t.image); } "=" MemberValue() | |
2274 | } | |
2275 | ||
2276 | void MemberValue(): | |
2277 | {} | |
2278 | { | |
2279 | Annotation() | |
2280 | | | |
2281 | MemberValueArrayInitializer() | |
2282 | | | |
2283 | ConditionalExpression() | |
2284 | } | |
2285 | ||
2286 | void MemberValueArrayInitializer(): | |
2287 | {} | |
2288 | { | |
2289 | "{" (MemberValue() ( LOOKAHEAD(2) "," MemberValue() )* [ "," ])? "}" | |
2290 | } | |
2291 | ||
2292 | ||
2293 | /* Annotation Types. */ | |
2294 | ||
2295 | void AnnotationTypeDeclaration(int modifiers): | |
2296 | { | |
2297 | Token t; | |
2298 | jjtThis.setModifiers(modifiers); | |
2299 | } | |
2300 | { | |
2301 | "@" "interface" t=<IDENTIFIER> {checkForBadAnnotationUsage();jjtThis.setImage(t.image);} AnnotationTypeBody() | |
2302 | } | |
2303 | ||
2304 | void AnnotationTypeBody(): | |
2305 | {} | |
2306 | { | |
2307 | "{" ( AnnotationTypeMemberDeclaration() )* "}" | |
2308 | } | |
2309 | ||
2310 | void AnnotationTypeMemberDeclaration(): | |
2311 | { | |
2312 | int modifiers; | |
2313 | } | |
2314 | { | |
2315 | modifiers = Modifiers() | |
2316 | ( | |
2317 | LOOKAHEAD(3) AnnotationMethodDeclaration(modifiers) | |
2318 | | | |
2319 | ClassOrInterfaceDeclaration(modifiers) | |
2320 | | | |
2321 | LOOKAHEAD(3) EnumDeclaration(modifiers) | |
2322 | | | |
2323 | AnnotationTypeDeclaration(modifiers) | |
2324 | | | |
2325 | FieldDeclaration(modifiers) | |
2326 | ) | |
2327 | | | |
2328 | ( ";" ) | |
2329 | } | |
2330 | ||
2331 | void AnnotationMethodDeclaration(int modifiers): | |
2332 | { | |
2333 | Token t; | |
2334 | jjtThis.setModifiers(modifiers); | |
2335 | } | |
2336 | { | |
2337 | Type() t=<IDENTIFIER> "(" ")" [ DefaultValue() ] ";" | |
2338 | { | |
2339 | jjtThis.setImage(t.image); | |
2340 | } | |
2341 | } | |
2342 | ||
2343 | void DefaultValue(): | |
2344 | {} | |
2345 | { | |
2346 | "default" MemberValue() | |
2347 | } | |
2348 | ||
2349 | ||
2350 | /*INFORM6 BEGIN */ | |
2351 | ||
2352 | ||
2353 | ||
2354 | ||
2355 | ||
2356 | ||
2357 | ||
2358 | ||
2359 | ||
2360 | ||
2361 | ||
2362 | ||
2363 | ||
2364 | ||
2365 | ||
2366 | /* | |
2367 | Thanks to Sreenivasa Viswanadha for suggesting how to get rid of expensive | |
2368 | lookahead here. | |
2369 | */ | |
2370 | boolean Line() : | |
2371 | {} | |
2372 | { | |
2373 | <EOF> { | |
2374 | //Interpreter.debug("End of File!"); | |
2375 | return true; | |
2376 | } | |
2377 | | | |
2378 | BlockStatement() { | |
2379 | ||
2380 | return false; | |
2381 | } | |
2382 | } | |
2383 | ||
2384 | ||
2385 | ||
2386 | ||
2387 | ||
2388 | ||
2389 | ||
2390 | ||
2391 | ||
2392 | ||
2393 | void I6PrintStatement() #I6PrintStatement : | |
2394 | {} | |
2395 | { | |
2396 | ( "print" | "print_ret" ) I6Expressions() ";" | |
2397 | } | |
2398 | ||
2399 | ||
2400 | void I6FormalParameters() #I6FormalParameters : | |
2401 | {} | |
2402 | { | |
2403 | ( I6FormalParameter() )* | |
2404 | } | |
2405 | ||
2406 | void I6FormalParameter() #I6FormalParameter : | |
2407 | { Token t; } | |
2408 | { | |
2409 | // added [] to Type for ish. Removed [ final ] - is that legal? | |
2410 | LOOKAHEAD(2) t=<IDENTIFIER> { jjtThis.name = t.image; } | |
2411 | | | |
2412 | t=<IDENTIFIER> { jjtThis.name = t.image; } | |
2413 | } | |
2414 | ||
2415 | void I6Expressions() #I6Expressions : | |
2416 | {} | |
2417 | { | |
2418 | I6Expression() ( [","] I6Expression() )* | |
2419 | } | |
2420 | ||
2421 | void I6Expression() #I6Expression : | |
2422 | { } | |
2423 | { | |
2424 | Expression() | |
2425 | //Arguments() | |
2426 | } | |
2427 | ||
2428 | void I6MethodDeclaration() #I6MethodDeclaration : | |
2429 | { Token t; } | |
2430 | { | |
2431 | "[" t=<IDENTIFIER> I6FormalParameters() ";" I6Block() "]" ";" | |
2432 | { | |
2433 | jjtThis.name = t.image; | |
2434 | } | |
2435 | } | |
2436 | ||
2437 | ||
2438 | void I6Block() #I6Block : | |
2439 | {} | |
2440 | { | |
2441 | ( BlockStatement() )* | |
2442 | } | |
2443 | ||
2444 | /* | |
2445 | void I6ForStatement() #I6ForStatement : | |
2446 | { Token t = null; } | |
2447 | { | |
2448 | "for" | |
2449 | "(" | |
2450 | [ I6ForInit() { jjtThis.hasForInit=true; } ] | |
2451 | (":"|";") [ I6ForExpression() { jjtThis.hasExpression=true; } ] | |
2452 | (":"|";") [ I6ForUpdate() { jjtThis.hasForUpdate=true; } ] | |
2453 | ")" | |
2454 | Statement() | |
2455 | } | |
2456 | ||
2457 | ||
2458 | ||
2459 | void I6ForStatement() #I6ForStatement : | |
2460 | { } | |
2461 | { | |
2462 | "for" "(" [ I6ForInit() ] ":" [ I6ForExpression() ] ":" [ I6ForUpdate() ] ")" Statement() | |
2463 | } | |
2464 | ||
2465 | ||
2466 | ||
2467 | void I6ForInit() #I6ForInit : | |
2468 | {} | |
2469 | { | |
2470 | ForInit() | |
2471 | } | |
2472 | void I6ForUpdate() #I6ForUpdate : | |
2473 | {}{ | |
2474 | ForUpdate() | |
2475 | } | |
2476 | void I6ForExpression() #I6ForExpression : | |
2477 | {}{ | |
2478 | Expression() | |
2479 | } | |
2480 | */ | |
2481 | ||
2482 | void RTrueStatement() #RTrueStatement(true) : | |
2483 | {} | |
2484 | { | |
2485 | "rtrue" ";" | |
2486 | } | |
2487 | ||
2488 | void RFalseStatement() #RFalseStatement : | |
2489 | {} | |
2490 | { | |
2491 | "rfalse" ";" | |
2492 | } | |
2493 | ||
2494 | void PushToLabel() #PushToLabel : | |
2495 | {} | |
2496 | { | |
2497 | ["-->" <IDENTIFIER>] | |
2498 | } | |
2499 | ||
2500 | ||
2501 | void AsmStatement() #AsmStatement : | |
2502 | {} | |
2503 | { | |
2504 | ( | |
2505 | <ULXCODE> I6Expressions() ";" | |
2506 | | | |
2507 | "@"Expression() I6Expressions() ";" | |
2508 | ) | |
2509 | } | |
2510 | ||
2511 | ||
2512 | ||
2513 | void I6ToplevelDeclaration() #I6TopevelDeclaration : | |
2514 | {} | |
2515 | { | |
2516 | I6MethodDeclaration() | |
2517 | | | |
2518 | I6ClassDeclaration() | |
2519 | } | |
2520 | ||
2521 | ||
2522 | ||
2523 | void I6ClassDeclaration() #I6ClassDeclaration : | |
2524 | {} | |
2525 | { | |
2526 | "CLASS DEF" | |
2527 | } | |
2528 | ||
2529 | ||
2530 | void i6FileDirective() #i6FileDirective : | |
2531 | {} | |
2532 | { | |
2533 | ( | |
2534 | "release" | "switches" | "include" | "#include" | |
2535 | "Release" | "Switches" | "Include" | "#Include" | |
2536 | ) Literal() ";" | |
2537 | } | |
2538 | ||
2539 | ||
2540 | void I6SpecificStatement() #I6SpecificStatement : | |
2541 | {} | |
2542 | { | |
2543 | ( | |
2544 | AsmStatement() | |
2545 | | | |
2546 | /*LOOKAHEAD ("for" "(" [ I6ForInit() ] | |
2547 | ":" [ I6ForExpression() ] | |
2548 | ":" [ I6ForUpdate() ] ")" ) | |
2549 | I6ForStatement() | |
2550 | |*/ | |
2551 | ||
2552 | ("Array"| "array") <IDENTIFIER> [("-->" | "->" ) I6Expressions()] ";" | |
2553 | | | |
2554 | ("Constant"| "constant") <IDENTIFIER> ["=" Expression()] ";" | |
2555 | | | |
2556 | ("Global"| "global") <IDENTIFIER> ["=" Expression()] ";" | |
2557 | //| | |
2558 | // i6FileDirective() | |
2559 | | | |
2560 | I6PrintStatement() | |
2561 | | | |
2562 | RFalseStatement() | |
2563 | | | |
2564 | RTrueStatement() | |
2565 | ) | |
2566 | } | |
2567 | ||
2568 | ||
2569 | ||
2570 | /*INFORM6 END */ |