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);
39 scan with {: return lexer.nextToken(); :};
41 terminal BOOLEAN; // primitive_type
42 terminal BYTE, SHORT, INT, LONG, CHAR; // integral_type
43 terminal FLOAT, DOUBLE; // floating_point_type
44 terminal LBRACK, RBRACK; // array_type
45 terminal java.lang.String IDENTIFIER; // name
46 terminal DOT; // qualified_name
47 terminal SEMICOLON, MULT, COMMA, LBRACE, RBRACE, EQ, LPAREN, RPAREN, COLON;
48 terminal PACKAGE; // package_declaration
49 terminal IMPORT; // import_declaration
50 terminal PUBLIC, PROTECTED, PRIVATE; // modifier
51 terminal STATIC; // modifier
52 terminal ABSTRACT, FINAL, NATIVE, SYNCHRONIZED, TRANSIENT, VOLATILE;
53 terminal CLASS; // class_declaration
54 terminal EXTENDS; // super
55 terminal IMPLEMENTS; // interfaces
56 terminal VOID; // method_header
57 terminal THROWS; // throws
58 terminal THIS, SUPER; // explicit_constructor_invocation
59 terminal INTERFACE; // interface_declaration
60 terminal IF, ELSE; // if_then_statement, if_then_else_statement
61 terminal SWITCH; // switch_statement
62 terminal CASE, DEFAULT; // switch_label
63 terminal DO, WHILE; // while_statement, do_statement
64 terminal FOR; // for_statement
65 terminal BREAK; // break_statement
66 terminal CONTINUE; // continue_statement
67 terminal RETURN; // return_statement
68 terminal THROW; // throw_statement
69 terminal TRY; // try_statement
70 terminal CATCH; // catch_clause
71 terminal FINALLY; // finally
72 terminal NEW; // class_instance_creation_expression
73 terminal NEWFLAG; // class_instance_creation_expression
74 terminal PLUSPLUS; // postincrement_expression
75 terminal MINUSMINUS; // postdecrement_expression
76 terminal PLUS, MINUS, COMP, NOT, DIV, MOD;
77 terminal LSHIFT, RSHIFT, URSHIFT; // shift_expression
78 terminal LT, GT, LTEQ, GTEQ, INSTANCEOF; // relational_expression
79 terminal EQEQ, NOTEQ; // equality_expression
80 terminal AND; // and_expression
81 terminal XOR; // exclusive_or_expression
82 terminal OR; // inclusive_or_expression
83 terminal ANDAND; // conditional_and_expression
84 terminal OROR; // conditional_or_expression
85 terminal QUESTION; // conditional_expression
86 terminal MULTEQ, DIVEQ, MODEQ, PLUSEQ, MINUSEQ; // assignment_operator
87 terminal LSHIFTEQ, RSHIFTEQ, URSHIFTEQ; // assignment_operator
88 terminal ANDEQ, XOREQ, OREQ; // assignment_operator
89 terminal AT; // support annotations
90 terminal LOCDEF; // declaration of location hierarchy
92 terminal java.lang.Number INTEGER_LITERAL;
93 terminal java.lang.Number FLOATING_POINT_LITERAL;
94 terminal java.lang.Boolean BOOLEAN_LITERAL;
95 terminal java.lang.Character CHARACTER_LITERAL;
96 terminal java.lang.String STRING_LITERAL;
97 terminal NULL_LITERAL;
99 // Reserved but unused:
100 terminal CONST, GOTO;
101 // strictfp keyword, new in Java 1.2
103 // assert keyword, new in Java 1.4
104 terminal ASSERT; // assert_statement
105 // lexer compatibility with Java 1.5
109 // added for disjoint reachability analysis
113 // 19.2) The Syntactic Grammar
114 non terminal ParseNode goal;
115 // 19.3) Lexical Structure
116 non terminal ParseNode literal;
117 // 19.4) Types, Values, and Variables
118 non terminal ParseNode type, primitive_type, numeric_type;
119 non terminal ParseNode integral_type, floating_point_type;
120 non terminal ParseNode reference_type;
121 non terminal ParseNode class_or_interface_type;
122 non terminal ParseNode class_type;
123 non terminal ParseNode interface_type;
124 non terminal ParseNode array_type;
126 non terminal ParseNode name, simple_name, qualified_name;
128 non terminal ParseNode compilation_unit;
129 non terminal ParseNode package_declaration_opt, package_declaration;
130 non terminal ParseNode import_declarations_opt, import_declarations;
131 non terminal ParseNode type_declarations_opt, type_declarations;
132 non terminal ParseNode import_declaration;
133 non terminal ParseNode single_type_import_declaration;
134 non terminal ParseNode type_import_on_demand_declaration;
135 non terminal ParseNode type_declaration;
136 // 19.7) Productions used only in the LALR(1) grammar
137 non terminal ParseNode modifiers_opt, modifiers, modifiers_at, modifier;
138 non terminal ParseNode mixed_modifiers, mixed_modifiers_at;
139 // 19.8.1) Class Declaration
140 non terminal ParseNode class_declaration, super, super_opt;
141 non terminal ParseNode interfaces, interfaces_opt, interface_type_list;
142 non terminal ParseNode class_body;
143 non terminal ParseNode class_body_declarations, class_body_declarations_opt;
144 non terminal ParseNode class_body_declaration, class_member_declaration;
145 // 19.8.2) Field Declarations
146 non terminal ParseNode field_declaration, variable_declarators, variable_declarator;
147 non terminal ParseNode variable_declarator_id;
148 non terminal ParseNode variable_initializer;
149 // 19.8.3) Method Declarations
150 non terminal ParseNode method_declaration, method_header, method_declarator;
151 non terminal ParseNode formal_parameter_list_opt, formal_parameter_list;
152 non terminal ParseNode formal_parameter;
153 non terminal ParseNode throws_opt;
154 non terminal ParseNode throws;
155 non terminal ParseNode class_type_list;
156 non terminal ParseNode method_body;
157 // 19.8.4) Static Initializers
158 non terminal ParseNode static_initializer;
159 // 19.8.5) Constructor Declarations
160 non terminal ParseNode constructor_declaration, constructor_declarator;
161 non terminal ParseNode constructor_body;
162 non terminal ParseNode explicit_constructor_invocation;
163 // 19.8.6) Location Hierarchy Declarations
164 non terminal ParseNode location_order_declaration, location_order_list, location_order;
165 // 19.9.1) Interface Declarations
166 non terminal ParseNode interface_declaration;
167 non terminal normal_interface_declaration, annotation_type_declaration;
168 non terminal ParseNode extends_interfaces_opt, extends_interfaces;
169 non terminal ParseNode interface_body;
170 non terminal ParseNode interface_member_declarations_opt, interface_member_declarations;
171 non terminal ParseNode interface_member_declaration, constant_declaration;
172 non terminal ParseNode abstract_method_declaration;
174 non terminal ParseNode array_initializer;
175 non terminal ParseNode variable_initializers;
176 // 19.11) Blocks and Statements
177 non terminal ParseNode block;
178 non terminal ParseNode block_statements_opt, block_statements, block_statement;
179 non terminal ParseNode local_variable_declaration_statement, local_variable_declaration;
180 non terminal ParseNode statement, statement_no_short_if;
181 non terminal ParseNode statement_without_trailing_substatement;
182 non terminal ParseNode empty_statement;
183 non terminal ParseNode labeled_statement, labeled_statement_no_short_if;
184 non terminal ParseNode expression_statement, statement_expression;
185 non terminal ParseNode if_then_statement;
186 non terminal ParseNode if_then_else_statement, if_then_else_statement_no_short_if;
187 non terminal ParseNode switch_statement, switch_block;
188 non terminal ParseNode switch_block_statement_groups;
189 non terminal ParseNode switch_block_statement_group;
190 non terminal ParseNode switch_labels, switch_label;
191 non terminal ParseNode while_statement, while_statement_no_short_if;
192 non terminal ParseNode do_statement;
193 non terminal ParseNode for_statement, for_statement_no_short_if;
194 non terminal ParseNode for_init_opt, for_init;
195 non terminal ParseNode for_update_opt, for_update;
196 non terminal ParseNode statement_expression_list;
197 //non terminal ParseNode identifier_opt;
198 non terminal ParseNode break_statement, continue_statement;
199 non terminal ParseNode return_statement;
200 non terminal ParseNode throw_statement;
201 non terminal ParseNode synchronized_statement;
202 non terminal ParseNode try_statement;
203 non terminal ParseNode catches_opt;
204 non terminal ParseNode catches, catch_clause;
205 non terminal ParseNode finally;
206 //non terminal ParseNode assert_statement;
207 non terminal ParseNode genreach_statement;
208 // 19.12) Expressions
209 non terminal ParseNode primary, primary_no_new_array;
210 non terminal ParseNode class_instance_creation_expression;
211 non terminal ParseNode cons_argument_list_opt, cons_argument_list;
212 non terminal ParseNode argument_list_opt, argument_list;
213 non terminal ParseNode array_creation_init;
214 non terminal ParseNode array_creation_uninit;
215 non terminal ParseNode dim_exprs, dim_expr;
216 non terminal Integer dims_opt, dims;
217 non terminal ParseNode field_access, method_invocation;
218 non terminal ParseNode array_access;
219 non terminal ParseNode postfix_expression;
220 non terminal ParseNode postincrement_expression, postdecrement_expression;
221 non terminal ParseNode unary_expression, unary_expression_not_plus_minus;
222 non terminal ParseNode preincrement_expression, predecrement_expression;
223 non terminal ParseNode cast_expression;
224 non terminal ParseNode multiplicative_expression, additive_expression;
225 non terminal ParseNode shift_expression, relational_expression, equality_expression;
226 non terminal ParseNode and_expression, exclusive_or_expression, inclusive_or_expression;
227 non terminal ParseNode conditional_and_expression, conditional_or_expression;
228 non terminal ParseNode conditional_expression;
229 non terminal ParseNode assignment_expression;
230 non terminal ParseNode assignment;
231 non terminal ParseNode assignment_operator;
232 non terminal ParseNode expression_opt, expression;
233 non terminal ParseNode constant_expression;
234 //failure aware computation keywords
237 terminal ISAVAILABLE;
242 non terminal ParseNode flag_declaration;
243 non terminal ParseNode task_declaration;
244 non terminal ParseNode task_parameter_list;
245 non terminal ParseNode task_parameter;
246 non terminal ParseNode flag_expression;
247 non terminal ParseNode flag_andexpression;
248 non terminal ParseNode flag_notexpression;
249 non terminal ParseNode task_exitstatement;
250 non terminal ParseNode flag_effects_opt;
251 non terminal ParseNode flag_effects;
252 non terminal ParseNode flag_effect;
253 non terminal ParseNode flag_list;
254 non terminal ParseNode flag_list_opt;
255 non terminal ParseNode flag_change;
257 non terminal ParseNode cons_checks_opt;
258 non terminal ParseNode cons_checks;
259 non terminal ParseNode cons_check;
261 non terminal ParseNode tag_variable_declaration_statement;
262 non terminal ParseNode tag_expression_list;
263 non terminal ParseNode tag_expression;
264 non terminal ParseNode tag_list;
265 non terminal ParseNode tag_list_opt;
266 non terminal ParseNode tag_change;
268 //distributed transaction keywords
273 non terminal ParseNode atomic_statement;
274 non terminal ParseNode getoffset_expression;
276 //disjointness for Java
279 //coarse-grain parallelization
282 non terminal ParseNode sese_statement;
285 // JSR-201) Enum Declaration
286 non terminal ParseNode enum_declaration;
287 non terminal ParseNode enum_body, enum_constants_opt, enum_constants, enum_constant;
288 //non terminal ParseNode enum_arguments_opt, enum_body_declarations_opt;
290 // annotation expressions
291 non terminal ParseNode annotations_opt, annotations, annotations_at, annotation, annotation_body;
292 non terminal ParseNode normal_annotation_body, marker_annotation_body;
293 non terminal ParseNode single_element_annotation_body;
294 non terminal ParseNode annotation_type_body, annotation_type_element_declarations;
295 non terminal ParseNode annotation_type_element_declarations_opt;
296 non terminal ParseNode annotation_type_element_declaration, default_value_opt, default_value;
297 non terminal ParseNode element_value_pairs_opt, element_value_pairs, element_value_pair;
298 non terminal ParseNode element_values_opt, element_values, element_value, element_value_array_initializer;
305 TASK IDENTIFIER:id LPAREN task_parameter_list:tpl RPAREN
309 ParseNode pn=new ParseNode("task_declaration",parser.lexer.line_num);
310 pn.addChild("name").addChild(id);
313 pn.addChild("body").addChild(body);
317 task_parameter_list ::=
319 ParseNode pn=new ParseNode("task_parameter_list",parser.lexer.line_num);
323 | task_parameter_list:fpl COMMA task_parameter:fp {:
330 type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE {:
331 ParseNode pn=new ParseNode("task_parameter",parser.lexer.line_num);
334 pn.addChild("flag").addChild(exp);
337 | type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE LBRACE tag_expression_list:texp RBRACE {:
338 ParseNode pn=new ParseNode("task_parameter",parser.lexer.line_num);
341 pn.addChild("flag").addChild(exp);
342 pn.addChild("tag").addChild(texp);
345 | type:type variable_declarator_id:name LBRACE RBRACE LBRACE tag_expression_list:texp RBRACE {:
346 ParseNode pn=new ParseNode("task_parameter",parser.lexer.line_num);
349 pn.addChild("tag").addChild(texp);
352 | OPTIONAL task_parameter:fp {:
353 ParseNode pn=new ParseNode("task_parameter",parser.lexer.line_num);
354 pn.addChild("optional").addChild(fp);
360 tag_expression_list ::= tag_expression:te {:
361 ParseNode pn=new ParseNode("tag_expression_list",parser.lexer.line_num);
365 | tag_expression_list:tel COMMA tag_expression:te {:
371 tag_expression ::= IDENTIFIER:type IDENTIFIER:id {:
372 ParseNode pn=new ParseNode("tag_expression",parser.lexer.line_num);
373 pn.addChild("type").addChild(type);
374 pn.addChild("single").addChild(id);
379 tag_list_opt ::= LBRACE tag_list:fl RBRACE {:RESULT=fl;:}
380 | LBRACE RBRACE {: RESULT = new ParseNode("empty",parser.lexer.line_num); :}
381 | {: RESULT = new ParseNode("empty",parser.lexer.line_num); :}
384 tag_list ::= tag_change:fc {:
385 ParseNode pn=new ParseNode("tag_list",parser.lexer.line_num);
389 | tag_list:fl COMMA tag_change:fc {:
394 tag_change ::= IDENTIFIER:id {:
395 RESULT=new ParseNode("name",parser.lexer.line_num).addChild(id).getRoot();
397 | NOT IDENTIFIER:id {:
398 RESULT=new ParseNode("not",parser.lexer.line_num).addChild("name").addChild(id).getRoot();
402 flag_andexpression:exp {:
405 | flag_expression:exp1 OROR flag_andexpression:exp2 {:
406 ParseNode pn=new ParseNode("or",parser.lexer.line_num);
413 flag_andexpression ::=
414 flag_notexpression:exp {: RESULT=exp; :}
415 | flag_notexpression:exp1 ANDAND flag_andexpression:exp2 {:
416 ParseNode pn=new ParseNode("and",parser.lexer.line_num);
423 flag_notexpression ::=
424 NOT flag_notexpression:exp {:
425 ParseNode pn=new ParseNode("not",parser.lexer.line_num);
429 | LPAREN flag_expression:exp RPAREN {:
433 ParseNode pn=new ParseNode("name",parser.lexer.line_num);
439 task_exitstatement ::= TASKEXIT flag_effects_opt:opt cons_checks_opt:cco SEMICOLON {:
440 RESULT=(new ParseNode("taskexit",parser.lexer.line_num)).addChild(opt).getRoot().addChild(cco).getRoot();
443 cons_checks_opt ::= ASSERT LPAREN cons_checks:cc RPAREN {: RESULT=cc; :}
444 | {: RESULT = new ParseNode("empty",parser.lexer.line_num); :}
447 cons_checks ::= cons_check:cc {:
448 ParseNode pn=new ParseNode("cons_checks",parser.lexer.line_num);
452 | cons_checks:ccs COMMA cons_check:cc {:
457 cons_check ::= IDENTIFIER:name LPAREN cons_argument_list_opt:args RPAREN {:
458 ParseNode pn=new ParseNode("cons_check",parser.lexer.line_num);
459 pn.addChild("name").addChild("identifier").addChild(name);
464 flag_effects_opt ::= LPAREN flag_effects:fe RPAREN {:RESULT=fe;:}
465 | {: RESULT = new ParseNode("empty",parser.lexer.line_num); :}
468 flag_effects ::= flag_effect:fe {:
469 ParseNode pn=new ParseNode("flag_effects_list",parser.lexer.line_num);
473 | flag_effects:fes COMMA flag_effect:fe {:
478 flag_effect ::= IDENTIFIER:id LBRACE flag_list:fl RBRACE tag_list_opt:tlo {:
479 ParseNode pn=new ParseNode("flag_effect",parser.lexer.line_num);
480 pn.addChild("name").addChild(id);
485 | IDENTIFIER:id LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
486 ParseNode pn=new ParseNode("flag_effect",parser.lexer.line_num);
487 pn.addChild("name").addChild(id);
492 flag_list_opt ::= LBRACE flag_list:fl RBRACE {:RESULT=fl;:}
493 | LBRACE RBRACE {: RESULT = new ParseNode("empty",parser.lexer.line_num); :}
495 {: RESULT = new ParseNode("empty",parser.lexer.line_num); :}
498 flag_list ::= flag_change:fc {:
499 ParseNode pn=new ParseNode("flag_list",parser.lexer.line_num);
503 | flag_list:fl COMMA flag_change:fc {:
508 flag_change ::= IDENTIFIER:id {:
509 RESULT=new ParseNode("name",parser.lexer.line_num).addChild(id).getRoot();
512 RESULT=new ParseNode("not",parser.lexer.line_num).addChild("name").addChild(id).getRoot();
515 // 19.2) The Syntactic Grammar
516 goal ::= compilation_unit:cu
522 // 19.3) Lexical Structure.
525 literal ::= INTEGER_LITERAL:integer_lit
527 ParseNode pn=new ParseNode("literal",parser.lexer.line_num);
528 pn.addChild("integer").setLiteral(integer_lit);
531 | FLOATING_POINT_LITERAL:float_lit
533 ParseNode pn=new ParseNode("literal",parser.lexer.line_num);
534 pn.addChild("float").setLiteral(float_lit);
537 | BOOLEAN_LITERAL:boolean_lit
539 ParseNode pn=new ParseNode("literal",parser.lexer.line_num);
540 pn.addChild("boolean").setLiteral(boolean_lit);
543 | CHARACTER_LITERAL:char_lit
545 ParseNode pn=new ParseNode("literal",parser.lexer.line_num);
546 pn.addChild("char").setLiteral(char_lit);
549 | STRING_LITERAL:string_lit
551 ParseNode pn=new ParseNode("literal",parser.lexer.line_num);
552 pn.addChild("string").setLiteral(string_lit);
557 RESULT=(new ParseNode("literal",parser.lexer.line_num)).addChild("null").getRoot();
561 // 19.4) Types, Values, and Variables
562 type ::= primitive_type:type {: RESULT=type; :}
563 | reference_type:type {: RESULT=type; :}
567 numeric_type:type {: RESULT=type; :}
568 | BOOLEAN {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("boolean").getRoot(); :}
570 numeric_type::= integral_type:type {: RESULT=type; :}
571 | floating_point_type:type {: RESULT=type; :}
574 BYTE {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("byte").getRoot(); :}
575 | SHORT {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("short").getRoot(); :}
576 | INT {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("int").getRoot(); :}
577 | LONG {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("long").getRoot(); :}
578 | CHAR {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("char").getRoot(); :}
580 floating_point_type ::=
581 FLOAT {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("float").getRoot(); :}
582 | DOUBLE {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("double").getRoot(); :}
586 class_or_interface_type:type {: RESULT=type; :}
587 | array_type:type {: RESULT=type; :}
589 class_or_interface_type ::= name:name {:
590 RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("class").addChild(name).getRoot();
593 class_type ::= class_or_interface_type:type {: RESULT=type; :};
594 interface_type ::= class_or_interface_type:type {: RESULT=type; :};
596 array_type ::= primitive_type:prim dims:dims {:
597 ParseNode pn=(new ParseNode("type",parser.lexer.line_num)).addChild("array");
598 pn.addChild("basetype").addChild(prim);
599 pn.addChild("dims").setLiteral(dims);
602 | name:name dims:dims {:
603 ParseNode pn=(new ParseNode("type",parser.lexer.line_num)).addChild("array");
604 pn.addChild("basetype").addChild("type").addChild("class").addChild(name);
605 pn.addChild("dims").setLiteral(dims);
611 name ::= simple_name:name {: RESULT=name; :}
612 | qualified_name:name {: RESULT=name; :}
614 simple_name ::= IDENTIFIER:id {:
615 RESULT=(new ParseNode("name",parser.lexer.line_num)).addChild("identifier").addChild(id).getRoot();
618 qualified_name ::= name:name DOT IDENTIFIER:id {:
619 ParseNode pn=new ParseNode("name",parser.lexer.line_num);
620 pn.addChild("base").addChild(name);
621 pn.addChild("identifier").addChild(id);
628 package_declaration_opt:pdo
629 import_declarations_opt:ido
630 type_declarations_opt:tdo {:
631 ParseNode pn=new ParseNode("compilation_unit",parser.lexer.line_num);
633 pn.addChild("packages").addChild(pdo);
634 pn.addChild("imports").addChild(ido);
638 package_declaration_opt ::= package_declaration:pdo {:
641 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
644 import_declarations_opt ::= import_declarations:ido {:
647 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
649 type_declarations_opt ::= type_declarations:tds {:
652 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
655 import_declarations ::=
656 import_declaration:id {:
657 ParseNode pn=new ParseNode("import_decls_list",parser.lexer.line_num);
661 | import_declarations:ids import_declaration:id {:
667 type_declarations ::=
668 type_declaration:td {:
669 ParseNode pn=new ParseNode("type_declaration_list",parser.lexer.line_num);
673 | type_declarations:tds type_declaration:td {:
679 package_declaration ::=
680 PACKAGE name:name SEMICOLON {:
681 ParseNode pn=new ParseNode("package",parser.lexer.line_num);
686 import_declaration ::=
687 single_type_import_declaration:sid {: RESULT=sid; :}
688 | type_import_on_demand_declaration:iod {: RESULT=iod; :}
690 single_type_import_declaration ::=
691 IMPORT name:name SEMICOLON {:
692 ParseNode pn=new ParseNode("import_single",parser.lexer.line_num);
697 type_import_on_demand_declaration ::=
698 IMPORT name:name DOT MULT SEMICOLON {:
699 ParseNode pn=new ParseNode("import_ondemand",parser.lexer.line_num);
710 | enum_declaration:ed
714 | task_declaration:td
718 | interface_declaration:in
722 | SEMICOLON {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
725 // 19.7) Productions used only in the LALR(1) grammar
727 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
736 modifiers ::= mixed_modifiers : mmo {:
739 | annotations : an {:
740 ParseNode pn=new ParseNode("modifier_list",parser.lexer.line_num);
745 mixed_modifiers_at ::=
746 mixed_modifiers : mmos AT {:
752 ParseNode pn=new ParseNode("modifier_list",parser.lexer.line_num);
756 | annotations:as modifier:mo {:
757 ParseNode pn=new ParseNode("modifier_list",parser.lexer.line_num);
762 | mixed_modifiers : mmos modifier : mo {:
766 | mixed_modifiers_at:mma annotation_body:ab {:
767 mma.addChild("annotation_list",parser.lexer.line_num).addChild(ab);
772 PUBLIC {: RESULT=new ParseNode("public",parser.lexer.line_num); :}|
773 PROTECTED {: RESULT=new ParseNode("protected",parser.lexer.line_num); :}|
774 PRIVATE {: RESULT=new ParseNode("private",parser.lexer.line_num); :}|
775 STATIC {: RESULT=new ParseNode("static",parser.lexer.line_num); :} |
776 ABSTRACT {: RESULT=new ParseNode("abstract",parser.lexer.line_num); :} |
777 FINAL {: RESULT=new ParseNode("final",parser.lexer.line_num); :}|
778 NATIVE {: RESULT=new ParseNode("native",parser.lexer.line_num); :} |
779 SYNCHRONIZED {: RESULT=new ParseNode("synchronized",parser.lexer.line_num); :} |
780 ATOMIC {: RESULT=new ParseNode("atomic",parser.lexer.line_num); :} |
781 VOLATILE {: RESULT=new ParseNode("volatile",parser.lexer.line_num); :} |
782 TRANSIENT {: RESULT=new ParseNode("transient",parser.lexer.line_num); :}
784 // STRICTFP // note that semantic analysis must check that the
785 // context of the modifier allows strictfp.
787 //annotations_opt ::=
788 // {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
789 // | annotations:an {:
794 AT annotation_body:ab {:
795 ParseNode pn=new ParseNode("annotation_list",parser.lexer.line_num);
799 | annotations_at:aat annotation_body:ab {:
810 AT annotation_body:ab {:
815 normal_annotation_body:nab {:
816 ParseNode pn=new ParseNode("annotation_body",parser.lexer.line_num);
820 | marker_annotation_body:mab {:
821 ParseNode pn=new ParseNode("annotation_body",parser.lexer.line_num);
825 | single_element_annotation_body:seab {:
826 ParseNode pn=new ParseNode("annotation_body",parser.lexer.line_num);
831 normal_annotation_body ::=
832 IDENTIFIER LPAREN element_value_pairs_opt RPAREN
834 marker_annotation_body ::=
837 ParseNode pn=new ParseNode("marker_annotation",parser.lexer.line_num);
838 pn.addChild("name").addChild(id);
842 single_element_annotation_body ::=
843 IDENTIFIER:id LPAREN STRING_LITERAL:ev RPAREN {:
844 ParseNode pn=new ParseNode("single_annotation",parser.lexer.line_num);
845 pn.addChild("name").addChild(id);
846 pn.addChild("element_value").addChild(ev);
850 element_value_pairs_opt ::=
851 | element_value_pairs
853 element_value_pairs ::=
855 | element_value_pairs COMMA element_value_pair
857 element_value_pair ::=
858 IDENTIFIER EQ element_value
864 | element_value_array_initializer:evai {:
867 | conditional_expression:ce {:
871 element_value_array_initializer ::=
872 LBRACE element_values_opt RBRACE
874 element_values_opt ::=
879 | element_values COMMA element_value
883 // 19.8.1) Class Declaration:
884 class_declaration ::=
885 modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so interfaces_opt:ifo
888 ParseNode pn=new ParseNode("class_declaration",parser.lexer.line_num);
889 pn.addChild("modifiers").addChild(mo);
890 pn.addChild("name").addChild(id);
891 pn.addChild("super").addChild(so);
892 pn.addChild("superIF").addChild(ifo);
893 pn.addChild("classbody").addChild(body);
897 super ::= EXTENDS class_type:classtype {:
902 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
908 interfaces ::= IMPLEMENTS interface_type_list:iftl {: RESULT=iftl; :}
911 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
912 | interfaces:ifs {: RESULT=ifs; :}
914 interface_type_list ::=
915 interface_type:ift {:
916 ParseNode pn=new ParseNode("interface_type_list",parser.lexer.line_num);
920 | interface_type_list:iftl COMMA interface_type:ift {:
926 class_body ::= LBRACE class_body_declarations_opt:cbdo RBRACE {: RESULT=cbdo; :}
929 class_body_declarations_opt ::=
930 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
931 | class_body_declarations:cbd {: RESULT=cbd; :};
933 class_body_declarations ::=
934 class_body_declaration:cbd {:
935 ParseNode pn=new ParseNode("class_body_declaration_list",parser.lexer.line_num);
939 | class_body_declarations:cbds class_body_declaration:cbd {:
945 class_body_declaration ::=
946 class_member_declaration:member {:
947 RESULT=(new ParseNode("member",parser.lexer.line_num)).addChild(member).getRoot();
949 | static_initializer:block{:
950 RESULT=(new ParseNode("static_block",parser.lexer.line_num)).addChild(block).getRoot();
952 | constructor_declaration:constructor {:
953 RESULT=(new ParseNode("constructor",parser.lexer.line_num)).addChild(constructor).getRoot();
956 RESULT=(new ParseNode("block",parser.lexer.line_num)).addChild(block).getRoot();
958 | location_order_declaration:lod {:
959 RESULT=(new ParseNode("location_order_declaration",parser.lexer.line_num)).addChild(lod).getRoot();
962 class_member_declaration ::=
963 //failure aware computation
964 flag_declaration:flag {:
965 RESULT=(new ParseNode("flag",parser.lexer.line_num)).addChild(flag).getRoot();
968 field_declaration:field {:
969 RESULT=(new ParseNode("field",parser.lexer.line_num)).addChild(field).getRoot();
971 | method_declaration:method {:
972 RESULT=(new ParseNode("method",parser.lexer.line_num)).addChild(method).getRoot();
974 /* repeat the prod for 'class_declaration' here: */
975 | modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so interfaces_opt:ifo class_body:body
977 ParseNode pn=new ParseNode("inner_class_declaration",parser.lexer.line_num);
978 pn.addChild("modifiers").addChild(mo);
979 pn.addChild("name").addChild(id);
980 pn.addChild("super").addChild(so);
981 pn.addChild("superIF").addChild(ifo);
982 pn.addChild("classbody").addChild(body);
985 | enum_declaration:ed
989 // | interface_declaration:interfaced {:
990 // RESULT=(new ParseNode("interface",parser.lexer.line_num)).addChild(interfaced).getRoot();
992 | SEMICOLON {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
996 // JSR-201) Enum Declaration
998 modifiers_opt:mo ENUM IDENTIFIER:id /*interfaces_opt:io*/ enum_body:body
1000 ParseNode pn=new ParseNode("enum_declaration",parser.lexer.line_num);
1001 pn.addChild("modifiers").addChild(mo);
1002 pn.addChild("name").addChild(id);
1003 //pn.addChild("superIF").addChild(ifo);
1004 pn.addChild("enumbody").addChild(body);
1009 LBRACE enum_constants_opt:eco /*enum_body_declarations_opt:ebdo*/ RBRACE
1012 enum_constants_opt ::=
1013 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1014 | enum_constants:ecs
1019 ParseNode pn=new ParseNode("enum_constants_list",parser.lexer.line_num);
1023 | enum_constants:ecs COMMA enum_constant:ec {:
1029 IDENTIFIER:id /*enum_arguments_opt*/
1031 ParseNode pn=new ParseNode("enum_constant",parser.lexer.line_num);
1032 pn.addChild("name").addChild(id);
1035 // | IDENTIFIER enum_arguments_opt class_body
1037 //enum_arguments_opt ::=
1038 // | LPAREN argument_list_opt RPAREN
1040 //enum_body_declarations_opt ::=
1041 // | SEMICOLON class_body_declarations_opt:cbdo
1044 //Failure aware computation
1045 flag_declaration ::=
1046 FLAG IDENTIFIER:id SEMICOLON {:
1047 ParseNode pn=new ParseNode("flag_declaration",parser.lexer.line_num);
1048 pn.addChild("name").addChild(id);
1051 EXTERNAL FLAG IDENTIFIER:id SEMICOLON {:
1052 ParseNode pn=new ParseNode("flag_declaration",parser.lexer.line_num);
1053 pn.addChild("name").addChild(id);
1054 pn.addChild("external");
1059 // 19.8.2) Field Declarations
1060 field_declaration ::=
1061 modifiers_opt:mo type:type variable_declarators:var SEMICOLON {:
1062 ParseNode pn=new ParseNode("field_declaration",parser.lexer.line_num);
1063 pn.addChild("modifier").addChild(mo);
1064 pn.addChild("type").addChild(type);
1065 pn.addChild("variables").addChild(var);
1068 modifiers_opt:mo GLOBAL type:type variable_declarators:var SEMICOLON {:
1069 ParseNode pn=new ParseNode("field_declaration",parser.lexer.line_num);
1070 pn.addChild("modifier").addChild(mo);
1071 pn.addChild("type").addChild(type);
1072 pn.addChild("variables").addChild(var);
1073 pn.addChild("global");
1078 variable_declarators ::=
1079 variable_declarator:vd {:
1080 ParseNode pn=new ParseNode("variable_declarators_list",parser.lexer.line_num);
1084 | variable_declarators:vds COMMA variable_declarator:vd {:
1089 variable_declarator ::=
1090 variable_declarator_id:id {:
1091 ParseNode pn=new ParseNode("variable_declarator",parser.lexer.line_num);
1095 | variable_declarator_id:id EQ variable_initializer:init {:
1096 ParseNode pn=new ParseNode("variable_declarator",parser.lexer.line_num);
1098 pn.addChild("initializer").addChild(init);
1102 variable_declarator_id ::=
1104 RESULT=(new ParseNode("single",parser.lexer.line_num)).addChild(id).getRoot();:}
1105 | variable_declarator_id:id LBRACK RBRACK {:
1106 RESULT=(new ParseNode("array",parser.lexer.line_num)).addChild(id).getRoot();:}
1108 variable_initializer ::=
1109 expression:exp {: RESULT=exp; :}
1110 | array_initializer:ai {: RESULT=(new ParseNode("array_initializer",parser.lexer.line_num)).addChild(ai).getRoot(); :}
1113 // 19.8.3) Method Declarations
1114 method_declaration ::=
1115 method_header:header method_body:body {:
1116 ParseNode pn=new ParseNode("method_declaration",parser.lexer.line_num);
1117 pn.addChild(header);
1118 pn.addChild("body").addChild(body);
1123 modifiers_opt:mo type:type method_declarator:decl throws_opt:to
1125 ParseNode pn=new ParseNode("method_header",parser.lexer.line_num);
1126 pn.addChild("modifiers").addChild(mo);
1127 pn.addChild("returntype").addChild(type);
1128 pn.addChild("throws").addChild(to);
1132 | modifiers_opt:mo VOID method_declarator:decl throws_opt:to
1134 ParseNode pn=new ParseNode("method_header",parser.lexer.line_num);
1135 pn.addChild("modifiers").addChild(mo);
1136 pn.addChild("throws").addChild(to);
1141 method_declarator ::=
1142 IDENTIFIER:id LPAREN formal_parameter_list_opt:params RPAREN {:
1143 ParseNode pn=new ParseNode("method_declarator",parser.lexer.line_num);
1144 pn.addChild("name").addChild(id);
1145 pn.addChild("parameters").addChild(params);
1148 // | method_declarator LBRACK RBRACK // deprecated
1149 // be careful; the above production also allows 'void foo() []'
1151 formal_parameter_list_opt ::=
1152 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1153 | formal_parameter_list:fpl {:
1157 formal_parameter_list ::=
1158 formal_parameter:fp {:
1159 ParseNode pn=new ParseNode("formal_parameter_list",parser.lexer.line_num);
1163 | formal_parameter_list:fpl COMMA formal_parameter:fp {:
1168 formal_parameter ::=
1169 type:type variable_declarator_id:name {:
1170 ParseNode pn=new ParseNode("formal_parameter",parser.lexer.line_num);
1176 TAG variable_declarator_id:name {:
1177 ParseNode pn=new ParseNode("tag_parameter",parser.lexer.line_num);
1181 | FINAL type:type variable_declarator_id:name {:
1182 ParseNode pn=new ParseNode("formal_parameter",parser.lexer.line_num);
1187 | annotation:an type:type variable_declarator_id:name {:
1188 ParseNode pn=new ParseNode("annotation_parameter",parser.lexer.line_num);
1196 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1200 throws ::= THROWS class_type_list:ctl
1201 {: RESULT=(new ParseNode("throw_list",parser.lexer.line_num)).addChild(ctl).getRoot(); :}
1206 ParseNode pn=new ParseNode("class_type_list",parser.lexer.line_num);
1210 | class_type_list:ctl COMMA class_type:ct
1216 method_body ::= block:block {:
1219 | SEMICOLON {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1222 // 19.8.4) Static Initializers
1223 static_initializer ::=
1224 STATIC block:body {:
1225 ParseNode pn=new ParseNode("static_block_declaration",parser.lexer.line_num);
1226 pn.addChild("body").addChild(body);
1231 // 19.8.5) Constructor Declarations
1232 constructor_declaration ::=
1233 modifiers_opt:mo constructor_declarator:cd throws_opt:to
1234 constructor_body:body {:
1235 ParseNode pn=new ParseNode("constructor_declaration",parser.lexer.line_num);
1236 pn.addChild("modifiers").addChild(mo);
1237 pn.addChild("throws").addChild(to);
1239 pn.addChild("body").addChild(body);
1242 modifiers_opt:mo GLOBAL constructor_declarator:cd throws_opt:to
1243 constructor_body:body {:
1244 ParseNode pn=new ParseNode("constructor_declaration",parser.lexer.line_num);
1245 pn.addChild("global");
1246 pn.addChild("modifiers").addChild(mo);
1247 pn.addChild("throws").addChild(to);
1249 pn.addChild("body").addChild(body);
1254 constructor_declarator ::=
1255 simple_name:name LPAREN formal_parameter_list_opt:fplo RPAREN {:
1256 ParseNode pn=new ParseNode("constructor_declarator",parser.lexer.line_num);
1258 pn.addChild("parameters").addChild(fplo);
1262 constructor_body ::=
1263 LBRACE explicit_constructor_invocation:eci block_statements:bs RBRACE {:
1264 ParseNode pn=new ParseNode("constructor_body",parser.lexer.line_num);
1269 LBRACE explicit_constructor_invocation:eci RBRACE {:
1270 ParseNode pn=new ParseNode("constructor_body",parser.lexer.line_num);
1274 LBRACE block_statements:block RBRACE {:
1275 ParseNode pn=new ParseNode("constructor_body",parser.lexer.line_num);
1279 | LBRACE RBRACE {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1281 explicit_constructor_invocation ::=
1282 THIS LPAREN argument_list_opt:alo RPAREN SEMICOLON {:
1283 ParseNode pn=new ParseNode("explconstrinv",parser.lexer.line_num);
1288 SUPER LPAREN argument_list_opt:alo RPAREN SEMICOLON {:
1289 ParseNode pn=new ParseNode("superinvoke",parser.lexer.line_num);
1293 // | primary DOT THIS LPAREN argument_list_opt RPAREN SEMICOLON
1294 // | primary DOT SUPER LPAREN argument_list_opt RPAREN SEMICOLON
1297 // 19.8.6) Location Hierarchy Declarations
1298 location_order_declaration ::= LOCDEF LBRACE location_order_list:lol RBRACE {:
1302 location_order_list ::=
1303 location_order:lo {:
1304 ParseNode pn=new ParseNode("location_order_list",parser.lexer.line_num);
1308 | location_order_list:lol COMMA location_order:lo {:
1314 IDENTIFIER:loc1 LT IDENTIFIER:loc2{:
1315 ParseNode pn=new ParseNode("location_order",parser.lexer.line_num);
1320 | IDENTIFIER:loc MULT{:
1321 ParseNode pn=new ParseNode("location_property",parser.lexer.line_num);
1329 // 19.9.1) Interface Declarations
1330 interface_declaration ::=
1331 modifiers_opt:mo INTERFACE IDENTIFIER:id extends_interfaces_opt:io
1334 ParseNode pn=new ParseNode("interface_declaration",parser.lexer.line_num);
1335 pn.addChild("modifiers").addChild(mo);
1336 pn.addChild("name").addChild(id);
1337 pn.addChild("superIF").addChild(io);
1338 pn.addChild("interfacebody").addChild(body);
1341 | annotation_type_declaration
1343 extends_interfaces_opt ::=
1344 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1345 | extends_interfaces:eifs {: RESULT=eifs; :}
1347 extends_interfaces ::=
1348 EXTENDS interface_type:ift
1350 ParseNode pn=new ParseNode("extend_interface_list",parser.lexer.line_num);
1354 | extends_interfaces:eifs COMMA interface_type:ift
1361 LBRACE interface_member_declarations_opt:imdo RBRACE
1364 interface_member_declarations_opt ::=
1365 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1366 | interface_member_declarations:imd {: RESULT=imd; :}
1368 interface_member_declarations ::=
1369 interface_member_declaration:imd {:
1370 ParseNode pn=new ParseNode("interface_member_declaration_list",parser.lexer.line_num);
1374 | interface_member_declarations:imds interface_member_declaration:imd {:
1379 interface_member_declaration ::=
1380 constant_declaration:constant {:
1381 RESULT=(new ParseNode("constant",parser.lexer.line_num)).addChild(constant).getRoot();
1383 | abstract_method_declaration:method {:
1384 RESULT=(new ParseNode("method",parser.lexer.line_num)).addChild(method).getRoot();
1386 | enum_declaration:ed {:
1387 RESULT=(new ParseNode("enum_declaration",parser.lexer.line_num)).addChild(ed).getRoot();
1389 // | class_declaration:class
1390 // | interface_declaration:interface
1392 RESULT=new ParseNode("empty",parser.lexer.line_num);
1395 constant_declaration ::=
1396 field_declaration:fd {: RESULT=fd; :}
1397 // need to semantically check that modifiers of field declaration
1398 // include only PUBLIC, STATIC, or FINAL. Other modifiers are
1401 abstract_method_declaration ::=
1402 method_header:header SEMICOLON {:
1403 ParseNode pn=new ParseNode("method_declaration",parser.lexer.line_num);
1404 pn.addChild("header").addChild(header);
1405 pn.addChild("body").addChild(new ParseNode("empty",parser.lexer.line_num));
1410 annotation_type_declaration ::=
1411 AT INTERFACE IDENTIFIER annotation_type_body
1412 | modifiers_at INTERFACE IDENTIFIER annotation_type_body
1414 annotation_type_body ::=
1415 LBRACE annotation_type_element_declarations_opt RBRACE
1417 annotation_type_element_declarations_opt ::=
1418 | annotation_type_element_declarations
1420 annotation_type_element_declarations ::=
1421 annotation_type_element_declaration
1422 | annotation_type_element_declarations annotation_type_element_declaration
1424 annotation_type_element_declaration ::=
1425 constant_declaration
1426 | modifiers_opt type IDENTIFIER LPAREN RPAREN default_value_opt SEMICOLON
1429 | interface_declaration
1434 array_initializer ::=
1435 LBRACE variable_initializers:var_init_list COMMA RBRACE {:
1436 RESULT=var_init_list;
1438 | LBRACE variable_initializers:var_init_list RBRACE {:
1439 RESULT=var_init_list;
1441 | LBRACE COMMA RBRACE {:
1442 RESULT=new ParseNode("empty",parser.lexer.line_num);
1445 RESULT=new ParseNode("empty",parser.lexer.line_num);
1448 variable_initializers ::=
1449 variable_initializer:var_init {:
1450 ParseNode pn=new ParseNode("var_init_list",parser.lexer.line_num);
1451 pn.addChild(var_init);
1454 | variable_initializers:var_init_list COMMA variable_initializer:var_init {:
1455 var_init_list.addChild(var_init);
1456 RESULT=var_init_list;
1460 // 19.11) Blocks and Statements
1461 block ::= LBRACE block_statements_opt:bso RBRACE {:
1465 block_statements_opt ::=
1466 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1467 | block_statements:bs {:
1471 block_statements ::=
1472 block_statement:bs {:
1473 ParseNode pn=new ParseNode("block_statement_list",parser.lexer.line_num);
1477 | block_statements:bss block_statement:bs {:
1483 tag_variable_declaration_statement:tvds {:
1486 | local_variable_declaration_statement:lvds {:
1489 | statement:statement {:
1492 // | enum_declaration:ed {:
1495 // | class_declaration
1496 // | interface_declaration
1498 tag_variable_declaration_statement ::=
1499 TAG IDENTIFIER:id EQ NEW TAG LPAREN IDENTIFIER:type RPAREN SEMICOLON {:
1500 ParseNode pn=new ParseNode("tag_declaration",parser.lexer.line_num);
1501 pn.addChild("single").addChild(id);
1502 pn.addChild("type").addChild(type);
1506 local_variable_declaration_statement ::=
1507 local_variable_declaration:lvd SEMICOLON {:
1511 local_variable_declaration ::=
1512 type:type variable_declarators:var {:
1513 ParseNode pn=new ParseNode("local_variable_declaration",parser.lexer.line_num);
1518 // | FINAL type:type variable_declarators:var {:
1519 /* CAUTION: only FINAL and annotations are legal modifiers here */
1520 | modifiers:mo type:type variable_declarators:var {:
1521 ParseNode pn=new ParseNode("local_variable_declaration",parser.lexer.line_num);
1524 pn.addChild("modifiers").addChild(mo);
1528 statement ::= statement_without_trailing_substatement:st {:
1531 | labeled_statement:st {: RESULT=st; :}
1532 | if_then_statement:st {: RESULT=st; :}
1533 | if_then_else_statement:st {: RESULT=st; :}
1534 | while_statement:st {: RESULT=st; :}
1535 | for_statement:st {: RESULT=st; :}
1537 statement_no_short_if ::=
1538 statement_without_trailing_substatement:st {: RESULT=st; :}
1539 | labeled_statement_no_short_if:st {: RESULT=st; :}
1540 | if_then_else_statement_no_short_if:st {: RESULT=st; :}
1541 | while_statement_no_short_if:st {: RESULT=st; :}
1542 | for_statement_no_short_if:st {: RESULT=st; :}
1544 statement_without_trailing_substatement ::=
1545 block:st {: RESULT=st; :}
1546 | empty_statement:st {: RESULT=st; :}
1547 | expression_statement:st {: RESULT=st; :}
1548 | switch_statement:st {: RESULT=st; :}
1549 | do_statement:dos {:RESULT=dos; :}
1550 | break_statement:st {: RESULT=st; :}
1551 | continue_statement:st {: RESULT=st; :}
1552 | return_statement:st {: RESULT=st; :}
1553 | task_exitstatement:st {: RESULT=st; :}
1554 | atomic_statement:st {: RESULT=st; :}
1555 | sese_statement:st {: RESULT=st; :}
1556 | synchronized_statement:st {: RESULT=st; :}
1557 | genreach_statement:st {: RESULT=st; :}
1558 | throw_statement:st {: RESULT=st; :}
1559 | try_statement:st {: RESULT=st; :}
1560 // | assert_statement
1563 SEMICOLON {: RESULT=new ParseNode("nop",parser.lexer.line_num); :}
1565 labeled_statement ::=
1566 IDENTIFIER:id COLON statement:st {:
1567 ParseNode pn=new ParseNode("labeledstatement",parser.lexer.line_num);
1568 pn.addChild("name").addChild(id);
1569 pn.addChild("statement").addChild(st);
1573 labeled_statement_no_short_if ::=
1574 IDENTIFIER:id COLON statement_no_short_if:st {:
1575 ParseNode pn=new ParseNode("labeledstatement",parser.lexer.line_num);
1576 pn.addChild("name").addChild(id);
1577 pn.addChild("statement").addChild(st);
1581 expression_statement ::=
1582 statement_expression:se SEMICOLON {:
1583 ParseNode pn=new ParseNode("expression",parser.lexer.line_num);
1587 statement_expression ::=
1588 assignment:st {: RESULT=st; :}
1589 | preincrement_expression:st {: RESULT=st; :}
1590 | predecrement_expression:st {: RESULT=st; :}
1591 | postincrement_expression:st {: RESULT=st; :}
1592 | postdecrement_expression:st {: RESULT=st; :}
1593 | method_invocation:st {: RESULT=st; :}
1594 | class_instance_creation_expression:st {: RESULT=st; :}
1596 if_then_statement ::=
1597 IF LPAREN expression:exp RPAREN statement:st {:
1598 ParseNode pn=new ParseNode("ifstatement",parser.lexer.line_num);
1599 pn.addChild("condition").addChild(exp);
1600 pn.addChild("statement").addChild(st);
1604 if_then_else_statement ::=
1605 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1606 ELSE statement:else_st {:
1607 ParseNode pn=new ParseNode("ifstatement",parser.lexer.line_num);
1608 pn.addChild("condition").addChild(exp);
1609 pn.addChild("statement").addChild(st);
1610 pn.addChild("else_statement").addChild(else_st);
1614 if_then_else_statement_no_short_if ::=
1615 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1616 ELSE statement_no_short_if:else_st {:
1617 ParseNode pn=new ParseNode("ifstatement",parser.lexer.line_num);
1618 pn.addChild("condition").addChild(exp);
1619 pn.addChild("statement").addChild(st);
1620 pn.addChild("else_statement").addChild(else_st);
1624 switch_statement ::=
1625 SWITCH LPAREN expression:exp RPAREN switch_block:body
1627 ParseNode pn=new ParseNode("switch_statement",parser.lexer.line_num);
1628 pn.addChild("condition").addChild(exp);
1629 pn.addChild("statement").addChild(body);
1634 LBRACE switch_block_statement_groups:sbsg switch_labels:sl RBRACE
1636 ParseNode pn = new ParseNode("switch_block",parser.lexer.line_num);
1637 pn.addChild("switch_labels").addChild(sl);
1638 pn.addChild("switch_statements").addChild(new ParseNode("empty",parser.lexer.line_num));
1642 | LBRACE switch_block_statement_groups:sbsg RBRACE
1646 | LBRACE switch_labels:sl RBRACE
1648 ParseNode pnb = new ParseNode("switch_block_list",parser.lexer.line_num);
1649 ParseNode pn = new ParseNode("switch_block",parser.lexer.line_num);
1650 pn.addChild("switch_labels").addChild(sl);
1651 pn.addChild("switch_statements").addChild(new ParseNode("empty",parser.lexer.line_num));
1655 | LBRACE RBRACE {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1657 switch_block_statement_groups ::=
1658 switch_block_statement_group:sbsg
1660 ParseNode pn = new ParseNode("switch_block_list",parser.lexer.line_num);
1664 | switch_block_statement_groups:sbsgs switch_block_statement_group:sbsg
1666 sbsgs.addChild(sbsg);
1670 switch_block_statement_group ::=
1671 switch_labels:sls block_statements:body
1673 ParseNode pn=new ParseNode("switch_block",parser.lexer.line_num);
1674 pn.addChild("switch_labels").addChild(sls);
1675 pn.addChild("switch_statements").addChild(body);
1682 ParseNode pn=new ParseNode("switch_label_list",parser.lexer.line_num);
1686 | switch_labels:sls switch_label:sl
1693 CASE constant_expression:ce COLON
1695 ParseNode pn=new ParseNode("switch_label",parser.lexer.line_num);
1701 RESULT=new ParseNode("default_switch_label",parser.lexer.line_num);
1706 WHILE LPAREN expression:exp RPAREN statement:st {:
1707 ParseNode pn=new ParseNode("whilestatement",parser.lexer.line_num);
1708 pn.addChild("condition").addChild(exp);
1709 pn.addChild("statement").addChild(st);
1713 while_statement_no_short_if ::=
1714 WHILE LPAREN expression:exp RPAREN statement_no_short_if:st {:
1715 ParseNode pn=new ParseNode("whilestatement",parser.lexer.line_num);
1716 pn.addChild("condition").addChild(exp);
1717 pn.addChild("statement").addChild(st);
1722 DO statement:st WHILE LPAREN expression:exp RPAREN SEMICOLON {:
1723 ParseNode pn=new ParseNode("dowhilestatement",parser.lexer.line_num);
1724 pn.addChild("condition").addChild(exp);
1725 pn.addChild("statement").addChild(st);
1730 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1731 for_update_opt:update RPAREN statement:st {:
1732 ParseNode pn=new ParseNode("forstatement",parser.lexer.line_num);
1733 pn.addChild("initializer").addChild(init);
1734 pn.addChild("condition").addChild(exp);
1735 pn.addChild("update").addChild(update);
1736 pn.addChild("statement").addChild(st);
1740 for_statement_no_short_if ::=
1741 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1742 for_update_opt:update RPAREN statement_no_short_if:st {:
1743 ParseNode pn=new ParseNode("forstatement",parser.lexer.line_num);
1744 pn.addChild("initializer").addChild(init);
1745 pn.addChild("condition").addChild(exp);
1746 pn.addChild("update").addChild(update);
1747 pn.addChild("statement").addChild(st);
1752 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1753 | for_init:init {: RESULT=init; :}
1755 for_init ::= statement_expression_list:list {: RESULT=list; :}
1756 | local_variable_declaration:decl {: RESULT=decl; :}
1759 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1760 | for_update:update {: RESULT=update; :}
1762 for_update ::= statement_expression_list:list {: RESULT=list; :}
1764 statement_expression_list ::=
1765 statement_expression:expr {:
1766 RESULT=(new ParseNode("statement_expression_list",parser.lexer.line_num)).addChild(expr).getRoot();
1768 | statement_expression_list:list COMMA statement_expression:expr {:
1769 list.addChild(expr);
1774 //identifier_opt ::=
1781 SEMICOLON {: RESULT=new ParseNode("break",parser.lexer.line_num); :}
1784 continue_statement ::=
1788 {: RESULT=new ParseNode("continue",parser.lexer.line_num); :}
1790 return_statement ::=
1791 RETURN expression_opt:exp SEMICOLON {:
1792 RESULT=(new ParseNode("return",parser.lexer.line_num)).addChild(exp).getRoot(); :}
1795 THROW expression:exp SEMICOLON {:
1796 RESULT=(new ParseNode("throwstatement",parser.lexer.line_num)).addChild(exp).getRoot();
1799 synchronized_statement ::=
1800 SYNCHRONIZED LPAREN expression:e RPAREN block:b {:
1801 ParseNode pn=new ParseNode("synchronized",parser.lexer.line_num);
1802 pn.addChild("expr").addChild(e);
1803 pn.addChild("block").addChild(b);
1807 atomic_statement ::=
1809 RESULT=(new ParseNode("atomic",parser.lexer.line_num)).addChild(blk).getRoot();
1814 ParseNode pn = new ParseNode("sese",parser.lexer.line_num);
1815 pn.addChild("body").addChild(blk);
1818 | SESE variable_declarator_id:id block:blk {:
1819 ParseNode pn = new ParseNode("sese",parser.lexer.line_num);
1820 pn.addChild("body").addChild(blk);
1821 pn.addChild("identifier").addChild(id);
1824 | RBLOCK block:blk {:
1825 ParseNode pn = new ParseNode("sese",parser.lexer.line_num);
1826 pn.addChild("body").addChild(blk);
1829 | RBLOCK variable_declarator_id:id block:blk {:
1830 ParseNode pn = new ParseNode("sese",parser.lexer.line_num);
1831 pn.addChild("body").addChild(blk);
1832 pn.addChild("identifier").addChild(id);
1837 TRY block:bk catches:ca
1839 ParseNode pn=new ParseNode("trycatchstatement",parser.lexer.line_num);
1840 pn.addChild("tryblock").addChild(bk);
1841 pn.addChild("catchblock").addChild(ca);
1844 | TRY block:bk catches_opt:ca finally:fi
1846 ParseNode pn=new ParseNode("trycatchstatement",parser.lexer.line_num);
1847 pn.addChild("tryblock").addChild(bk);
1848 pn.addChild("catchblock").addChild(ca);
1849 pn.addChild("finallyblock").addChild(fi);
1854 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1858 catches ::= catch_clause:ca
1860 ParseNode pn=new ParseNode("catchlist",parser.lexer.line_num);
1864 | catches:cas catch_clause:ca
1871 CATCH LPAREN formal_parameter:fp RPAREN block:bk
1873 ParseNode pn=new ParseNode("catchclause",parser.lexer.line_num);
1874 pn.addChild("parameter").addChild(fp);
1875 pn.addChild("block").addChild(bk);
1879 finally ::= FINALLY block:bk
1884 //assert_statement ::=
1885 // ASSERT expression SEMICOLON
1886 // | ASSERT expression COLON expression SEMICOLON
1889 // 19.12) Expressions
1890 primary ::= primary_no_new_array:st {:
1892 | array_creation_init:st {:
1895 | array_creation_uninit:st {:
1899 primary_no_new_array ::=
1900 literal:lit {: RESULT=lit; :}
1901 | THIS {: RESULT=new ParseNode("this",parser.lexer.line_num); :}
1902 | LPAREN expression:exp RPAREN {: RESULT=exp; :}
1903 | class_instance_creation_expression:exp {: RESULT=exp; :}
1904 | field_access:exp {: RESULT=exp; :}
1905 | method_invocation:exp {: RESULT=exp; :}
1906 | array_access:exp {: RESULT=exp; :}
1907 | ISAVAILABLE LPAREN IDENTIFIER:id RPAREN {:
1908 ParseNode pn=new ParseNode("isavailable",parser.lexer.line_num);
1912 // | primitive_type:pt DOT CLASS {:
1913 // ParseNode pn=new ParseNode("class_type",parser.lexer.line_num);
1918 // | array_type:at DOT CLASS {:
1919 // ParseNode pn=new ParseNode("class_type",parser.lexer.line_num);
1923 | name:name DOT CLASS {:
1924 ParseNode pn=new ParseNode("class_type",parser.lexer.line_num);
1925 pn.addChild("type").addChild("class").addChild(name);
1930 class_instance_creation_expression ::=
1931 NEWFLAG class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {:
1932 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
1938 NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {:
1939 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
1945 | GLOBAL NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {:
1946 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
1949 pn.addChild("global");
1952 | SCRATCH NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {:
1953 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
1956 pn.addChild("scratch");
1959 // Objects we want to track in disjointness analysis
1960 | DISJOINT IDENTIFIER:id NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {:
1961 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
1964 pn.addChild("disjoint").addChild(id);
1967 | NEWFLAG class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
1968 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
1974 | NEWFLAG class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE flag_list:fl RBRACE LBRACE tag_list:tl RBRACE {:
1975 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
1982 | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN class_body:body {:
1983 ParseNode pn=new ParseNode("createobjectcls",parser.lexer.line_num);
1986 pn.addChild("decl").addChild("classbody").addChild(body);
1989 // | primary DOT NEW IDENTIFIER
1990 // LPAREN argument_list_opt RPAREN {:
1993 // | primary DOT NEW IDENTIFIER
1994 // LPAREN argument_list_opt RPAREN class_body
1995 // | name DOT NEW IDENTIFIER
1996 // LPAREN argument_list_opt RPAREN
1997 // | name DOT NEW IDENTIFIER
1998 // LPAREN argument_list_opt RPAREN class_body
2000 cons_argument_list_opt ::=
2001 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
2002 | cons_argument_list:args {: RESULT=args; :}
2005 cons_argument_list ::=
2006 IDENTIFIER:id COLON expression:exp {:
2007 ParseNode pn=new ParseNode("cons_argument_list",parser.lexer.line_num);
2008 ParseNode pnarg=pn.addChild("binding");
2009 pnarg.addChild("var").addChild(id);
2010 pnarg.addChild("exp").addChild(exp);
2013 | argument_list:list COMMA IDENTIFIER:id COLON expression:exp {:
2014 ParseNode pnarg=new ParseNode("binding",parser.lexer.line_num);
2015 pnarg.addChild("var").addChild(id);
2016 pnarg.addChild("exp").addChild(exp);
2017 list.addChild(pnarg);
2022 argument_list_opt ::=
2023 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
2024 | argument_list:args {: RESULT=args; :}
2029 ParseNode pn=new ParseNode("argument_list",parser.lexer.line_num);
2033 | argument_list:list COMMA expression:exp {:
2038 array_creation_uninit ::=
2039 NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
2040 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2042 pn.addChild(dimexpr);
2043 pn.addChild("dims_opt").setLiteral(dims);
2046 | NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
2047 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2049 pn.addChild(dimexpr);
2050 pn.addChild("dims_opt").setLiteral(dims);
2053 | GLOBAL NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
2054 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2056 pn.addChild(dimexpr);
2057 pn.addChild("dims_opt").setLiteral(dims);
2058 pn.addChild("global");
2061 | SCRATCH NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
2062 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2064 pn.addChild(dimexpr);
2065 pn.addChild("dims_opt").setLiteral(dims);
2066 pn.addChild("scratch");
2069 | DISJOINT IDENTIFIER:id NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
2070 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2072 pn.addChild(dimexpr);
2073 pn.addChild("dims_opt").setLiteral(dims);
2074 pn.addChild("disjoint").addChild(id);
2077 | GLOBAL NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
2078 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2080 pn.addChild(dimexpr);
2081 pn.addChild("dims_opt").setLiteral(dims);
2082 pn.addChild("global");
2085 | SCRATCH NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
2086 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2088 pn.addChild(dimexpr);
2089 pn.addChild("dims_opt").setLiteral(dims);
2090 pn.addChild("scratch");
2093 | DISJOINT IDENTIFIER:id NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
2094 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2096 pn.addChild(dimexpr);
2097 pn.addChild("dims_opt").setLiteral(dims);
2098 pn.addChild("disjoint").addChild(id);
2102 array_creation_init ::=
2103 NEW primitive_type:type dims:dims array_initializer:ai {:
2104 ParseNode pn=new ParseNode("createarray2",parser.lexer.line_num);
2106 pn.addChild("dims_opt").setLiteral(dims);
2107 pn.addChild("initializer").addChild(ai);
2110 | NEW class_or_interface_type:type dims:dims array_initializer:ai {:
2111 ParseNode pn=new ParseNode("createarray2",parser.lexer.line_num);
2113 pn.addChild("dims_opt").setLiteral(dims);
2114 pn.addChild("initializer").addChild(ai);
2118 dim_exprs ::= dim_expr:exp {:
2119 ParseNode pn=new ParseNode("dim_exprs",parser.lexer.line_num);
2122 | dim_exprs:base dim_expr:exp {:
2127 dim_expr ::= LBRACK expression:exp RBRACK {: RESULT=exp; :}
2129 dims_opt ::= {: RESULT=new Integer(0); :}
2130 | dims:dims {: RESULT = dims; :}
2133 dims ::= LBRACK RBRACK {: RESULT=new Integer(1); :}
2134 | dims:dims LBRACK RBRACK {: RESULT=new Integer(dims.intValue()+1); :}
2138 primary:base DOT IDENTIFIER:id {:
2139 ParseNode pn=new ParseNode("fieldaccess",parser.lexer.line_num);
2140 pn.addChild("base").addChild(base);
2141 pn.addChild("field").addChild(id);
2144 // | SUPER DOT IDENTIFIER
2145 // | name DOT SUPER DOT IDENTIFIER
2147 method_invocation ::=
2148 name:name LPAREN argument_list_opt:args RPAREN {:
2149 ParseNode pn=new ParseNode("methodinvoke1",parser.lexer.line_num);
2154 | primary:base DOT IDENTIFIER:name LPAREN argument_list_opt:args RPAREN {:
2155 ParseNode pn=new ParseNode("methodinvoke2",parser.lexer.line_num);
2156 pn.addChild("base").addChild(base);
2157 pn.addChild("id").addChild(name);
2161 | SUPER DOT IDENTIFIER:id LPAREN argument_list_opt:args RPAREN {:
2162 ParseNode name=new ParseNode("name",parser.lexer.line_num);
2163 name.addChild("base").addChild("name").addChild("identifier").addChild("super");
2164 name.addChild("identifier").addChild(id);
2165 ParseNode pn=new ParseNode("methodinvoke1",parser.lexer.line_num);
2170 // | name DOT SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
2173 name:name LBRACK expression:exp RBRACK {:
2174 ParseNode pn=new ParseNode("arrayaccess",parser.lexer.line_num);
2175 pn.addChild("base").addChild(name);
2176 pn.addChild("index").addChild(exp);
2179 | primary_no_new_array:base LBRACK expression:exp RBRACK {:
2180 ParseNode pn=new ParseNode("arrayaccess",parser.lexer.line_num);
2181 pn.addChild("base").addChild(base);
2182 pn.addChild("index").addChild(exp);
2185 // | array_creation_init:init LBRACK expression:exp RBRACK {:
2186 // ParseNode pn=new ParseNode("arrayaccess",parser.lexer.line_num);
2187 // pn.addChild("init").addChild(init);
2188 // pn.addChild("index").addChild(exp);
2193 postfix_expression ::=
2196 | name:exp {: RESULT=exp; :}
2197 | postincrement_expression:exp {: RESULT=exp; :}
2198 | postdecrement_expression:exp {: RESULT=exp; :}
2200 postincrement_expression ::=
2201 postfix_expression:exp PLUSPLUS
2202 {: RESULT=(new ParseNode("postinc",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2204 postdecrement_expression ::=
2205 postfix_expression:exp MINUSMINUS
2206 {: RESULT=(new ParseNode("postdec",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2208 unary_expression ::=
2209 preincrement_expression:exp {: RESULT=exp; :}
2210 | predecrement_expression:exp {: RESULT=exp; :}
2211 | PLUS unary_expression:exp
2212 {: RESULT=(new ParseNode("unaryplus",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2213 | MINUS unary_expression:exp
2214 {: RESULT=(new ParseNode("unaryminus",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2215 | unary_expression_not_plus_minus:exp {:
2218 preincrement_expression ::=
2219 PLUSPLUS unary_expression:exp
2220 {: RESULT=(new ParseNode("preinc",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2222 predecrement_expression ::=
2223 MINUSMINUS unary_expression:exp
2224 {: RESULT=(new ParseNode("predec",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2226 unary_expression_not_plus_minus ::=
2227 postfix_expression:exp {:
2229 | COMP unary_expression:exp
2230 {: RESULT=(new ParseNode("comp",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2231 | NOT unary_expression:exp
2232 {: RESULT=(new ParseNode("not",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2233 | cast_expression:exp {: RESULT=exp; :}
2236 LPAREN primitive_type:type dims_opt:dims
2237 RPAREN unary_expression:exp {:
2238 ParseNode pn=new ParseNode("cast1",parser.lexer.line_num);
2239 if (dims.intValue()==0)
2240 pn.addChild("type").addChild(type);
2242 ParseNode arrayt=pn.addChild("type").addChild("type").addChild("array");
2243 arrayt.addChild("basetype").addChild(type);
2244 arrayt.addChild("dims").setLiteral(dims);
2246 pn.addChild("exp").addChild(exp);
2249 | LPAREN expression:type RPAREN unary_expression_not_plus_minus:exp {:
2250 ParseNode pn=new ParseNode("cast2",parser.lexer.line_num);
2251 pn.addChild("type").addChild(type);
2252 pn.addChild("exp").addChild(exp);
2256 | LPAREN name:name dims:dims RPAREN unary_expression_not_plus_minus:exp {:
2257 ParseNode pn=new ParseNode("cast1",parser.lexer.line_num);
2258 if (dims.intValue()==0)
2259 pn.addChild("type").addChild("class").addChild(name);
2261 ParseNode arrayt=pn.addChild("type").addChild("type").addChild("array");
2262 arrayt.addChild("basetype").addChild("type").addChild("class").addChild(name);
2263 arrayt.addChild("dims").setLiteral(dims);
2265 pn.addChild("exp").addChild(exp);
2270 multiplicative_expression ::=
2271 unary_expression:exp {:
2273 | multiplicative_expression:exp1 MULT unary_expression:exp2 {:
2274 ParseNode pn=new ParseNode("mult",parser.lexer.line_num);
2279 | multiplicative_expression:exp1 DIV unary_expression:exp2 {:
2280 ParseNode pn=new ParseNode("div",parser.lexer.line_num);
2285 | multiplicative_expression:exp1 MOD unary_expression:exp2 {:
2286 ParseNode pn=new ParseNode("mod",parser.lexer.line_num);
2292 additive_expression ::=
2293 multiplicative_expression:exp {:
2295 | additive_expression:exp1 PLUS multiplicative_expression:exp2 {:
2296 ParseNode pn=new ParseNode("add",parser.lexer.line_num);
2301 | additive_expression:exp1 MINUS multiplicative_expression:exp2 {:
2302 ParseNode pn=new ParseNode("sub",parser.lexer.line_num);
2308 shift_expression ::=
2309 additive_expression:exp {:
2311 | shift_expression:exp1 LSHIFT additive_expression:exp2 {:
2312 ParseNode pn=new ParseNode("leftshift",parser.lexer.line_num);
2317 | shift_expression:exp1 RSHIFT additive_expression:exp2 {:
2318 ParseNode pn=new ParseNode("rightshift",parser.lexer.line_num);
2323 | shift_expression:exp1 URSHIFT additive_expression:exp2 {:
2324 ParseNode pn=new ParseNode("urightshift",parser.lexer.line_num);
2330 relational_expression ::=
2331 shift_expression:exp {:
2333 | relational_expression:exp1 LT shift_expression:exp2 {:
2334 ParseNode pn=new ParseNode("comp_lt",parser.lexer.line_num);
2339 | relational_expression:exp1 GT shift_expression:exp2 {:
2340 ParseNode pn=new ParseNode("comp_gt",parser.lexer.line_num);
2345 | relational_expression:exp1 LTEQ shift_expression:exp2 {:
2346 ParseNode pn=new ParseNode("comp_lte",parser.lexer.line_num);
2351 | relational_expression:exp1 GTEQ shift_expression:exp2 {:
2352 ParseNode pn=new ParseNode("comp_gte",parser.lexer.line_num);
2357 | relational_expression:exp INSTANCEOF reference_type:type {:
2358 ParseNode pn=new ParseNode("instanceof",parser.lexer.line_num);
2359 pn.addChild("exp").addChild(exp);
2365 equality_expression ::=
2366 relational_expression:exp {:
2368 | equality_expression:exp1 EQEQ relational_expression:exp2 {:
2369 ParseNode pn=new ParseNode("equal",parser.lexer.line_num);
2374 | equality_expression:exp1 NOTEQ relational_expression:exp2 {:
2375 ParseNode pn=new ParseNode("not_equal",parser.lexer.line_num);
2382 equality_expression:exp {:
2384 | and_expression:exp1 AND equality_expression:exp2 {:
2385 ParseNode pn=new ParseNode("bitwise_and",parser.lexer.line_num);
2391 exclusive_or_expression ::=
2392 and_expression:expr {:
2395 | exclusive_or_expression:exp1 XOR and_expression:exp2 {:
2396 ParseNode pn=new ParseNode("bitwise_xor",parser.lexer.line_num);
2402 inclusive_or_expression ::=
2403 exclusive_or_expression:exclor {:
2405 | inclusive_or_expression:exp1 OR exclusive_or_expression:exp2 {:
2406 ParseNode pn=new ParseNode("bitwise_or",parser.lexer.line_num);
2412 conditional_and_expression ::=
2413 inclusive_or_expression:inclor {:
2415 | conditional_and_expression:exp1 ANDAND inclusive_or_expression:exp2 {:
2416 ParseNode pn=new ParseNode("logical_and",parser.lexer.line_num);
2422 conditional_or_expression ::=
2423 conditional_and_expression:condand {:
2425 | conditional_or_expression:exp1 OROR conditional_and_expression:exp2 {:
2426 ParseNode pn=new ParseNode("logical_or",parser.lexer.line_num);
2432 conditional_expression ::=
2433 conditional_or_expression:condor {:
2435 | conditional_or_expression:condor QUESTION expression:exptrue
2436 COLON conditional_expression:expfalse {:
2437 ParseNode pn=new ParseNode("tert",parser.lexer.line_num);
2438 pn.addChild("cond").addChild(condor);
2439 pn.addChild("trueexpr").addChild(exptrue);
2440 pn.addChild("falseexpr").addChild(expfalse);
2444 getoffset_expression ::=
2445 GETOFFSET LBRACE class_or_interface_type:type COMMA IDENTIFIER:id RBRACE {:
2446 ParseNode pn = new ParseNode("getoffset",parser.lexer.line_num);
2448 pn.addChild("field").addChild(id);
2453 assignment_expression ::=
2454 conditional_expression:expr {:
2456 assignment:assign {:
2458 getoffset_expression:expr {:
2461 // semantic check necessary here to ensure a valid left-hand side.
2462 // allowing a parenthesized variable here on the lhs was introduced in
2463 // JLS 2; thanks to Eric Blake for pointing this out.
2464 assignment ::= postfix_expression:lvalue assignment_operator:op assignment_expression:rvalue {:
2465 ParseNode pn=new ParseNode("assignment",parser.lexer.line_num);
2466 pn.addChild("op").addChild(op);
2467 ParseNode pnargs=pn.addChild("args");
2468 pnargs.addChild(lvalue);
2469 pnargs.addChild(rvalue);
2473 assignment_operator ::=
2474 EQ {: RESULT=new ParseNode("eq",parser.lexer.line_num); :}
2475 | MULTEQ {: RESULT=new ParseNode("multeq",parser.lexer.line_num); :}
2476 | DIVEQ {: RESULT=new ParseNode("diveq",parser.lexer.line_num); :}
2477 | MODEQ {: RESULT=new ParseNode("modeq",parser.lexer.line_num); :}
2478 | PLUSEQ {: RESULT=new ParseNode("pluseq",parser.lexer.line_num); :}
2479 | MINUSEQ {: RESULT=new ParseNode("minuseq",parser.lexer.line_num); :}
2480 | LSHIFTEQ {: RESULT=new ParseNode("lshifteq",parser.lexer.line_num); :}
2481 | RSHIFTEQ {: RESULT=new ParseNode("rshifteq",parser.lexer.line_num); :}
2482 | URSHIFTEQ {: RESULT=new ParseNode("urshifteq",parser.lexer.line_num); :}
2483 | ANDEQ {: RESULT=new ParseNode("andeq",parser.lexer.line_num); :}
2484 | XOREQ {: RESULT=new ParseNode("xoreq",parser.lexer.line_num); :}
2485 | OREQ {: RESULT=new ParseNode("oreq",parser.lexer.line_num); :}
2488 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
2492 expression ::= assignment_expression:exp {:
2495 // note that this constraint must be enforced during semantic checking
2496 // 'constant_expression' should include enumerated constants.
2497 constant_expression ::=
2500 ParseNode pn = new ParseNode("constant_expression",parser.lexer.line_num);
2507 genreach_statement ::=
2508 GENREACH IDENTIFIER:graphName SEMICOLON {:
2509 ParseNode pn=new ParseNode("genreach",parser.lexer.line_num);
2510 pn.addChild("graphName").addChild(graphName);