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
228 non terminal ParseNode flag_declaration;
229 non terminal ParseNode task_declaration;
230 non terminal ParseNode task_parameter_list;
231 non terminal ParseNode task_parameter;
232 non terminal ParseNode flag_expression;
233 non terminal ParseNode flag_andexpression;
234 non terminal ParseNode flag_notexpression;
235 non terminal ParseNode task_exitstatement;
236 non terminal ParseNode flag_effects_opt;
237 non terminal ParseNode flag_effects;
238 non terminal ParseNode flag_effect;
239 non terminal ParseNode flag_list;
240 non terminal ParseNode flag_list_opt;
241 non terminal ParseNode flag_change;
243 non terminal ParseNode cons_checks_opt;
244 non terminal ParseNode cons_checks;
245 non terminal ParseNode cons_check;
247 non terminal ParseNode tag_variable_declaration_statement;
248 non terminal ParseNode tag_expression_list;
249 non terminal ParseNode tag_expression;
250 non terminal ParseNode tag_list;
251 non terminal ParseNode tag_list_opt;
252 non terminal ParseNode tag_change;
259 TASK IDENTIFIER:id LPAREN task_parameter_list:tpl RPAREN
263 ParseNode pn=new ParseNode("task_declaration");
264 pn.addChild("name").addChild(id);
267 pn.addChild("body").addChild(body);
271 task_parameter_list ::=
273 ParseNode pn=new ParseNode("task_parameter_list");
277 | task_parameter_list:fpl COMMA task_parameter:fp {:
284 type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE {:
285 ParseNode pn=new ParseNode("task_parameter");
288 pn.addChild("flag").addChild(exp);
291 | type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE LBRACE tag_expression_list:texp RBRACE {:
292 ParseNode pn=new ParseNode("task_parameter");
295 pn.addChild("flag").addChild(exp);
296 pn.addChild("tag").addChild(texp);
301 tag_expression_list ::= tag_expression:te {:
302 ParseNode pn=new ParseNode("tag_expression_list");
306 | tag_expression_list:tel COMMA tag_expression:te {:
312 tag_expression ::= IDENTIFIER:type IDENTIFIER:id {:
313 ParseNode pn=new ParseNode("tag_expression");
314 pn.addChild("type").addChild(type);
315 pn.addChild("single").addChild(id);
320 tag_list_opt ::= LBRACE tag_list:fl RBRACE {:RESULT=fl;:}
321 | LBRACE RBRACE {: RESULT = new ParseNode("empty"); :}
322 | {: RESULT = new ParseNode("empty"); :}
325 tag_list ::= tag_change:fc {:
326 ParseNode pn=new ParseNode("tag_list");
330 | tag_list:fl COMMA tag_change:fc {:
335 tag_change ::= IDENTIFIER:id {:
336 RESULT=new ParseNode("name").addChild(id).getRoot();
338 | NOT IDENTIFIER:id {:
339 RESULT=new ParseNode("not").addChild("name").addChild(id).getRoot();
343 flag_andexpression:exp {:
346 | flag_expression:exp1 OROR flag_andexpression:exp2 {:
347 ParseNode pn=new ParseNode("or");
354 flag_andexpression ::=
355 flag_notexpression:exp {: RESULT=exp; :}
356 | flag_notexpression:exp1 ANDAND flag_andexpression:exp2 {:
357 ParseNode pn=new ParseNode("and");
364 flag_notexpression ::=
365 NOT flag_notexpression:exp {:
366 ParseNode pn=new ParseNode("not");
370 | LPAREN flag_expression:exp RPAREN {:
374 ParseNode pn=new ParseNode("name");
380 task_exitstatement ::= TASKEXIT flag_effects_opt:opt cons_checks_opt:cco SEMICOLON {:
381 RESULT=(new ParseNode("taskexit")).addChild(opt).getRoot().addChild(cco).getRoot();
384 cons_checks_opt ::= ASSERT LPAREN cons_checks:cc RPAREN {: RESULT=cc; :}
385 | {: RESULT = new ParseNode("empty"); :}
388 cons_checks ::= cons_check:cc {:
389 ParseNode pn=new ParseNode("cons_checks");
393 | cons_checks:ccs COMMA cons_check:cc {:
398 cons_check ::= IDENTIFIER:name LPAREN cons_argument_list_opt:args RPAREN {:
399 ParseNode pn=new ParseNode("cons_check");
400 pn.addChild("name").addChild("identifier").addChild(name);
405 flag_effects_opt ::= LPAREN flag_effects:fe RPAREN {:RESULT=fe;:}
406 | {: RESULT = new ParseNode("empty"); :}
409 flag_effects ::= flag_effect:fe {:
410 ParseNode pn=new ParseNode("flag_effects_list");
414 | flag_effects:fes COMMA flag_effect:fe {:
419 flag_effect ::= IDENTIFIER:id LBRACE flag_list:fl RBRACE tag_list_opt:tlo {:
420 ParseNode pn=new ParseNode("flag_effect");
421 pn.addChild("name").addChild(id);
426 | IDENTIFIER:id LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
427 ParseNode pn=new ParseNode("flag_effect");
428 pn.addChild("name").addChild(id);
433 flag_list_opt ::= LBRACE flag_list:fl RBRACE {:RESULT=fl;:}
434 | LBRACE RBRACE {: RESULT = new ParseNode("empty"); :}
436 {: RESULT = new ParseNode("empty"); :}
439 flag_list ::= flag_change:fc {:
440 ParseNode pn=new ParseNode("flag_list");
444 | flag_list:fl COMMA flag_change:fc {:
449 flag_change ::= IDENTIFIER:id {:
450 RESULT=new ParseNode("name").addChild(id).getRoot();
453 RESULT=new ParseNode("not").addChild("name").addChild(id).getRoot();
456 // 19.2) The Syntactic Grammar
457 goal ::= compilation_unit:cu
463 // 19.3) Lexical Structure.
466 literal ::= INTEGER_LITERAL:integer_lit
468 ParseNode pn=new ParseNode("literal");
469 pn.addChild("integer").setLiteral(integer_lit);
472 | FLOATING_POINT_LITERAL:float_lit
474 ParseNode pn=new ParseNode("literal");
475 pn.addChild("float").setLiteral(float_lit);
478 | BOOLEAN_LITERAL:boolean_lit
480 ParseNode pn=new ParseNode("literal");
481 pn.addChild("boolean").setLiteral(boolean_lit);
484 | CHARACTER_LITERAL:char_lit
486 ParseNode pn=new ParseNode("literal");
487 pn.addChild("char").setLiteral(char_lit);
490 | STRING_LITERAL:string_lit
492 ParseNode pn=new ParseNode("literal");
493 pn.addChild("string").setLiteral(string_lit);
498 RESULT=(new ParseNode("literal")).addChild("null").getRoot();
502 // 19.4) Types, Values, and Variables
503 type ::= primitive_type:type {: RESULT=type; :}
504 | reference_type:type {: RESULT=type; :}
508 numeric_type:type {: RESULT=type; :}
509 | BOOLEAN {: RESULT=(new ParseNode("type")).addChild("boolean").getRoot(); :}
511 numeric_type::= integral_type:type {: RESULT=type; :}
512 | floating_point_type:type {: RESULT=type; :}
515 BYTE {: RESULT=(new ParseNode("type")).addChild("byte").getRoot(); :}
516 | SHORT {: RESULT=(new ParseNode("type")).addChild("short").getRoot(); :}
517 | INT {: RESULT=(new ParseNode("type")).addChild("int").getRoot(); :}
518 | LONG {: RESULT=(new ParseNode("type")).addChild("long").getRoot(); :}
519 | CHAR {: RESULT=(new ParseNode("type")).addChild("char").getRoot(); :}
521 floating_point_type ::=
522 FLOAT {: RESULT=(new ParseNode("type")).addChild("float").getRoot(); :}
523 | DOUBLE {: RESULT=(new ParseNode("type")).addChild("double").getRoot(); :}
527 class_or_interface_type:type {: RESULT=type; :}
528 | array_type:type {: RESULT=type; :}
530 class_or_interface_type ::= name:name {:
531 RESULT=(new ParseNode("type")).addChild("class").addChild(name).getRoot();
534 class_type ::= class_or_interface_type:type {: RESULT=type; :};
535 //interface_type ::= class_or_interface_type;
537 array_type ::= primitive_type:prim dims:dims {:
538 ParseNode pn=(new ParseNode("type")).addChild("array");
539 pn.addChild("basetype").addChild(prim);
540 pn.addChild("dims").setLiteral(dims);
543 | name:name dims:dims {:
544 ParseNode pn=(new ParseNode("type")).addChild("array");
545 pn.addChild("basetype").addChild("type").addChild("class").addChild(name);
546 pn.addChild("dims").setLiteral(dims);
552 name ::= simple_name:name {: RESULT=name; :}
553 | qualified_name:name {: RESULT=name; :}
555 simple_name ::= IDENTIFIER:id {:
556 RESULT=(new ParseNode("name")).addChild("identifier").addChild(id).getRoot();
559 qualified_name ::= name:name DOT IDENTIFIER:id {:
560 ParseNode pn=new ParseNode("name");
561 pn.addChild("base").addChild(name);
562 pn.addChild("identifier").addChild(id);
569 package_declaration_opt:pdo
570 import_declarations_opt:ido
571 type_declarations_opt:tdo {:
572 ParseNode pn=new ParseNode("compilation_unit");
574 pn.addChild("packages").addChild(pdo);
575 pn.addChild("imports").addChild(ido);
579 package_declaration_opt ::= package_declaration:pdo {:
582 {: RESULT=new ParseNode("empty"); :}
585 import_declarations_opt ::= import_declarations:ido {:
588 {: RESULT=new ParseNode("empty"); :}
590 type_declarations_opt ::= type_declarations:tds {:
593 {: RESULT=new ParseNode("empty"); :}
596 import_declarations ::=
597 import_declaration:id {:
598 ParseNode pn=new ParseNode("import_decls_list");
602 | import_declarations:ids import_declaration:id {:
608 type_declarations ::=
609 type_declaration:td {:
610 ParseNode pn=new ParseNode("type_declaration_list");
614 | type_declarations:tds type_declaration:td {:
620 package_declaration ::=
621 PACKAGE name:name SEMICOLON {:
622 ParseNode pn=new ParseNode("package");
627 import_declaration ::=
628 single_type_import_declaration:sid {: RESULT=sid; :}
629 | type_import_on_demand_declaration:iod {: RESULT=iod; :}
631 single_type_import_declaration ::=
632 IMPORT name:name SEMICOLON {:
633 ParseNode pn=new ParseNode("import_single");
638 type_import_on_demand_declaration ::=
639 IMPORT name:name DOT MULT SEMICOLON {:
640 ParseNode pn=new ParseNode("import_ondemand");
651 | task_declaration:td
655 // | interface_declaration
656 | SEMICOLON {: RESULT=new ParseNode("empty"); :}
659 // 19.7) Productions used only in the LALR(1) grammar
661 {: RESULT=new ParseNode("empty"); :}
666 modifiers ::= modifier:mo {:
667 ParseNode pn=new ParseNode("modifier_list");
671 | modifiers:mos modifier:mo {:
677 PUBLIC {: RESULT=new ParseNode("public"); :}|
678 PROTECTED {: RESULT=new ParseNode("protected"); :}|
679 PRIVATE {: RESULT=new ParseNode("private"); :}|
680 STATIC {: RESULT=new ParseNode("static"); :} |
682 FINAL {: RESULT=new ParseNode("final"); :}|
683 NATIVE {: RESULT=new ParseNode("native"); :} |
684 SYNCHRONIZED {: RESULT=new ParseNode("synchronized"); :}
687 // STRICTFP // note that semantic analysis must check that the
688 // context of the modifier allows strictfp.
693 // 19.8.1) Class Declaration:
694 class_declaration ::=
695 modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so //interfaces_opt
698 ParseNode pn=new ParseNode("class_declaration");
699 pn.addChild("modifiers").addChild(mo);
700 pn.addChild("name").addChild(id);
701 pn.addChild("super").addChild(so);
702 pn.addChild("classbody").addChild(body);
706 super ::= EXTENDS class_type:classtype {:
711 {: RESULT=new ParseNode("empty"); :}
717 //interfaces ::= IMPLEMENTS interface_type_list
722 //interface_type_list ::=
724 // | interface_type_list COMMA interface_type
727 class_body ::= LBRACE class_body_declarations_opt:cbdo RBRACE {: RESULT=cbdo; :}
730 class_body_declarations_opt ::=
731 {: RESULT=new ParseNode("empty"); :}
732 | class_body_declarations:cbd {: RESULT=cbd; :};
734 class_body_declarations ::=
735 class_body_declaration:cbd {:
736 ParseNode pn=new ParseNode("class_body_declaration_list");
740 | class_body_declarations:cbds class_body_declaration:cbd {:
746 class_body_declaration ::=
747 class_member_declaration:member {:
748 RESULT=(new ParseNode("member")).addChild(member).getRoot();
750 // | static_initializer
751 | constructor_declaration:constructor {:
752 RESULT=(new ParseNode("constructor")).addChild(constructor).getRoot();
755 RESULT=(new ParseNode("block")).addChild(block).getRoot();
758 class_member_declaration ::=
759 //failure aware computation
760 flag_declaration:flag {:
761 RESULT=(new ParseNode("flag")).addChild(flag).getRoot();
764 field_declaration:field {:
765 RESULT=(new ParseNode("field")).addChild(field).getRoot();
767 | method_declaration:method {:
768 RESULT=(new ParseNode("method")).addChild(method).getRoot();
770 /* repeat the prod for 'class_declaration' here: */
771 // | modifiers_opt CLASS IDENTIFIER super_opt class_body
772 // | interface_declaration
773 | SEMICOLON {: RESULT=new ParseNode("empty"); :}
776 //Failure aware computation
778 FLAG IDENTIFIER:id SEMICOLON {:
779 ParseNode pn=new ParseNode("flag_declaration");
780 pn.addChild("name").addChild(id);
783 EXTERNAL FLAG IDENTIFIER:id SEMICOLON {:
784 ParseNode pn=new ParseNode("flag_declaration");
785 pn.addChild("name").addChild(id);
786 pn.addChild("external");
791 // 19.8.2) Field Declarations
792 field_declaration ::=
793 modifiers_opt:mo type:type variable_declarators:var SEMICOLON {:
794 ParseNode pn=new ParseNode("field_declaration");
795 pn.addChild("modifier").addChild(mo);
796 pn.addChild("type").addChild(type);
797 pn.addChild("variables").addChild(var);
802 variable_declarators ::=
803 variable_declarator:vd {:
804 ParseNode pn=new ParseNode("variable_declarators_list");
808 | variable_declarators:vds COMMA variable_declarator:vd {:
813 variable_declarator ::=
814 variable_declarator_id:id {:
815 ParseNode pn=new ParseNode("variable_declarator");
819 | variable_declarator_id:id EQ variable_initializer:init {:
820 ParseNode pn=new ParseNode("variable_declarator");
822 pn.addChild("initializer").addChild(init);
826 variable_declarator_id ::=
828 RESULT=(new ParseNode("single")).addChild(id).getRoot();:}
829 | variable_declarator_id:id LBRACK RBRACK {:
830 RESULT=(new ParseNode("array")).addChild(id).getRoot();:}
832 variable_initializer ::=
833 expression:exp {: RESULT=exp; :}
834 // | array_initializer
837 // 19.8.3) Method Declarations
838 method_declaration ::=
839 method_header:header method_body:body {:
840 ParseNode pn=new ParseNode("method_declaration");
842 pn.addChild("body").addChild(body);
847 modifiers_opt:mo type:type method_declarator:decl //throws_opt
849 ParseNode pn=new ParseNode("method_header");
850 pn.addChild("modifiers").addChild(mo);
851 pn.addChild("returntype").addChild(type);
855 | modifiers_opt:mo VOID method_declarator:decl //throws_opt
857 ParseNode pn=new ParseNode("method_header");
858 pn.addChild("modifiers").addChild(mo);
863 method_declarator ::=
864 IDENTIFIER:id LPAREN formal_parameter_list_opt:params RPAREN {:
865 ParseNode pn=new ParseNode("method_declarator");
866 pn.addChild("name").addChild(id);
867 pn.addChild("parameters").addChild(params);
870 // | method_declarator LBRACK RBRACK // deprecated
871 // be careful; the above production also allows 'void foo() []'
873 formal_parameter_list_opt ::=
874 {: RESULT=new ParseNode("empty"); :}
875 | formal_parameter_list:fpl {:
879 formal_parameter_list ::=
880 formal_parameter:fp {:
881 ParseNode pn=new ParseNode("formal_parameter_list");
885 | formal_parameter_list:fpl COMMA formal_parameter:fp {:
891 type:type variable_declarator_id:name {:
892 ParseNode pn=new ParseNode("formal_parameter");
897 // | FINAL type variable_declarator_id
902 //throws ::= THROWS class_type_list
904 //class_type_list ::=
906 // | class_type_list COMMA class_type
908 method_body ::= block:block {:
911 | SEMICOLON {: RESULT=new ParseNode("empty"); :}
914 // 19.8.4) Static Initializers
915 //static_initializer ::=
919 // 19.8.5) Constructor Declarations
920 constructor_declaration ::=
921 modifiers_opt:mo constructor_declarator:cd
923 constructor_body:body {:
924 ParseNode pn=new ParseNode("constructor_declaration");
925 pn.addChild("modifiers").addChild(mo);
927 pn.addChild("body").addChild(body);
931 constructor_declarator ::=
932 simple_name:name LPAREN formal_parameter_list_opt:fplo RPAREN {:
933 ParseNode pn=new ParseNode("constructor_declarator");
935 pn.addChild("parameters").addChild(fplo);
940 // LBRACE explicit_constructor_invocation:eci block_statements:bs RBRACE |
941 // LBRACE explicit_constructor_invocation RBRACE |
942 LBRACE block_statements:block RBRACE {:
943 ParseNode pn=new ParseNode("constructor_body");
947 | LBRACE RBRACE {: RESULT=new ParseNode("empty"); :}
949 //explicit_constructor_invocation ::=
950 // THIS LPAREN argument_list_opt RPAREN SEMICOLON
951 // | SUPER LPAREN argument_list_opt RPAREN SEMICOLON
952 // | primary DOT THIS LPAREN argument_list_opt RPAREN SEMICOLON
953 // | primary DOT SUPER LPAREN argument_list_opt RPAREN SEMICOLON
958 // 19.9.1) Interface Declarations
959 //interface_declaration ::=
960 // modifiers_opt INTERFACE IDENTIFIER extends_interfaces_opt
963 //extends_interfaces_opt ::=
964 // | extends_interfaces
966 //extends_interfaces ::=
967 // EXTENDS interface_type
968 // | extends_interfaces COMMA interface_type
971 // LBRACE interface_member_declarations_opt RBRACE
973 //interface_member_declarations_opt ::=
974 // | interface_member_declarations
976 //interface_member_declarations ::=
977 // interface_member_declaration
978 // | interface_member_declarations interface_member_declaration
980 //interface_member_declaration ::=
981 // constant_declaration
982 // | abstract_method_declaration
983 // | class_declaration
984 // | interface_declaration
987 //constant_declaration ::=
989 // // need to semantically check that modifiers of field declaration
990 // // include only PUBLIC, STATIC, or FINAL. Other modifiers are
993 //abstract_method_declaration ::=
994 // method_header SEMICOLON
999 //array_initializer ::=
1000 // LBRACE variable_initializers COMMA RBRACE
1001 // | LBRACE variable_initializers RBRACE
1002 // | LBRACE COMMA RBRACE
1005 //variable_initializers ::=
1006 // variable_initializer
1007 // | variable_initializers COMMA variable_initializer
1010 // 19.11) Blocks and Statements
1011 block ::= LBRACE block_statements_opt:bso RBRACE {:
1015 block_statements_opt ::=
1016 {: RESULT=new ParseNode("empty"); :}
1017 | block_statements:bs {:
1021 block_statements ::=
1022 block_statement:bs {:
1023 ParseNode pn=new ParseNode("block_statement_list");
1027 | block_statements:bss block_statement:bs {:
1033 tag_variable_declaration_statement:tvds {:
1036 | local_variable_declaration_statement:lvds {:
1039 | statement:statement {:
1042 // | class_declaration
1043 // | interface_declaration
1045 tag_variable_declaration_statement ::=
1046 TAG IDENTIFIER:id EQ NEW TAG LPAREN IDENTIFIER:type RPAREN SEMICOLON {:
1047 ParseNode pn=new ParseNode("tag_declaration");
1048 pn.addChild("single").addChild(id);
1049 pn.addChild("type").addChild(type);
1053 local_variable_declaration_statement ::=
1054 local_variable_declaration:lvd SEMICOLON {:
1058 local_variable_declaration ::=
1059 type:type variable_declarators:var {:
1060 ParseNode pn=new ParseNode("local_variable_declaration");
1065 // | FINAL type variable_declarators
1067 statement ::= statement_without_trailing_substatement:st {:
1070 // | labeled_statement:st {: RESULT=st; :}
1071 | if_then_statement:st {: RESULT=st; :}
1072 | if_then_else_statement:st {: RESULT=st; :}
1073 | while_statement:st {: RESULT=st; :}
1074 | for_statement:st {: RESULT=st; :}
1076 statement_no_short_if ::=
1077 statement_without_trailing_substatement:st {: RESULT=st; :}
1078 // | labeled_statement_no_short_if:st {: RESULT=st; :}
1079 | if_then_else_statement_no_short_if:st {: RESULT=st; :}
1080 | while_statement_no_short_if:st {: RESULT=st; :}
1081 | for_statement_no_short_if:st {: RESULT=st; :}
1083 statement_without_trailing_substatement ::=
1084 block:st {: RESULT=st; :}
1085 | empty_statement:st {: RESULT=st; :}
1086 | expression_statement:st {: RESULT=st; :}
1087 // | switch_statement
1088 | do_statement:dos {:RESULT=dos; :}
1089 | break_statement:st {: RESULT=st; :}
1090 | continue_statement:st {: RESULT=st; :}
1091 | return_statement:st {: RESULT=st; :}
1092 | task_exitstatement:st {: RESULT=st; :}
1093 // | synchronized_statement
1094 // | throw_statement
1096 // | assert_statement
1099 SEMICOLON {: RESULT=new ParseNode("nop"); :}
1101 //labeled_statement ::=
1102 // IDENTIFIER COLON statement
1104 //labeled_statement_no_short_if ::=
1105 // IDENTIFIER COLON statement_no_short_if
1107 expression_statement ::=
1108 statement_expression:se SEMICOLON {:
1109 ParseNode pn=new ParseNode("expression");
1113 statement_expression ::=
1114 assignment:st {: RESULT=st; :}
1115 | preincrement_expression:st {: RESULT=st; :}
1116 | predecrement_expression:st {: RESULT=st; :}
1117 | postincrement_expression:st {: RESULT=st; :}
1118 | postdecrement_expression:st {: RESULT=st; :}
1119 | method_invocation:st {: RESULT=st; :}
1120 | class_instance_creation_expression:st {: RESULT=st; :}
1122 if_then_statement ::=
1123 IF LPAREN expression:exp RPAREN statement:st {:
1124 ParseNode pn=new ParseNode("ifstatement");
1125 pn.addChild("condition").addChild(exp);
1126 pn.addChild("statement").addChild(st);
1130 if_then_else_statement ::=
1131 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1132 ELSE statement:else_st {:
1133 ParseNode pn=new ParseNode("ifstatement");
1134 pn.addChild("condition").addChild(exp);
1135 pn.addChild("statement").addChild(st);
1136 pn.addChild("else_statement").addChild(else_st);
1140 if_then_else_statement_no_short_if ::=
1141 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1142 ELSE statement_no_short_if:else_st {:
1143 ParseNode pn=new ParseNode("ifstatement");
1144 pn.addChild("condition").addChild(exp);
1145 pn.addChild("statement").addChild(st);
1146 pn.addChild("else_statement").addChild(else_st);
1150 //switch_statement ::=
1151 // SWITCH LPAREN expression RPAREN switch_block
1154 // LBRACE switch_block_statement_groups switch_labels RBRACE
1155 // | LBRACE switch_block_statement_groups RBRACE
1156 // | LBRACE switch_labels RBRACE
1159 //switch_block_statement_groups ::=
1160 // switch_block_statement_group
1161 // | switch_block_statement_groups switch_block_statement_group
1163 //switch_block_statement_group ::=
1164 // switch_labels block_statements
1168 // | switch_labels switch_label
1171 // CASE constant_expression COLON
1176 WHILE LPAREN expression:exp RPAREN statement:st {:
1177 ParseNode pn=new ParseNode("whilestatement");
1178 pn.addChild("condition").addChild(exp);
1179 pn.addChild("statement").addChild(st);
1183 while_statement_no_short_if ::=
1184 WHILE LPAREN expression:exp RPAREN statement_no_short_if:st {:
1185 ParseNode pn=new ParseNode("whilestatement");
1186 pn.addChild("condition").addChild(exp);
1187 pn.addChild("statement").addChild(st);
1192 DO statement:st WHILE LPAREN expression:exp RPAREN SEMICOLON {:
1193 ParseNode pn=new ParseNode("dowhilestatement");
1194 pn.addChild("condition").addChild(exp);
1195 pn.addChild("statement").addChild(st);
1200 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1201 for_update_opt:update RPAREN statement:st {:
1202 ParseNode pn=new ParseNode("forstatement");
1203 pn.addChild("initializer").addChild(init);
1204 pn.addChild("condition").addChild(exp);
1205 pn.addChild("update").addChild(update);
1206 pn.addChild("statement").addChild(st);
1210 for_statement_no_short_if ::=
1211 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1212 for_update_opt:update RPAREN statement_no_short_if:st {:
1213 ParseNode pn=new ParseNode("forstatement");
1214 pn.addChild("initializer").addChild(init);
1215 pn.addChild("condition").addChild(exp);
1216 pn.addChild("update").addChild(update);
1217 pn.addChild("statement").addChild(st);
1222 {: RESULT=new ParseNode("empty"); :}
1223 | for_init:init {: RESULT=init; :}
1225 for_init ::= statement_expression_list:list {: RESULT=list; :}
1226 | local_variable_declaration:decl {: RESULT=decl; :}
1229 {: RESULT=new ParseNode("empty"); :}
1230 | for_update:update {: RESULT=update; :}
1232 for_update ::= statement_expression_list:list {: RESULT=list; :}
1234 statement_expression_list ::=
1235 statement_expression:expr {:
1236 RESULT=(new ParseNode("statement_expression_list")).addChild(expr).getRoot();
1238 | statement_expression_list:list COMMA statement_expression:expr {:
1239 list.addChild(expr);
1244 //identifier_opt ::=
1251 SEMICOLON {: RESULT=new ParseNode("break"); :}
1254 continue_statement ::=
1258 {: RESULT=new ParseNode("continue"); :}
1260 return_statement ::=
1261 RETURN expression_opt:exp SEMICOLON {:
1262 RESULT=(new ParseNode("return")).addChild(exp).getRoot(); :}
1264 //throw_statement ::=
1265 // THROW expression SEMICOLON
1267 //synchronized_statement ::=
1268 // SYNCHRONIZED LPAREN expression RPAREN block
1271 // TRY block catches
1272 // | TRY block catches_opt finally
1277 //catches ::= catch_clause
1278 // | catches catch_clause
1281 // CATCH LPAREN formal_parameter RPAREN block
1283 //finally ::= FINALLY block
1285 //assert_statement ::=
1286 // ASSERT expression SEMICOLON
1287 // | ASSERT expression COLON expression SEMICOLON
1290 // 19.12) Expressions
1291 primary ::= primary_no_new_array:st {:
1293 // | array_creation_init:st {:
1296 | array_creation_uninit:st {:
1300 primary_no_new_array ::=
1301 literal:lit {: RESULT=lit; :}
1302 | THIS {: RESULT=new ParseNode("this"); :}
1303 | LPAREN expression:exp RPAREN {: RESULT=exp; :}
1304 | class_instance_creation_expression:exp {: RESULT=exp; :}
1305 | field_access:exp {: RESULT=exp; :}
1306 | method_invocation:exp {: RESULT=exp; :}
1307 | array_access:exp {: RESULT=exp; :}
1308 // | primitive_type DOT CLASS
1310 // | array_type DOT CLASS
1314 class_instance_creation_expression ::=
1315 NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {:
1316 ParseNode pn=new ParseNode("createobject");
1322 | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
1323 ParseNode pn=new ParseNode("createobject");
1329 | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE flag_list:fl RBRACE LBRACE tag_list:tl RBRACE {:
1330 ParseNode pn=new ParseNode("createobject");
1338 // | NEW class_or_interface_type LPAREN argument_list_opt RPAREN class_body
1339 // | primary DOT NEW IDENTIFIER
1340 // LPAREN argument_list_opt RPAREN {:
1343 // | primary DOT NEW IDENTIFIER
1344 // LPAREN argument_list_opt RPAREN class_body
1345 // | name DOT NEW IDENTIFIER
1346 // LPAREN argument_list_opt RPAREN
1347 // | name DOT NEW IDENTIFIER
1348 // LPAREN argument_list_opt RPAREN class_body
1350 cons_argument_list_opt ::=
1351 {: RESULT=new ParseNode("empty"); :}
1352 | cons_argument_list:args {: RESULT=args; :}
1355 cons_argument_list ::=
1356 IDENTIFIER:id COLON expression:exp {:
1357 ParseNode pn=new ParseNode("cons_argument_list");
1358 ParseNode pnarg=pn.addChild("binding");
1359 pnarg.addChild("var").addChild(id);
1360 pnarg.addChild("exp").addChild(exp);
1363 | argument_list:list COMMA IDENTIFIER:id COLON expression:exp {:
1364 ParseNode pnarg=new ParseNode("binding");
1365 pnarg.addChild("var").addChild(id);
1366 pnarg.addChild("exp").addChild(exp);
1367 list.addChild(pnarg);
1372 argument_list_opt ::=
1373 {: RESULT=new ParseNode("empty"); :}
1374 | argument_list:args {: RESULT=args; :}
1379 ParseNode pn=new ParseNode("argument_list");
1383 | argument_list:list COMMA expression:exp {:
1388 array_creation_uninit ::=
1389 NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
1390 ParseNode pn=new ParseNode("createarray");
1392 pn.addChild(dimexpr);
1393 pn.addChild("dims_opt").setLiteral(dims);
1396 | NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
1397 ParseNode pn=new ParseNode("createarray");
1399 pn.addChild(dimexpr);
1400 pn.addChild("dims_opt").setLiteral(dims);
1404 //array_creation_init ::=
1405 // NEW primitive_type dims array_initializer
1406 // | NEW class_or_interface_type dims array_initializer
1408 dim_exprs ::= dim_expr:exp {:
1409 ParseNode pn=new ParseNode("dim_exprs");
1412 | dim_exprs:base dim_expr:exp {:
1417 dim_expr ::= LBRACK expression:exp RBRACK {: RESULT=exp; :}
1419 dims_opt ::= {: RESULT=new Integer(0); :}
1420 | dims:dims {: RESULT = dims; :}
1423 dims ::= LBRACK RBRACK {: RESULT=new Integer(1); :}
1424 | dims:dims LBRACK RBRACK {: RESULT=new Integer(dims.intValue()+1); :}
1428 primary:base DOT IDENTIFIER:id {:
1429 ParseNode pn=new ParseNode("fieldaccess");
1430 pn.addChild("base").addChild(base);
1431 pn.addChild("field").addChild(id);
1434 // | SUPER DOT IDENTIFIER
1435 // | name DOT SUPER DOT IDENTIFIER
1437 method_invocation ::=
1438 name:name LPAREN argument_list_opt:args RPAREN {:
1439 ParseNode pn=new ParseNode("methodinvoke1");
1444 | primary:base DOT IDENTIFIER:name LPAREN argument_list_opt:args RPAREN {:
1445 ParseNode pn=new ParseNode("methodinvoke2");
1446 pn.addChild("base").addChild(base);
1447 pn.addChild("id").addChild(name);
1451 // | SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
1452 // | name DOT SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
1455 name:name LBRACK expression:exp RBRACK {:
1456 ParseNode pn=new ParseNode("arrayaccess");
1457 pn.addChild("base").addChild(name);
1458 pn.addChild("index").addChild(exp);
1461 | primary_no_new_array:base LBRACK expression:exp RBRACK {:
1462 ParseNode pn=new ParseNode("arrayaccess");
1463 pn.addChild("base").addChild(base);
1464 pn.addChild("index").addChild(exp);
1467 // | array_creation_init:init LBRACK expression:exp RBRACK {:
1468 // ParseNode pn=new ParseNode("arrayaccess");
1469 // pn.addChild("init").addChild(init);
1470 // pn.addChild("index").addChild(exp);
1474 postfix_expression ::=
1477 | name:exp {: RESULT=exp; :}
1478 | postincrement_expression:exp {: RESULT=exp; :}
1479 | postdecrement_expression:exp {: RESULT=exp; :}
1481 postincrement_expression ::=
1482 postfix_expression:exp PLUSPLUS
1483 {: RESULT=(new ParseNode("postinc")).addChild(exp).getRoot(); :}
1485 postdecrement_expression ::=
1486 postfix_expression:exp MINUSMINUS
1487 {: RESULT=(new ParseNode("postdec")).addChild(exp).getRoot(); :}
1489 unary_expression ::=
1490 preincrement_expression:exp {: RESULT=exp; :}
1491 | predecrement_expression:exp {: RESULT=exp; :}
1492 | PLUS unary_expression:exp
1493 {: RESULT=(new ParseNode("unaryplus")).addChild(exp).getRoot(); :}
1494 | MINUS unary_expression:exp
1495 {: RESULT=(new ParseNode("unaryminus")).addChild(exp).getRoot(); :}
1496 | unary_expression_not_plus_minus:exp {:
1499 preincrement_expression ::=
1500 PLUSPLUS unary_expression:exp
1501 {: RESULT=(new ParseNode("preinc")).addChild(exp).getRoot(); :}
1503 predecrement_expression ::=
1504 MINUSMINUS unary_expression:exp
1505 {: RESULT=(new ParseNode("predec")).addChild(exp).getRoot(); :}
1507 unary_expression_not_plus_minus ::=
1508 postfix_expression:exp {:
1510 // | COMP unary_expression
1511 | NOT unary_expression:exp
1512 {: RESULT=(new ParseNode("not")).addChild(exp).getRoot(); :}
1513 | cast_expression:exp {: RESULT=exp; :}
1516 LPAREN primitive_type:type
1518 RPAREN unary_expression:exp {:
1519 ParseNode pn=new ParseNode("cast1");
1520 pn.addChild("type").addChild(type);
1521 pn.addChild("exp").addChild(exp);
1524 | LPAREN expression:type RPAREN unary_expression_not_plus_minus:exp {:
1525 ParseNode pn=new ParseNode("cast2");
1526 pn.addChild("type").addChild(type);
1527 pn.addChild("exp").addChild(exp);
1531 // | LPAREN name dims RPAREN unary_expression_not_plus_minus
1533 multiplicative_expression ::=
1534 unary_expression:exp {:
1536 | multiplicative_expression:exp1 MULT unary_expression:exp2 {:
1537 ParseNode pn=new ParseNode("mult");
1542 | multiplicative_expression:exp1 DIV unary_expression:exp2 {:
1543 ParseNode pn=new ParseNode("div");
1548 | multiplicative_expression:exp1 MOD unary_expression:exp2 {:
1549 ParseNode pn=new ParseNode("mod");
1555 additive_expression ::=
1556 multiplicative_expression:exp {:
1558 | additive_expression:exp1 PLUS multiplicative_expression:exp2 {:
1559 ParseNode pn=new ParseNode("add");
1564 | additive_expression:exp1 MINUS multiplicative_expression:exp2 {:
1565 ParseNode pn=new ParseNode("sub");
1571 shift_expression ::=
1572 additive_expression:exp {:
1574 | shift_expression:exp1 LSHIFT additive_expression:exp2 {:
1575 ParseNode pn=new ParseNode("leftshift");
1580 | shift_expression:exp1 RSHIFT additive_expression:exp2 {:
1581 ParseNode pn=new ParseNode("rightshift");
1586 // | shift_expression URSHIFT additive_expression
1588 relational_expression ::=
1589 shift_expression:exp {:
1591 | relational_expression:exp1 LT shift_expression:exp2 {:
1592 ParseNode pn=new ParseNode("comp_lt");
1597 | relational_expression:exp1 GT shift_expression:exp2 {:
1598 ParseNode pn=new ParseNode("comp_gt");
1603 | relational_expression:exp1 LTEQ shift_expression:exp2 {:
1604 ParseNode pn=new ParseNode("comp_lte");
1609 | relational_expression:exp1 GTEQ shift_expression:exp2 {:
1610 ParseNode pn=new ParseNode("comp_gte");
1615 // | relational_expression INSTANCEOF reference_type
1618 equality_expression ::=
1619 relational_expression:exp {:
1621 | equality_expression:exp1 EQEQ relational_expression:exp2 {:
1622 ParseNode pn=new ParseNode("equal");
1627 | equality_expression:exp1 NOTEQ relational_expression:exp2 {:
1628 ParseNode pn=new ParseNode("not_equal");
1635 equality_expression:exp {:
1637 | and_expression:exp1 AND equality_expression:exp2 {:
1638 ParseNode pn=new ParseNode("bitwise_and");
1644 exclusive_or_expression ::=
1645 and_expression:expr {:
1648 | exclusive_or_expression:exp1 XOR and_expression:exp2 {:
1649 ParseNode pn=new ParseNode("bitwise_xor");
1655 inclusive_or_expression ::=
1656 exclusive_or_expression:exclor {:
1658 | inclusive_or_expression:exp1 OR exclusive_or_expression:exp2 {:
1659 ParseNode pn=new ParseNode("bitwise_or");
1665 conditional_and_expression ::=
1666 inclusive_or_expression:inclor {:
1668 | conditional_and_expression:exp1 ANDAND inclusive_or_expression:exp2 {:
1669 ParseNode pn=new ParseNode("logical_and");
1675 conditional_or_expression ::=
1676 conditional_and_expression:condand {:
1678 | conditional_or_expression:exp1 OROR conditional_and_expression:exp2 {:
1679 ParseNode pn=new ParseNode("logical_or");
1685 conditional_expression ::=
1686 conditional_or_expression:condor {:
1688 // | conditional_or_expression QUESTION expression
1689 // COLON conditional_expression
1691 assignment_expression ::=
1692 conditional_expression:expr {:
1694 assignment:assign {:
1697 // semantic check necessary here to ensure a valid left-hand side.
1698 // allowing a parenthesized variable here on the lhs was introduced in
1699 // JLS 2; thanks to Eric Blake for pointing this out.
1700 assignment ::= postfix_expression:lvalue assignment_operator:op assignment_expression:rvalue {:
1701 ParseNode pn=new ParseNode("assignment");
1702 pn.addChild("op").addChild(op);
1703 ParseNode pnargs=pn.addChild("args");
1704 pnargs.addChild(lvalue);
1705 pnargs.addChild(rvalue);
1709 assignment_operator ::=
1710 EQ {: RESULT=new ParseNode("eq"); :}
1711 | MULTEQ {: RESULT=new ParseNode("multeq"); :}
1712 | DIVEQ {: RESULT=new ParseNode("diveq"); :}
1713 | MODEQ {: RESULT=new ParseNode("modeq"); :}
1714 | PLUSEQ {: RESULT=new ParseNode("pluseq"); :}
1715 | MINUSEQ {: RESULT=new ParseNode("minuseq"); :}
1716 | LSHIFTEQ {: RESULT=new ParseNode("lshifteq"); :}
1717 | RSHIFTEQ {: RESULT=new ParseNode("rshifteq"); :}
1718 // | URSHIFTEQ {: RESULT=new ParseNode("urshifteq"); :}
1719 | ANDEQ {: RESULT=new ParseNode("andeq"); :}
1720 | XOREQ {: RESULT=new ParseNode("xoreq"); :}
1721 | OREQ {: RESULT=new ParseNode("oreq"); :}
1724 {: RESULT=new ParseNode("empty"); :}
1728 expression ::= assignment_expression:exp {:
1731 //constant_expression ::=