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 PLUSPLUS; // postincrement_expression
74 terminal MINUSMINUS; // postdecrement_expression
75 terminal PLUS, MINUS, COMP, NOT, DIV, MOD;
76 terminal LSHIFT, RSHIFT, URSHIFT; // shift_expression
77 terminal LT, GT, LTEQ, GTEQ, INSTANCEOF; // relational_expression
78 terminal EQEQ, NOTEQ; // equality_expression
79 terminal AND; // and_expression
80 terminal XOR; // exclusive_or_expression
81 terminal OR; // inclusive_or_expression
82 terminal ANDAND; // conditional_and_expression
83 terminal OROR; // conditional_or_expression
84 terminal QUESTION; // conditional_expression
85 terminal MULTEQ, DIVEQ, MODEQ, PLUSEQ, MINUSEQ; // assignment_operator
86 terminal LSHIFTEQ, RSHIFTEQ, URSHIFTEQ; // assignment_operator
87 terminal ANDEQ, XOREQ, OREQ; // assignment_operator
89 terminal java.lang.Number INTEGER_LITERAL;
90 terminal java.lang.Number FLOATING_POINT_LITERAL;
91 terminal java.lang.Boolean BOOLEAN_LITERAL;
92 terminal java.lang.Character CHARACTER_LITERAL;
93 terminal java.lang.String STRING_LITERAL;
94 terminal NULL_LITERAL;
96 // Reserved but unused:
98 // strictfp keyword, new in Java 1.2
100 // assert keyword, new in Java 1.4
101 terminal ASSERT; // assert_statement
102 // lexer compatibility with Java 1.5
107 // 19.2) The Syntactic Grammar
108 non terminal ParseNode goal;
109 // 19.3) Lexical Structure
110 non terminal ParseNode literal;
111 // 19.4) Types, Values, and Variables
112 non terminal ParseNode type, primitive_type, numeric_type;
113 non terminal ParseNode integral_type, floating_point_type;
114 non terminal ParseNode reference_type;
115 non terminal ParseNode class_or_interface_type;
116 non terminal ParseNode class_type;
117 //non terminal ParseNode interface_type;
118 non terminal ParseNode array_type;
120 non terminal ParseNode name, simple_name, qualified_name;
122 non terminal ParseNode compilation_unit;
123 non terminal ParseNode package_declaration_opt, package_declaration;
124 non terminal ParseNode import_declarations_opt, import_declarations;
125 non terminal ParseNode type_declarations_opt, type_declarations;
126 non terminal ParseNode import_declaration;
127 non terminal ParseNode single_type_import_declaration;
128 non terminal ParseNode type_import_on_demand_declaration;
129 non terminal ParseNode type_declaration;
130 // 19.7) Productions used only in the LALR(1) grammar
131 non terminal ParseNode modifiers_opt, modifiers, modifier;
132 // 19.8.1) Class Declaration
133 non terminal ParseNode class_declaration, super, super_opt;
134 //non terminal interfaces, interfaces_opt, interface_type_list;
135 non terminal ParseNode class_body;
136 non terminal ParseNode class_body_declarations, class_body_declarations_opt;
137 non terminal ParseNode class_body_declaration, class_member_declaration;
138 // 19.8.2) Field Declarations
139 non terminal ParseNode field_declaration, variable_declarators, variable_declarator;
140 non terminal ParseNode variable_declarator_id;
141 non terminal ParseNode variable_initializer;
142 // 19.8.3) Method Declarations
143 non terminal ParseNode method_declaration, method_header, method_declarator;
144 non terminal ParseNode formal_parameter_list_opt, formal_parameter_list;
145 non terminal ParseNode formal_parameter;
146 //non terminal ParseNode throws_opt;
147 //non terminal ParseNode throws;
148 //non terminal ParseNode class_type_list;
149 non terminal ParseNode method_body;
150 // 19.8.4) Static Initializers
151 //non terminal ParseNode static_initializer;
152 // 19.8.5) Constructor Declarations
153 non terminal ParseNode constructor_declaration, constructor_declarator;
154 non terminal ParseNode constructor_body;
155 //non terminal ParseNode explicit_constructor_invocation;
156 // 19.9.1) Interface Declarations
157 //non terminal ParseNode interface_declaration;
158 //non terminal ParseNode extends_interfaces_opt, extends_interfaces;
159 //non terminal ParseNode interface_body;
160 //non terminal ParseNode interface_member_declarations_opt, interface_member_declarations;
161 //non terminal ParseNode interface_member_declaration, constant_declaration;
162 //non terminal ParseNode abstract_method_declaration;
164 //non terminal ParseNode array_initializer;
165 //non terminal ParseNode variable_initializers;
166 // 19.11) Blocks and Statements
167 non terminal ParseNode block;
168 non terminal ParseNode block_statements_opt, block_statements, block_statement;
169 non terminal ParseNode local_variable_declaration_statement, local_variable_declaration;
170 non terminal ParseNode statement, statement_no_short_if;
171 non terminal ParseNode statement_without_trailing_substatement;
172 non terminal ParseNode empty_statement;
173 //non terminal ParseNode labeled_statement, labeled_statement_no_short_if;
174 non terminal ParseNode expression_statement, statement_expression;
175 non terminal ParseNode if_then_statement;
176 non terminal ParseNode if_then_else_statement, if_then_else_statement_no_short_if;
177 //non terminal ParseNode switch_statement, switch_block;
178 //non terminal ParseNode switch_block_statement_groups;
179 //non terminal ParseNode switch_block_statement_group;
180 //non terminal ParseNode switch_labels, switch_label;
181 non terminal ParseNode while_statement, while_statement_no_short_if;
182 non terminal ParseNode do_statement;
183 non terminal ParseNode for_statement, for_statement_no_short_if;
184 non terminal ParseNode for_init_opt, for_init;
185 non terminal ParseNode for_update_opt, for_update;
186 non terminal ParseNode statement_expression_list;
187 //non terminal ParseNode identifier_opt;
188 non terminal ParseNode break_statement, continue_statement;
189 non terminal ParseNode return_statement;
190 //non terminal ParseNode throw_statement;
191 //non terminal ParseNode synchronized_statement, try_statement;
192 //non terminal ParseNode catches_opt;
193 //non terminal ParseNode catches, catch_clause;
194 //non terminal ParseNode finally;
195 //non terminal ParseNode assert_statement;
196 // 19.12) Expressions
197 non terminal ParseNode primary, primary_no_new_array;
198 non terminal ParseNode class_instance_creation_expression;
199 non terminal ParseNode cons_argument_list_opt, cons_argument_list;
200 non terminal ParseNode argument_list_opt, argument_list;
201 //non terminal ParseNode array_creation_init;
202 non terminal ParseNode array_creation_uninit;
203 non terminal ParseNode dim_exprs, dim_expr;
204 non terminal Integer dims_opt, dims;
205 non terminal ParseNode field_access, method_invocation;
206 non terminal ParseNode array_access;
207 non terminal ParseNode postfix_expression;
208 non terminal ParseNode postincrement_expression, postdecrement_expression;
209 non terminal ParseNode unary_expression, unary_expression_not_plus_minus;
210 non terminal ParseNode preincrement_expression, predecrement_expression;
211 non terminal ParseNode cast_expression;
212 non terminal ParseNode multiplicative_expression, additive_expression;
213 non terminal ParseNode shift_expression, relational_expression, equality_expression;
214 non terminal ParseNode and_expression, exclusive_or_expression, inclusive_or_expression;
215 non terminal ParseNode conditional_and_expression, conditional_or_expression;
216 non terminal ParseNode conditional_expression;
217 non terminal ParseNode assignment_expression;
218 non terminal ParseNode assignment;
219 non terminal ParseNode assignment_operator;
220 non terminal ParseNode expression_opt, expression;
221 //non terminal ParseNode constant_expression;
222 //failure aware computation keywords
229 non terminal ParseNode flag_declaration;
230 non terminal ParseNode task_declaration;
231 non terminal ParseNode task_parameter_list;
232 non terminal ParseNode task_parameter;
233 non terminal ParseNode flag_expression;
234 non terminal ParseNode flag_andexpression;
235 non terminal ParseNode flag_notexpression;
236 non terminal ParseNode task_exitstatement;
237 non terminal ParseNode flag_effects_opt;
238 non terminal ParseNode flag_effects;
239 non terminal ParseNode flag_effect;
240 non terminal ParseNode flag_list;
241 non terminal ParseNode flag_list_opt;
242 non terminal ParseNode flag_change;
244 non terminal ParseNode cons_checks_opt;
245 non terminal ParseNode cons_checks;
246 non terminal ParseNode cons_check;
248 non terminal ParseNode tag_variable_declaration_statement;
249 non terminal ParseNode tag_expression_list;
250 non terminal ParseNode tag_expression;
251 non terminal ParseNode tag_list;
252 non terminal ParseNode tag_list_opt;
253 non terminal ParseNode tag_change;
260 TASK IDENTIFIER:id LPAREN task_parameter_list:tpl RPAREN
264 ParseNode pn=new ParseNode("task_declaration");
265 pn.addChild("name").addChild(id);
268 pn.addChild("body").addChild(body);
272 task_parameter_list ::=
274 ParseNode pn=new ParseNode("task_parameter_list");
278 | task_parameter_list:fpl COMMA task_parameter:fp {:
285 type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE {:
286 ParseNode pn=new ParseNode("task_parameter");
289 pn.addChild("flag").addChild(exp);
292 | type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE LBRACE tag_expression_list:texp RBRACE {:
293 ParseNode pn=new ParseNode("task_parameter");
296 pn.addChild("flag").addChild(exp);
297 pn.addChild("tag").addChild(texp);
300 | type:type variable_declarator_id:name LBRACE RBRACE LBRACE tag_expression_list:texp RBRACE {:
301 ParseNode pn=new ParseNode("task_parameter");
304 pn.addChild("tag").addChild(texp);
307 | OPTIONAL task_parameter:fp {:
308 ParseNode pn=new ParseNode("task_parameter");
309 pn.addChild("optional").addChild(fp);
315 tag_expression_list ::= tag_expression:te {:
316 ParseNode pn=new ParseNode("tag_expression_list");
320 | tag_expression_list:tel COMMA tag_expression:te {:
326 tag_expression ::= IDENTIFIER:type IDENTIFIER:id {:
327 ParseNode pn=new ParseNode("tag_expression");
328 pn.addChild("type").addChild(type);
329 pn.addChild("single").addChild(id);
334 tag_list_opt ::= LBRACE tag_list:fl RBRACE {:RESULT=fl;:}
335 | LBRACE RBRACE {: RESULT = new ParseNode("empty"); :}
336 | {: RESULT = new ParseNode("empty"); :}
339 tag_list ::= tag_change:fc {:
340 ParseNode pn=new ParseNode("tag_list");
344 | tag_list:fl COMMA tag_change:fc {:
349 tag_change ::= IDENTIFIER:id {:
350 RESULT=new ParseNode("name").addChild(id).getRoot();
352 | NOT IDENTIFIER:id {:
353 RESULT=new ParseNode("not").addChild("name").addChild(id).getRoot();
357 flag_andexpression:exp {:
360 | flag_expression:exp1 OROR flag_andexpression:exp2 {:
361 ParseNode pn=new ParseNode("or");
368 flag_andexpression ::=
369 flag_notexpression:exp {: RESULT=exp; :}
370 | flag_notexpression:exp1 ANDAND flag_andexpression:exp2 {:
371 ParseNode pn=new ParseNode("and");
378 flag_notexpression ::=
379 NOT flag_notexpression:exp {:
380 ParseNode pn=new ParseNode("not");
384 | LPAREN flag_expression:exp RPAREN {:
388 ParseNode pn=new ParseNode("name");
394 task_exitstatement ::= TASKEXIT flag_effects_opt:opt cons_checks_opt:cco SEMICOLON {:
395 RESULT=(new ParseNode("taskexit")).addChild(opt).getRoot().addChild(cco).getRoot();
398 cons_checks_opt ::= ASSERT LPAREN cons_checks:cc RPAREN {: RESULT=cc; :}
399 | {: RESULT = new ParseNode("empty"); :}
402 cons_checks ::= cons_check:cc {:
403 ParseNode pn=new ParseNode("cons_checks");
407 | cons_checks:ccs COMMA cons_check:cc {:
412 cons_check ::= IDENTIFIER:name LPAREN cons_argument_list_opt:args RPAREN {:
413 ParseNode pn=new ParseNode("cons_check");
414 pn.addChild("name").addChild("identifier").addChild(name);
419 flag_effects_opt ::= LPAREN flag_effects:fe RPAREN {:RESULT=fe;:}
420 | {: RESULT = new ParseNode("empty"); :}
423 flag_effects ::= flag_effect:fe {:
424 ParseNode pn=new ParseNode("flag_effects_list");
428 | flag_effects:fes COMMA flag_effect:fe {:
433 flag_effect ::= IDENTIFIER:id LBRACE flag_list:fl RBRACE tag_list_opt:tlo {:
434 ParseNode pn=new ParseNode("flag_effect");
435 pn.addChild("name").addChild(id);
440 | IDENTIFIER:id LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
441 ParseNode pn=new ParseNode("flag_effect");
442 pn.addChild("name").addChild(id);
447 flag_list_opt ::= LBRACE flag_list:fl RBRACE {:RESULT=fl;:}
448 | LBRACE RBRACE {: RESULT = new ParseNode("empty"); :}
450 {: RESULT = new ParseNode("empty"); :}
453 flag_list ::= flag_change:fc {:
454 ParseNode pn=new ParseNode("flag_list");
458 | flag_list:fl COMMA flag_change:fc {:
463 flag_change ::= IDENTIFIER:id {:
464 RESULT=new ParseNode("name").addChild(id).getRoot();
467 RESULT=new ParseNode("not").addChild("name").addChild(id).getRoot();
470 // 19.2) The Syntactic Grammar
471 goal ::= compilation_unit:cu
477 // 19.3) Lexical Structure.
480 literal ::= INTEGER_LITERAL:integer_lit
482 ParseNode pn=new ParseNode("literal");
483 pn.addChild("integer").setLiteral(integer_lit);
486 | FLOATING_POINT_LITERAL:float_lit
488 ParseNode pn=new ParseNode("literal");
489 pn.addChild("float").setLiteral(float_lit);
492 | BOOLEAN_LITERAL:boolean_lit
494 ParseNode pn=new ParseNode("literal");
495 pn.addChild("boolean").setLiteral(boolean_lit);
498 | CHARACTER_LITERAL:char_lit
500 ParseNode pn=new ParseNode("literal");
501 pn.addChild("char").setLiteral(char_lit);
504 | STRING_LITERAL:string_lit
506 ParseNode pn=new ParseNode("literal");
507 pn.addChild("string").setLiteral(string_lit);
512 RESULT=(new ParseNode("literal")).addChild("null").getRoot();
516 // 19.4) Types, Values, and Variables
517 type ::= primitive_type:type {: RESULT=type; :}
518 | reference_type:type {: RESULT=type; :}
522 numeric_type:type {: RESULT=type; :}
523 | BOOLEAN {: RESULT=(new ParseNode("type")).addChild("boolean").getRoot(); :}
525 numeric_type::= integral_type:type {: RESULT=type; :}
526 | floating_point_type:type {: RESULT=type; :}
529 BYTE {: RESULT=(new ParseNode("type")).addChild("byte").getRoot(); :}
530 | SHORT {: RESULT=(new ParseNode("type")).addChild("short").getRoot(); :}
531 | INT {: RESULT=(new ParseNode("type")).addChild("int").getRoot(); :}
532 | LONG {: RESULT=(new ParseNode("type")).addChild("long").getRoot(); :}
533 | CHAR {: RESULT=(new ParseNode("type")).addChild("char").getRoot(); :}
535 floating_point_type ::=
536 FLOAT {: RESULT=(new ParseNode("type")).addChild("float").getRoot(); :}
537 | DOUBLE {: RESULT=(new ParseNode("type")).addChild("double").getRoot(); :}
541 class_or_interface_type:type {: RESULT=type; :}
542 | array_type:type {: RESULT=type; :}
544 class_or_interface_type ::= name:name {:
545 RESULT=(new ParseNode("type")).addChild("class").addChild(name).getRoot();
548 class_type ::= class_or_interface_type:type {: RESULT=type; :};
549 //interface_type ::= class_or_interface_type;
551 array_type ::= primitive_type:prim dims:dims {:
552 ParseNode pn=(new ParseNode("type")).addChild("array");
553 pn.addChild("basetype").addChild(prim);
554 pn.addChild("dims").setLiteral(dims);
557 | name:name dims:dims {:
558 ParseNode pn=(new ParseNode("type")).addChild("array");
559 pn.addChild("basetype").addChild("type").addChild("class").addChild(name);
560 pn.addChild("dims").setLiteral(dims);
566 name ::= simple_name:name {: RESULT=name; :}
567 | qualified_name:name {: RESULT=name; :}
569 simple_name ::= IDENTIFIER:id {:
570 RESULT=(new ParseNode("name")).addChild("identifier").addChild(id).getRoot();
573 qualified_name ::= name:name DOT IDENTIFIER:id {:
574 ParseNode pn=new ParseNode("name");
575 pn.addChild("base").addChild(name);
576 pn.addChild("identifier").addChild(id);
583 package_declaration_opt:pdo
584 import_declarations_opt:ido
585 type_declarations_opt:tdo {:
586 ParseNode pn=new ParseNode("compilation_unit");
588 pn.addChild("packages").addChild(pdo);
589 pn.addChild("imports").addChild(ido);
593 package_declaration_opt ::= package_declaration:pdo {:
596 {: RESULT=new ParseNode("empty"); :}
599 import_declarations_opt ::= import_declarations:ido {:
602 {: RESULT=new ParseNode("empty"); :}
604 type_declarations_opt ::= type_declarations:tds {:
607 {: RESULT=new ParseNode("empty"); :}
610 import_declarations ::=
611 import_declaration:id {:
612 ParseNode pn=new ParseNode("import_decls_list");
616 | import_declarations:ids import_declaration:id {:
622 type_declarations ::=
623 type_declaration:td {:
624 ParseNode pn=new ParseNode("type_declaration_list");
628 | type_declarations:tds type_declaration:td {:
634 package_declaration ::=
635 PACKAGE name:name SEMICOLON {:
636 ParseNode pn=new ParseNode("package");
641 import_declaration ::=
642 single_type_import_declaration:sid {: RESULT=sid; :}
643 | type_import_on_demand_declaration:iod {: RESULT=iod; :}
645 single_type_import_declaration ::=
646 IMPORT name:name SEMICOLON {:
647 ParseNode pn=new ParseNode("import_single");
652 type_import_on_demand_declaration ::=
653 IMPORT name:name DOT MULT SEMICOLON {:
654 ParseNode pn=new ParseNode("import_ondemand");
665 | task_declaration:td
669 // | interface_declaration
670 | SEMICOLON {: RESULT=new ParseNode("empty"); :}
673 // 19.7) Productions used only in the LALR(1) grammar
675 {: RESULT=new ParseNode("empty"); :}
680 modifiers ::= modifier:mo {:
681 ParseNode pn=new ParseNode("modifier_list");
685 | modifiers:mos modifier:mo {:
691 PUBLIC {: RESULT=new ParseNode("public"); :}|
692 PROTECTED {: RESULT=new ParseNode("protected"); :}|
693 PRIVATE {: RESULT=new ParseNode("private"); :}|
694 STATIC {: RESULT=new ParseNode("static"); :} |
696 FINAL {: RESULT=new ParseNode("final"); :}|
697 NATIVE {: RESULT=new ParseNode("native"); :} |
698 SYNCHRONIZED {: RESULT=new ParseNode("synchronized"); :}
701 // STRICTFP // note that semantic analysis must check that the
702 // context of the modifier allows strictfp.
707 // 19.8.1) Class Declaration:
708 class_declaration ::=
709 modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so //interfaces_opt
712 ParseNode pn=new ParseNode("class_declaration");
713 pn.addChild("modifiers").addChild(mo);
714 pn.addChild("name").addChild(id);
715 pn.addChild("super").addChild(so);
716 pn.addChild("classbody").addChild(body);
720 super ::= EXTENDS class_type:classtype {:
725 {: RESULT=new ParseNode("empty"); :}
731 //interfaces ::= IMPLEMENTS interface_type_list
736 //interface_type_list ::=
738 // | interface_type_list COMMA interface_type
741 class_body ::= LBRACE class_body_declarations_opt:cbdo RBRACE {: RESULT=cbdo; :}
744 class_body_declarations_opt ::=
745 {: RESULT=new ParseNode("empty"); :}
746 | class_body_declarations:cbd {: RESULT=cbd; :};
748 class_body_declarations ::=
749 class_body_declaration:cbd {:
750 ParseNode pn=new ParseNode("class_body_declaration_list");
754 | class_body_declarations:cbds class_body_declaration:cbd {:
760 class_body_declaration ::=
761 class_member_declaration:member {:
762 RESULT=(new ParseNode("member")).addChild(member).getRoot();
764 // | static_initializer
765 | constructor_declaration:constructor {:
766 RESULT=(new ParseNode("constructor")).addChild(constructor).getRoot();
769 RESULT=(new ParseNode("block")).addChild(block).getRoot();
772 class_member_declaration ::=
773 //failure aware computation
774 flag_declaration:flag {:
775 RESULT=(new ParseNode("flag")).addChild(flag).getRoot();
778 field_declaration:field {:
779 RESULT=(new ParseNode("field")).addChild(field).getRoot();
781 | method_declaration:method {:
782 RESULT=(new ParseNode("method")).addChild(method).getRoot();
784 /* repeat the prod for 'class_declaration' here: */
785 // | modifiers_opt CLASS IDENTIFIER super_opt class_body
786 // | interface_declaration
787 | SEMICOLON {: RESULT=new ParseNode("empty"); :}
790 //Failure aware computation
792 FLAG IDENTIFIER:id SEMICOLON {:
793 ParseNode pn=new ParseNode("flag_declaration");
794 pn.addChild("name").addChild(id);
797 EXTERNAL FLAG IDENTIFIER:id SEMICOLON {:
798 ParseNode pn=new ParseNode("flag_declaration");
799 pn.addChild("name").addChild(id);
800 pn.addChild("external");
805 // 19.8.2) Field Declarations
806 field_declaration ::=
807 modifiers_opt:mo type:type variable_declarators:var SEMICOLON {:
808 ParseNode pn=new ParseNode("field_declaration");
809 pn.addChild("modifier").addChild(mo);
810 pn.addChild("type").addChild(type);
811 pn.addChild("variables").addChild(var);
816 variable_declarators ::=
817 variable_declarator:vd {:
818 ParseNode pn=new ParseNode("variable_declarators_list");
822 | variable_declarators:vds COMMA variable_declarator:vd {:
827 variable_declarator ::=
828 variable_declarator_id:id {:
829 ParseNode pn=new ParseNode("variable_declarator");
833 | variable_declarator_id:id EQ variable_initializer:init {:
834 ParseNode pn=new ParseNode("variable_declarator");
836 pn.addChild("initializer").addChild(init);
840 variable_declarator_id ::=
842 RESULT=(new ParseNode("single")).addChild(id).getRoot();:}
843 | variable_declarator_id:id LBRACK RBRACK {:
844 RESULT=(new ParseNode("array")).addChild(id).getRoot();:}
846 variable_initializer ::=
847 expression:exp {: RESULT=exp; :}
848 // | array_initializer
851 // 19.8.3) Method Declarations
852 method_declaration ::=
853 method_header:header method_body:body {:
854 ParseNode pn=new ParseNode("method_declaration");
856 pn.addChild("body").addChild(body);
861 modifiers_opt:mo type:type method_declarator:decl //throws_opt
863 ParseNode pn=new ParseNode("method_header");
864 pn.addChild("modifiers").addChild(mo);
865 pn.addChild("returntype").addChild(type);
869 | modifiers_opt:mo VOID method_declarator:decl //throws_opt
871 ParseNode pn=new ParseNode("method_header");
872 pn.addChild("modifiers").addChild(mo);
877 method_declarator ::=
878 IDENTIFIER:id LPAREN formal_parameter_list_opt:params RPAREN {:
879 ParseNode pn=new ParseNode("method_declarator");
880 pn.addChild("name").addChild(id);
881 pn.addChild("parameters").addChild(params);
884 // | method_declarator LBRACK RBRACK // deprecated
885 // be careful; the above production also allows 'void foo() []'
887 formal_parameter_list_opt ::=
888 {: RESULT=new ParseNode("empty"); :}
889 | formal_parameter_list:fpl {:
893 formal_parameter_list ::=
894 formal_parameter:fp {:
895 ParseNode pn=new ParseNode("formal_parameter_list");
899 | formal_parameter_list:fpl COMMA formal_parameter:fp {:
905 type:type variable_declarator_id:name {:
906 ParseNode pn=new ParseNode("formal_parameter");
912 TAG variable_declarator_id:name {:
913 ParseNode pn=new ParseNode("tag_parameter");
917 // | FINAL type variable_declarator_id
922 //throws ::= THROWS class_type_list
924 //class_type_list ::=
926 // | class_type_list COMMA class_type
928 method_body ::= block:block {:
931 | SEMICOLON {: RESULT=new ParseNode("empty"); :}
934 // 19.8.4) Static Initializers
935 //static_initializer ::=
939 // 19.8.5) Constructor Declarations
940 constructor_declaration ::=
941 modifiers_opt:mo constructor_declarator:cd
943 constructor_body:body {:
944 ParseNode pn=new ParseNode("constructor_declaration");
945 pn.addChild("modifiers").addChild(mo);
947 pn.addChild("body").addChild(body);
951 constructor_declarator ::=
952 simple_name:name LPAREN formal_parameter_list_opt:fplo RPAREN {:
953 ParseNode pn=new ParseNode("constructor_declarator");
955 pn.addChild("parameters").addChild(fplo);
960 // LBRACE explicit_constructor_invocation:eci block_statements:bs RBRACE |
961 // LBRACE explicit_constructor_invocation RBRACE |
962 LBRACE block_statements:block RBRACE {:
963 ParseNode pn=new ParseNode("constructor_body");
967 | LBRACE RBRACE {: RESULT=new ParseNode("empty"); :}
969 //explicit_constructor_invocation ::=
970 // THIS LPAREN argument_list_opt RPAREN SEMICOLON
971 // | SUPER LPAREN argument_list_opt RPAREN SEMICOLON
972 // | primary DOT THIS LPAREN argument_list_opt RPAREN SEMICOLON
973 // | primary DOT SUPER LPAREN argument_list_opt RPAREN SEMICOLON
978 // 19.9.1) Interface Declarations
979 //interface_declaration ::=
980 // modifiers_opt INTERFACE IDENTIFIER extends_interfaces_opt
983 //extends_interfaces_opt ::=
984 // | extends_interfaces
986 //extends_interfaces ::=
987 // EXTENDS interface_type
988 // | extends_interfaces COMMA interface_type
991 // LBRACE interface_member_declarations_opt RBRACE
993 //interface_member_declarations_opt ::=
994 // | interface_member_declarations
996 //interface_member_declarations ::=
997 // interface_member_declaration
998 // | interface_member_declarations interface_member_declaration
1000 //interface_member_declaration ::=
1001 // constant_declaration
1002 // | abstract_method_declaration
1003 // | class_declaration
1004 // | interface_declaration
1007 //constant_declaration ::=
1008 // field_declaration
1009 // // need to semantically check that modifiers of field declaration
1010 // // include only PUBLIC, STATIC, or FINAL. Other modifiers are
1013 //abstract_method_declaration ::=
1014 // method_header SEMICOLON
1019 //array_initializer ::=
1020 // LBRACE variable_initializers COMMA RBRACE
1021 // | LBRACE variable_initializers RBRACE
1022 // | LBRACE COMMA RBRACE
1025 //variable_initializers ::=
1026 // variable_initializer
1027 // | variable_initializers COMMA variable_initializer
1030 // 19.11) Blocks and Statements
1031 block ::= LBRACE block_statements_opt:bso RBRACE {:
1035 block_statements_opt ::=
1036 {: RESULT=new ParseNode("empty"); :}
1037 | block_statements:bs {:
1041 block_statements ::=
1042 block_statement:bs {:
1043 ParseNode pn=new ParseNode("block_statement_list");
1047 | block_statements:bss block_statement:bs {:
1053 tag_variable_declaration_statement:tvds {:
1056 | local_variable_declaration_statement:lvds {:
1059 | statement:statement {:
1062 // | class_declaration
1063 // | interface_declaration
1065 tag_variable_declaration_statement ::=
1066 TAG IDENTIFIER:id EQ NEW TAG LPAREN IDENTIFIER:type RPAREN SEMICOLON {:
1067 ParseNode pn=new ParseNode("tag_declaration");
1068 pn.addChild("single").addChild(id);
1069 pn.addChild("type").addChild(type);
1073 local_variable_declaration_statement ::=
1074 local_variable_declaration:lvd SEMICOLON {:
1078 local_variable_declaration ::=
1079 type:type variable_declarators:var {:
1080 ParseNode pn=new ParseNode("local_variable_declaration");
1085 // | FINAL type variable_declarators
1087 statement ::= statement_without_trailing_substatement:st {:
1090 // | labeled_statement:st {: RESULT=st; :}
1091 | if_then_statement:st {: RESULT=st; :}
1092 | if_then_else_statement:st {: RESULT=st; :}
1093 | while_statement:st {: RESULT=st; :}
1094 | for_statement:st {: RESULT=st; :}
1096 statement_no_short_if ::=
1097 statement_without_trailing_substatement:st {: RESULT=st; :}
1098 // | labeled_statement_no_short_if:st {: RESULT=st; :}
1099 | if_then_else_statement_no_short_if:st {: RESULT=st; :}
1100 | while_statement_no_short_if:st {: RESULT=st; :}
1101 | for_statement_no_short_if:st {: RESULT=st; :}
1103 statement_without_trailing_substatement ::=
1104 block:st {: RESULT=st; :}
1105 | empty_statement:st {: RESULT=st; :}
1106 | expression_statement:st {: RESULT=st; :}
1107 // | switch_statement
1108 | do_statement:dos {:RESULT=dos; :}
1109 | break_statement:st {: RESULT=st; :}
1110 | continue_statement:st {: RESULT=st; :}
1111 | return_statement:st {: RESULT=st; :}
1112 | task_exitstatement:st {: RESULT=st; :}
1113 // | synchronized_statement
1114 // | throw_statement
1116 // | assert_statement
1119 SEMICOLON {: RESULT=new ParseNode("nop"); :}
1121 //labeled_statement ::=
1122 // IDENTIFIER COLON statement
1124 //labeled_statement_no_short_if ::=
1125 // IDENTIFIER COLON statement_no_short_if
1127 expression_statement ::=
1128 statement_expression:se SEMICOLON {:
1129 ParseNode pn=new ParseNode("expression");
1133 statement_expression ::=
1134 assignment:st {: RESULT=st; :}
1135 | preincrement_expression:st {: RESULT=st; :}
1136 | predecrement_expression:st {: RESULT=st; :}
1137 | postincrement_expression:st {: RESULT=st; :}
1138 | postdecrement_expression:st {: RESULT=st; :}
1139 | method_invocation:st {: RESULT=st; :}
1140 | class_instance_creation_expression:st {: RESULT=st; :}
1142 if_then_statement ::=
1143 IF LPAREN expression:exp RPAREN statement:st {:
1144 ParseNode pn=new ParseNode("ifstatement");
1145 pn.addChild("condition").addChild(exp);
1146 pn.addChild("statement").addChild(st);
1150 if_then_else_statement ::=
1151 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1152 ELSE statement:else_st {:
1153 ParseNode pn=new ParseNode("ifstatement");
1154 pn.addChild("condition").addChild(exp);
1155 pn.addChild("statement").addChild(st);
1156 pn.addChild("else_statement").addChild(else_st);
1160 if_then_else_statement_no_short_if ::=
1161 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1162 ELSE statement_no_short_if:else_st {:
1163 ParseNode pn=new ParseNode("ifstatement");
1164 pn.addChild("condition").addChild(exp);
1165 pn.addChild("statement").addChild(st);
1166 pn.addChild("else_statement").addChild(else_st);
1170 //switch_statement ::=
1171 // SWITCH LPAREN expression RPAREN switch_block
1174 // LBRACE switch_block_statement_groups switch_labels RBRACE
1175 // | LBRACE switch_block_statement_groups RBRACE
1176 // | LBRACE switch_labels RBRACE
1179 //switch_block_statement_groups ::=
1180 // switch_block_statement_group
1181 // | switch_block_statement_groups switch_block_statement_group
1183 //switch_block_statement_group ::=
1184 // switch_labels block_statements
1188 // | switch_labels switch_label
1191 // CASE constant_expression COLON
1196 WHILE LPAREN expression:exp RPAREN statement:st {:
1197 ParseNode pn=new ParseNode("whilestatement");
1198 pn.addChild("condition").addChild(exp);
1199 pn.addChild("statement").addChild(st);
1203 while_statement_no_short_if ::=
1204 WHILE LPAREN expression:exp RPAREN statement_no_short_if:st {:
1205 ParseNode pn=new ParseNode("whilestatement");
1206 pn.addChild("condition").addChild(exp);
1207 pn.addChild("statement").addChild(st);
1212 DO statement:st WHILE LPAREN expression:exp RPAREN SEMICOLON {:
1213 ParseNode pn=new ParseNode("dowhilestatement");
1214 pn.addChild("condition").addChild(exp);
1215 pn.addChild("statement").addChild(st);
1220 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1221 for_update_opt:update RPAREN statement:st {:
1222 ParseNode pn=new ParseNode("forstatement");
1223 pn.addChild("initializer").addChild(init);
1224 pn.addChild("condition").addChild(exp);
1225 pn.addChild("update").addChild(update);
1226 pn.addChild("statement").addChild(st);
1230 for_statement_no_short_if ::=
1231 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1232 for_update_opt:update RPAREN statement_no_short_if:st {:
1233 ParseNode pn=new ParseNode("forstatement");
1234 pn.addChild("initializer").addChild(init);
1235 pn.addChild("condition").addChild(exp);
1236 pn.addChild("update").addChild(update);
1237 pn.addChild("statement").addChild(st);
1242 {: RESULT=new ParseNode("empty"); :}
1243 | for_init:init {: RESULT=init; :}
1245 for_init ::= statement_expression_list:list {: RESULT=list; :}
1246 | local_variable_declaration:decl {: RESULT=decl; :}
1249 {: RESULT=new ParseNode("empty"); :}
1250 | for_update:update {: RESULT=update; :}
1252 for_update ::= statement_expression_list:list {: RESULT=list; :}
1254 statement_expression_list ::=
1255 statement_expression:expr {:
1256 RESULT=(new ParseNode("statement_expression_list")).addChild(expr).getRoot();
1258 | statement_expression_list:list COMMA statement_expression:expr {:
1259 list.addChild(expr);
1264 //identifier_opt ::=
1271 SEMICOLON {: RESULT=new ParseNode("break"); :}
1274 continue_statement ::=
1278 {: RESULT=new ParseNode("continue"); :}
1280 return_statement ::=
1281 RETURN expression_opt:exp SEMICOLON {:
1282 RESULT=(new ParseNode("return")).addChild(exp).getRoot(); :}
1284 //throw_statement ::=
1285 // THROW expression SEMICOLON
1287 //synchronized_statement ::=
1288 // SYNCHRONIZED LPAREN expression RPAREN block
1291 // TRY block catches
1292 // | TRY block catches_opt finally
1297 //catches ::= catch_clause
1298 // | catches catch_clause
1301 // CATCH LPAREN formal_parameter RPAREN block
1303 //finally ::= FINALLY block
1305 //assert_statement ::=
1306 // ASSERT expression SEMICOLON
1307 // | ASSERT expression COLON expression SEMICOLON
1310 // 19.12) Expressions
1311 primary ::= primary_no_new_array:st {:
1313 // | array_creation_init:st {:
1316 | array_creation_uninit:st {:
1320 primary_no_new_array ::=
1321 literal:lit {: RESULT=lit; :}
1322 | THIS {: RESULT=new ParseNode("this"); :}
1323 | LPAREN expression:exp RPAREN {: RESULT=exp; :}
1324 | class_instance_creation_expression:exp {: RESULT=exp; :}
1325 | field_access:exp {: RESULT=exp; :}
1326 | method_invocation:exp {: RESULT=exp; :}
1327 | array_access:exp {: RESULT=exp; :}
1328 // | primitive_type DOT CLASS
1330 // | array_type DOT CLASS
1334 class_instance_creation_expression ::=
1335 NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {:
1336 ParseNode pn=new ParseNode("createobject");
1342 | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
1343 ParseNode pn=new ParseNode("createobject");
1349 | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE flag_list:fl RBRACE LBRACE tag_list:tl RBRACE {:
1350 ParseNode pn=new ParseNode("createobject");
1358 // | NEW class_or_interface_type LPAREN argument_list_opt RPAREN class_body
1359 // | primary DOT NEW IDENTIFIER
1360 // LPAREN argument_list_opt RPAREN {:
1363 // | primary DOT NEW IDENTIFIER
1364 // LPAREN argument_list_opt RPAREN class_body
1365 // | name DOT NEW IDENTIFIER
1366 // LPAREN argument_list_opt RPAREN
1367 // | name DOT NEW IDENTIFIER
1368 // LPAREN argument_list_opt RPAREN class_body
1370 cons_argument_list_opt ::=
1371 {: RESULT=new ParseNode("empty"); :}
1372 | cons_argument_list:args {: RESULT=args; :}
1375 cons_argument_list ::=
1376 IDENTIFIER:id COLON expression:exp {:
1377 ParseNode pn=new ParseNode("cons_argument_list");
1378 ParseNode pnarg=pn.addChild("binding");
1379 pnarg.addChild("var").addChild(id);
1380 pnarg.addChild("exp").addChild(exp);
1383 | argument_list:list COMMA IDENTIFIER:id COLON expression:exp {:
1384 ParseNode pnarg=new ParseNode("binding");
1385 pnarg.addChild("var").addChild(id);
1386 pnarg.addChild("exp").addChild(exp);
1387 list.addChild(pnarg);
1392 argument_list_opt ::=
1393 {: RESULT=new ParseNode("empty"); :}
1394 | argument_list:args {: RESULT=args; :}
1399 ParseNode pn=new ParseNode("argument_list");
1403 | argument_list:list COMMA expression:exp {:
1408 array_creation_uninit ::=
1409 NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
1410 ParseNode pn=new ParseNode("createarray");
1412 pn.addChild(dimexpr);
1413 pn.addChild("dims_opt").setLiteral(dims);
1416 | NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
1417 ParseNode pn=new ParseNode("createarray");
1419 pn.addChild(dimexpr);
1420 pn.addChild("dims_opt").setLiteral(dims);
1424 //array_creation_init ::=
1425 // NEW primitive_type dims array_initializer
1426 // | NEW class_or_interface_type dims array_initializer
1428 dim_exprs ::= dim_expr:exp {:
1429 ParseNode pn=new ParseNode("dim_exprs");
1432 | dim_exprs:base dim_expr:exp {:
1437 dim_expr ::= LBRACK expression:exp RBRACK {: RESULT=exp; :}
1439 dims_opt ::= {: RESULT=new Integer(0); :}
1440 | dims:dims {: RESULT = dims; :}
1443 dims ::= LBRACK RBRACK {: RESULT=new Integer(1); :}
1444 | dims:dims LBRACK RBRACK {: RESULT=new Integer(dims.intValue()+1); :}
1448 primary:base DOT IDENTIFIER:id {:
1449 ParseNode pn=new ParseNode("fieldaccess");
1450 pn.addChild("base").addChild(base);
1451 pn.addChild("field").addChild(id);
1454 // | SUPER DOT IDENTIFIER
1455 // | name DOT SUPER DOT IDENTIFIER
1457 method_invocation ::=
1458 name:name LPAREN argument_list_opt:args RPAREN {:
1459 ParseNode pn=new ParseNode("methodinvoke1");
1464 | primary:base DOT IDENTIFIER:name LPAREN argument_list_opt:args RPAREN {:
1465 ParseNode pn=new ParseNode("methodinvoke2");
1466 pn.addChild("base").addChild(base);
1467 pn.addChild("id").addChild(name);
1471 // | SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
1472 // | name DOT SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
1475 name:name LBRACK expression:exp RBRACK {:
1476 ParseNode pn=new ParseNode("arrayaccess");
1477 pn.addChild("base").addChild(name);
1478 pn.addChild("index").addChild(exp);
1481 | primary_no_new_array:base LBRACK expression:exp RBRACK {:
1482 ParseNode pn=new ParseNode("arrayaccess");
1483 pn.addChild("base").addChild(base);
1484 pn.addChild("index").addChild(exp);
1487 // | array_creation_init:init LBRACK expression:exp RBRACK {:
1488 // ParseNode pn=new ParseNode("arrayaccess");
1489 // pn.addChild("init").addChild(init);
1490 // pn.addChild("index").addChild(exp);
1494 postfix_expression ::=
1497 | name:exp {: RESULT=exp; :}
1498 | postincrement_expression:exp {: RESULT=exp; :}
1499 | postdecrement_expression:exp {: RESULT=exp; :}
1501 postincrement_expression ::=
1502 postfix_expression:exp PLUSPLUS
1503 {: RESULT=(new ParseNode("postinc")).addChild(exp).getRoot(); :}
1505 postdecrement_expression ::=
1506 postfix_expression:exp MINUSMINUS
1507 {: RESULT=(new ParseNode("postdec")).addChild(exp).getRoot(); :}
1509 unary_expression ::=
1510 preincrement_expression:exp {: RESULT=exp; :}
1511 | predecrement_expression:exp {: RESULT=exp; :}
1512 | PLUS unary_expression:exp
1513 {: RESULT=(new ParseNode("unaryplus")).addChild(exp).getRoot(); :}
1514 | MINUS unary_expression:exp
1515 {: RESULT=(new ParseNode("unaryminus")).addChild(exp).getRoot(); :}
1516 | unary_expression_not_plus_minus:exp {:
1519 preincrement_expression ::=
1520 PLUSPLUS unary_expression:exp
1521 {: RESULT=(new ParseNode("preinc")).addChild(exp).getRoot(); :}
1523 predecrement_expression ::=
1524 MINUSMINUS unary_expression:exp
1525 {: RESULT=(new ParseNode("predec")).addChild(exp).getRoot(); :}
1527 unary_expression_not_plus_minus ::=
1528 postfix_expression:exp {:
1530 // | COMP unary_expression
1531 | NOT unary_expression:exp
1532 {: RESULT=(new ParseNode("not")).addChild(exp).getRoot(); :}
1533 | cast_expression:exp {: RESULT=exp; :}
1536 LPAREN primitive_type:type
1538 RPAREN unary_expression:exp {:
1539 ParseNode pn=new ParseNode("cast1");
1540 pn.addChild("type").addChild(type);
1541 pn.addChild("exp").addChild(exp);
1544 | LPAREN expression:type RPAREN unary_expression_not_plus_minus:exp {:
1545 ParseNode pn=new ParseNode("cast2");
1546 pn.addChild("type").addChild(type);
1547 pn.addChild("exp").addChild(exp);
1551 // | LPAREN name dims RPAREN unary_expression_not_plus_minus
1553 multiplicative_expression ::=
1554 unary_expression:exp {:
1556 | multiplicative_expression:exp1 MULT unary_expression:exp2 {:
1557 ParseNode pn=new ParseNode("mult");
1562 | multiplicative_expression:exp1 DIV unary_expression:exp2 {:
1563 ParseNode pn=new ParseNode("div");
1568 | multiplicative_expression:exp1 MOD unary_expression:exp2 {:
1569 ParseNode pn=new ParseNode("mod");
1575 additive_expression ::=
1576 multiplicative_expression:exp {:
1578 | additive_expression:exp1 PLUS multiplicative_expression:exp2 {:
1579 ParseNode pn=new ParseNode("add");
1584 | additive_expression:exp1 MINUS multiplicative_expression:exp2 {:
1585 ParseNode pn=new ParseNode("sub");
1591 shift_expression ::=
1592 additive_expression:exp {:
1594 | shift_expression:exp1 LSHIFT additive_expression:exp2 {:
1595 ParseNode pn=new ParseNode("leftshift");
1600 | shift_expression:exp1 RSHIFT additive_expression:exp2 {:
1601 ParseNode pn=new ParseNode("rightshift");
1606 // | shift_expression URSHIFT additive_expression
1608 relational_expression ::=
1609 shift_expression:exp {:
1611 | relational_expression:exp1 LT shift_expression:exp2 {:
1612 ParseNode pn=new ParseNode("comp_lt");
1617 | relational_expression:exp1 GT shift_expression:exp2 {:
1618 ParseNode pn=new ParseNode("comp_gt");
1623 | relational_expression:exp1 LTEQ shift_expression:exp2 {:
1624 ParseNode pn=new ParseNode("comp_lte");
1629 | relational_expression:exp1 GTEQ shift_expression:exp2 {:
1630 ParseNode pn=new ParseNode("comp_gte");
1635 // | relational_expression INSTANCEOF reference_type
1638 equality_expression ::=
1639 relational_expression:exp {:
1641 | equality_expression:exp1 EQEQ relational_expression:exp2 {:
1642 ParseNode pn=new ParseNode("equal");
1647 | equality_expression:exp1 NOTEQ relational_expression:exp2 {:
1648 ParseNode pn=new ParseNode("not_equal");
1655 equality_expression:exp {:
1657 | and_expression:exp1 AND equality_expression:exp2 {:
1658 ParseNode pn=new ParseNode("bitwise_and");
1664 exclusive_or_expression ::=
1665 and_expression:expr {:
1668 | exclusive_or_expression:exp1 XOR and_expression:exp2 {:
1669 ParseNode pn=new ParseNode("bitwise_xor");
1675 inclusive_or_expression ::=
1676 exclusive_or_expression:exclor {:
1678 | inclusive_or_expression:exp1 OR exclusive_or_expression:exp2 {:
1679 ParseNode pn=new ParseNode("bitwise_or");
1685 conditional_and_expression ::=
1686 inclusive_or_expression:inclor {:
1688 | conditional_and_expression:exp1 ANDAND inclusive_or_expression:exp2 {:
1689 ParseNode pn=new ParseNode("logical_and");
1695 conditional_or_expression ::=
1696 conditional_and_expression:condand {:
1698 | conditional_or_expression:exp1 OROR conditional_and_expression:exp2 {:
1699 ParseNode pn=new ParseNode("logical_or");
1705 conditional_expression ::=
1706 conditional_or_expression:condor {:
1708 // | conditional_or_expression QUESTION expression
1709 // COLON conditional_expression
1711 assignment_expression ::=
1712 conditional_expression:expr {:
1714 assignment:assign {:
1717 // semantic check necessary here to ensure a valid left-hand side.
1718 // allowing a parenthesized variable here on the lhs was introduced in
1719 // JLS 2; thanks to Eric Blake for pointing this out.
1720 assignment ::= postfix_expression:lvalue assignment_operator:op assignment_expression:rvalue {:
1721 ParseNode pn=new ParseNode("assignment");
1722 pn.addChild("op").addChild(op);
1723 ParseNode pnargs=pn.addChild("args");
1724 pnargs.addChild(lvalue);
1725 pnargs.addChild(rvalue);
1729 assignment_operator ::=
1730 EQ {: RESULT=new ParseNode("eq"); :}
1731 | MULTEQ {: RESULT=new ParseNode("multeq"); :}
1732 | DIVEQ {: RESULT=new ParseNode("diveq"); :}
1733 | MODEQ {: RESULT=new ParseNode("modeq"); :}
1734 | PLUSEQ {: RESULT=new ParseNode("pluseq"); :}
1735 | MINUSEQ {: RESULT=new ParseNode("minuseq"); :}
1736 | LSHIFTEQ {: RESULT=new ParseNode("lshifteq"); :}
1737 | RSHIFTEQ {: RESULT=new ParseNode("rshifteq"); :}
1738 // | URSHIFTEQ {: RESULT=new ParseNode("urshifteq"); :}
1739 | ANDEQ {: RESULT=new ParseNode("andeq"); :}
1740 | XOREQ {: RESULT=new ParseNode("xoreq"); :}
1741 | OREQ {: RESULT=new ParseNode("oreq"); :}
1744 {: RESULT=new ParseNode("empty"); :}
1748 expression ::= assignment_expression:exp {:
1751 //constant_expression ::=