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
111 terminal GEN_DEF_REACH;
114 // 19.2) The Syntactic Grammar
115 non terminal ParseNode goal;
116 // 19.3) Lexical Structure
117 non terminal ParseNode literal;
118 // 19.4) Types, Values, and Variables
119 non terminal ParseNode type, primitive_type, numeric_type;
120 non terminal ParseNode integral_type, floating_point_type;
121 non terminal ParseNode reference_type;
122 non terminal ParseNode class_or_interface_type;
123 non terminal ParseNode class_type;
124 non terminal ParseNode interface_type;
125 non terminal ParseNode array_type;
127 non terminal ParseNode name, simple_name, qualified_name;
129 non terminal ParseNode compilation_unit;
130 non terminal ParseNode package_declaration_opt, package_declaration;
131 non terminal ParseNode import_declarations_opt, import_declarations;
132 non terminal ParseNode type_declarations_opt, type_declarations;
133 non terminal ParseNode import_declaration;
134 non terminal ParseNode single_type_import_declaration;
135 non terminal ParseNode type_import_on_demand_declaration;
136 non terminal ParseNode type_declaration;
137 // 19.7) Productions used only in the LALR(1) grammar
138 non terminal ParseNode modifiers_opt, modifiers, modifiers_at, modifier;
139 non terminal ParseNode mixed_modifiers, mixed_modifiers_at;
140 // 19.8.1) Class Declaration
141 non terminal ParseNode class_declaration, super, super_opt;
142 non terminal ParseNode interfaces, interfaces_opt, interface_type_list;
143 non terminal ParseNode class_body;
144 non terminal ParseNode class_body_declarations, class_body_declarations_opt;
145 non terminal ParseNode class_body_declaration, class_member_declaration;
146 // 19.8.2) Field Declarations
147 non terminal ParseNode field_declaration, variable_declarators, variable_declarator;
148 non terminal ParseNode variable_declarator_id;
149 non terminal ParseNode variable_initializer;
150 // 19.8.3) Method Declarations
151 non terminal ParseNode method_declaration, method_header, method_declarator;
152 non terminal ParseNode formal_parameter_list_opt, formal_parameter_list;
153 non terminal ParseNode formal_parameter;
154 non terminal ParseNode throws_opt;
155 non terminal ParseNode throws;
156 non terminal ParseNode class_type_list;
157 non terminal ParseNode method_body;
158 // 19.8.4) Static Initializers
159 non terminal ParseNode static_initializer;
160 // 19.8.5) Constructor Declarations
161 non terminal ParseNode constructor_declaration, constructor_declarator;
162 non terminal ParseNode constructor_body;
163 non terminal ParseNode explicit_constructor_invocation;
164 // 19.9.1) Interface Declarations
165 non terminal ParseNode interface_declaration;
166 //non terminal ParseNode normal_interface_declaration
167 non terminal ParseNode 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 non terminal ParseNode gen_def_reach_statement;
209 // 19.12) Expressions
210 non terminal ParseNode primary, primary_no_new_array;
211 non terminal ParseNode class_instance_creation_expression;
212 non terminal ParseNode cons_argument_list_opt, cons_argument_list;
213 non terminal ParseNode argument_list_opt, argument_list;
214 non terminal ParseNode array_creation_init;
215 non terminal ParseNode array_creation_uninit;
216 non terminal ParseNode dim_exprs, dim_expr;
217 non terminal Integer dims_opt, dims;
218 non terminal ParseNode field_access, method_invocation;
219 non terminal ParseNode array_access;
220 non terminal ParseNode postfix_expression;
221 non terminal ParseNode postincrement_expression, postdecrement_expression;
222 non terminal ParseNode unary_expression, unary_expression_not_plus_minus;
223 non terminal ParseNode preincrement_expression, predecrement_expression;
224 non terminal ParseNode cast_expression;
225 non terminal ParseNode multiplicative_expression, additive_expression;
226 non terminal ParseNode shift_expression, relational_expression, equality_expression;
227 non terminal ParseNode and_expression, exclusive_or_expression, inclusive_or_expression;
228 non terminal ParseNode conditional_and_expression, conditional_or_expression;
229 non terminal ParseNode conditional_expression;
230 non terminal ParseNode assignment_expression;
231 non terminal ParseNode assignment;
232 non terminal ParseNode assignment_operator;
233 non terminal ParseNode expression_opt, expression;
234 non terminal ParseNode constant_expression;
235 //failure aware computation keywords
238 terminal ISAVAILABLE;
243 non terminal ParseNode flag_declaration;
244 non terminal ParseNode task_declaration;
245 non terminal ParseNode task_parameter_list;
246 non terminal ParseNode task_parameter;
247 non terminal ParseNode flag_expression;
248 non terminal ParseNode flag_andexpression;
249 non terminal ParseNode flag_notexpression;
250 non terminal ParseNode task_exitstatement;
251 non terminal ParseNode flag_effects_opt;
252 non terminal ParseNode flag_effects;
253 non terminal ParseNode flag_effect;
254 non terminal ParseNode flag_list;
255 non terminal ParseNode flag_list_opt;
256 non terminal ParseNode flag_change;
258 non terminal ParseNode cons_checks_opt;
259 non terminal ParseNode cons_checks;
260 non terminal ParseNode cons_check;
262 non terminal ParseNode tag_variable_declaration_statement;
263 non terminal ParseNode tag_expression_list;
264 non terminal ParseNode tag_expression;
265 non terminal ParseNode tag_list;
266 non terminal ParseNode tag_list_opt;
267 non terminal ParseNode tag_change;
269 //distributed transaction keywords
274 non terminal ParseNode atomic_statement;
275 non terminal ParseNode getoffset_expression;
277 //disjointness for Java
280 //coarse-grain parallelization
283 non terminal ParseNode sese_statement;
286 // JSR-201) Enum Declaration
287 non terminal ParseNode enum_declaration;
288 non terminal ParseNode enum_body, enum_constants_opt, enum_constants, enum_constant;
289 //non terminal ParseNode enum_arguments_opt, enum_body_declarations_opt;
291 // annotation expressions
292 // non terminal ParseNode annotations_opt,
293 non terminal ParseNode annotations, annotations_at, annotation, annotation_body;
294 non terminal ParseNode normal_annotation_body, marker_annotation_body;
295 non terminal ParseNode single_element_annotation_body;
296 non terminal ParseNode annotation_type_body, annotation_type_element_declarations;
297 non terminal ParseNode annotation_type_element_declarations_opt;
298 non terminal ParseNode annotation_type_element_declaration, default_value_opt, default_value;
299 non terminal ParseNode element_value_pairs_opt, element_value_pairs, element_value_pair;
300 non terminal ParseNode element_values_opt, element_values, element_value, element_value_array_initializer;
307 TASK IDENTIFIER:id LPAREN task_parameter_list:tpl RPAREN
311 ParseNode pn=new ParseNode("task_declaration",parser.lexer.line_num);
312 pn.addChild("name").addChild(id);
315 pn.addChild("body").addChild(body);
319 task_parameter_list ::=
321 ParseNode pn=new ParseNode("task_parameter_list",parser.lexer.line_num);
325 | task_parameter_list:fpl COMMA task_parameter:fp {:
332 type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE {:
333 ParseNode pn=new ParseNode("task_parameter",parser.lexer.line_num);
336 pn.addChild("flag").addChild(exp);
339 | type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE LBRACE tag_expression_list:texp RBRACE {:
340 ParseNode pn=new ParseNode("task_parameter",parser.lexer.line_num);
343 pn.addChild("flag").addChild(exp);
344 pn.addChild("tag").addChild(texp);
347 | type:type variable_declarator_id:name LBRACE RBRACE LBRACE tag_expression_list:texp RBRACE {:
348 ParseNode pn=new ParseNode("task_parameter",parser.lexer.line_num);
351 pn.addChild("tag").addChild(texp);
354 | OPTIONAL task_parameter:fp {:
355 ParseNode pn=new ParseNode("task_parameter",parser.lexer.line_num);
356 pn.addChild("optional").addChild(fp);
362 tag_expression_list ::= tag_expression:te {:
363 ParseNode pn=new ParseNode("tag_expression_list",parser.lexer.line_num);
367 | tag_expression_list:tel COMMA tag_expression:te {:
373 tag_expression ::= IDENTIFIER:type IDENTIFIER:id {:
374 ParseNode pn=new ParseNode("tag_expression",parser.lexer.line_num);
375 pn.addChild("type").addChild(type);
376 pn.addChild("single").addChild(id);
381 tag_list_opt ::= LBRACE tag_list:fl RBRACE {:RESULT=fl;:}
382 | LBRACE RBRACE {: RESULT = new ParseNode("empty",parser.lexer.line_num); :}
383 | {: RESULT = new ParseNode("empty",parser.lexer.line_num); :}
386 tag_list ::= tag_change:fc {:
387 ParseNode pn=new ParseNode("tag_list",parser.lexer.line_num);
391 | tag_list:fl COMMA tag_change:fc {:
396 tag_change ::= IDENTIFIER:id {:
397 RESULT=new ParseNode("name",parser.lexer.line_num).addChild(id).getRoot();
399 | NOT IDENTIFIER:id {:
400 RESULT=new ParseNode("not",parser.lexer.line_num).addChild("name").addChild(id).getRoot();
404 flag_andexpression:exp {:
407 | flag_expression:exp1 OROR flag_andexpression:exp2 {:
408 ParseNode pn=new ParseNode("or",parser.lexer.line_num);
415 flag_andexpression ::=
416 flag_notexpression:exp {: RESULT=exp; :}
417 | flag_notexpression:exp1 ANDAND flag_andexpression:exp2 {:
418 ParseNode pn=new ParseNode("and",parser.lexer.line_num);
425 flag_notexpression ::=
426 NOT flag_notexpression:exp {:
427 ParseNode pn=new ParseNode("not",parser.lexer.line_num);
431 | LPAREN flag_expression:exp RPAREN {:
435 ParseNode pn=new ParseNode("name",parser.lexer.line_num);
441 task_exitstatement ::= TASKEXIT flag_effects_opt:opt cons_checks_opt:cco SEMICOLON {:
442 RESULT=(new ParseNode("taskexit",parser.lexer.line_num)).addChild(opt).getRoot().addChild(cco).getRoot();
445 cons_checks_opt ::= ASSERT LPAREN cons_checks:cc RPAREN {: RESULT=cc; :}
446 | {: RESULT = new ParseNode("empty",parser.lexer.line_num); :}
449 cons_checks ::= cons_check:cc {:
450 ParseNode pn=new ParseNode("cons_checks",parser.lexer.line_num);
454 | cons_checks:ccs COMMA cons_check:cc {:
459 cons_check ::= IDENTIFIER:name LPAREN cons_argument_list_opt:args RPAREN {:
460 ParseNode pn=new ParseNode("cons_check",parser.lexer.line_num);
461 pn.addChild("name").addChild("identifier").addChild(name);
466 flag_effects_opt ::= LPAREN flag_effects:fe RPAREN {:RESULT=fe;:}
467 | {: RESULT = new ParseNode("empty",parser.lexer.line_num); :}
470 flag_effects ::= flag_effect:fe {:
471 ParseNode pn=new ParseNode("flag_effects_list",parser.lexer.line_num);
475 | flag_effects:fes COMMA flag_effect:fe {:
480 flag_effect ::= IDENTIFIER:id LBRACE flag_list:fl RBRACE tag_list_opt:tlo {:
481 ParseNode pn=new ParseNode("flag_effect",parser.lexer.line_num);
482 pn.addChild("name").addChild(id);
487 | IDENTIFIER:id LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
488 ParseNode pn=new ParseNode("flag_effect",parser.lexer.line_num);
489 pn.addChild("name").addChild(id);
494 flag_list_opt ::= LBRACE flag_list:fl RBRACE {:RESULT=fl;:}
495 | LBRACE RBRACE {: RESULT = new ParseNode("empty",parser.lexer.line_num); :}
497 {: RESULT = new ParseNode("empty",parser.lexer.line_num); :}
500 flag_list ::= flag_change:fc {:
501 ParseNode pn=new ParseNode("flag_list",parser.lexer.line_num);
505 | flag_list:fl COMMA flag_change:fc {:
510 flag_change ::= IDENTIFIER:id {:
511 RESULT=new ParseNode("name",parser.lexer.line_num).addChild(id).getRoot();
514 RESULT=new ParseNode("not",parser.lexer.line_num).addChild("name").addChild(id).getRoot();
517 // 19.2) The Syntactic Grammar
518 goal ::= compilation_unit:cu
524 // 19.3) Lexical Structure.
527 literal ::= INTEGER_LITERAL:integer_lit
529 ParseNode pn=new ParseNode("literal",parser.lexer.line_num);
530 pn.addChild("integer").setLiteral(integer_lit);
533 | FLOATING_POINT_LITERAL:float_lit
535 ParseNode pn=new ParseNode("literal",parser.lexer.line_num);
536 pn.addChild("float").setLiteral(float_lit);
539 | BOOLEAN_LITERAL:boolean_lit
541 ParseNode pn=new ParseNode("literal",parser.lexer.line_num);
542 pn.addChild("boolean").setLiteral(boolean_lit);
545 | CHARACTER_LITERAL:char_lit
547 ParseNode pn=new ParseNode("literal",parser.lexer.line_num);
548 pn.addChild("char").setLiteral(char_lit);
551 | STRING_LITERAL:string_lit
553 ParseNode pn=new ParseNode("literal",parser.lexer.line_num);
554 pn.addChild("string").setLiteral(string_lit);
559 RESULT=(new ParseNode("literal",parser.lexer.line_num)).addChild("null").getRoot();
563 // 19.4) Types, Values, and Variables
564 type ::= primitive_type:type {: RESULT=type; :}
565 | reference_type:type {: RESULT=type; :}
569 numeric_type:type {: RESULT=type; :}
570 | BOOLEAN {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("boolean").getRoot(); :}
572 numeric_type::= integral_type:type {: RESULT=type; :}
573 | floating_point_type:type {: RESULT=type; :}
576 BYTE {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("byte").getRoot(); :}
577 | SHORT {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("short").getRoot(); :}
578 | INT {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("int").getRoot(); :}
579 | LONG {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("long").getRoot(); :}
580 | CHAR {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("char").getRoot(); :}
582 floating_point_type ::=
583 FLOAT {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("float").getRoot(); :}
584 | DOUBLE {: RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("double").getRoot(); :}
588 class_or_interface_type:type {: RESULT=type; :}
589 | array_type:type {: RESULT=type; :}
591 class_or_interface_type ::= name:name {:
592 RESULT=(new ParseNode("type",parser.lexer.line_num)).addChild("class").addChild(name).getRoot();
595 class_type ::= class_or_interface_type:type {: RESULT=type; :};
596 interface_type ::= class_or_interface_type:type {: RESULT=type; :};
598 array_type ::= primitive_type:prim dims:dims {:
599 ParseNode pn=(new ParseNode("type",parser.lexer.line_num)).addChild("array");
600 pn.addChild("basetype").addChild(prim);
601 pn.addChild("dims").setLiteral(dims);
604 | name:name dims:dims {:
605 ParseNode pn=(new ParseNode("type",parser.lexer.line_num)).addChild("array");
606 pn.addChild("basetype").addChild("type").addChild("class").addChild(name);
607 pn.addChild("dims").setLiteral(dims);
613 name ::= simple_name:name {: RESULT=name; :}
614 | qualified_name:name {: RESULT=name; :}
616 simple_name ::= IDENTIFIER:id {:
617 RESULT=(new ParseNode("name",parser.lexer.line_num)).addChild("identifier").addChild(id).getRoot();
620 qualified_name ::= name:name DOT IDENTIFIER:id {:
621 ParseNode pn=new ParseNode("name",parser.lexer.line_num);
622 pn.addChild("base").addChild(name);
623 pn.addChild("identifier").addChild(id);
630 package_declaration_opt:pdo
631 import_declarations_opt:ido
632 type_declarations_opt:tdo {:
633 ParseNode pn=new ParseNode("compilation_unit",parser.lexer.line_num);
635 pn.addChild("packages").addChild(pdo);
636 pn.addChild("imports").addChild(ido);
640 package_declaration_opt ::= package_declaration:pdo {:
643 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
646 import_declarations_opt ::= import_declarations:ido {:
649 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
651 type_declarations_opt ::= type_declarations:tds {:
654 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
657 import_declarations ::=
658 import_declaration:id {:
659 ParseNode pn=new ParseNode("import_decls_list",parser.lexer.line_num);
663 | import_declarations:ids import_declaration:id {:
669 type_declarations ::=
670 type_declaration:td {:
671 ParseNode pn=new ParseNode("type_declaration_list",parser.lexer.line_num);
675 | type_declarations:tds type_declaration:td {:
681 package_declaration ::=
682 PACKAGE name:name SEMICOLON {:
683 ParseNode pn=new ParseNode("package",parser.lexer.line_num);
688 import_declaration ::=
689 single_type_import_declaration:sid {: RESULT=sid; :}
690 | type_import_on_demand_declaration:iod {: RESULT=iod; :}
692 single_type_import_declaration ::=
693 IMPORT name:name SEMICOLON {:
694 ParseNode pn=new ParseNode("import_single",parser.lexer.line_num);
699 type_import_on_demand_declaration ::=
700 IMPORT name:name DOT MULT SEMICOLON {:
701 ParseNode pn=new ParseNode("import_ondemand",parser.lexer.line_num);
712 | enum_declaration:ed
716 | task_declaration:td
720 | interface_declaration:in
724 | SEMICOLON {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
727 // 19.7) Productions used only in the LALR(1) grammar
729 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
738 modifiers ::= mixed_modifiers : mmo {:
741 | annotations : an {:
742 ParseNode pn=new ParseNode("modifier_list",parser.lexer.line_num);
747 mixed_modifiers_at ::=
748 mixed_modifiers : mmos AT {:
754 ParseNode pn=new ParseNode("modifier_list",parser.lexer.line_num);
758 | annotations:as modifier:mo {:
759 ParseNode pn=new ParseNode("modifier_list",parser.lexer.line_num);
764 | mixed_modifiers : mmos modifier : mo {:
768 | mixed_modifiers_at:mma annotation_body:ab {:
769 mma.addChild("annotation_list",parser.lexer.line_num).addChild(ab);
774 PUBLIC {: RESULT=new ParseNode("public",parser.lexer.line_num); :}|
775 PROTECTED {: RESULT=new ParseNode("protected",parser.lexer.line_num); :}|
776 PRIVATE {: RESULT=new ParseNode("private",parser.lexer.line_num); :}|
777 STATIC {: RESULT=new ParseNode("static",parser.lexer.line_num); :} |
778 ABSTRACT {: RESULT=new ParseNode("abstract",parser.lexer.line_num); :} |
779 FINAL {: RESULT=new ParseNode("final",parser.lexer.line_num); :}|
780 NATIVE {: RESULT=new ParseNode("native",parser.lexer.line_num); :} |
781 SYNCHRONIZED {: RESULT=new ParseNode("synchronized",parser.lexer.line_num); :} |
782 ATOMIC {: RESULT=new ParseNode("atomic",parser.lexer.line_num); :} |
783 VOLATILE {: RESULT=new ParseNode("volatile",parser.lexer.line_num); :} |
784 TRANSIENT {: RESULT=new ParseNode("transient",parser.lexer.line_num); :}
786 // STRICTFP // note that semantic analysis must check that the
787 // context of the modifier allows strictfp.
789 //annotations_opt ::=
790 // {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
791 // | annotations:an {:
796 AT annotation_body:ab {:
797 ParseNode pn=new ParseNode("annotation_list",parser.lexer.line_num);
801 | annotations_at:aat annotation_body:ab {:
812 AT annotation_body:ab {:
817 normal_annotation_body:nab {:
818 ParseNode pn=new ParseNode("annotation_body",parser.lexer.line_num);
822 | marker_annotation_body:mab {:
823 ParseNode pn=new ParseNode("annotation_body",parser.lexer.line_num);
827 | single_element_annotation_body:seab {:
828 ParseNode pn=new ParseNode("annotation_body",parser.lexer.line_num);
833 normal_annotation_body ::=
834 IDENTIFIER LPAREN element_value_pairs_opt RPAREN
836 marker_annotation_body ::=
839 ParseNode pn=new ParseNode("marker_annotation",parser.lexer.line_num);
840 pn.addChild("name").addChild(id);
844 single_element_annotation_body ::=
845 IDENTIFIER:id LPAREN STRING_LITERAL:ev RPAREN {:
846 ParseNode pn=new ParseNode("single_annotation",parser.lexer.line_num);
847 pn.addChild("name").addChild(id);
848 pn.addChild("element_value").addChild(ev);
852 element_value_pairs_opt ::=
853 | element_value_pairs
855 element_value_pairs ::=
857 | element_value_pairs COMMA element_value_pair
859 element_value_pair ::=
860 IDENTIFIER EQ element_value
866 | element_value_array_initializer:evai {:
869 | conditional_expression:ce {:
873 element_value_array_initializer ::=
874 LBRACE element_values_opt RBRACE
876 element_values_opt ::=
881 | element_values COMMA element_value
885 // 19.8.1) Class Declaration:
886 class_declaration ::=
887 modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so interfaces_opt:ifo
890 ParseNode pn=new ParseNode("class_declaration",parser.lexer.line_num);
891 pn.addChild("modifiers").addChild(mo);
892 pn.addChild("name").addChild(id);
893 pn.addChild("super").addChild(so);
894 pn.addChild("superIF").addChild(ifo);
895 pn.addChild("classbody").addChild(body);
899 super ::= EXTENDS class_type:classtype {:
904 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
910 interfaces ::= IMPLEMENTS interface_type_list:iftl {: RESULT=iftl; :}
913 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
914 | interfaces:ifs {: RESULT=ifs; :}
916 interface_type_list ::=
917 interface_type:ift {:
918 ParseNode pn=new ParseNode("interface_type_list",parser.lexer.line_num);
922 | interface_type_list:iftl COMMA interface_type:ift {:
928 class_body ::= LBRACE class_body_declarations_opt:cbdo RBRACE {: RESULT=cbdo; :}
931 class_body_declarations_opt ::=
932 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
933 | class_body_declarations:cbd {: RESULT=cbd; :};
935 class_body_declarations ::=
936 class_body_declaration:cbd {:
937 ParseNode pn=new ParseNode("class_body_declaration_list",parser.lexer.line_num);
941 | class_body_declarations:cbds class_body_declaration:cbd {:
947 class_body_declaration ::=
948 class_member_declaration:member {:
949 RESULT=(new ParseNode("member",parser.lexer.line_num)).addChild(member).getRoot();
951 | static_initializer:block{:
952 RESULT=(new ParseNode("static_block",parser.lexer.line_num)).addChild(block).getRoot();
954 | constructor_declaration:constructor {:
955 RESULT=(new ParseNode("constructor",parser.lexer.line_num)).addChild(constructor).getRoot();
958 RESULT=(new ParseNode("block",parser.lexer.line_num)).addChild(block).getRoot();
961 class_member_declaration ::=
962 //failure aware computation
963 flag_declaration:flag {:
964 RESULT=(new ParseNode("flag",parser.lexer.line_num)).addChild(flag).getRoot();
967 field_declaration:field {:
968 RESULT=(new ParseNode("field",parser.lexer.line_num)).addChild(field).getRoot();
970 | method_declaration:method {:
971 RESULT=(new ParseNode("method",parser.lexer.line_num)).addChild(method).getRoot();
973 /* repeat the prod for 'class_declaration' here: */
974 | modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so interfaces_opt:ifo class_body:body
976 ParseNode pn=new ParseNode("inner_class_declaration",parser.lexer.line_num);
977 pn.addChild("modifiers").addChild(mo);
978 pn.addChild("name").addChild(id);
979 pn.addChild("super").addChild(so);
980 pn.addChild("superIF").addChild(ifo);
981 pn.addChild("classbody").addChild(body);
984 | enum_declaration:ed
988 | interface_declaration:interfaced {: RESULT=interfaced; :}
989 | SEMICOLON {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
993 // JSR-201) Enum Declaration
995 modifiers_opt:mo ENUM IDENTIFIER:id /*interfaces_opt:io*/ enum_body:body
997 ParseNode pn=new ParseNode("enum_declaration",parser.lexer.line_num);
998 pn.addChild("modifiers").addChild(mo);
999 pn.addChild("name").addChild(id);
1000 //pn.addChild("superIF").addChild(ifo);
1001 pn.addChild("enumbody").addChild(body);
1006 LBRACE enum_constants_opt:eco /*enum_body_declarations_opt:ebdo*/ RBRACE
1009 enum_constants_opt ::=
1010 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1011 | enum_constants:ecs
1016 ParseNode pn=new ParseNode("enum_constants_list",parser.lexer.line_num);
1020 | enum_constants:ecs COMMA enum_constant:ec {:
1026 IDENTIFIER:id /*enum_arguments_opt*/
1028 ParseNode pn=new ParseNode("enum_constant",parser.lexer.line_num);
1029 pn.addChild("name").addChild(id);
1032 // | IDENTIFIER enum_arguments_opt class_body
1034 //enum_arguments_opt ::=
1035 // | LPAREN argument_list_opt RPAREN
1037 //enum_body_declarations_opt ::=
1038 // | SEMICOLON class_body_declarations_opt:cbdo
1041 //Failure aware computation
1042 flag_declaration ::=
1043 FLAG IDENTIFIER:id SEMICOLON {:
1044 ParseNode pn=new ParseNode("flag_declaration",parser.lexer.line_num);
1045 pn.addChild("name").addChild(id);
1048 EXTERNAL FLAG IDENTIFIER:id SEMICOLON {:
1049 ParseNode pn=new ParseNode("flag_declaration",parser.lexer.line_num);
1050 pn.addChild("name").addChild(id);
1051 pn.addChild("external");
1056 // 19.8.2) Field Declarations
1057 field_declaration ::=
1058 modifiers_opt:mo type:type variable_declarators:var SEMICOLON {:
1059 ParseNode pn=new ParseNode("field_declaration",parser.lexer.line_num);
1060 pn.addChild("modifier").addChild(mo);
1061 pn.addChild("type").addChild(type);
1062 pn.addChild("variables").addChild(var);
1065 modifiers_opt:mo GLOBAL type:type variable_declarators:var SEMICOLON {:
1066 ParseNode pn=new ParseNode("field_declaration",parser.lexer.line_num);
1067 pn.addChild("modifier").addChild(mo);
1068 pn.addChild("type").addChild(type);
1069 pn.addChild("variables").addChild(var);
1070 pn.addChild("global");
1075 variable_declarators ::=
1076 variable_declarator:vd {:
1077 ParseNode pn=new ParseNode("variable_declarators_list",parser.lexer.line_num);
1081 | variable_declarators:vds COMMA variable_declarator:vd {:
1086 variable_declarator ::=
1087 variable_declarator_id:id {:
1088 ParseNode pn=new ParseNode("variable_declarator",parser.lexer.line_num);
1092 | variable_declarator_id:id EQ variable_initializer:init {:
1093 ParseNode pn=new ParseNode("variable_declarator",parser.lexer.line_num);
1095 pn.addChild("initializer").addChild(init);
1099 variable_declarator_id ::=
1101 RESULT=(new ParseNode("single",parser.lexer.line_num)).addChild(id).getRoot();:}
1102 | variable_declarator_id:id LBRACK RBRACK {:
1103 RESULT=(new ParseNode("array",parser.lexer.line_num)).addChild(id).getRoot();:}
1105 variable_initializer ::=
1106 expression:exp {: RESULT=exp; :}
1107 | array_initializer:ai {: RESULT=(new ParseNode("array_initializer",parser.lexer.line_num)).addChild(ai).getRoot(); :}
1110 // 19.8.3) Method Declarations
1111 method_declaration ::=
1112 method_header:header method_body:body {:
1113 ParseNode pn=new ParseNode("method_declaration",parser.lexer.line_num);
1114 pn.addChild(header);
1115 pn.addChild("body").addChild(body);
1120 modifiers_opt:mo type:type method_declarator:decl throws_opt:to
1122 ParseNode pn=new ParseNode("method_header",parser.lexer.line_num);
1123 pn.addChild("modifiers").addChild(mo);
1124 pn.addChild("returntype").addChild(type);
1125 pn.addChild("throws").addChild(to);
1129 | modifiers_opt:mo VOID method_declarator:decl throws_opt:to
1131 ParseNode pn=new ParseNode("method_header",parser.lexer.line_num);
1132 pn.addChild("modifiers").addChild(mo);
1133 pn.addChild("throws").addChild(to);
1138 method_declarator ::=
1139 IDENTIFIER:id LPAREN formal_parameter_list_opt:params RPAREN {:
1140 ParseNode pn=new ParseNode("method_declarator",parser.lexer.line_num);
1141 pn.addChild("name").addChild(id);
1142 pn.addChild("parameters").addChild(params);
1145 // | method_declarator LBRACK RBRACK // deprecated
1146 // be careful; the above production also allows 'void foo() []'
1148 formal_parameter_list_opt ::=
1149 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1150 | formal_parameter_list:fpl {:
1154 formal_parameter_list ::=
1155 formal_parameter:fp {:
1156 ParseNode pn=new ParseNode("formal_parameter_list",parser.lexer.line_num);
1160 | formal_parameter_list:fpl COMMA formal_parameter:fp {:
1165 formal_parameter ::=
1166 type:type variable_declarator_id:name {:
1167 ParseNode pn=new ParseNode("formal_parameter",parser.lexer.line_num);
1173 TAG variable_declarator_id:name {:
1174 ParseNode pn=new ParseNode("tag_parameter",parser.lexer.line_num);
1178 | FINAL type:type variable_declarator_id:name {:
1179 ParseNode pn=new ParseNode("formal_parameter",parser.lexer.line_num);
1184 | annotations:an type:type variable_declarator_id:name {:
1185 ParseNode pn=new ParseNode("annotation_parameter",parser.lexer.line_num);
1193 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1197 throws ::= THROWS class_type_list:ctl
1198 {: RESULT=(new ParseNode("throw_list",parser.lexer.line_num)).addChild(ctl).getRoot(); :}
1203 ParseNode pn=new ParseNode("class_type_list",parser.lexer.line_num);
1207 | class_type_list:ctl COMMA class_type:ct
1213 method_body ::= block:block {:
1216 | SEMICOLON {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1219 // 19.8.4) Static Initializers
1220 static_initializer ::=
1221 STATIC block:body {:
1222 ParseNode pn=new ParseNode("static_block_declaration",parser.lexer.line_num);
1223 pn.addChild("body").addChild(body);
1228 // 19.8.5) Constructor Declarations
1229 constructor_declaration ::=
1230 modifiers_opt:mo constructor_declarator:cd throws_opt:to
1231 constructor_body:body {:
1232 ParseNode pn=new ParseNode("constructor_declaration",parser.lexer.line_num);
1233 pn.addChild("modifiers").addChild(mo);
1234 pn.addChild("throws").addChild(to);
1236 pn.addChild("body").addChild(body);
1239 modifiers_opt:mo GLOBAL constructor_declarator:cd throws_opt:to
1240 constructor_body:body {:
1241 ParseNode pn=new ParseNode("constructor_declaration",parser.lexer.line_num);
1242 pn.addChild("global");
1243 pn.addChild("modifiers").addChild(mo);
1244 pn.addChild("throws").addChild(to);
1246 pn.addChild("body").addChild(body);
1251 constructor_declarator ::=
1252 simple_name:name LPAREN formal_parameter_list_opt:fplo RPAREN {:
1253 ParseNode pn=new ParseNode("constructor_declarator",parser.lexer.line_num);
1255 pn.addChild("parameters").addChild(fplo);
1259 constructor_body ::=
1260 LBRACE explicit_constructor_invocation:eci block_statements:bs RBRACE {:
1261 ParseNode pn=new ParseNode("constructor_body",parser.lexer.line_num);
1266 LBRACE explicit_constructor_invocation:eci RBRACE {:
1267 ParseNode pn=new ParseNode("constructor_body",parser.lexer.line_num);
1271 LBRACE block_statements:block RBRACE {:
1272 ParseNode pn=new ParseNode("constructor_body",parser.lexer.line_num);
1276 | LBRACE RBRACE {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1278 explicit_constructor_invocation ::=
1279 THIS LPAREN argument_list_opt:alo RPAREN SEMICOLON {:
1280 ParseNode pn=new ParseNode("explconstrinv",parser.lexer.line_num);
1285 SUPER LPAREN argument_list_opt:alo RPAREN SEMICOLON {:
1286 ParseNode pn=new ParseNode("superinvoke",parser.lexer.line_num);
1290 | primary DOT THIS LPAREN argument_list_opt RPAREN SEMICOLON
1291 | primary DOT SUPER LPAREN argument_list_opt RPAREN SEMICOLON
1296 // 19.9.1) Interface Declarations
1297 interface_declaration ::=
1298 modifiers_opt:mo INTERFACE IDENTIFIER:id extends_interfaces_opt:io
1301 ParseNode pn=new ParseNode("interface_declaration",parser.lexer.line_num);
1302 pn.addChild("modifiers").addChild(mo);
1303 pn.addChild("name").addChild(id);
1304 pn.addChild("superIF").addChild(io);
1305 pn.addChild("interfacebody").addChild(body);
1308 | annotation_type_declaration:atd{:
1312 extends_interfaces_opt ::=
1313 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1314 | extends_interfaces:eifs {: RESULT=eifs; :}
1316 extends_interfaces ::=
1317 EXTENDS interface_type:ift
1319 ParseNode pn=new ParseNode("extend_interface_list",parser.lexer.line_num);
1323 | extends_interfaces:eifs COMMA interface_type:ift
1330 LBRACE interface_member_declarations_opt:imdo RBRACE
1333 interface_member_declarations_opt ::=
1334 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1335 | interface_member_declarations:imd {: RESULT=imd; :}
1337 interface_member_declarations ::=
1338 interface_member_declaration:imd {:
1339 ParseNode pn=new ParseNode("interface_member_declaration_list",parser.lexer.line_num);
1343 | interface_member_declarations:imds interface_member_declaration:imd {:
1348 interface_member_declaration ::=
1349 constant_declaration:constant {:
1350 RESULT=(new ParseNode("constant",parser.lexer.line_num)).addChild(constant).getRoot();
1352 | abstract_method_declaration:method {:
1353 RESULT=(new ParseNode("method",parser.lexer.line_num)).addChild(method).getRoot();
1355 | enum_declaration:ed {:
1356 RESULT=(new ParseNode("enum_declaration",parser.lexer.line_num)).addChild(ed).getRoot();
1358 // | class_declaration:class
1359 | interface_declaration:interfaced {: RESULT=interfaced; :}
1361 RESULT=new ParseNode("empty",parser.lexer.line_num);
1364 constant_declaration ::=
1365 field_declaration:fd {: RESULT=fd; :}
1366 // need to semantically check that modifiers of field declaration
1367 // include only PUBLIC, STATIC, or FINAL. Other modifiers are
1370 abstract_method_declaration ::=
1371 method_header:header SEMICOLON {:
1372 ParseNode pn=new ParseNode("method_declaration",parser.lexer.line_num);
1373 pn.addChild("header").addChild(header);
1374 pn.addChild("body").addChild(new ParseNode("empty",parser.lexer.line_num));
1379 annotation_type_declaration ::=
1380 AT INTERFACE IDENTIFIER:id annotation_type_body:atb{:
1381 ParseNode pn=new ParseNode("annotation_type_declaration",parser.lexer.line_num);
1382 pn.addChild("name").addChild(id);
1383 pn.addChild("body").addChild(atb);
1387 | modifiers_at:ma INTERFACE IDENTIFIER:id annotation_type_body:atb{:
1388 ParseNode pn=new ParseNode("annotation_type_declaration",parser.lexer.line_num);
1389 pn.addChild("name").addChild(id);
1390 pn.addChild("modifiers").addChild(ma);
1391 pn.addChild("body").addChild(atb);
1395 annotation_type_body ::=
1396 LBRACE annotation_type_element_declarations_opt:atedo RBRACE{:
1400 annotation_type_element_declarations_opt ::={:
1401 RESULT=new ParseNode("empty",parser.lexer.line_num);
1403 | annotation_type_element_declarations:ated{:
1407 annotation_type_element_declarations ::=
1408 annotation_type_element_declaration:ated{:
1409 ParseNode pn=new ParseNode("annotation_type_element_list",parser.lexer.line_num);
1413 | annotation_type_element_declarations:ateds annotation_type_element_declaration:ated{:
1414 ateds.addChild(ated);
1418 annotation_type_element_declaration ::=
1419 constant_declaration:cd {:
1422 | modifiers_opt:mo type:type IDENTIFIER:id LPAREN RPAREN default_value_opt:dvo SEMICOLON {:
1423 ParseNode pn=new ParseNode("annotation_type_element_declaration",parser.lexer.line_num);
1424 pn.addChild("modifier").addChild(mo);
1425 pn.addChild("type").addChild(type);
1426 pn.addChild("name").addChild(id);
1427 pn.addChild("defaultvalue").addChild(dvo);
1430 | class_declaration:cd{:
1433 | enum_declaration:ed{:
1436 | interface_declaration:id{:
1440 RESULT=new ParseNode("empty",parser.lexer.line_num);
1443 default_value_opt ::= {:
1444 RESULT=new ParseNode("empty",parser.lexer.line_num);
1446 | default_value:dv{:
1450 default_value ::= DEFAULT element_value:ev {:
1456 array_initializer ::=
1457 LBRACE variable_initializers:var_init_list COMMA RBRACE {:
1458 RESULT=var_init_list;
1460 | LBRACE variable_initializers:var_init_list RBRACE {:
1461 RESULT=var_init_list;
1463 | LBRACE COMMA RBRACE {:
1464 RESULT=new ParseNode("empty",parser.lexer.line_num);
1467 RESULT=new ParseNode("empty",parser.lexer.line_num);
1470 variable_initializers ::=
1471 variable_initializer:var_init {:
1472 ParseNode pn=new ParseNode("var_init_list",parser.lexer.line_num);
1473 pn.addChild(var_init);
1476 | variable_initializers:var_init_list COMMA variable_initializer:var_init {:
1477 var_init_list.addChild(var_init);
1478 RESULT=var_init_list;
1482 // 19.11) Blocks and Statements
1483 block ::= LBRACE block_statements_opt:bso RBRACE {:
1487 block_statements_opt ::=
1488 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1489 | block_statements:bs {:
1493 block_statements ::=
1494 block_statement:bs {:
1495 ParseNode pn=new ParseNode("block_statement_list",parser.lexer.line_num);
1499 | block_statements:bss block_statement:bs {:
1505 tag_variable_declaration_statement:tvds {:
1508 | local_variable_declaration_statement:lvds {:
1511 | statement:statement {:
1514 // | enum_declaration:ed {:
1517 // | class_declaration
1518 // | interface_declaration
1520 tag_variable_declaration_statement ::=
1521 TAG IDENTIFIER:id EQ NEW TAG LPAREN IDENTIFIER:type RPAREN SEMICOLON {:
1522 ParseNode pn=new ParseNode("tag_declaration",parser.lexer.line_num);
1523 pn.addChild("single").addChild(id);
1524 pn.addChild("type").addChild(type);
1528 local_variable_declaration_statement ::=
1529 local_variable_declaration:lvd SEMICOLON {:
1533 local_variable_declaration ::=
1534 type:type variable_declarators:var {:
1535 ParseNode pn=new ParseNode("local_variable_declaration",parser.lexer.line_num);
1540 // | FINAL type:type variable_declarators:var {:
1541 /* CAUTION: only FINAL and annotations are legal modifiers here */
1542 | modifiers:mo type:type variable_declarators:var {:
1543 ParseNode pn=new ParseNode("local_variable_declaration",parser.lexer.line_num);
1546 pn.addChild("modifiers").addChild(mo);
1550 statement ::= statement_without_trailing_substatement:st {:
1553 | labeled_statement:st {: RESULT=st; :}
1554 | if_then_statement:st {: RESULT=st; :}
1555 | if_then_else_statement:st {: RESULT=st; :}
1556 | while_statement:st {: RESULT=st; :}
1557 | for_statement:st {: RESULT=st; :}
1559 statement_no_short_if ::=
1560 statement_without_trailing_substatement:st {: RESULT=st; :}
1561 | labeled_statement_no_short_if:st {: RESULT=st; :}
1562 | if_then_else_statement_no_short_if:st {: RESULT=st; :}
1563 | while_statement_no_short_if:st {: RESULT=st; :}
1564 | for_statement_no_short_if:st {: RESULT=st; :}
1566 statement_without_trailing_substatement ::=
1567 block:st {: RESULT=st; :}
1568 | empty_statement:st {: RESULT=st; :}
1569 | expression_statement:st {: RESULT=st; :}
1570 | switch_statement:st {: RESULT=st; :}
1571 | do_statement:dos {:RESULT=dos; :}
1572 | break_statement:st {: RESULT=st; :}
1573 | continue_statement:st {: RESULT=st; :}
1574 | return_statement:st {: RESULT=st; :}
1575 | task_exitstatement:st {: RESULT=st; :}
1576 | atomic_statement:st {: RESULT=st; :}
1577 | sese_statement:st {: RESULT=st; :}
1578 | synchronized_statement:st {: RESULT=st; :}
1579 | genreach_statement:st {: RESULT=st; :}
1580 | gen_def_reach_statement:st {: RESULT=st; :}
1581 | throw_statement:st {: RESULT=st; :}
1582 | try_statement:st {: RESULT=st; :}
1583 // | assert_statement
1586 SEMICOLON {: RESULT=new ParseNode("nop",parser.lexer.line_num); :}
1588 labeled_statement ::=
1589 IDENTIFIER:id COLON statement:st {:
1590 ParseNode pn=new ParseNode("labeledstatement",parser.lexer.line_num);
1591 pn.addChild("name").addChild(id);
1592 pn.addChild("statement").addChild(st);
1596 labeled_statement_no_short_if ::=
1597 IDENTIFIER:id COLON statement_no_short_if:st {:
1598 ParseNode pn=new ParseNode("labeledstatement",parser.lexer.line_num);
1599 pn.addChild("name").addChild(id);
1600 pn.addChild("statement").addChild(st);
1604 expression_statement ::=
1605 statement_expression:se SEMICOLON {:
1606 ParseNode pn=new ParseNode("expression",parser.lexer.line_num);
1610 statement_expression ::=
1611 assignment:st {: RESULT=st; :}
1612 | preincrement_expression:st {: RESULT=st; :}
1613 | predecrement_expression:st {: RESULT=st; :}
1614 | postincrement_expression:st {: RESULT=st; :}
1615 | postdecrement_expression:st {: RESULT=st; :}
1616 | method_invocation:st {: RESULT=st; :}
1617 | class_instance_creation_expression:st {: RESULT=st; :}
1619 if_then_statement ::=
1620 IF LPAREN expression:exp RPAREN statement:st {:
1621 ParseNode pn=new ParseNode("ifstatement",parser.lexer.line_num);
1622 pn.addChild("condition").addChild(exp);
1623 pn.addChild("statement").addChild(st);
1627 if_then_else_statement ::=
1628 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1629 ELSE statement:else_st {:
1630 ParseNode pn=new ParseNode("ifstatement",parser.lexer.line_num);
1631 pn.addChild("condition").addChild(exp);
1632 pn.addChild("statement").addChild(st);
1633 pn.addChild("else_statement").addChild(else_st);
1637 if_then_else_statement_no_short_if ::=
1638 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1639 ELSE statement_no_short_if:else_st {:
1640 ParseNode pn=new ParseNode("ifstatement",parser.lexer.line_num);
1641 pn.addChild("condition").addChild(exp);
1642 pn.addChild("statement").addChild(st);
1643 pn.addChild("else_statement").addChild(else_st);
1647 switch_statement ::=
1648 SWITCH LPAREN expression:exp RPAREN switch_block:body
1650 ParseNode pn=new ParseNode("switch_statement",parser.lexer.line_num);
1651 pn.addChild("condition").addChild(exp);
1652 pn.addChild("statement").addChild(body);
1657 LBRACE switch_block_statement_groups:sbsg switch_labels:sl RBRACE
1659 ParseNode pn = new ParseNode("switch_block",parser.lexer.line_num);
1660 pn.addChild("switch_labels").addChild(sl);
1661 pn.addChild("switch_statements").addChild(new ParseNode("empty",parser.lexer.line_num));
1665 | LBRACE switch_block_statement_groups:sbsg RBRACE
1669 | LBRACE switch_labels:sl RBRACE
1671 ParseNode pnb = new ParseNode("switch_block_list",parser.lexer.line_num);
1672 ParseNode pn = new ParseNode("switch_block",parser.lexer.line_num);
1673 pn.addChild("switch_labels").addChild(sl);
1674 pn.addChild("switch_statements").addChild(new ParseNode("empty",parser.lexer.line_num));
1678 | LBRACE RBRACE {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1680 switch_block_statement_groups ::=
1681 switch_block_statement_group:sbsg
1683 ParseNode pn = new ParseNode("switch_block_list",parser.lexer.line_num);
1687 | switch_block_statement_groups:sbsgs switch_block_statement_group:sbsg
1689 sbsgs.addChild(sbsg);
1693 switch_block_statement_group ::=
1694 switch_labels:sls block_statements:body
1696 ParseNode pn=new ParseNode("switch_block",parser.lexer.line_num);
1697 pn.addChild("switch_labels").addChild(sls);
1698 pn.addChild("switch_statements").addChild(body);
1705 ParseNode pn=new ParseNode("switch_label_list",parser.lexer.line_num);
1709 | switch_labels:sls switch_label:sl
1716 CASE constant_expression:ce COLON
1718 ParseNode pn=new ParseNode("switch_label",parser.lexer.line_num);
1724 RESULT=new ParseNode("default_switch_label",parser.lexer.line_num);
1729 WHILE LPAREN expression:exp RPAREN statement:st {:
1730 ParseNode pn=new ParseNode("whilestatement",parser.lexer.line_num);
1731 pn.addChild("condition").addChild(exp);
1732 pn.addChild("statement").addChild(st);
1736 while_statement_no_short_if ::=
1737 WHILE LPAREN expression:exp RPAREN statement_no_short_if:st {:
1738 ParseNode pn=new ParseNode("whilestatement",parser.lexer.line_num);
1739 pn.addChild("condition").addChild(exp);
1740 pn.addChild("statement").addChild(st);
1745 DO statement:st WHILE LPAREN expression:exp RPAREN SEMICOLON {:
1746 ParseNode pn=new ParseNode("dowhilestatement",parser.lexer.line_num);
1747 pn.addChild("condition").addChild(exp);
1748 pn.addChild("statement").addChild(st);
1753 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1754 for_update_opt:update RPAREN statement:st {:
1755 ParseNode pn=new ParseNode("forstatement",parser.lexer.line_num);
1756 pn.addChild("initializer").addChild(init);
1757 pn.addChild("condition").addChild(exp);
1758 pn.addChild("update").addChild(update);
1759 pn.addChild("statement").addChild(st);
1763 for_statement_no_short_if ::=
1764 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1765 for_update_opt:update RPAREN statement_no_short_if:st {:
1766 ParseNode pn=new ParseNode("forstatement",parser.lexer.line_num);
1767 pn.addChild("initializer").addChild(init);
1768 pn.addChild("condition").addChild(exp);
1769 pn.addChild("update").addChild(update);
1770 pn.addChild("statement").addChild(st);
1775 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1776 | for_init:init {: RESULT=init; :}
1778 for_init ::= statement_expression_list:list {: RESULT=list; :}
1779 | local_variable_declaration:decl {: RESULT=decl; :}
1782 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1783 | for_update:update {: RESULT=update; :}
1785 for_update ::= statement_expression_list:list {: RESULT=list; :}
1787 statement_expression_list ::=
1788 statement_expression:expr {:
1789 RESULT=(new ParseNode("statement_expression_list",parser.lexer.line_num)).addChild(expr).getRoot();
1791 | statement_expression_list:list COMMA statement_expression:expr {:
1792 list.addChild(expr);
1797 identifier_opt ::= {: RESULT=new ParseNode("identifier_opt",parser.lexer.line_num);
1800 ParseNode pn=new ParseNode("identifier_opt",parser.lexer.line_num);
1801 pn.addChild("name").addChild(id);
1807 BREAK identifier_opt:id SEMICOLON {:
1808 ParseNode pn=new ParseNode("break",parser.lexer.line_num);
1814 continue_statement ::=
1818 {: RESULT=new ParseNode("continue",parser.lexer.line_num); :}
1820 return_statement ::=
1821 RETURN expression_opt:exp SEMICOLON {:
1822 RESULT=(new ParseNode("return",parser.lexer.line_num)).addChild(exp).getRoot(); :}
1825 THROW expression:exp SEMICOLON {:
1826 RESULT=(new ParseNode("throwstatement",parser.lexer.line_num)).addChild(exp).getRoot();
1829 synchronized_statement ::=
1830 SYNCHRONIZED LPAREN expression:e RPAREN block:b {:
1831 ParseNode pn=new ParseNode("synchronized",parser.lexer.line_num);
1832 pn.addChild("expr").addChild(e);
1833 pn.addChild("block").addChild(b);
1837 atomic_statement ::=
1839 RESULT=(new ParseNode("atomic",parser.lexer.line_num)).addChild(blk).getRoot();
1844 ParseNode pn = new ParseNode("sese",parser.lexer.line_num);
1845 pn.addChild("body").addChild(blk);
1848 | SESE variable_declarator_id:id block:blk {:
1849 ParseNode pn = new ParseNode("sese",parser.lexer.line_num);
1850 pn.addChild("body").addChild(blk);
1851 pn.addChild("identifier").addChild(id);
1854 | RBLOCK block:blk {:
1855 ParseNode pn = new ParseNode("sese",parser.lexer.line_num);
1856 pn.addChild("body").addChild(blk);
1859 | RBLOCK variable_declarator_id:id block:blk {:
1860 ParseNode pn = new ParseNode("sese",parser.lexer.line_num);
1861 pn.addChild("body").addChild(blk);
1862 pn.addChild("identifier").addChild(id);
1867 TRY block:bk catches:ca
1869 ParseNode pn=new ParseNode("trycatchstatement",parser.lexer.line_num);
1870 pn.addChild("tryblock").addChild(bk);
1871 pn.addChild("catchblock").addChild(ca);
1874 | TRY block:bk catches_opt:ca finally:fi
1876 ParseNode pn=new ParseNode("trycatchstatement",parser.lexer.line_num);
1877 pn.addChild("tryblock").addChild(bk);
1878 pn.addChild("catchblock").addChild(ca);
1879 pn.addChild("finallyblock").addChild(fi);
1884 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
1888 catches ::= catch_clause:ca
1890 ParseNode pn=new ParseNode("catchlist",parser.lexer.line_num);
1894 | catches:cas catch_clause:ca
1901 CATCH LPAREN formal_parameter:fp RPAREN block:bk
1903 ParseNode pn=new ParseNode("catchclause",parser.lexer.line_num);
1904 pn.addChild("parameter").addChild(fp);
1905 pn.addChild("block").addChild(bk);
1909 finally ::= FINALLY block:bk
1914 //assert_statement ::=
1915 // ASSERT expression SEMICOLON
1916 // | ASSERT expression COLON expression SEMICOLON
1919 // 19.12) Expressions
1920 primary ::= primary_no_new_array:st {:
1922 | array_creation_init:st {:
1925 | array_creation_uninit:st {:
1929 primary_no_new_array ::=
1930 literal:lit {: RESULT=lit; :}
1931 | THIS {: RESULT=new ParseNode("this",parser.lexer.line_num); :}
1932 | LPAREN expression:exp RPAREN {: RESULT=exp; :}
1933 | class_instance_creation_expression:exp {: RESULT=exp; :}
1934 | field_access:exp {: RESULT=exp; :}
1935 | method_invocation:exp {: RESULT=exp; :}
1936 | array_access:exp {: RESULT=exp; :}
1937 | ISAVAILABLE LPAREN IDENTIFIER:id RPAREN {:
1938 ParseNode pn=new ParseNode("isavailable",parser.lexer.line_num);
1942 | primitive_type:pt DOT CLASS {:
1943 ParseNode pn=new ParseNode("class_type",parser.lexer.line_num);
1948 ParseNode pn=new ParseNode("class_type",parser.lexer.line_num);
1949 pn.addChild("type").addChild("void");
1952 | array_type:at DOT CLASS {:
1953 ParseNode pn=new ParseNode("class_type",parser.lexer.line_num);
1957 | name:name DOT CLASS {:
1958 ParseNode pn=new ParseNode("class_type",parser.lexer.line_num);
1959 pn.addChild("type").addChild("class").addChild(name);
1962 | name:name DOT THIS {:
1963 ParseNode pn=new ParseNode("parentclass",parser.lexer.line_num);
1964 pn.addChild("name").addChild(name);
1968 class_instance_creation_expression ::=
1969 NEWFLAG class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {:
1970 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
1976 NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {:
1977 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
1983 | GLOBAL NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {:
1984 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
1987 pn.addChild("global");
1990 | SCRATCH NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {:
1991 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
1994 pn.addChild("scratch");
1997 // Objects we want to track in disjointness analysis
1998 | DISJOINT IDENTIFIER:id NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {:
1999 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
2002 pn.addChild("disjoint").addChild(id);
2005 | NEWFLAG class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
2006 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
2012 | NEWFLAG class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE flag_list:fl RBRACE LBRACE tag_list:tl RBRACE {:
2013 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
2020 | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN class_body:body {:
2021 ParseNode pn=new ParseNode("createobjectcls",parser.lexer.line_num);
2024 pn.addChild("decl").addChild("classbody").addChild(body);
2027 | primary: base DOT NEW class_or_interface_type:type
2028 LPAREN argument_list_opt:args RPAREN {:
2029 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
2032 pn.addChild( "base" ).addChild( base );
2036 | primary: base DOT NEW class_or_interface_type:type
2037 LPAREN argument_list_opt:args RPAREN class_body:body {:
2038 ParseNode pn=new ParseNode("createobjectcls",parser.lexer.line_num);
2041 pn.addChild( "base" ).addChild( base );
2042 pn.addChild("decl").addChild("classbody").addChild(body);
2045 | name:id DOT NEW class_or_interface_type:type
2046 LPAREN argument_list_opt:args RPAREN {:
2047 ParseNode pn=new ParseNode("createobject",parser.lexer.line_num);
2050 pn.addChild( "id" ).addChild( id );
2053 | name:id DOT NEW class_or_interface_type:type
2054 LPAREN argument_list_opt:args RPAREN class_body:body {:
2055 ParseNode pn=new ParseNode("createobjectcls",parser.lexer.line_num);
2058 pn.addChild("decl").addChild("classbody").addChild(body);
2059 pn.addChild( "id" ).addChild( id );
2063 cons_argument_list_opt ::=
2064 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
2065 | cons_argument_list:args {: RESULT=args; :}
2068 cons_argument_list ::=
2069 IDENTIFIER:id COLON expression:exp {:
2070 ParseNode pn=new ParseNode("cons_argument_list",parser.lexer.line_num);
2071 ParseNode pnarg=pn.addChild("binding");
2072 pnarg.addChild("var").addChild(id);
2073 pnarg.addChild("exp").addChild(exp);
2076 | argument_list:list COMMA IDENTIFIER:id COLON expression:exp {:
2077 ParseNode pnarg=new ParseNode("binding",parser.lexer.line_num);
2078 pnarg.addChild("var").addChild(id);
2079 pnarg.addChild("exp").addChild(exp);
2080 list.addChild(pnarg);
2085 argument_list_opt ::=
2086 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
2087 | argument_list:args {: RESULT=args; :}
2092 ParseNode pn=new ParseNode("argument_list",parser.lexer.line_num);
2096 | argument_list:list COMMA expression:exp {:
2101 array_creation_uninit ::=
2102 NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
2103 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2105 pn.addChild(dimexpr);
2106 pn.addChild("dims_opt").setLiteral(dims);
2109 | NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
2110 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2112 pn.addChild(dimexpr);
2113 pn.addChild("dims_opt").setLiteral(dims);
2116 | GLOBAL NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
2117 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2119 pn.addChild(dimexpr);
2120 pn.addChild("dims_opt").setLiteral(dims);
2121 pn.addChild("global");
2124 | SCRATCH NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
2125 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2127 pn.addChild(dimexpr);
2128 pn.addChild("dims_opt").setLiteral(dims);
2129 pn.addChild("scratch");
2132 | DISJOINT IDENTIFIER:id NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
2133 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2135 pn.addChild(dimexpr);
2136 pn.addChild("dims_opt").setLiteral(dims);
2137 pn.addChild("disjoint").addChild(id);
2140 | GLOBAL NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
2141 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2143 pn.addChild(dimexpr);
2144 pn.addChild("dims_opt").setLiteral(dims);
2145 pn.addChild("global");
2148 | SCRATCH NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
2149 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2151 pn.addChild(dimexpr);
2152 pn.addChild("dims_opt").setLiteral(dims);
2153 pn.addChild("scratch");
2156 | DISJOINT IDENTIFIER:id NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
2157 ParseNode pn=new ParseNode("createarray",parser.lexer.line_num);
2159 pn.addChild(dimexpr);
2160 pn.addChild("dims_opt").setLiteral(dims);
2161 pn.addChild("disjoint").addChild(id);
2165 array_creation_init ::=
2166 NEW primitive_type:type dims:dims array_initializer:ai {:
2167 ParseNode pn=new ParseNode("createarray2",parser.lexer.line_num);
2169 pn.addChild("dims_opt").setLiteral(dims);
2170 pn.addChild("initializer").addChild(ai);
2173 | NEW class_or_interface_type:type dims:dims array_initializer:ai {:
2174 ParseNode pn=new ParseNode("createarray2",parser.lexer.line_num);
2176 pn.addChild("dims_opt").setLiteral(dims);
2177 pn.addChild("initializer").addChild(ai);
2181 dim_exprs ::= dim_expr:exp {:
2182 ParseNode pn=new ParseNode("dim_exprs",parser.lexer.line_num);
2185 | dim_exprs:base dim_expr:exp {:
2190 dim_expr ::= LBRACK expression:exp RBRACK {: RESULT=exp; :}
2192 dims_opt ::= {: RESULT=new Integer(0); :}
2193 | dims:dims {: RESULT = dims; :}
2196 dims ::= LBRACK RBRACK {: RESULT=new Integer(1); :}
2197 | dims:dims LBRACK RBRACK {: RESULT=new Integer(dims.intValue()+1); :}
2201 primary:base DOT IDENTIFIER:id {:
2202 ParseNode pn=new ParseNode("fieldaccess",parser.lexer.line_num);
2203 pn.addChild("base").addChild(base);
2204 pn.addChild("field").addChild(id);
2207 | SUPER DOT IDENTIFIER:id {:
2208 ParseNode pn=new ParseNode("superfieldaccess",parser.lexer.line_num);
2209 pn.addChild("field").addChild(id);
2212 | name:name DOT SUPER DOT IDENTIFIER:id {:
2213 ParseNode pn=new ParseNode("supernamefieldaccess",parser.lexer.line_num);
2214 pn.addChild("base").addChild(name);
2215 pn.addChild("field").addChild(id);
2219 method_invocation ::=
2220 name:name LPAREN argument_list_opt:args RPAREN {:
2221 ParseNode pn=new ParseNode("methodinvoke1",parser.lexer.line_num);
2226 | primary:base DOT IDENTIFIER:name LPAREN argument_list_opt:args RPAREN {:
2227 ParseNode pn=new ParseNode("methodinvoke2",parser.lexer.line_num);
2228 pn.addChild("base").addChild(base);
2229 pn.addChild("id").addChild(name);
2233 | SUPER DOT IDENTIFIER:id LPAREN argument_list_opt:args RPAREN {:
2234 ParseNode name=new ParseNode("name",parser.lexer.line_num);
2235 name.addChild("base").addChild("name").addChild("identifier").addChild("super");
2236 name.addChild("identifier").addChild(id);
2237 ParseNode pn=new ParseNode("methodinvoke1",parser.lexer.line_num);
2242 // | name DOT SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
2245 name:name LBRACK expression:exp RBRACK {:
2246 ParseNode pn=new ParseNode("arrayaccess",parser.lexer.line_num);
2247 pn.addChild("base").addChild(name);
2248 pn.addChild("index").addChild(exp);
2251 | primary_no_new_array:base LBRACK expression:exp RBRACK {:
2252 ParseNode pn=new ParseNode("arrayaccess",parser.lexer.line_num);
2253 pn.addChild("base").addChild(base);
2254 pn.addChild("index").addChild(exp);
2257 // | array_creation_init:init LBRACK expression:exp RBRACK {:
2258 // ParseNode pn=new ParseNode("arrayaccess",parser.lexer.line_num);
2259 // pn.addChild("init").addChild(init);
2260 // pn.addChild("index").addChild(exp);
2265 postfix_expression ::=
2268 | name:exp {: RESULT=exp; :}
2269 | postincrement_expression:exp {: RESULT=exp; :}
2270 | postdecrement_expression:exp {: RESULT=exp; :}
2272 postincrement_expression ::=
2273 postfix_expression:exp PLUSPLUS
2274 {: RESULT=(new ParseNode("postinc",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2276 postdecrement_expression ::=
2277 postfix_expression:exp MINUSMINUS
2278 {: RESULT=(new ParseNode("postdec",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2280 unary_expression ::=
2281 preincrement_expression:exp {: RESULT=exp; :}
2282 | predecrement_expression:exp {: RESULT=exp; :}
2283 | PLUS unary_expression:exp
2284 {: RESULT=(new ParseNode("unaryplus",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2285 | MINUS unary_expression:exp
2286 {: RESULT=(new ParseNode("unaryminus",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2287 | unary_expression_not_plus_minus:exp {:
2290 preincrement_expression ::=
2291 PLUSPLUS unary_expression:exp
2292 {: RESULT=(new ParseNode("preinc",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2294 predecrement_expression ::=
2295 MINUSMINUS unary_expression:exp
2296 {: RESULT=(new ParseNode("predec",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2298 unary_expression_not_plus_minus ::=
2299 postfix_expression:exp {:
2301 | COMP unary_expression:exp
2302 {: RESULT=(new ParseNode("comp",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2303 | NOT unary_expression:exp
2304 {: RESULT=(new ParseNode("not",parser.lexer.line_num)).addChild(exp).getRoot(); :}
2305 | cast_expression:exp {: RESULT=exp; :}
2308 LPAREN primitive_type:type dims_opt:dims
2309 RPAREN unary_expression:exp {:
2310 ParseNode pn=new ParseNode("cast1",parser.lexer.line_num);
2311 if (dims.intValue()==0)
2312 pn.addChild("type").addChild(type);
2314 ParseNode arrayt=pn.addChild("type").addChild("type").addChild("array");
2315 arrayt.addChild("basetype").addChild(type);
2316 arrayt.addChild("dims").setLiteral(dims);
2318 pn.addChild("exp").addChild(exp);
2321 | LPAREN expression:type RPAREN unary_expression_not_plus_minus:exp {:
2322 ParseNode pn=new ParseNode("cast2",parser.lexer.line_num);
2323 pn.addChild("type").addChild(type);
2324 pn.addChild("exp").addChild(exp);
2328 | LPAREN name:name dims:dims RPAREN unary_expression_not_plus_minus:exp {:
2329 ParseNode pn=new ParseNode("cast1",parser.lexer.line_num);
2330 if (dims.intValue()==0)
2331 pn.addChild("type").addChild("class").addChild(name);
2333 ParseNode arrayt=pn.addChild("type").addChild("type").addChild("array");
2334 arrayt.addChild("basetype").addChild("type").addChild("class").addChild(name);
2335 arrayt.addChild("dims").setLiteral(dims);
2337 pn.addChild("exp").addChild(exp);
2342 multiplicative_expression ::=
2343 unary_expression:exp {:
2345 | multiplicative_expression:exp1 MULT unary_expression:exp2 {:
2346 ParseNode pn=new ParseNode("mult",parser.lexer.line_num);
2351 | multiplicative_expression:exp1 DIV unary_expression:exp2 {:
2352 ParseNode pn=new ParseNode("div",parser.lexer.line_num);
2357 | multiplicative_expression:exp1 MOD unary_expression:exp2 {:
2358 ParseNode pn=new ParseNode("mod",parser.lexer.line_num);
2364 additive_expression ::=
2365 multiplicative_expression:exp {:
2367 | additive_expression:exp1 PLUS multiplicative_expression:exp2 {:
2368 ParseNode pn=new ParseNode("add",parser.lexer.line_num);
2373 | additive_expression:exp1 MINUS multiplicative_expression:exp2 {:
2374 ParseNode pn=new ParseNode("sub",parser.lexer.line_num);
2380 shift_expression ::=
2381 additive_expression:exp {:
2383 | shift_expression:exp1 LSHIFT additive_expression:exp2 {:
2384 ParseNode pn=new ParseNode("leftshift",parser.lexer.line_num);
2389 | shift_expression:exp1 RSHIFT additive_expression:exp2 {:
2390 ParseNode pn=new ParseNode("rightshift",parser.lexer.line_num);
2395 | shift_expression:exp1 URSHIFT additive_expression:exp2 {:
2396 ParseNode pn=new ParseNode("urightshift",parser.lexer.line_num);
2402 relational_expression ::=
2403 shift_expression:exp {:
2405 | relational_expression:exp1 LT shift_expression:exp2 {:
2406 ParseNode pn=new ParseNode("comp_lt",parser.lexer.line_num);
2411 | relational_expression:exp1 GT shift_expression:exp2 {:
2412 ParseNode pn=new ParseNode("comp_gt",parser.lexer.line_num);
2417 | relational_expression:exp1 LTEQ shift_expression:exp2 {:
2418 ParseNode pn=new ParseNode("comp_lte",parser.lexer.line_num);
2423 | relational_expression:exp1 GTEQ shift_expression:exp2 {:
2424 ParseNode pn=new ParseNode("comp_gte",parser.lexer.line_num);
2429 | relational_expression:exp INSTANCEOF reference_type:type {:
2430 ParseNode pn=new ParseNode("instanceof",parser.lexer.line_num);
2431 pn.addChild("exp").addChild(exp);
2437 equality_expression ::=
2438 relational_expression:exp {:
2440 | equality_expression:exp1 EQEQ relational_expression:exp2 {:
2441 ParseNode pn=new ParseNode("equal",parser.lexer.line_num);
2446 | equality_expression:exp1 NOTEQ relational_expression:exp2 {:
2447 ParseNode pn=new ParseNode("not_equal",parser.lexer.line_num);
2454 equality_expression:exp {:
2456 | and_expression:exp1 AND equality_expression:exp2 {:
2457 ParseNode pn=new ParseNode("bitwise_and",parser.lexer.line_num);
2463 exclusive_or_expression ::=
2464 and_expression:expr {:
2467 | exclusive_or_expression:exp1 XOR and_expression:exp2 {:
2468 ParseNode pn=new ParseNode("bitwise_xor",parser.lexer.line_num);
2474 inclusive_or_expression ::=
2475 exclusive_or_expression:exclor {:
2477 | inclusive_or_expression:exp1 OR exclusive_or_expression:exp2 {:
2478 ParseNode pn=new ParseNode("bitwise_or",parser.lexer.line_num);
2484 conditional_and_expression ::=
2485 inclusive_or_expression:inclor {:
2487 | conditional_and_expression:exp1 ANDAND inclusive_or_expression:exp2 {:
2488 ParseNode pn=new ParseNode("logical_and",parser.lexer.line_num);
2494 conditional_or_expression ::=
2495 conditional_and_expression:condand {:
2497 | conditional_or_expression:exp1 OROR conditional_and_expression:exp2 {:
2498 ParseNode pn=new ParseNode("logical_or",parser.lexer.line_num);
2504 conditional_expression ::=
2505 conditional_or_expression:condor {:
2507 | conditional_or_expression:condor QUESTION expression:exptrue
2508 COLON conditional_expression:expfalse {:
2509 ParseNode pn=new ParseNode("tert",parser.lexer.line_num);
2510 pn.addChild("cond").addChild(condor);
2511 pn.addChild("trueexpr").addChild(exptrue);
2512 pn.addChild("falseexpr").addChild(expfalse);
2516 getoffset_expression ::=
2517 GETOFFSET LBRACE class_or_interface_type:type COMMA IDENTIFIER:id RBRACE {:
2518 ParseNode pn = new ParseNode("getoffset",parser.lexer.line_num);
2520 pn.addChild("field").addChild(id);
2525 assignment_expression ::=
2526 conditional_expression:expr {:
2528 assignment:assign {:
2530 getoffset_expression:expr {:
2533 // semantic check necessary here to ensure a valid left-hand side.
2534 // allowing a parenthesized variable here on the lhs was introduced in
2535 // JLS 2; thanks to Eric Blake for pointing this out.
2536 assignment ::= postfix_expression:lvalue assignment_operator:op assignment_expression:rvalue {:
2537 ParseNode pn=new ParseNode("assignment",parser.lexer.line_num);
2538 pn.addChild("op").addChild(op);
2539 ParseNode pnargs=pn.addChild("args");
2540 pnargs.addChild(lvalue);
2541 pnargs.addChild(rvalue);
2545 assignment_operator ::=
2546 EQ {: RESULT=new ParseNode("eq",parser.lexer.line_num); :}
2547 | MULTEQ {: RESULT=new ParseNode("multeq",parser.lexer.line_num); :}
2548 | DIVEQ {: RESULT=new ParseNode("diveq",parser.lexer.line_num); :}
2549 | MODEQ {: RESULT=new ParseNode("modeq",parser.lexer.line_num); :}
2550 | PLUSEQ {: RESULT=new ParseNode("pluseq",parser.lexer.line_num); :}
2551 | MINUSEQ {: RESULT=new ParseNode("minuseq",parser.lexer.line_num); :}
2552 | LSHIFTEQ {: RESULT=new ParseNode("lshifteq",parser.lexer.line_num); :}
2553 | RSHIFTEQ {: RESULT=new ParseNode("rshifteq",parser.lexer.line_num); :}
2554 | URSHIFTEQ {: RESULT=new ParseNode("urshifteq",parser.lexer.line_num); :}
2555 | ANDEQ {: RESULT=new ParseNode("andeq",parser.lexer.line_num); :}
2556 | XOREQ {: RESULT=new ParseNode("xoreq",parser.lexer.line_num); :}
2557 | OREQ {: RESULT=new ParseNode("oreq",parser.lexer.line_num); :}
2560 {: RESULT=new ParseNode("empty",parser.lexer.line_num); :}
2564 expression ::= assignment_expression:exp {:
2567 // note that this constraint must be enforced during semantic checking
2568 // 'constant_expression' should include enumerated constants.
2569 constant_expression ::=
2572 ParseNode pn = new ParseNode("constant_expression",parser.lexer.line_num);
2579 genreach_statement ::=
2580 GENREACH IDENTIFIER:graphName SEMICOLON {:
2581 ParseNode pn=new ParseNode("genreach",parser.lexer.line_num);
2582 pn.addChild("graphName").addChild(graphName);
2586 gen_def_reach_statement ::=
2587 GEN_DEF_REACH IDENTIFIER:outputName SEMICOLON {:
2588 ParseNode pn=new ParseNode("gen_def_reach",parser.lexer.line_num);
2589 pn.addChild("outputName").addChild(outputName);