3 import java_cup.runtime.*;
7 /* Java 1.4 parser for CUP.
8 * Copyright (C) 2002-2003 C. Scott Ananian <cananian@alumni.princeton.edu>
9 * This program is released under the terms of the GPL; see the file
10 * COPYING for more details. There is NO WARRANTY on this code.
14 JDK 1.4 Features added:
16 statement_without_trailing_substatement ::= ...
19 ASSERT expression SEMICOLON
20 | ASSERT expression COLON expression SEMICOLON
26 public Parser(Lexer l) {
31 public void syntax_error(java_cup.runtime.Symbol current) {
32 report_error("Syntax error (" + current.sym + ")", current);
34 public void report_error(String message, java_cup.runtime.Symbol info) {
35 lexer.errorMsg(message, info);
38 return lexer.line_num;
42 scan with {: return lexer.nextToken(); :};
44 terminal BOOLEAN; // primitive_type
45 terminal BYTE, SHORT, INT, LONG, CHAR; // integral_type
46 terminal FLOAT, DOUBLE; // floating_point_type
47 terminal LBRACK, RBRACK; // array_type
48 terminal java.lang.String IDENTIFIER; // name
49 terminal DOT; // qualified_name
50 terminal SEMICOLON, MULT, COMMA, LBRACE, RBRACE, EQ, LPAREN, RPAREN, COLON;
51 terminal PACKAGE; // package_declaration
52 terminal IMPORT; // import_declaration
53 terminal PUBLIC, PROTECTED, PRIVATE; // modifier
54 terminal STATIC; // modifier
55 terminal ABSTRACT, FINAL, NATIVE, SYNCHRONIZED, TRANSIENT, VOLATILE;
56 terminal CLASS; // class_declaration
57 terminal EXTENDS; // super
58 terminal IMPLEMENTS; // interfaces
59 terminal VOID; // method_header
60 terminal THROWS; // throws
61 terminal THIS, SUPER; // explicit_constructor_invocation
62 terminal INTERFACE; // interface_declaration
63 terminal IF, ELSE; // if_then_statement, if_then_else_statement
64 terminal SWITCH; // switch_statement
65 terminal CASE, DEFAULT; // switch_label
66 terminal DO, WHILE; // while_statement, do_statement
67 terminal FOR; // for_statement
68 terminal BREAK; // break_statement
69 terminal CONTINUE; // continue_statement
70 terminal RETURN; // return_statement
71 terminal THROW; // throw_statement
72 terminal TRY; // try_statement
73 terminal CATCH; // catch_clause
74 terminal FINALLY; // finally
75 terminal NEW; // class_instance_creation_expression
76 terminal NEWFLAG; // class_instance_creation_expression
77 terminal PLUSPLUS; // postincrement_expression
78 terminal MINUSMINUS; // postdecrement_expression
79 terminal PLUS, MINUS, COMP, NOT, DIV, MOD;
80 terminal LSHIFT, RSHIFT, URSHIFT; // shift_expression
81 terminal LT, GT, LTEQ, GTEQ, INSTANCEOF; // relational_expression
82 terminal EQEQ, NOTEQ; // equality_expression
83 terminal AND; // and_expression
84 terminal XOR; // exclusive_or_expression
85 terminal OR; // inclusive_or_expression
86 terminal ANDAND; // conditional_and_expression
87 terminal OROR; // conditional_or_expression
88 terminal QUESTION; // conditional_expression
89 terminal MULTEQ, DIVEQ, MODEQ, PLUSEQ, MINUSEQ; // assignment_operator
90 terminal LSHIFTEQ, RSHIFTEQ, URSHIFTEQ; // assignment_operator
91 terminal ANDEQ, XOREQ, OREQ; // assignment_operator
92 terminal AT; // support annotations
93 terminal LOCDEF; // declaration of location hierarchy
95 terminal java.lang.Number INTEGER_LITERAL;
96 terminal java.lang.Number FLOATING_POINT_LITERAL;
97 terminal java.lang.Boolean BOOLEAN_LITERAL;
98 terminal java.lang.Character CHARACTER_LITERAL;
99 terminal java.lang.String STRING_LITERAL;
100 terminal NULL_LITERAL;
102 // Reserved but unused:
103 terminal CONST, GOTO;
104 // strictfp keyword, new in Java 1.2
106 // assert keyword, new in Java 1.4
107 terminal ASSERT; // assert_statement
108 // lexer compatibility with Java 1.5
112 // added for disjoint reachability analysis
116 // 19.2) The Syntactic Grammar
117 non terminal ParseNode goal;
118 // 19.3) Lexical Structure
119 non terminal ParseNode literal;
120 // 19.4) Types, Values, and Variables
121 non terminal ParseNode type, primitive_type, numeric_type;
122 non terminal ParseNode integral_type, floating_point_type;
123 non terminal ParseNode reference_type;
124 non terminal ParseNode class_or_interface_type;
125 non terminal ParseNode class_type;
126 non terminal ParseNode interface_type;
127 non terminal ParseNode array_type;
129 non terminal ParseNode name, simple_name, qualified_name;
131 non terminal ParseNode compilation_unit;
132 non terminal ParseNode package_declaration_opt, package_declaration;
133 non terminal ParseNode import_declarations_opt, import_declarations;
134 non terminal ParseNode type_declarations_opt, type_declarations;
135 non terminal ParseNode import_declaration;
136 non terminal ParseNode single_type_import_declaration;
137 non terminal ParseNode type_import_on_demand_declaration;
138 non terminal ParseNode type_declaration;
139 // 19.7) Productions used only in the LALR(1) grammar
140 non terminal ParseNode modifiers_opt, modifiers, modifiers_at, modifier;
141 non terminal ParseNode mixed_modifiers, mixed_modifiers_at;
142 // 19.8.1) Class Declaration
143 non terminal ParseNode class_declaration, super, super_opt;
144 non terminal ParseNode interfaces, interfaces_opt, interface_type_list;
145 non terminal ParseNode class_body;
146 non terminal ParseNode class_body_declarations, class_body_declarations_opt;
147 non terminal ParseNode class_body_declaration, class_member_declaration;
148 // 19.8.2) Field Declarations
149 non terminal ParseNode field_declaration, variable_declarators, variable_declarator;
150 non terminal ParseNode variable_declarator_id;
151 non terminal ParseNode variable_initializer;
152 // 19.8.3) Method Declarations
153 non terminal ParseNode method_declaration, method_header, method_declarator;
154 non terminal ParseNode formal_parameter_list_opt, formal_parameter_list;
155 non terminal ParseNode formal_parameter;
156 non terminal ParseNode throws_opt;
157 non terminal ParseNode throws;
158 non terminal ParseNode class_type_list;
159 non terminal ParseNode method_body;
160 // 19.8.4) Static Initializers
161 non terminal ParseNode static_initializer;
162 // 19.8.5) Constructor Declarations
163 non terminal ParseNode constructor_declaration, constructor_declarator;
164 non terminal ParseNode constructor_body;
165 non terminal ParseNode explicit_constructor_invocation;
166 // 19.8.6) Location Hierarchy Declarations
167 non terminal ParseNode location_order_declaration, location_order_list, location_order;
168 // 19.9.1) Interface Declarations
169 non terminal ParseNode interface_declaration;
170 non terminal normal_interface_declaration, annotation_type_declaration;
171 non terminal ParseNode extends_interfaces_opt, extends_interfaces;
172 non terminal ParseNode interface_body;
173 non terminal ParseNode interface_member_declarations_opt, interface_member_declarations;
174 non terminal ParseNode interface_member_declaration, constant_declaration;
175 non terminal ParseNode abstract_method_declaration;
177 non terminal ParseNode array_initializer;
178 non terminal ParseNode variable_initializers;
179 // 19.11) Blocks and Statements
180 non terminal ParseNode block;
181 non terminal ParseNode block_statements_opt, block_statements, block_statement;
182 non terminal ParseNode local_variable_declaration_statement, local_variable_declaration;
183 non terminal ParseNode statement, statement_no_short_if;
184 non terminal ParseNode statement_without_trailing_substatement;
185 non terminal ParseNode empty_statement;
186 non terminal ParseNode labeled_statement, labeled_statement_no_short_if;
187 non terminal ParseNode expression_statement, statement_expression;
188 non terminal ParseNode if_then_statement;
189 non terminal ParseNode if_then_else_statement, if_then_else_statement_no_short_if;
190 non terminal ParseNode switch_statement, switch_block;
191 non terminal ParseNode switch_block_statement_groups;
192 non terminal ParseNode switch_block_statement_group;
193 non terminal ParseNode switch_labels, switch_label;
194 non terminal ParseNode while_statement, while_statement_no_short_if;
195 non terminal ParseNode do_statement;
196 non terminal ParseNode for_statement, for_statement_no_short_if;
197 non terminal ParseNode for_init_opt, for_init;
198 non terminal ParseNode for_update_opt, for_update;
199 non terminal ParseNode statement_expression_list;
200 non terminal ParseNode identifier_opt;
201 non terminal ParseNode break_statement, continue_statement;
202 non terminal ParseNode return_statement;
203 non terminal ParseNode throw_statement;
204 non terminal ParseNode synchronized_statement;
205 non terminal ParseNode try_statement;
206 non terminal ParseNode catches_opt;
207 non terminal ParseNode catches, catch_clause;
208 non terminal ParseNode finally;
209 //non terminal ParseNode assert_statement;
210 non terminal ParseNode genreach_statement;
211 // 19.12) Expressions
212 non terminal ParseNode primary, primary_no_new_array;
213 non terminal ParseNode class_instance_creation_expression;
214 non terminal ParseNode cons_argument_list_opt, cons_argument_list;
215 non terminal ParseNode argument_list_opt, argument_list;
216 non terminal ParseNode array_creation_init;
217 non terminal ParseNode array_creation_uninit;
218 non terminal ParseNode dim_exprs, dim_expr;
219 non terminal Integer dims_opt, dims;
220 non terminal ParseNode field_access, method_invocation;
221 non terminal ParseNode array_access;
222 non terminal ParseNode postfix_expression;
223 non terminal ParseNode postincrement_expression, postdecrement_expression;
224 non terminal ParseNode unary_expression, unary_expression_not_plus_minus;
225 non terminal ParseNode preincrement_expression, predecrement_expression;
226 non terminal ParseNode cast_expression;
227 non terminal ParseNode multiplicative_expression, additive_expression;
228 non terminal ParseNode shift_expression, relational_expression, equality_expression;
229 non terminal ParseNode and_expression, exclusive_or_expression, inclusive_or_expression;
230 non terminal ParseNode conditional_and_expression, conditional_or_expression;
231 non terminal ParseNode conditional_expression;
232 non terminal ParseNode assignment_expression;
233 non terminal ParseNode assignment;
234 non terminal ParseNode assignment_operator;
235 non terminal ParseNode expression_opt, expression;
236 non terminal ParseNode constant_expression;
237 //failure aware computation keywords
240 terminal ISAVAILABLE;
245 non terminal ParseNode flag_declaration;
246 non terminal ParseNode task_declaration;
247 non terminal ParseNode task_parameter_list;
248 non terminal ParseNode task_parameter;
249 non terminal ParseNode flag_expression;
250 non terminal ParseNode flag_andexpression;
251 non terminal ParseNode flag_notexpression;
252 non terminal ParseNode task_exitstatement;
253 non terminal ParseNode flag_effects_opt;
254 non terminal ParseNode flag_effects;
255 non terminal ParseNode flag_effect;
256 non terminal ParseNode flag_list;
257 non terminal ParseNode flag_list_opt;
258 non terminal ParseNode flag_change;
260 non terminal ParseNode cons_checks_opt;
261 non terminal ParseNode cons_checks;
262 non terminal ParseNode cons_check;
264 non terminal ParseNode tag_variable_declaration_statement;
265 non terminal ParseNode tag_expression_list;
266 non terminal ParseNode tag_expression;
267 non terminal ParseNode tag_list;
268 non terminal ParseNode tag_list_opt;
269 non terminal ParseNode tag_change;
271 //distributed transaction keywords
276 non terminal ParseNode atomic_statement;
277 non terminal ParseNode getoffset_expression;
279 //disjointness for Java
282 //coarse-grain parallelization
285 non terminal ParseNode sese_statement;
288 // JSR-201) Enum Declaration
289 non terminal ParseNode enum_declaration;
290 non terminal ParseNode enum_body, enum_constants_opt, enum_constants, enum_constant;
291 //non terminal ParseNode enum_arguments_opt, enum_body_declarations_opt;
293 // annotation expressions
294 non terminal ParseNode annotations_opt, annotations, annotations_at, annotation, annotation_body;
295 non terminal ParseNode normal_annotation_body, marker_annotation_body;
296 non terminal ParseNode single_element_annotation_body;
297 non terminal ParseNode annotation_type_body, annotation_type_element_declarations;
298 non terminal ParseNode annotation_type_element_declarations_opt;
299 non terminal ParseNode annotation_type_element_declaration, default_value_opt, default_value;
300 non terminal ParseNode element_value_pairs_opt, element_value_pairs, element_value_pair;
301 non terminal ParseNode element_values_opt, element_values, element_value, element_value_array_initializer;
308 TASK IDENTIFIER:id LPAREN task_parameter_list:tpl RPAREN
312 ParseNode pn=new ParseNode("task_declaration",parser.n());
313 pn.addChild("name").addChild(id);
316 pn.addChild("body").addChild(body);
320 task_parameter_list ::=
322 ParseNode pn=new ParseNode("task_parameter_list",parser.n());
326 | task_parameter_list:fpl COMMA task_parameter:fp {:
333 type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE {:
334 ParseNode pn=new ParseNode("task_parameter",parser.n());
337 pn.addChild("flag").addChild(exp);
340 | type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE LBRACE tag_expression_list:texp RBRACE {:
341 ParseNode pn=new ParseNode("task_parameter",parser.n());
344 pn.addChild("flag").addChild(exp);
345 pn.addChild("tag").addChild(texp);
348 | type:type variable_declarator_id:name LBRACE RBRACE LBRACE tag_expression_list:texp RBRACE {:
349 ParseNode pn=new ParseNode("task_parameter",parser.n());
352 pn.addChild("tag").addChild(texp);
355 | OPTIONAL task_parameter:fp {:
356 ParseNode pn=new ParseNode("task_parameter",parser.n());
357 pn.addChild("optional").addChild(fp);
363 tag_expression_list ::= tag_expression:te {:
364 ParseNode pn=new ParseNode("tag_expression_list",parser.n());
368 | tag_expression_list:tel COMMA tag_expression:te {:
374 tag_expression ::= IDENTIFIER:type IDENTIFIER:id {:
375 ParseNode pn=new ParseNode("tag_expression",parser.n());
376 pn.addChild("type").addChild(type);
377 pn.addChild("single").addChild(id);
382 tag_list_opt ::= LBRACE tag_list:fl RBRACE {:RESULT=fl;:}
383 | LBRACE RBRACE {: RESULT = new ParseNode("empty",parser.n()); :}
384 | {: RESULT = new ParseNode("empty",parser.n()); :}
387 tag_list ::= tag_change:fc {:
388 ParseNode pn=new ParseNode("tag_list",parser.n());
392 | tag_list:fl COMMA tag_change:fc {:
397 tag_change ::= IDENTIFIER:id {:
398 RESULT=new ParseNode("name",parser.n()).addChild(id).getRoot();
400 | NOT IDENTIFIER:id {:
401 RESULT=new ParseNode("not",parser.n()).addChild("name").addChild(id).getRoot();
405 flag_andexpression:exp {:
408 | flag_expression:exp1 OROR flag_andexpression:exp2 {:
409 ParseNode pn=new ParseNode("or",parser.n());
416 flag_andexpression ::=
417 flag_notexpression:exp {: RESULT=exp; :}
418 | flag_notexpression:exp1 ANDAND flag_andexpression:exp2 {:
419 ParseNode pn=new ParseNode("and",parser.n());
426 flag_notexpression ::=
427 NOT flag_notexpression:exp {:
428 ParseNode pn=new ParseNode("not",parser.n());
432 | LPAREN flag_expression:exp RPAREN {:
436 ParseNode pn=new ParseNode("name",parser.n());
442 task_exitstatement ::= TASKEXIT flag_effects_opt:opt cons_checks_opt:cco SEMICOLON {:
443 RESULT=(new ParseNode("taskexit",parser.n())).addChild(opt).getRoot().addChild(cco).getRoot();
446 cons_checks_opt ::= ASSERT LPAREN cons_checks:cc RPAREN {: RESULT=cc; :}
447 | {: RESULT = new ParseNode("empty",parser.n()); :}
450 cons_checks ::= cons_check:cc {:
451 ParseNode pn=new ParseNode("cons_checks",parser.n());
455 | cons_checks:ccs COMMA cons_check:cc {:
460 cons_check ::= IDENTIFIER:name LPAREN cons_argument_list_opt:args RPAREN {:
461 ParseNode pn=new ParseNode("cons_check",parser.n());
462 pn.addChild("name").addChild("identifier").addChild(name);
467 flag_effects_opt ::= LPAREN flag_effects:fe RPAREN {:RESULT=fe;:}
468 | {: RESULT = new ParseNode("empty",parser.n()); :}
471 flag_effects ::= flag_effect:fe {:
472 ParseNode pn=new ParseNode("flag_effects_list",parser.n());
476 | flag_effects:fes COMMA flag_effect:fe {:
481 flag_effect ::= IDENTIFIER:id LBRACE flag_list:fl RBRACE tag_list_opt:tlo {:
482 ParseNode pn=new ParseNode("flag_effect",parser.n());
483 pn.addChild("name").addChild(id);
488 | IDENTIFIER:id LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
489 ParseNode pn=new ParseNode("flag_effect",parser.n());
490 pn.addChild("name").addChild(id);
495 flag_list_opt ::= LBRACE flag_list:fl RBRACE {:RESULT=fl;:}
496 | LBRACE RBRACE {: RESULT = new ParseNode("empty",parser.n()); :}
498 {: RESULT = new ParseNode("empty",parser.n()); :}
501 flag_list ::= flag_change:fc {:
502 ParseNode pn=new ParseNode("flag_list",parser.n());
506 | flag_list:fl COMMA flag_change:fc {:
511 flag_change ::= IDENTIFIER:id {:
512 RESULT=new ParseNode("name",parser.n()).addChild(id).getRoot();
515 RESULT=new ParseNode("not",parser.n()).addChild("name").addChild(id).getRoot();
518 // 19.2) The Syntactic Grammar
519 goal ::= compilation_unit:cu
525 // 19.3) Lexical Structure.
528 literal ::= INTEGER_LITERAL:integer_lit
530 ParseNode pn=new ParseNode("literal",parser.n());
531 pn.addChild("integer").setLiteral(integer_lit);
534 | FLOATING_POINT_LITERAL:float_lit
536 ParseNode pn=new ParseNode("literal",parser.n());
537 pn.addChild("float").setLiteral(float_lit);
540 | BOOLEAN_LITERAL:boolean_lit
542 ParseNode pn=new ParseNode("literal",parser.n());
543 pn.addChild("boolean").setLiteral(boolean_lit);
546 | CHARACTER_LITERAL:char_lit
548 ParseNode pn=new ParseNode("literal",parser.n());
549 pn.addChild("char").setLiteral(char_lit);
552 | STRING_LITERAL:string_lit
554 ParseNode pn=new ParseNode("literal",parser.n());
555 pn.addChild("string").setLiteral(string_lit);
560 RESULT=(new ParseNode("literal",parser.n())).addChild("null").getRoot();
564 // 19.4) Types, Values, and Variables
565 type ::= primitive_type:type {: RESULT=type; :}
566 | reference_type:type {: RESULT=type; :}
570 numeric_type:type {: RESULT=type; :}
571 | BOOLEAN {: RESULT=(new ParseNode("type",parser.n())).addChild("boolean").getRoot(); :}
573 numeric_type::= integral_type:type {: RESULT=type; :}
574 | floating_point_type:type {: RESULT=type; :}
577 BYTE {: RESULT=(new ParseNode("type",parser.n())).addChild("byte").getRoot(); :}
578 | SHORT {: RESULT=(new ParseNode("type",parser.n())).addChild("short").getRoot(); :}
579 | INT {: RESULT=(new ParseNode("type",parser.n())).addChild("int").getRoot(); :}
580 | LONG {: RESULT=(new ParseNode("type",parser.n())).addChild("long").getRoot(); :}
581 | CHAR {: RESULT=(new ParseNode("type",parser.n())).addChild("char").getRoot(); :}
583 floating_point_type ::=
584 FLOAT {: RESULT=(new ParseNode("type",parser.n())).addChild("float").getRoot(); :}
585 | DOUBLE {: RESULT=(new ParseNode("type",parser.n())).addChild("double").getRoot(); :}
589 class_or_interface_type:type {: RESULT=type; :}
590 | array_type:type {: RESULT=type; :}
592 class_or_interface_type ::= name:name {:
593 RESULT=(new ParseNode("type",parser.n())).addChild("class").addChild(name).getRoot();
596 class_type ::= class_or_interface_type:type {: RESULT=type; :};
597 interface_type ::= class_or_interface_type:type {: RESULT=type; :};
599 array_type ::= primitive_type:prim dims:dims {:
600 ParseNode pn=(new ParseNode("type",parser.n())).addChild("array");
601 pn.addChild("basetype").addChild(prim);
602 pn.addChild("dims").setLiteral(dims);
605 | name:name dims:dims {:
606 ParseNode pn=(new ParseNode("type",parser.n())).addChild("array");
607 pn.addChild("basetype").addChild("type").addChild("class").addChild(name);
608 pn.addChild("dims").setLiteral(dims);
614 name ::= simple_name:name {: RESULT=name; :}
615 | qualified_name:name {: RESULT=name; :}
617 simple_name ::= IDENTIFIER:id {:
618 RESULT=(new ParseNode("name",parser.n())).addChild("identifier").addChild(id).getRoot();
621 qualified_name ::= name:name DOT IDENTIFIER:id {:
622 ParseNode pn=new ParseNode("name",parser.n());
623 pn.addChild("base").addChild(name);
624 pn.addChild("identifier").addChild(id);
631 package_declaration_opt:pdo
632 import_declarations_opt:ido
633 type_declarations_opt:tdo {:
634 ParseNode pn=new ParseNode("compilation_unit",parser.n());
636 pn.addChild("packages").addChild(pdo);
637 pn.addChild("imports").addChild(ido);
641 package_declaration_opt ::= package_declaration:pdo {:
644 {: RESULT=new ParseNode("empty",parser.n()); :}
647 import_declarations_opt ::= import_declarations:ido {:
650 {: RESULT=new ParseNode("empty",parser.n()); :}
652 type_declarations_opt ::= type_declarations:tds {:
655 {: RESULT=new ParseNode("empty",parser.n()); :}
658 import_declarations ::=
659 import_declaration:id {:
660 ParseNode pn=new ParseNode("import_decls_list",parser.n());
664 | import_declarations:ids import_declaration:id {:
670 type_declarations ::=
671 type_declaration:td {:
672 ParseNode pn=new ParseNode("type_declaration_list",parser.n());
676 | type_declarations:tds type_declaration:td {:
682 package_declaration ::=
683 PACKAGE name:name SEMICOLON {:
684 ParseNode pn=new ParseNode("package",parser.n());
689 import_declaration ::=
690 single_type_import_declaration:sid {: RESULT=sid; :}
691 | type_import_on_demand_declaration:iod {: RESULT=iod; :}
693 single_type_import_declaration ::=
694 IMPORT name:name SEMICOLON {:
695 ParseNode pn=new ParseNode("import_single",parser.n());
700 type_import_on_demand_declaration ::=
701 IMPORT name:name DOT MULT SEMICOLON {:
702 ParseNode pn=new ParseNode("import_ondemand",parser.n());
713 | enum_declaration:ed
717 | task_declaration:td
721 | interface_declaration:in
725 | SEMICOLON {: RESULT=new ParseNode("empty",parser.n()); :}
728 // 19.7) Productions used only in the LALR(1) grammar
730 {: RESULT=new ParseNode("empty",parser.n()); :}
739 modifiers ::= mixed_modifiers : mmo {:
742 | annotations : an {:
743 ParseNode pn=new ParseNode("modifier_list",parser.n());
748 mixed_modifiers_at ::=
749 mixed_modifiers : mmos AT {:
755 ParseNode pn=new ParseNode("modifier_list",parser.n());
759 | annotations:as modifier:mo {:
760 ParseNode pn=new ParseNode("modifier_list",parser.n());
765 | mixed_modifiers : mmos modifier : mo {:
769 | mixed_modifiers_at:mma annotation_body:ab {:
770 mma.addChild("annotation_list",parser.n()).addChild(ab);
775 PUBLIC {: RESULT=new ParseNode("public",parser.n()); :}|
776 PROTECTED {: RESULT=new ParseNode("protected",parser.n()); :}|
777 PRIVATE {: RESULT=new ParseNode("private",parser.n()); :}|
778 STATIC {: RESULT=new ParseNode("static",parser.n()); :} |
779 ABSTRACT {: RESULT=new ParseNode("abstract",parser.n()); :} |
780 FINAL {: RESULT=new ParseNode("final",parser.n()); :}|
781 NATIVE {: RESULT=new ParseNode("native",parser.n()); :} |
782 SYNCHRONIZED {: RESULT=new ParseNode("synchronized",parser.n()); :} |
783 ATOMIC {: RESULT=new ParseNode("atomic",parser.n()); :} |
784 VOLATILE {: RESULT=new ParseNode("volatile",parser.n()); :} |
785 TRANSIENT {: RESULT=new ParseNode("transient",parser.n()); :}
787 // STRICTFP // note that semantic analysis must check that the
788 // context of the modifier allows strictfp.
790 //annotations_opt ::=
791 // {: RESULT=new ParseNode("empty",parser.n()); :}
792 // | annotations:an {:
797 AT annotation_body:ab {:
798 ParseNode pn=new ParseNode("annotation_list",parser.n());
802 | annotations_at:aat annotation_body:ab {:
813 AT annotation_body:ab {:
818 normal_annotation_body:nab {:
819 ParseNode pn=new ParseNode("annotation_body",parser.n());
823 | marker_annotation_body:mab {:
824 ParseNode pn=new ParseNode("annotation_body",parser.n());
828 | single_element_annotation_body:seab {:
829 ParseNode pn=new ParseNode("annotation_body",parser.n());
834 normal_annotation_body ::=
835 IDENTIFIER LPAREN element_value_pairs_opt RPAREN
837 marker_annotation_body ::=
840 ParseNode pn=new ParseNode("marker_annotation",parser.n());
841 pn.addChild("name").addChild(id);
845 single_element_annotation_body ::=
846 IDENTIFIER:id LPAREN STRING_LITERAL:ev RPAREN {:
847 ParseNode pn=new ParseNode("single_annotation",parser.n());
848 pn.addChild("name").addChild(id);
849 pn.addChild("element_value").addChild(ev);
853 element_value_pairs_opt ::=
854 | element_value_pairs
856 element_value_pairs ::=
858 | element_value_pairs COMMA element_value_pair
860 element_value_pair ::=
861 IDENTIFIER EQ element_value
867 | element_value_array_initializer:evai {:
870 | conditional_expression:ce {:
874 element_value_array_initializer ::=
875 LBRACE element_values_opt RBRACE
877 element_values_opt ::=
882 | element_values COMMA element_value
886 // 19.8.1) Class Declaration:
887 class_declaration ::=
888 modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so interfaces_opt:ifo
891 ParseNode pn=new ParseNode("class_declaration",parser.n());
892 pn.addChild("modifiers").addChild(mo);
893 pn.addChild("name").addChild(id);
894 pn.addChild("super").addChild(so);
895 pn.addChild("superIF").addChild(ifo);
896 pn.addChild("classbody").addChild(body);
900 super ::= EXTENDS class_type:classtype {:
905 {: RESULT=new ParseNode("empty",parser.n()); :}
911 interfaces ::= IMPLEMENTS interface_type_list:iftl {: RESULT=iftl; :}
914 {: RESULT=new ParseNode("empty",parser.n()); :}
915 | interfaces:ifs {: RESULT=ifs; :}
917 interface_type_list ::=
918 interface_type:ift {:
919 ParseNode pn=new ParseNode("interface_type_list",parser.n());
923 | interface_type_list:iftl COMMA interface_type:ift {:
929 class_body ::= LBRACE class_body_declarations_opt:cbdo RBRACE {: RESULT=cbdo; :}
932 class_body_declarations_opt ::=
933 {: RESULT=new ParseNode("empty",parser.n()); :}
934 | class_body_declarations:cbd {: RESULT=cbd; :};
936 class_body_declarations ::=
937 class_body_declaration:cbd {:
938 ParseNode pn=new ParseNode("class_body_declaration_list",parser.n());
942 | class_body_declarations:cbds class_body_declaration:cbd {:
948 class_body_declaration ::=
949 class_member_declaration:member {:
950 RESULT=(new ParseNode("member",parser.n())).addChild(member).getRoot();
952 | static_initializer:block{:
953 RESULT=(new ParseNode("static_block",parser.n())).addChild(block).getRoot();
955 | constructor_declaration:constructor {:
956 RESULT=(new ParseNode("constructor",parser.n())).addChild(constructor).getRoot();
959 RESULT=(new ParseNode("block",parser.n())).addChild(block).getRoot();
961 | location_order_declaration:lod {:
962 RESULT=(new ParseNode("location_order_declaration",parser.n())).addChild(lod).getRoot();
965 class_member_declaration ::=
966 //failure aware computation
967 flag_declaration:flag {:
968 RESULT=(new ParseNode("flag",parser.n())).addChild(flag).getRoot();
971 field_declaration:field {:
972 RESULT=(new ParseNode("field",parser.n())).addChild(field).getRoot();
974 | method_declaration:method {:
975 RESULT=(new ParseNode("method",parser.n())).addChild(method).getRoot();
977 /* repeat the prod for 'class_declaration' here: */
978 | modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so interfaces_opt:ifo class_body:body
980 ParseNode pn=new ParseNode("inner_class_declaration",parser.n());
981 pn.addChild("modifiers").addChild(mo);
982 pn.addChild("name").addChild(id);
983 pn.addChild("super").addChild(so);
984 pn.addChild("superIF").addChild(ifo);
985 pn.addChild("classbody").addChild(body);
988 | enum_declaration:ed
992 // | interface_declaration:interfaced {:
993 // RESULT=(new ParseNode("interface",parser.n())).addChild(interfaced).getRoot();
995 | SEMICOLON {: RESULT=new ParseNode("empty",parser.n()); :}
999 // JSR-201) Enum Declaration
1000 enum_declaration ::=
1001 modifiers_opt:mo ENUM IDENTIFIER:id /*interfaces_opt:io*/ enum_body:body
1003 ParseNode pn=new ParseNode("enum_declaration",parser.n());
1004 pn.addChild("modifiers").addChild(mo);
1005 pn.addChild("name").addChild(id);
1006 //pn.addChild("superIF").addChild(ifo);
1007 pn.addChild("enumbody").addChild(body);
1012 LBRACE enum_constants_opt:eco /*enum_body_declarations_opt:ebdo*/ RBRACE
1015 enum_constants_opt ::=
1016 {: RESULT=new ParseNode("empty",parser.n()); :}
1017 | enum_constants:ecs
1022 ParseNode pn=new ParseNode("enum_constants_list",parser.n());
1026 | enum_constants:ecs COMMA enum_constant:ec {:
1032 IDENTIFIER:id /*enum_arguments_opt*/
1034 ParseNode pn=new ParseNode("enum_constant",parser.n());
1035 pn.addChild("name").addChild(id);
1038 // | IDENTIFIER enum_arguments_opt class_body
1040 //enum_arguments_opt ::=
1041 // | LPAREN argument_list_opt RPAREN
1043 //enum_body_declarations_opt ::=
1044 // | SEMICOLON class_body_declarations_opt:cbdo
1047 //Failure aware computation
1048 flag_declaration ::=
1049 FLAG IDENTIFIER:id SEMICOLON {:
1050 ParseNode pn=new ParseNode("flag_declaration",parser.n());
1051 pn.addChild("name").addChild(id);
1054 EXTERNAL FLAG IDENTIFIER:id SEMICOLON {:
1055 ParseNode pn=new ParseNode("flag_declaration",parser.n());
1056 pn.addChild("name").addChild(id);
1057 pn.addChild("external");
1062 // 19.8.2) Field Declarations
1063 field_declaration ::=
1064 modifiers_opt:mo type:type variable_declarators:var SEMICOLON {:
1065 ParseNode pn=new ParseNode("field_declaration",parser.n());
1066 pn.addChild("modifier").addChild(mo);
1067 pn.addChild("type").addChild(type);
1068 pn.addChild("variables").addChild(var);
1071 modifiers_opt:mo GLOBAL type:type variable_declarators:var SEMICOLON {:
1072 ParseNode pn=new ParseNode("field_declaration",parser.n());
1073 pn.addChild("modifier").addChild(mo);
1074 pn.addChild("type").addChild(type);
1075 pn.addChild("variables").addChild(var);
1076 pn.addChild("global");
1081 variable_declarators ::=
1082 variable_declarator:vd {:
1083 ParseNode pn=new ParseNode("variable_declarators_list",parser.n());
1087 | variable_declarators:vds COMMA variable_declarator:vd {:
1092 variable_declarator ::=
1093 variable_declarator_id:id {:
1094 ParseNode pn=new ParseNode("variable_declarator",parser.n());
1098 | variable_declarator_id:id EQ variable_initializer:init {:
1099 ParseNode pn=new ParseNode("variable_declarator",parser.n());
1101 pn.addChild("initializer").addChild(init);
1105 variable_declarator_id ::=
1107 RESULT=(new ParseNode("single",parser.n())).addChild(id).getRoot();:}
1108 | variable_declarator_id:id LBRACK RBRACK {:
1109 RESULT=(new ParseNode("array",parser.n())).addChild(id).getRoot();:}
1111 variable_initializer ::=
1112 expression:exp {: RESULT=exp; :}
1113 | array_initializer:ai {: RESULT=(new ParseNode("array_initializer",parser.n())).addChild(ai).getRoot(); :}
1116 // 19.8.3) Method Declarations
1117 method_declaration ::=
1118 method_header:header method_body:body {:
1119 ParseNode pn=new ParseNode("method_declaration",parser.n());
1120 pn.addChild(header);
1121 pn.addChild("body").addChild(body);
1126 modifiers_opt:mo type:type method_declarator:decl throws_opt:to
1128 ParseNode pn=new ParseNode("method_header",parser.n());
1129 pn.addChild("modifiers").addChild(mo);
1130 pn.addChild("returntype").addChild(type);
1131 pn.addChild("throws").addChild(to);
1135 | modifiers_opt:mo VOID method_declarator:decl throws_opt:to
1137 ParseNode pn=new ParseNode("method_header",parser.n());
1138 pn.addChild("modifiers").addChild(mo);
1139 pn.addChild("throws").addChild(to);
1144 method_declarator ::=
1145 IDENTIFIER:id LPAREN formal_parameter_list_opt:params RPAREN {:
1146 ParseNode pn=new ParseNode("method_declarator",parser.n());
1147 pn.addChild("name").addChild(id);
1148 pn.addChild("parameters").addChild(params);
1151 // | method_declarator LBRACK RBRACK // deprecated
1152 // be careful; the above production also allows 'void foo() []'
1154 formal_parameter_list_opt ::=
1155 {: RESULT=new ParseNode("empty",parser.n()); :}
1156 | formal_parameter_list:fpl {:
1160 formal_parameter_list ::=
1161 formal_parameter:fp {:
1162 ParseNode pn=new ParseNode("formal_parameter_list",parser.n());
1166 | formal_parameter_list:fpl COMMA formal_parameter:fp {:
1171 formal_parameter ::=
1172 type:type variable_declarator_id:name {:
1173 ParseNode pn=new ParseNode("formal_parameter",parser.n());
1179 TAG variable_declarator_id:name {:
1180 ParseNode pn=new ParseNode("tag_parameter",parser.n());
1184 | FINAL type:type variable_declarator_id:name {:
1185 ParseNode pn=new ParseNode("formal_parameter",parser.n());
1190 | annotation:an type:type variable_declarator_id:name {:
1191 ParseNode pn=new ParseNode("annotation_parameter",parser.n());
1199 {: RESULT=new ParseNode("empty",parser.n()); :}
1203 throws ::= THROWS class_type_list:ctl
1204 {: RESULT=(new ParseNode("throw_list",parser.n())).addChild(ctl).getRoot(); :}
1209 ParseNode pn=new ParseNode("class_type_list",parser.n());
1213 | class_type_list:ctl COMMA class_type:ct
1219 method_body ::= block:block {:
1222 | SEMICOLON {: RESULT=new ParseNode("empty",parser.n()); :}
1225 // 19.8.4) Static Initializers
1226 static_initializer ::=
1227 STATIC block:body {:
1228 ParseNode pn=new ParseNode("static_block_declaration",parser.n());
1229 pn.addChild("body").addChild(body);
1234 // 19.8.5) Constructor Declarations
1235 constructor_declaration ::=
1236 modifiers_opt:mo constructor_declarator:cd throws_opt:to
1237 constructor_body:body {:
1238 ParseNode pn=new ParseNode("constructor_declaration",parser.n());
1239 pn.addChild("modifiers").addChild(mo);
1240 pn.addChild("throws").addChild(to);
1242 pn.addChild("body").addChild(body);
1245 modifiers_opt:mo GLOBAL constructor_declarator:cd throws_opt:to
1246 constructor_body:body {:
1247 ParseNode pn=new ParseNode("constructor_declaration",parser.n());
1248 pn.addChild("global");
1249 pn.addChild("modifiers").addChild(mo);
1250 pn.addChild("throws").addChild(to);
1252 pn.addChild("body").addChild(body);
1257 constructor_declarator ::=
1258 simple_name:name LPAREN formal_parameter_list_opt:fplo RPAREN {:
1259 ParseNode pn=new ParseNode("constructor_declarator",parser.n());
1261 pn.addChild("parameters").addChild(fplo);
1265 constructor_body ::=
1266 LBRACE explicit_constructor_invocation:eci block_statements:bs RBRACE {:
1267 ParseNode pn=new ParseNode("constructor_body",parser.n());
1272 LBRACE explicit_constructor_invocation:eci RBRACE {:
1273 ParseNode pn=new ParseNode("constructor_body",parser.n());
1277 LBRACE block_statements:block RBRACE {:
1278 ParseNode pn=new ParseNode("constructor_body",parser.n());
1282 | LBRACE RBRACE {: RESULT=new ParseNode("empty",parser.n()); :}
1284 explicit_constructor_invocation ::=
1285 THIS LPAREN argument_list_opt:alo RPAREN SEMICOLON {:
1286 ParseNode pn=new ParseNode("explconstrinv",parser.n());
1291 SUPER LPAREN argument_list_opt:alo RPAREN SEMICOLON {:
1292 ParseNode pn=new ParseNode("superinvoke",parser.n());
1296 // | primary DOT THIS LPAREN argument_list_opt RPAREN SEMICOLON
1297 // | primary DOT SUPER LPAREN argument_list_opt RPAREN SEMICOLON
1300 // 19.8.6) Location Hierarchy Declarations
1301 location_order_declaration ::= LOCDEF LBRACE location_order_list:lol RBRACE {:
1305 location_order_list ::=
1306 location_order:lo {:
1307 ParseNode pn=new ParseNode("location_order_list",parser.n());
1311 | location_order_list:lol COMMA location_order:lo {:
1317 IDENTIFIER:loc1 LT IDENTIFIER:loc2{:
1318 ParseNode pn=new ParseNode("location_order",parser.n());
1323 | IDENTIFIER:loc MULT{:
1324 ParseNode pn=new ParseNode("location_property",parser.n());
1332 // 19.9.1) Interface Declarations
1333 interface_declaration ::=
1334 modifiers_opt:mo INTERFACE IDENTIFIER:id extends_interfaces_opt:io
1337 ParseNode pn=new ParseNode("interface_declaration",parser.n());
1338 pn.addChild("modifiers").addChild(mo);
1339 pn.addChild("name").addChild(id);
1340 pn.addChild("superIF").addChild(io);
1341 pn.addChild("interfacebody").addChild(body);
1344 | annotation_type_declaration
1346 extends_interfaces_opt ::=
1347 {: RESULT=new ParseNode("empty",parser.n()); :}
1348 | extends_interfaces:eifs {: RESULT=eifs; :}
1350 extends_interfaces ::=
1351 EXTENDS interface_type:ift
1353 ParseNode pn=new ParseNode("extend_interface_list",parser.n());
1357 | extends_interfaces:eifs COMMA interface_type:ift
1364 LBRACE interface_member_declarations_opt:imdo RBRACE
1367 interface_member_declarations_opt ::=
1368 {: RESULT=new ParseNode("empty",parser.n()); :}
1369 | interface_member_declarations:imd {: RESULT=imd; :}
1371 interface_member_declarations ::=
1372 interface_member_declaration:imd {:
1373 ParseNode pn=new ParseNode("interface_member_declaration_list",parser.n());
1377 | interface_member_declarations:imds interface_member_declaration:imd {:
1382 interface_member_declaration ::=
1383 constant_declaration:constant {:
1384 RESULT=(new ParseNode("constant",parser.n())).addChild(constant).getRoot();
1386 | abstract_method_declaration:method {:
1387 RESULT=(new ParseNode("method",parser.n())).addChild(method).getRoot();
1389 | enum_declaration:ed {:
1390 RESULT=(new ParseNode("enum_declaration",parser.n())).addChild(ed).getRoot();
1392 // | class_declaration:class
1393 // | interface_declaration:interface
1395 RESULT=new ParseNode("empty",parser.n());
1398 constant_declaration ::=
1399 field_declaration:fd {: RESULT=fd; :}
1400 // need to semantically check that modifiers of field declaration
1401 // include only PUBLIC, STATIC, or FINAL. Other modifiers are
1404 abstract_method_declaration ::=
1405 method_header:header SEMICOLON {:
1406 ParseNode pn=new ParseNode("method_declaration",parser.n());
1407 pn.addChild("header").addChild(header);
1408 pn.addChild("body").addChild(new ParseNode("empty",parser.n()));
1413 annotation_type_declaration ::=
1414 AT INTERFACE IDENTIFIER annotation_type_body
1415 | modifiers_at INTERFACE IDENTIFIER annotation_type_body
1417 annotation_type_body ::=
1418 LBRACE annotation_type_element_declarations_opt RBRACE
1420 annotation_type_element_declarations_opt ::=
1421 | annotation_type_element_declarations
1423 annotation_type_element_declarations ::=
1424 annotation_type_element_declaration
1425 | annotation_type_element_declarations annotation_type_element_declaration
1427 annotation_type_element_declaration ::=
1428 constant_declaration
1429 | modifiers_opt type IDENTIFIER LPAREN RPAREN default_value_opt SEMICOLON
1432 | interface_declaration
1437 array_initializer ::=
1438 LBRACE variable_initializers:var_init_list COMMA RBRACE {:
1439 RESULT=var_init_list;
1441 | LBRACE variable_initializers:var_init_list RBRACE {:
1442 RESULT=var_init_list;
1444 | LBRACE COMMA RBRACE {:
1445 RESULT=new ParseNode("empty",parser.n());
1448 RESULT=new ParseNode("empty",parser.n());
1451 variable_initializers ::=
1452 variable_initializer:var_init {:
1453 ParseNode pn=new ParseNode("var_init_list",parser.n());
1454 pn.addChild(var_init);
1457 | variable_initializers:var_init_list COMMA variable_initializer:var_init {:
1458 var_init_list.addChild(var_init);
1459 RESULT=var_init_list;
1463 // 19.11) Blocks and Statements
1464 block ::= LBRACE block_statements_opt:bso RBRACE {:
1468 block_statements_opt ::=
1469 {: RESULT=new ParseNode("empty",parser.n()); :}
1470 | block_statements:bs {:
1474 block_statements ::=
1475 block_statement:bs {:
1476 ParseNode pn=new ParseNode("block_statement_list",parser.n());
1480 | block_statements:bss block_statement:bs {:
1486 tag_variable_declaration_statement:tvds {:
1489 | local_variable_declaration_statement:lvds {:
1492 | statement:statement {:
1495 // | enum_declaration:ed {:
1498 // | class_declaration
1499 // | interface_declaration
1501 tag_variable_declaration_statement ::=
1502 TAG IDENTIFIER:id EQ NEW TAG LPAREN IDENTIFIER:type RPAREN SEMICOLON {:
1503 ParseNode pn=new ParseNode("tag_declaration",parser.n());
1504 pn.addChild("single").addChild(id);
1505 pn.addChild("type").addChild(type);
1509 local_variable_declaration_statement ::=
1510 local_variable_declaration:lvd SEMICOLON {:
1514 local_variable_declaration ::=
1515 type:type variable_declarators:var {:
1516 ParseNode pn=new ParseNode("local_variable_declaration",parser.n());
1521 // | FINAL type:type variable_declarators:var {:
1522 /* CAUTION: only FINAL and annotations are legal modifiers here */
1523 | modifiers:mo type:type variable_declarators:var {:
1524 ParseNode pn=new ParseNode("local_variable_declaration",parser.n());
1527 pn.addChild("modifiers").addChild(mo);
1531 statement ::= statement_without_trailing_substatement:st {:
1534 | labeled_statement:st {: RESULT=st; :}
1535 | if_then_statement:st {: RESULT=st; :}
1536 | if_then_else_statement:st {: RESULT=st; :}
1537 | while_statement:st {: RESULT=st; :}
1538 | for_statement:st {: RESULT=st; :}
1540 statement_no_short_if ::=
1541 statement_without_trailing_substatement:st {: RESULT=st; :}
1542 | labeled_statement_no_short_if:st {: RESULT=st; :}
1543 | if_then_else_statement_no_short_if:st {: RESULT=st; :}
1544 | while_statement_no_short_if:st {: RESULT=st; :}
1545 | for_statement_no_short_if:st {: RESULT=st; :}
1547 statement_without_trailing_substatement ::=
1548 block:st {: RESULT=st; :}
1549 | empty_statement:st {: RESULT=st; :}
1550 | expression_statement:st {: RESULT=st; :}
1551 | switch_statement:st {: RESULT=st; :}
1552 | do_statement:dos {:RESULT=dos; :}
1553 | break_statement:st {: RESULT=st; :}
1554 | continue_statement:st {: RESULT=st; :}
1555 | return_statement:st {: RESULT=st; :}
1556 | task_exitstatement:st {: RESULT=st; :}
1557 | atomic_statement:st {: RESULT=st; :}
1558 | sese_statement:st {: RESULT=st; :}
1559 | synchronized_statement:st {: RESULT=st; :}
1560 | genreach_statement:st {: RESULT=st; :}
1561 | throw_statement:st {: RESULT=st; :}
1562 | try_statement:st {: RESULT=st; :}
1563 // | assert_statement
1566 SEMICOLON {: RESULT=new ParseNode("nop",parser.n()); :}
1568 labeled_statement ::=
1569 IDENTIFIER:id COLON statement:st {:
1570 ParseNode pn=new ParseNode("labeledstatement",parser.n());
1571 pn.addChild("name").addChild(id);
1572 pn.addChild("statement").addChild(st);
1576 labeled_statement_no_short_if ::=
1577 IDENTIFIER:id COLON statement_no_short_if:st {:
1578 ParseNode pn=new ParseNode("labeledstatement",parser.n());
1579 pn.addChild("name").addChild(id);
1580 pn.addChild("statement").addChild(st);
1584 expression_statement ::=
1585 statement_expression:se SEMICOLON {:
1586 ParseNode pn=new ParseNode("expression",parser.n());
1590 statement_expression ::=
1591 assignment:st {: RESULT=st; :}
1592 | preincrement_expression:st {: RESULT=st; :}
1593 | predecrement_expression:st {: RESULT=st; :}
1594 | postincrement_expression:st {: RESULT=st; :}
1595 | postdecrement_expression:st {: RESULT=st; :}
1596 | method_invocation:st {: RESULT=st; :}
1597 | class_instance_creation_expression:st {: RESULT=st; :}
1599 if_then_statement ::=
1600 IF LPAREN expression:exp RPAREN statement:st {:
1601 ParseNode pn=new ParseNode("ifstatement",parser.n());
1602 pn.addChild("condition").addChild(exp);
1603 pn.addChild("statement").addChild(st);
1607 if_then_else_statement ::=
1608 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1609 ELSE statement:else_st {:
1610 ParseNode pn=new ParseNode("ifstatement",parser.n());
1611 pn.addChild("condition").addChild(exp);
1612 pn.addChild("statement").addChild(st);
1613 pn.addChild("else_statement").addChild(else_st);
1617 if_then_else_statement_no_short_if ::=
1618 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1619 ELSE statement_no_short_if:else_st {:
1620 ParseNode pn=new ParseNode("ifstatement",parser.n());
1621 pn.addChild("condition").addChild(exp);
1622 pn.addChild("statement").addChild(st);
1623 pn.addChild("else_statement").addChild(else_st);
1627 switch_statement ::=
1628 SWITCH LPAREN expression:exp RPAREN switch_block:body
1630 ParseNode pn=new ParseNode("switch_statement",parser.n());
1631 pn.addChild("condition").addChild(exp);
1632 pn.addChild("statement").addChild(body);
1637 LBRACE switch_block_statement_groups:sbsg switch_labels:sl RBRACE
1639 ParseNode pn = new ParseNode("switch_block",parser.n());
1640 pn.addChild("switch_labels").addChild(sl);
1641 pn.addChild("switch_statements").addChild(new ParseNode("empty",parser.n()));
1645 | LBRACE switch_block_statement_groups:sbsg RBRACE
1649 | LBRACE switch_labels:sl RBRACE
1651 ParseNode pnb = new ParseNode("switch_block_list",parser.n());
1652 ParseNode pn = new ParseNode("switch_block",parser.n());
1653 pn.addChild("switch_labels").addChild(sl);
1654 pn.addChild("switch_statements").addChild(new ParseNode("empty",parser.n()));
1658 | LBRACE RBRACE {: RESULT=new ParseNode("empty",parser.n()); :}
1660 switch_block_statement_groups ::=
1661 switch_block_statement_group:sbsg
1663 ParseNode pn = new ParseNode("switch_block_list",parser.n());
1667 | switch_block_statement_groups:sbsgs switch_block_statement_group:sbsg
1669 sbsgs.addChild(sbsg);
1673 switch_block_statement_group ::=
1674 switch_labels:sls block_statements:body
1676 ParseNode pn=new ParseNode("switch_block",parser.n());
1677 pn.addChild("switch_labels").addChild(sls);
1678 pn.addChild("switch_statements").addChild(body);
1685 ParseNode pn=new ParseNode("switch_label_list",parser.n());
1689 | switch_labels:sls switch_label:sl
1696 CASE constant_expression:ce COLON
1698 ParseNode pn=new ParseNode("switch_label",parser.n());
1704 RESULT=new ParseNode("default_switch_label",parser.n());
1709 WHILE LPAREN expression:exp RPAREN statement:st {:
1710 ParseNode pn=new ParseNode("whilestatement",parser.n());
1711 pn.addChild("condition").addChild(exp);
1712 pn.addChild("statement").addChild(st);
1716 while_statement_no_short_if ::=
1717 WHILE LPAREN expression:exp RPAREN statement_no_short_if:st {:
1718 ParseNode pn=new ParseNode("whilestatement",parser.n());
1719 pn.addChild("condition").addChild(exp);
1720 pn.addChild("statement").addChild(st);
1725 DO statement:st WHILE LPAREN expression:exp RPAREN SEMICOLON {:
1726 ParseNode pn=new ParseNode("dowhilestatement",parser.n());
1727 pn.addChild("condition").addChild(exp);
1728 pn.addChild("statement").addChild(st);
1733 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1734 for_update_opt:update RPAREN statement:st {:
1735 ParseNode pn=new ParseNode("forstatement",parser.n());
1736 pn.addChild("initializer").addChild(init);
1737 pn.addChild("condition").addChild(exp);
1738 pn.addChild("update").addChild(update);
1739 pn.addChild("statement").addChild(st);
1743 for_statement_no_short_if ::=
1744 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1745 for_update_opt:update RPAREN statement_no_short_if:st {:
1746 ParseNode pn=new ParseNode("forstatement",parser.n());
1747 pn.addChild("initializer").addChild(init);
1748 pn.addChild("condition").addChild(exp);
1749 pn.addChild("update").addChild(update);
1750 pn.addChild("statement").addChild(st);
1755 {: RESULT=new ParseNode("empty",parser.n()); :}
1756 | for_init:init {: RESULT=init; :}
1758 for_init ::= statement_expression_list:list {: RESULT=list; :}
1759 | local_variable_declaration:decl {: RESULT=decl; :}
1762 {: RESULT=new ParseNode("empty",parser.n()); :}
1763 | for_update:update {: RESULT=update; :}
1765 for_update ::= statement_expression_list:list {: RESULT=list; :}
1767 statement_expression_list ::=
1768 statement_expression:expr {:
1769 RESULT=(new ParseNode("statement_expression_list",parser.n())).addChild(expr).getRoot();
1771 | statement_expression_list:list COMMA statement_expression:expr {:
1772 list.addChild(expr);
1777 identifier_opt ::= {: RESULT=new ParseNode("identifier_opt",parser.n());
1780 ParseNode pn=new ParseNode("identifier_opt",parser.n());
1781 pn.addChild("name").addChild(id);
1787 BREAK identifier_opt:id SEMICOLON {:
1788 ParseNode pn=new ParseNode("break",parser.n());
1794 continue_statement ::=
1798 {: RESULT=new ParseNode("continue",parser.n()); :}
1800 return_statement ::=
1801 RETURN expression_opt:exp SEMICOLON {:
1802 RESULT=(new ParseNode("return",parser.n())).addChild(exp).getRoot(); :}
1805 THROW expression:exp SEMICOLON {:
1806 RESULT=(new ParseNode("throwstatement",parser.n())).addChild(exp).getRoot();
1809 synchronized_statement ::=
1810 SYNCHRONIZED LPAREN expression:e RPAREN block:b {:
1811 ParseNode pn=new ParseNode("synchronized",parser.n());
1812 pn.addChild("expr").addChild(e);
1813 pn.addChild("block").addChild(b);
1817 atomic_statement ::=
1819 RESULT=(new ParseNode("atomic",parser.n())).addChild(blk).getRoot();
1824 ParseNode pn = new ParseNode("sese",parser.n());
1825 pn.addChild("body").addChild(blk);
1828 | SESE variable_declarator_id:id block:blk {:
1829 ParseNode pn = new ParseNode("sese",parser.n());
1830 pn.addChild("body").addChild(blk);
1831 pn.addChild("identifier").addChild(id);
1834 | RBLOCK block:blk {:
1835 ParseNode pn = new ParseNode("sese",parser.n());
1836 pn.addChild("body").addChild(blk);
1839 | RBLOCK variable_declarator_id:id block:blk {:
1840 ParseNode pn = new ParseNode("sese",parser.n());
1841 pn.addChild("body").addChild(blk);
1842 pn.addChild("identifier").addChild(id);
1847 TRY block:bk catches:ca
1849 ParseNode pn=new ParseNode("trycatchstatement",parser.n());
1850 pn.addChild("tryblock").addChild(bk);
1851 pn.addChild("catchblock").addChild(ca);
1854 | TRY block:bk catches_opt:ca finally:fi
1856 ParseNode pn=new ParseNode("trycatchstatement",parser.n());
1857 pn.addChild("tryblock").addChild(bk);
1858 pn.addChild("catchblock").addChild(ca);
1859 pn.addChild("finallyblock").addChild(fi);
1864 {: RESULT=new ParseNode("empty",parser.n()); :}
1868 catches ::= catch_clause:ca
1870 ParseNode pn=new ParseNode("catchlist",parser.n());
1874 | catches:cas catch_clause:ca
1881 CATCH LPAREN formal_parameter:fp RPAREN block:bk
1883 ParseNode pn=new ParseNode("catchclause",parser.n());
1884 pn.addChild("parameter").addChild(fp);
1885 pn.addChild("block").addChild(bk);
1889 finally ::= FINALLY block:bk
1894 //assert_statement ::=
1895 // ASSERT expression SEMICOLON
1896 // | ASSERT expression COLON expression SEMICOLON
1899 // 19.12) Expressions
1900 primary ::= primary_no_new_array:st {:
1902 | array_creation_init:st {:
1905 | array_creation_uninit:st {:
1909 primary_no_new_array ::=
1910 literal:lit {: RESULT=lit; :}
1911 | THIS {: RESULT=new ParseNode("this",parser.n()); :}
1912 | LPAREN expression:exp RPAREN {: RESULT=exp; :}
1913 | class_instance_creation_expression:exp {: RESULT=exp; :}
1914 | field_access:exp {: RESULT=exp; :}
1915 | method_invocation:exp {: RESULT=exp; :}
1916 | array_access:exp {: RESULT=exp; :}
1917 | ISAVAILABLE LPAREN IDENTIFIER:id RPAREN {:
1918 ParseNode pn=new ParseNode("isavailable",parser.n());
1922 // | primitive_type:pt DOT CLASS {:
1923 // ParseNode pn=new ParseNode("class_type",parser.n());
1928 // | array_type:at DOT CLASS {:
1929 // ParseNode pn=new ParseNode("class_type",parser.n());
1933 | name:name DOT CLASS {:
1934 ParseNode pn=new ParseNode("class_type",parser.n());
1935 pn.addChild("type").addChild("class").addChild(name);
1940 class_instance_creation_expression ::=
1941 NEWFLAG class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {:
1942 ParseNode pn=new ParseNode("createobject",parser.n());
1948 NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {:
1949 ParseNode pn=new ParseNode("createobject",parser.n());
1955 | GLOBAL NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {:
1956 ParseNode pn=new ParseNode("createobject",parser.n());
1959 pn.addChild("global");
1962 | SCRATCH NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {:
1963 ParseNode pn=new ParseNode("createobject",parser.n());
1966 pn.addChild("scratch");
1969 // Objects we want to track in disjointness analysis
1970 | DISJOINT IDENTIFIER:id NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {:
1971 ParseNode pn=new ParseNode("createobject",parser.n());
1974 pn.addChild("disjoint").addChild(id);
1977 | NEWFLAG class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
1978 ParseNode pn=new ParseNode("createobject",parser.n());
1984 | NEWFLAG class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE flag_list:fl RBRACE LBRACE tag_list:tl RBRACE {:
1985 ParseNode pn=new ParseNode("createobject",parser.n());
1992 | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN class_body:body {:
1993 ParseNode pn=new ParseNode("createobjectcls",parser.n());
1996 pn.addChild("decl").addChild("classbody").addChild(body);
1999 // | primary DOT NEW IDENTIFIER
2000 // LPAREN argument_list_opt RPAREN {:
2003 // | primary DOT NEW IDENTIFIER
2004 // LPAREN argument_list_opt RPAREN class_body
2005 // | name DOT NEW IDENTIFIER
2006 // LPAREN argument_list_opt RPAREN
2007 // | name DOT NEW IDENTIFIER
2008 // LPAREN argument_list_opt RPAREN class_body
2010 cons_argument_list_opt ::=
2011 {: RESULT=new ParseNode("empty",parser.n()); :}
2012 | cons_argument_list:args {: RESULT=args; :}
2015 cons_argument_list ::=
2016 IDENTIFIER:id COLON expression:exp {:
2017 ParseNode pn=new ParseNode("cons_argument_list",parser.n());
2018 ParseNode pnarg=pn.addChild("binding");
2019 pnarg.addChild("var").addChild(id);
2020 pnarg.addChild("exp").addChild(exp);
2023 | argument_list:list COMMA IDENTIFIER:id COLON expression:exp {:
2024 ParseNode pnarg=new ParseNode("binding",parser.n());
2025 pnarg.addChild("var").addChild(id);
2026 pnarg.addChild("exp").addChild(exp);
2027 list.addChild(pnarg);
2032 argument_list_opt ::=
2033 {: RESULT=new ParseNode("empty",parser.n()); :}
2034 | argument_list:args {: RESULT=args; :}
2039 ParseNode pn=new ParseNode("argument_list",parser.n());
2043 | argument_list:list COMMA expression:exp {:
2048 array_creation_uninit ::=
2049 NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
2050 ParseNode pn=new ParseNode("createarray",parser.n());
2052 pn.addChild(dimexpr);
2053 pn.addChild("dims_opt").setLiteral(dims);
2056 | NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
2057 ParseNode pn=new ParseNode("createarray",parser.n());
2059 pn.addChild(dimexpr);
2060 pn.addChild("dims_opt").setLiteral(dims);
2063 | GLOBAL NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
2064 ParseNode pn=new ParseNode("createarray",parser.n());
2066 pn.addChild(dimexpr);
2067 pn.addChild("dims_opt").setLiteral(dims);
2068 pn.addChild("global");
2071 | SCRATCH NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
2072 ParseNode pn=new ParseNode("createarray",parser.n());
2074 pn.addChild(dimexpr);
2075 pn.addChild("dims_opt").setLiteral(dims);
2076 pn.addChild("scratch");
2079 | DISJOINT IDENTIFIER:id NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
2080 ParseNode pn=new ParseNode("createarray",parser.n());
2082 pn.addChild(dimexpr);
2083 pn.addChild("dims_opt").setLiteral(dims);
2084 pn.addChild("disjoint").addChild(id);
2087 | GLOBAL NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
2088 ParseNode pn=new ParseNode("createarray",parser.n());
2090 pn.addChild(dimexpr);
2091 pn.addChild("dims_opt").setLiteral(dims);
2092 pn.addChild("global");
2095 | SCRATCH NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
2096 ParseNode pn=new ParseNode("createarray",parser.n());
2098 pn.addChild(dimexpr);
2099 pn.addChild("dims_opt").setLiteral(dims);
2100 pn.addChild("scratch");
2103 | DISJOINT IDENTIFIER:id NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
2104 ParseNode pn=new ParseNode("createarray",parser.n());
2106 pn.addChild(dimexpr);
2107 pn.addChild("dims_opt").setLiteral(dims);
2108 pn.addChild("disjoint").addChild(id);
2112 array_creation_init ::=
2113 NEW primitive_type:type dims:dims array_initializer:ai {:
2114 ParseNode pn=new ParseNode("createarray2",parser.n());
2116 pn.addChild("dims_opt").setLiteral(dims);
2117 pn.addChild("initializer").addChild(ai);
2120 | NEW class_or_interface_type:type dims:dims array_initializer:ai {:
2121 ParseNode pn=new ParseNode("createarray2",parser.n());
2123 pn.addChild("dims_opt").setLiteral(dims);
2124 pn.addChild("initializer").addChild(ai);
2128 dim_exprs ::= dim_expr:exp {:
2129 ParseNode pn=new ParseNode("dim_exprs",parser.n());
2132 | dim_exprs:base dim_expr:exp {:
2137 dim_expr ::= LBRACK expression:exp RBRACK {: RESULT=exp; :}
2139 dims_opt ::= {: RESULT=new Integer(0); :}
2140 | dims:dims {: RESULT = dims; :}
2143 dims ::= LBRACK RBRACK {: RESULT=new Integer(1); :}
2144 | dims:dims LBRACK RBRACK {: RESULT=new Integer(dims.intValue()+1); :}
2148 primary:base DOT IDENTIFIER:id {:
2149 ParseNode pn=new ParseNode("fieldaccess",parser.n());
2150 pn.addChild("base").addChild(base);
2151 pn.addChild("field").addChild(id);
2154 // | SUPER DOT IDENTIFIER
2155 // | name DOT SUPER DOT IDENTIFIER
2157 method_invocation ::=
2158 name:name LPAREN argument_list_opt:args RPAREN {:
2159 ParseNode pn=new ParseNode("methodinvoke1",parser.n());
2164 | primary:base DOT IDENTIFIER:name LPAREN argument_list_opt:args RPAREN {:
2165 ParseNode pn=new ParseNode("methodinvoke2",parser.n());
2166 pn.addChild("base").addChild(base);
2167 pn.addChild("id").addChild(name);
2171 | SUPER DOT IDENTIFIER:id LPAREN argument_list_opt:args RPAREN {:
2172 ParseNode name=new ParseNode("name",parser.n());
2173 name.addChild("base").addChild("name").addChild("identifier").addChild("super");
2174 name.addChild("identifier").addChild(id);
2175 ParseNode pn=new ParseNode("methodinvoke1",parser.n());
2180 // | name DOT SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
2183 name:name LBRACK expression:exp RBRACK {:
2184 ParseNode pn=new ParseNode("arrayaccess",parser.n());
2185 pn.addChild("base").addChild(name);
2186 pn.addChild("index").addChild(exp);
2189 | primary_no_new_array:base LBRACK expression:exp RBRACK {:
2190 ParseNode pn=new ParseNode("arrayaccess",parser.n());
2191 pn.addChild("base").addChild(base);
2192 pn.addChild("index").addChild(exp);
2195 // | array_creation_init:init LBRACK expression:exp RBRACK {:
2196 // ParseNode pn=new ParseNode("arrayaccess",parser.n());
2197 // pn.addChild("init").addChild(init);
2198 // pn.addChild("index").addChild(exp);
2203 postfix_expression ::=
2206 | name:exp {: RESULT=exp; :}
2207 | postincrement_expression:exp {: RESULT=exp; :}
2208 | postdecrement_expression:exp {: RESULT=exp; :}
2210 postincrement_expression ::=
2211 postfix_expression:exp PLUSPLUS
2212 {: RESULT=(new ParseNode("postinc",parser.n())).addChild(exp).getRoot(); :}
2214 postdecrement_expression ::=
2215 postfix_expression:exp MINUSMINUS
2216 {: RESULT=(new ParseNode("postdec",parser.n())).addChild(exp).getRoot(); :}
2218 unary_expression ::=
2219 preincrement_expression:exp {: RESULT=exp; :}
2220 | predecrement_expression:exp {: RESULT=exp; :}
2221 | PLUS unary_expression:exp
2222 {: RESULT=(new ParseNode("unaryplus",parser.n())).addChild(exp).getRoot(); :}
2223 | MINUS unary_expression:exp
2224 {: RESULT=(new ParseNode("unaryminus",parser.n())).addChild(exp).getRoot(); :}
2225 | unary_expression_not_plus_minus:exp {:
2228 preincrement_expression ::=
2229 PLUSPLUS unary_expression:exp
2230 {: RESULT=(new ParseNode("preinc",parser.n())).addChild(exp).getRoot(); :}
2232 predecrement_expression ::=
2233 MINUSMINUS unary_expression:exp
2234 {: RESULT=(new ParseNode("predec",parser.n())).addChild(exp).getRoot(); :}
2236 unary_expression_not_plus_minus ::=
2237 postfix_expression:exp {:
2239 | COMP unary_expression:exp
2240 {: RESULT=(new ParseNode("comp",parser.n())).addChild(exp).getRoot(); :}
2241 | NOT unary_expression:exp
2242 {: RESULT=(new ParseNode("not",parser.n())).addChild(exp).getRoot(); :}
2243 | cast_expression:exp {: RESULT=exp; :}
2246 LPAREN primitive_type:type dims_opt:dims
2247 RPAREN unary_expression:exp {:
2248 ParseNode pn=new ParseNode("cast1",parser.n());
2249 if (dims.intValue()==0)
2250 pn.addChild("type").addChild(type);
2252 ParseNode arrayt=pn.addChild("type").addChild("type").addChild("array");
2253 arrayt.addChild("basetype").addChild(type);
2254 arrayt.addChild("dims").setLiteral(dims);
2256 pn.addChild("exp").addChild(exp);
2259 | LPAREN expression:type RPAREN unary_expression_not_plus_minus:exp {:
2260 ParseNode pn=new ParseNode("cast2",parser.n());
2261 pn.addChild("type").addChild(type);
2262 pn.addChild("exp").addChild(exp);
2266 | LPAREN name:name dims:dims RPAREN unary_expression_not_plus_minus:exp {:
2267 ParseNode pn=new ParseNode("cast1",parser.n());
2268 if (dims.intValue()==0)
2269 pn.addChild("type").addChild("class").addChild(name);
2271 ParseNode arrayt=pn.addChild("type").addChild("type").addChild("array");
2272 arrayt.addChild("basetype").addChild("type").addChild("class").addChild(name);
2273 arrayt.addChild("dims").setLiteral(dims);
2275 pn.addChild("exp").addChild(exp);
2280 multiplicative_expression ::=
2281 unary_expression:exp {:
2283 | multiplicative_expression:exp1 MULT unary_expression:exp2 {:
2284 ParseNode pn=new ParseNode("mult",parser.n());
2289 | multiplicative_expression:exp1 DIV unary_expression:exp2 {:
2290 ParseNode pn=new ParseNode("div",parser.n());
2295 | multiplicative_expression:exp1 MOD unary_expression:exp2 {:
2296 ParseNode pn=new ParseNode("mod",parser.n());
2302 additive_expression ::=
2303 multiplicative_expression:exp {:
2305 | additive_expression:exp1 PLUS multiplicative_expression:exp2 {:
2306 ParseNode pn=new ParseNode("add",parser.n());
2311 | additive_expression:exp1 MINUS multiplicative_expression:exp2 {:
2312 ParseNode pn=new ParseNode("sub",parser.n());
2318 shift_expression ::=
2319 additive_expression:exp {:
2321 | shift_expression:exp1 LSHIFT additive_expression:exp2 {:
2322 ParseNode pn=new ParseNode("leftshift",parser.n());
2327 | shift_expression:exp1 RSHIFT additive_expression:exp2 {:
2328 ParseNode pn=new ParseNode("rightshift",parser.n());
2333 | shift_expression:exp1 URSHIFT additive_expression:exp2 {:
2334 ParseNode pn=new ParseNode("urightshift",parser.n());
2340 relational_expression ::=
2341 shift_expression:exp {:
2343 | relational_expression:exp1 LT shift_expression:exp2 {:
2344 ParseNode pn=new ParseNode("comp_lt",parser.n());
2349 | relational_expression:exp1 GT shift_expression:exp2 {:
2350 ParseNode pn=new ParseNode("comp_gt",parser.n());
2355 | relational_expression:exp1 LTEQ shift_expression:exp2 {:
2356 ParseNode pn=new ParseNode("comp_lte",parser.n());
2361 | relational_expression:exp1 GTEQ shift_expression:exp2 {:
2362 ParseNode pn=new ParseNode("comp_gte",parser.n());
2367 | relational_expression:exp INSTANCEOF reference_type:type {:
2368 ParseNode pn=new ParseNode("instanceof",parser.n());
2369 pn.addChild("exp").addChild(exp);
2375 equality_expression ::=
2376 relational_expression:exp {:
2378 | equality_expression:exp1 EQEQ relational_expression:exp2 {:
2379 ParseNode pn=new ParseNode("equal",parser.n());
2384 | equality_expression:exp1 NOTEQ relational_expression:exp2 {:
2385 ParseNode pn=new ParseNode("not_equal",parser.n());
2392 equality_expression:exp {:
2394 | and_expression:exp1 AND equality_expression:exp2 {:
2395 ParseNode pn=new ParseNode("bitwise_and",parser.n());
2401 exclusive_or_expression ::=
2402 and_expression:expr {:
2405 | exclusive_or_expression:exp1 XOR and_expression:exp2 {:
2406 ParseNode pn=new ParseNode("bitwise_xor",parser.n());
2412 inclusive_or_expression ::=
2413 exclusive_or_expression:exclor {:
2415 | inclusive_or_expression:exp1 OR exclusive_or_expression:exp2 {:
2416 ParseNode pn=new ParseNode("bitwise_or",parser.n());
2422 conditional_and_expression ::=
2423 inclusive_or_expression:inclor {:
2425 | conditional_and_expression:exp1 ANDAND inclusive_or_expression:exp2 {:
2426 ParseNode pn=new ParseNode("logical_and",parser.n());
2432 conditional_or_expression ::=
2433 conditional_and_expression:condand {:
2435 | conditional_or_expression:exp1 OROR conditional_and_expression:exp2 {:
2436 ParseNode pn=new ParseNode("logical_or",parser.n());
2442 conditional_expression ::=
2443 conditional_or_expression:condor {:
2445 | conditional_or_expression:condor QUESTION expression:exptrue
2446 COLON conditional_expression:expfalse {:
2447 ParseNode pn=new ParseNode("tert",parser.n());
2448 pn.addChild("cond").addChild(condor);
2449 pn.addChild("trueexpr").addChild(exptrue);
2450 pn.addChild("falseexpr").addChild(expfalse);
2454 getoffset_expression ::=
2455 GETOFFSET LBRACE class_or_interface_type:type COMMA IDENTIFIER:id RBRACE {:
2456 ParseNode pn = new ParseNode("getoffset",parser.n());
2458 pn.addChild("field").addChild(id);
2463 assignment_expression ::=
2464 conditional_expression:expr {:
2466 assignment:assign {:
2468 getoffset_expression:expr {:
2471 // semantic check necessary here to ensure a valid left-hand side.
2472 // allowing a parenthesized variable here on the lhs was introduced in
2473 // JLS 2; thanks to Eric Blake for pointing this out.
2474 assignment ::= postfix_expression:lvalue assignment_operator:op assignment_expression:rvalue {:
2475 ParseNode pn=new ParseNode("assignment",parser.n());
2476 pn.addChild("op").addChild(op);
2477 ParseNode pnargs=pn.addChild("args");
2478 pnargs.addChild(lvalue);
2479 pnargs.addChild(rvalue);
2483 assignment_operator ::=
2484 EQ {: RESULT=new ParseNode("eq",parser.n()); :}
2485 | MULTEQ {: RESULT=new ParseNode("multeq",parser.n()); :}
2486 | DIVEQ {: RESULT=new ParseNode("diveq",parser.n()); :}
2487 | MODEQ {: RESULT=new ParseNode("modeq",parser.n()); :}
2488 | PLUSEQ {: RESULT=new ParseNode("pluseq",parser.n()); :}
2489 | MINUSEQ {: RESULT=new ParseNode("minuseq",parser.n()); :}
2490 | LSHIFTEQ {: RESULT=new ParseNode("lshifteq",parser.n()); :}
2491 | RSHIFTEQ {: RESULT=new ParseNode("rshifteq",parser.n()); :}
2492 | URSHIFTEQ {: RESULT=new ParseNode("urshifteq",parser.n()); :}
2493 | ANDEQ {: RESULT=new ParseNode("andeq",parser.n()); :}
2494 | XOREQ {: RESULT=new ParseNode("xoreq",parser.n()); :}
2495 | OREQ {: RESULT=new ParseNode("oreq",parser.n()); :}
2498 {: RESULT=new ParseNode("empty",parser.n()); :}
2502 expression ::= assignment_expression:exp {:
2505 // note that this constraint must be enforced during semantic checking
2506 // 'constant_expression' should include enumerated constants.
2507 constant_expression ::=
2510 ParseNode pn = new ParseNode("constant_expression",parser.n());
2517 genreach_statement ::=
2518 GENREACH IDENTIFIER:graphName SEMICOLON {:
2519 ParseNode pn=new ParseNode("genreach",parser.n());
2520 pn.addChild("graphName").addChild(graphName);