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);
299 | type:type variable_declarator_id:name LBRACE RBRACE LBRACE tag_expression_list:texp RBRACE {:
300 ParseNode pn=new ParseNode("task_parameter");
303 pn.addChild("tag").addChild(texp);
308 tag_expression_list ::= tag_expression:te {:
309 ParseNode pn=new ParseNode("tag_expression_list");
313 | tag_expression_list:tel COMMA tag_expression:te {:
319 tag_expression ::= IDENTIFIER:type IDENTIFIER:id {:
320 ParseNode pn=new ParseNode("tag_expression");
321 pn.addChild("type").addChild(type);
322 pn.addChild("single").addChild(id);
327 tag_list_opt ::= LBRACE tag_list:fl RBRACE {:RESULT=fl;:}
328 | LBRACE RBRACE {: RESULT = new ParseNode("empty"); :}
329 | {: RESULT = new ParseNode("empty"); :}
332 tag_list ::= tag_change:fc {:
333 ParseNode pn=new ParseNode("tag_list");
337 | tag_list:fl COMMA tag_change:fc {:
342 tag_change ::= IDENTIFIER:id {:
343 RESULT=new ParseNode("name").addChild(id).getRoot();
345 | NOT IDENTIFIER:id {:
346 RESULT=new ParseNode("not").addChild("name").addChild(id).getRoot();
350 flag_andexpression:exp {:
353 | flag_expression:exp1 OROR flag_andexpression:exp2 {:
354 ParseNode pn=new ParseNode("or");
361 flag_andexpression ::=
362 flag_notexpression:exp {: RESULT=exp; :}
363 | flag_notexpression:exp1 ANDAND flag_andexpression:exp2 {:
364 ParseNode pn=new ParseNode("and");
371 flag_notexpression ::=
372 NOT flag_notexpression:exp {:
373 ParseNode pn=new ParseNode("not");
377 | LPAREN flag_expression:exp RPAREN {:
381 ParseNode pn=new ParseNode("name");
387 task_exitstatement ::= TASKEXIT flag_effects_opt:opt cons_checks_opt:cco SEMICOLON {:
388 RESULT=(new ParseNode("taskexit")).addChild(opt).getRoot().addChild(cco).getRoot();
391 cons_checks_opt ::= ASSERT LPAREN cons_checks:cc RPAREN {: RESULT=cc; :}
392 | {: RESULT = new ParseNode("empty"); :}
395 cons_checks ::= cons_check:cc {:
396 ParseNode pn=new ParseNode("cons_checks");
400 | cons_checks:ccs COMMA cons_check:cc {:
405 cons_check ::= IDENTIFIER:name LPAREN cons_argument_list_opt:args RPAREN {:
406 ParseNode pn=new ParseNode("cons_check");
407 pn.addChild("name").addChild("identifier").addChild(name);
412 flag_effects_opt ::= LPAREN flag_effects:fe RPAREN {:RESULT=fe;:}
413 | {: RESULT = new ParseNode("empty"); :}
416 flag_effects ::= flag_effect:fe {:
417 ParseNode pn=new ParseNode("flag_effects_list");
421 | flag_effects:fes COMMA flag_effect:fe {:
426 flag_effect ::= IDENTIFIER:id LBRACE flag_list:fl RBRACE tag_list_opt:tlo {:
427 ParseNode pn=new ParseNode("flag_effect");
428 pn.addChild("name").addChild(id);
433 | IDENTIFIER:id LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
434 ParseNode pn=new ParseNode("flag_effect");
435 pn.addChild("name").addChild(id);
440 flag_list_opt ::= LBRACE flag_list:fl RBRACE {:RESULT=fl;:}
441 | LBRACE RBRACE {: RESULT = new ParseNode("empty"); :}
443 {: RESULT = new ParseNode("empty"); :}
446 flag_list ::= flag_change:fc {:
447 ParseNode pn=new ParseNode("flag_list");
451 | flag_list:fl COMMA flag_change:fc {:
456 flag_change ::= IDENTIFIER:id {:
457 RESULT=new ParseNode("name").addChild(id).getRoot();
460 RESULT=new ParseNode("not").addChild("name").addChild(id).getRoot();
463 // 19.2) The Syntactic Grammar
464 goal ::= compilation_unit:cu
470 // 19.3) Lexical Structure.
473 literal ::= INTEGER_LITERAL:integer_lit
475 ParseNode pn=new ParseNode("literal");
476 pn.addChild("integer").setLiteral(integer_lit);
479 | FLOATING_POINT_LITERAL:float_lit
481 ParseNode pn=new ParseNode("literal");
482 pn.addChild("float").setLiteral(float_lit);
485 | BOOLEAN_LITERAL:boolean_lit
487 ParseNode pn=new ParseNode("literal");
488 pn.addChild("boolean").setLiteral(boolean_lit);
491 | CHARACTER_LITERAL:char_lit
493 ParseNode pn=new ParseNode("literal");
494 pn.addChild("char").setLiteral(char_lit);
497 | STRING_LITERAL:string_lit
499 ParseNode pn=new ParseNode("literal");
500 pn.addChild("string").setLiteral(string_lit);
505 RESULT=(new ParseNode("literal")).addChild("null").getRoot();
509 // 19.4) Types, Values, and Variables
510 type ::= primitive_type:type {: RESULT=type; :}
511 | reference_type:type {: RESULT=type; :}
515 numeric_type:type {: RESULT=type; :}
516 | BOOLEAN {: RESULT=(new ParseNode("type")).addChild("boolean").getRoot(); :}
518 numeric_type::= integral_type:type {: RESULT=type; :}
519 | floating_point_type:type {: RESULT=type; :}
522 BYTE {: RESULT=(new ParseNode("type")).addChild("byte").getRoot(); :}
523 | SHORT {: RESULT=(new ParseNode("type")).addChild("short").getRoot(); :}
524 | INT {: RESULT=(new ParseNode("type")).addChild("int").getRoot(); :}
525 | LONG {: RESULT=(new ParseNode("type")).addChild("long").getRoot(); :}
526 | CHAR {: RESULT=(new ParseNode("type")).addChild("char").getRoot(); :}
528 floating_point_type ::=
529 FLOAT {: RESULT=(new ParseNode("type")).addChild("float").getRoot(); :}
530 | DOUBLE {: RESULT=(new ParseNode("type")).addChild("double").getRoot(); :}
534 class_or_interface_type:type {: RESULT=type; :}
535 | array_type:type {: RESULT=type; :}
537 class_or_interface_type ::= name:name {:
538 RESULT=(new ParseNode("type")).addChild("class").addChild(name).getRoot();
541 class_type ::= class_or_interface_type:type {: RESULT=type; :};
542 //interface_type ::= class_or_interface_type;
544 array_type ::= primitive_type:prim dims:dims {:
545 ParseNode pn=(new ParseNode("type")).addChild("array");
546 pn.addChild("basetype").addChild(prim);
547 pn.addChild("dims").setLiteral(dims);
550 | name:name dims:dims {:
551 ParseNode pn=(new ParseNode("type")).addChild("array");
552 pn.addChild("basetype").addChild("type").addChild("class").addChild(name);
553 pn.addChild("dims").setLiteral(dims);
559 name ::= simple_name:name {: RESULT=name; :}
560 | qualified_name:name {: RESULT=name; :}
562 simple_name ::= IDENTIFIER:id {:
563 RESULT=(new ParseNode("name")).addChild("identifier").addChild(id).getRoot();
566 qualified_name ::= name:name DOT IDENTIFIER:id {:
567 ParseNode pn=new ParseNode("name");
568 pn.addChild("base").addChild(name);
569 pn.addChild("identifier").addChild(id);
576 package_declaration_opt:pdo
577 import_declarations_opt:ido
578 type_declarations_opt:tdo {:
579 ParseNode pn=new ParseNode("compilation_unit");
581 pn.addChild("packages").addChild(pdo);
582 pn.addChild("imports").addChild(ido);
586 package_declaration_opt ::= package_declaration:pdo {:
589 {: RESULT=new ParseNode("empty"); :}
592 import_declarations_opt ::= import_declarations:ido {:
595 {: RESULT=new ParseNode("empty"); :}
597 type_declarations_opt ::= type_declarations:tds {:
600 {: RESULT=new ParseNode("empty"); :}
603 import_declarations ::=
604 import_declaration:id {:
605 ParseNode pn=new ParseNode("import_decls_list");
609 | import_declarations:ids import_declaration:id {:
615 type_declarations ::=
616 type_declaration:td {:
617 ParseNode pn=new ParseNode("type_declaration_list");
621 | type_declarations:tds type_declaration:td {:
627 package_declaration ::=
628 PACKAGE name:name SEMICOLON {:
629 ParseNode pn=new ParseNode("package");
634 import_declaration ::=
635 single_type_import_declaration:sid {: RESULT=sid; :}
636 | type_import_on_demand_declaration:iod {: RESULT=iod; :}
638 single_type_import_declaration ::=
639 IMPORT name:name SEMICOLON {:
640 ParseNode pn=new ParseNode("import_single");
645 type_import_on_demand_declaration ::=
646 IMPORT name:name DOT MULT SEMICOLON {:
647 ParseNode pn=new ParseNode("import_ondemand");
658 | task_declaration:td
662 // | interface_declaration
663 | SEMICOLON {: RESULT=new ParseNode("empty"); :}
666 // 19.7) Productions used only in the LALR(1) grammar
668 {: RESULT=new ParseNode("empty"); :}
673 modifiers ::= modifier:mo {:
674 ParseNode pn=new ParseNode("modifier_list");
678 | modifiers:mos modifier:mo {:
684 PUBLIC {: RESULT=new ParseNode("public"); :}|
685 PROTECTED {: RESULT=new ParseNode("protected"); :}|
686 PRIVATE {: RESULT=new ParseNode("private"); :}|
687 STATIC {: RESULT=new ParseNode("static"); :} |
689 FINAL {: RESULT=new ParseNode("final"); :}|
690 NATIVE {: RESULT=new ParseNode("native"); :} |
691 SYNCHRONIZED {: RESULT=new ParseNode("synchronized"); :}
694 // STRICTFP // note that semantic analysis must check that the
695 // context of the modifier allows strictfp.
700 // 19.8.1) Class Declaration:
701 class_declaration ::=
702 modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so //interfaces_opt
705 ParseNode pn=new ParseNode("class_declaration");
706 pn.addChild("modifiers").addChild(mo);
707 pn.addChild("name").addChild(id);
708 pn.addChild("super").addChild(so);
709 pn.addChild("classbody").addChild(body);
713 super ::= EXTENDS class_type:classtype {:
718 {: RESULT=new ParseNode("empty"); :}
724 //interfaces ::= IMPLEMENTS interface_type_list
729 //interface_type_list ::=
731 // | interface_type_list COMMA interface_type
734 class_body ::= LBRACE class_body_declarations_opt:cbdo RBRACE {: RESULT=cbdo; :}
737 class_body_declarations_opt ::=
738 {: RESULT=new ParseNode("empty"); :}
739 | class_body_declarations:cbd {: RESULT=cbd; :};
741 class_body_declarations ::=
742 class_body_declaration:cbd {:
743 ParseNode pn=new ParseNode("class_body_declaration_list");
747 | class_body_declarations:cbds class_body_declaration:cbd {:
753 class_body_declaration ::=
754 class_member_declaration:member {:
755 RESULT=(new ParseNode("member")).addChild(member).getRoot();
757 // | static_initializer
758 | constructor_declaration:constructor {:
759 RESULT=(new ParseNode("constructor")).addChild(constructor).getRoot();
762 RESULT=(new ParseNode("block")).addChild(block).getRoot();
765 class_member_declaration ::=
766 //failure aware computation
767 flag_declaration:flag {:
768 RESULT=(new ParseNode("flag")).addChild(flag).getRoot();
771 field_declaration:field {:
772 RESULT=(new ParseNode("field")).addChild(field).getRoot();
774 | method_declaration:method {:
775 RESULT=(new ParseNode("method")).addChild(method).getRoot();
777 /* repeat the prod for 'class_declaration' here: */
778 // | modifiers_opt CLASS IDENTIFIER super_opt class_body
779 // | interface_declaration
780 | SEMICOLON {: RESULT=new ParseNode("empty"); :}
783 //Failure aware computation
785 FLAG IDENTIFIER:id SEMICOLON {:
786 ParseNode pn=new ParseNode("flag_declaration");
787 pn.addChild("name").addChild(id);
790 EXTERNAL FLAG IDENTIFIER:id SEMICOLON {:
791 ParseNode pn=new ParseNode("flag_declaration");
792 pn.addChild("name").addChild(id);
793 pn.addChild("external");
798 // 19.8.2) Field Declarations
799 field_declaration ::=
800 modifiers_opt:mo type:type variable_declarators:var SEMICOLON {:
801 ParseNode pn=new ParseNode("field_declaration");
802 pn.addChild("modifier").addChild(mo);
803 pn.addChild("type").addChild(type);
804 pn.addChild("variables").addChild(var);
809 variable_declarators ::=
810 variable_declarator:vd {:
811 ParseNode pn=new ParseNode("variable_declarators_list");
815 | variable_declarators:vds COMMA variable_declarator:vd {:
820 variable_declarator ::=
821 variable_declarator_id:id {:
822 ParseNode pn=new ParseNode("variable_declarator");
826 | variable_declarator_id:id EQ variable_initializer:init {:
827 ParseNode pn=new ParseNode("variable_declarator");
829 pn.addChild("initializer").addChild(init);
833 variable_declarator_id ::=
835 RESULT=(new ParseNode("single")).addChild(id).getRoot();:}
836 | variable_declarator_id:id LBRACK RBRACK {:
837 RESULT=(new ParseNode("array")).addChild(id).getRoot();:}
839 variable_initializer ::=
840 expression:exp {: RESULT=exp; :}
841 // | array_initializer
844 // 19.8.3) Method Declarations
845 method_declaration ::=
846 method_header:header method_body:body {:
847 ParseNode pn=new ParseNode("method_declaration");
849 pn.addChild("body").addChild(body);
854 modifiers_opt:mo type:type method_declarator:decl //throws_opt
856 ParseNode pn=new ParseNode("method_header");
857 pn.addChild("modifiers").addChild(mo);
858 pn.addChild("returntype").addChild(type);
862 | modifiers_opt:mo VOID method_declarator:decl //throws_opt
864 ParseNode pn=new ParseNode("method_header");
865 pn.addChild("modifiers").addChild(mo);
870 method_declarator ::=
871 IDENTIFIER:id LPAREN formal_parameter_list_opt:params RPAREN {:
872 ParseNode pn=new ParseNode("method_declarator");
873 pn.addChild("name").addChild(id);
874 pn.addChild("parameters").addChild(params);
877 // | method_declarator LBRACK RBRACK // deprecated
878 // be careful; the above production also allows 'void foo() []'
880 formal_parameter_list_opt ::=
881 {: RESULT=new ParseNode("empty"); :}
882 | formal_parameter_list:fpl {:
886 formal_parameter_list ::=
887 formal_parameter:fp {:
888 ParseNode pn=new ParseNode("formal_parameter_list");
892 | formal_parameter_list:fpl COMMA formal_parameter:fp {:
898 type:type variable_declarator_id:name {:
899 ParseNode pn=new ParseNode("formal_parameter");
905 TAG variable_declarator_id:name {:
906 ParseNode pn=new ParseNode("tag_parameter");
910 // | FINAL type variable_declarator_id
915 //throws ::= THROWS class_type_list
917 //class_type_list ::=
919 // | class_type_list COMMA class_type
921 method_body ::= block:block {:
924 | SEMICOLON {: RESULT=new ParseNode("empty"); :}
927 // 19.8.4) Static Initializers
928 //static_initializer ::=
932 // 19.8.5) Constructor Declarations
933 constructor_declaration ::=
934 modifiers_opt:mo constructor_declarator:cd
936 constructor_body:body {:
937 ParseNode pn=new ParseNode("constructor_declaration");
938 pn.addChild("modifiers").addChild(mo);
940 pn.addChild("body").addChild(body);
944 constructor_declarator ::=
945 simple_name:name LPAREN formal_parameter_list_opt:fplo RPAREN {:
946 ParseNode pn=new ParseNode("constructor_declarator");
948 pn.addChild("parameters").addChild(fplo);
953 // LBRACE explicit_constructor_invocation:eci block_statements:bs RBRACE |
954 // LBRACE explicit_constructor_invocation RBRACE |
955 LBRACE block_statements:block RBRACE {:
956 ParseNode pn=new ParseNode("constructor_body");
960 | LBRACE RBRACE {: RESULT=new ParseNode("empty"); :}
962 //explicit_constructor_invocation ::=
963 // THIS LPAREN argument_list_opt RPAREN SEMICOLON
964 // | SUPER LPAREN argument_list_opt RPAREN SEMICOLON
965 // | primary DOT THIS LPAREN argument_list_opt RPAREN SEMICOLON
966 // | primary DOT SUPER LPAREN argument_list_opt RPAREN SEMICOLON
971 // 19.9.1) Interface Declarations
972 //interface_declaration ::=
973 // modifiers_opt INTERFACE IDENTIFIER extends_interfaces_opt
976 //extends_interfaces_opt ::=
977 // | extends_interfaces
979 //extends_interfaces ::=
980 // EXTENDS interface_type
981 // | extends_interfaces COMMA interface_type
984 // LBRACE interface_member_declarations_opt RBRACE
986 //interface_member_declarations_opt ::=
987 // | interface_member_declarations
989 //interface_member_declarations ::=
990 // interface_member_declaration
991 // | interface_member_declarations interface_member_declaration
993 //interface_member_declaration ::=
994 // constant_declaration
995 // | abstract_method_declaration
996 // | class_declaration
997 // | interface_declaration
1000 //constant_declaration ::=
1001 // field_declaration
1002 // // need to semantically check that modifiers of field declaration
1003 // // include only PUBLIC, STATIC, or FINAL. Other modifiers are
1006 //abstract_method_declaration ::=
1007 // method_header SEMICOLON
1012 //array_initializer ::=
1013 // LBRACE variable_initializers COMMA RBRACE
1014 // | LBRACE variable_initializers RBRACE
1015 // | LBRACE COMMA RBRACE
1018 //variable_initializers ::=
1019 // variable_initializer
1020 // | variable_initializers COMMA variable_initializer
1023 // 19.11) Blocks and Statements
1024 block ::= LBRACE block_statements_opt:bso RBRACE {:
1028 block_statements_opt ::=
1029 {: RESULT=new ParseNode("empty"); :}
1030 | block_statements:bs {:
1034 block_statements ::=
1035 block_statement:bs {:
1036 ParseNode pn=new ParseNode("block_statement_list");
1040 | block_statements:bss block_statement:bs {:
1046 tag_variable_declaration_statement:tvds {:
1049 | local_variable_declaration_statement:lvds {:
1052 | statement:statement {:
1055 // | class_declaration
1056 // | interface_declaration
1058 tag_variable_declaration_statement ::=
1059 TAG IDENTIFIER:id EQ NEW TAG LPAREN IDENTIFIER:type RPAREN SEMICOLON {:
1060 ParseNode pn=new ParseNode("tag_declaration");
1061 pn.addChild("single").addChild(id);
1062 pn.addChild("type").addChild(type);
1066 local_variable_declaration_statement ::=
1067 local_variable_declaration:lvd SEMICOLON {:
1071 local_variable_declaration ::=
1072 type:type variable_declarators:var {:
1073 ParseNode pn=new ParseNode("local_variable_declaration");
1078 // | FINAL type variable_declarators
1080 statement ::= statement_without_trailing_substatement:st {:
1083 // | labeled_statement:st {: RESULT=st; :}
1084 | if_then_statement:st {: RESULT=st; :}
1085 | if_then_else_statement:st {: RESULT=st; :}
1086 | while_statement:st {: RESULT=st; :}
1087 | for_statement:st {: RESULT=st; :}
1089 statement_no_short_if ::=
1090 statement_without_trailing_substatement:st {: RESULT=st; :}
1091 // | labeled_statement_no_short_if:st {: RESULT=st; :}
1092 | if_then_else_statement_no_short_if:st {: RESULT=st; :}
1093 | while_statement_no_short_if:st {: RESULT=st; :}
1094 | for_statement_no_short_if:st {: RESULT=st; :}
1096 statement_without_trailing_substatement ::=
1097 block:st {: RESULT=st; :}
1098 | empty_statement:st {: RESULT=st; :}
1099 | expression_statement:st {: RESULT=st; :}
1100 // | switch_statement
1101 | do_statement:dos {:RESULT=dos; :}
1102 | break_statement:st {: RESULT=st; :}
1103 | continue_statement:st {: RESULT=st; :}
1104 | return_statement:st {: RESULT=st; :}
1105 | task_exitstatement:st {: RESULT=st; :}
1106 // | synchronized_statement
1107 // | throw_statement
1109 // | assert_statement
1112 SEMICOLON {: RESULT=new ParseNode("nop"); :}
1114 //labeled_statement ::=
1115 // IDENTIFIER COLON statement
1117 //labeled_statement_no_short_if ::=
1118 // IDENTIFIER COLON statement_no_short_if
1120 expression_statement ::=
1121 statement_expression:se SEMICOLON {:
1122 ParseNode pn=new ParseNode("expression");
1126 statement_expression ::=
1127 assignment:st {: RESULT=st; :}
1128 | preincrement_expression:st {: RESULT=st; :}
1129 | predecrement_expression:st {: RESULT=st; :}
1130 | postincrement_expression:st {: RESULT=st; :}
1131 | postdecrement_expression:st {: RESULT=st; :}
1132 | method_invocation:st {: RESULT=st; :}
1133 | class_instance_creation_expression:st {: RESULT=st; :}
1135 if_then_statement ::=
1136 IF LPAREN expression:exp RPAREN statement:st {:
1137 ParseNode pn=new ParseNode("ifstatement");
1138 pn.addChild("condition").addChild(exp);
1139 pn.addChild("statement").addChild(st);
1143 if_then_else_statement ::=
1144 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1145 ELSE statement:else_st {:
1146 ParseNode pn=new ParseNode("ifstatement");
1147 pn.addChild("condition").addChild(exp);
1148 pn.addChild("statement").addChild(st);
1149 pn.addChild("else_statement").addChild(else_st);
1153 if_then_else_statement_no_short_if ::=
1154 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1155 ELSE statement_no_short_if:else_st {:
1156 ParseNode pn=new ParseNode("ifstatement");
1157 pn.addChild("condition").addChild(exp);
1158 pn.addChild("statement").addChild(st);
1159 pn.addChild("else_statement").addChild(else_st);
1163 //switch_statement ::=
1164 // SWITCH LPAREN expression RPAREN switch_block
1167 // LBRACE switch_block_statement_groups switch_labels RBRACE
1168 // | LBRACE switch_block_statement_groups RBRACE
1169 // | LBRACE switch_labels RBRACE
1172 //switch_block_statement_groups ::=
1173 // switch_block_statement_group
1174 // | switch_block_statement_groups switch_block_statement_group
1176 //switch_block_statement_group ::=
1177 // switch_labels block_statements
1181 // | switch_labels switch_label
1184 // CASE constant_expression COLON
1189 WHILE LPAREN expression:exp RPAREN statement:st {:
1190 ParseNode pn=new ParseNode("whilestatement");
1191 pn.addChild("condition").addChild(exp);
1192 pn.addChild("statement").addChild(st);
1196 while_statement_no_short_if ::=
1197 WHILE LPAREN expression:exp RPAREN statement_no_short_if:st {:
1198 ParseNode pn=new ParseNode("whilestatement");
1199 pn.addChild("condition").addChild(exp);
1200 pn.addChild("statement").addChild(st);
1205 DO statement:st WHILE LPAREN expression:exp RPAREN SEMICOLON {:
1206 ParseNode pn=new ParseNode("dowhilestatement");
1207 pn.addChild("condition").addChild(exp);
1208 pn.addChild("statement").addChild(st);
1213 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1214 for_update_opt:update RPAREN statement:st {:
1215 ParseNode pn=new ParseNode("forstatement");
1216 pn.addChild("initializer").addChild(init);
1217 pn.addChild("condition").addChild(exp);
1218 pn.addChild("update").addChild(update);
1219 pn.addChild("statement").addChild(st);
1223 for_statement_no_short_if ::=
1224 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1225 for_update_opt:update RPAREN statement_no_short_if:st {:
1226 ParseNode pn=new ParseNode("forstatement");
1227 pn.addChild("initializer").addChild(init);
1228 pn.addChild("condition").addChild(exp);
1229 pn.addChild("update").addChild(update);
1230 pn.addChild("statement").addChild(st);
1235 {: RESULT=new ParseNode("empty"); :}
1236 | for_init:init {: RESULT=init; :}
1238 for_init ::= statement_expression_list:list {: RESULT=list; :}
1239 | local_variable_declaration:decl {: RESULT=decl; :}
1242 {: RESULT=new ParseNode("empty"); :}
1243 | for_update:update {: RESULT=update; :}
1245 for_update ::= statement_expression_list:list {: RESULT=list; :}
1247 statement_expression_list ::=
1248 statement_expression:expr {:
1249 RESULT=(new ParseNode("statement_expression_list")).addChild(expr).getRoot();
1251 | statement_expression_list:list COMMA statement_expression:expr {:
1252 list.addChild(expr);
1257 //identifier_opt ::=
1264 SEMICOLON {: RESULT=new ParseNode("break"); :}
1267 continue_statement ::=
1271 {: RESULT=new ParseNode("continue"); :}
1273 return_statement ::=
1274 RETURN expression_opt:exp SEMICOLON {:
1275 RESULT=(new ParseNode("return")).addChild(exp).getRoot(); :}
1277 //throw_statement ::=
1278 // THROW expression SEMICOLON
1280 //synchronized_statement ::=
1281 // SYNCHRONIZED LPAREN expression RPAREN block
1284 // TRY block catches
1285 // | TRY block catches_opt finally
1290 //catches ::= catch_clause
1291 // | catches catch_clause
1294 // CATCH LPAREN formal_parameter RPAREN block
1296 //finally ::= FINALLY block
1298 //assert_statement ::=
1299 // ASSERT expression SEMICOLON
1300 // | ASSERT expression COLON expression SEMICOLON
1303 // 19.12) Expressions
1304 primary ::= primary_no_new_array:st {:
1306 // | array_creation_init:st {:
1309 | array_creation_uninit:st {:
1313 primary_no_new_array ::=
1314 literal:lit {: RESULT=lit; :}
1315 | THIS {: RESULT=new ParseNode("this"); :}
1316 | LPAREN expression:exp RPAREN {: RESULT=exp; :}
1317 | class_instance_creation_expression:exp {: RESULT=exp; :}
1318 | field_access:exp {: RESULT=exp; :}
1319 | method_invocation:exp {: RESULT=exp; :}
1320 | array_access:exp {: RESULT=exp; :}
1321 // | primitive_type DOT CLASS
1323 // | array_type DOT CLASS
1327 class_instance_creation_expression ::=
1328 NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {:
1329 ParseNode pn=new ParseNode("createobject");
1335 | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
1336 ParseNode pn=new ParseNode("createobject");
1342 | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE flag_list:fl RBRACE LBRACE tag_list:tl RBRACE {:
1343 ParseNode pn=new ParseNode("createobject");
1351 // | NEW class_or_interface_type LPAREN argument_list_opt RPAREN class_body
1352 // | primary DOT NEW IDENTIFIER
1353 // LPAREN argument_list_opt RPAREN {:
1356 // | primary DOT NEW IDENTIFIER
1357 // LPAREN argument_list_opt RPAREN class_body
1358 // | name DOT NEW IDENTIFIER
1359 // LPAREN argument_list_opt RPAREN
1360 // | name DOT NEW IDENTIFIER
1361 // LPAREN argument_list_opt RPAREN class_body
1363 cons_argument_list_opt ::=
1364 {: RESULT=new ParseNode("empty"); :}
1365 | cons_argument_list:args {: RESULT=args; :}
1368 cons_argument_list ::=
1369 IDENTIFIER:id COLON expression:exp {:
1370 ParseNode pn=new ParseNode("cons_argument_list");
1371 ParseNode pnarg=pn.addChild("binding");
1372 pnarg.addChild("var").addChild(id);
1373 pnarg.addChild("exp").addChild(exp);
1376 | argument_list:list COMMA IDENTIFIER:id COLON expression:exp {:
1377 ParseNode pnarg=new ParseNode("binding");
1378 pnarg.addChild("var").addChild(id);
1379 pnarg.addChild("exp").addChild(exp);
1380 list.addChild(pnarg);
1385 argument_list_opt ::=
1386 {: RESULT=new ParseNode("empty"); :}
1387 | argument_list:args {: RESULT=args; :}
1392 ParseNode pn=new ParseNode("argument_list");
1396 | argument_list:list COMMA expression:exp {:
1401 array_creation_uninit ::=
1402 NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
1403 ParseNode pn=new ParseNode("createarray");
1405 pn.addChild(dimexpr);
1406 pn.addChild("dims_opt").setLiteral(dims);
1409 | NEW class_or_interface_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);
1417 //array_creation_init ::=
1418 // NEW primitive_type dims array_initializer
1419 // | NEW class_or_interface_type dims array_initializer
1421 dim_exprs ::= dim_expr:exp {:
1422 ParseNode pn=new ParseNode("dim_exprs");
1425 | dim_exprs:base dim_expr:exp {:
1430 dim_expr ::= LBRACK expression:exp RBRACK {: RESULT=exp; :}
1432 dims_opt ::= {: RESULT=new Integer(0); :}
1433 | dims:dims {: RESULT = dims; :}
1436 dims ::= LBRACK RBRACK {: RESULT=new Integer(1); :}
1437 | dims:dims LBRACK RBRACK {: RESULT=new Integer(dims.intValue()+1); :}
1441 primary:base DOT IDENTIFIER:id {:
1442 ParseNode pn=new ParseNode("fieldaccess");
1443 pn.addChild("base").addChild(base);
1444 pn.addChild("field").addChild(id);
1447 // | SUPER DOT IDENTIFIER
1448 // | name DOT SUPER DOT IDENTIFIER
1450 method_invocation ::=
1451 name:name LPAREN argument_list_opt:args RPAREN {:
1452 ParseNode pn=new ParseNode("methodinvoke1");
1457 | primary:base DOT IDENTIFIER:name LPAREN argument_list_opt:args RPAREN {:
1458 ParseNode pn=new ParseNode("methodinvoke2");
1459 pn.addChild("base").addChild(base);
1460 pn.addChild("id").addChild(name);
1464 // | SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
1465 // | name DOT SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
1468 name:name LBRACK expression:exp RBRACK {:
1469 ParseNode pn=new ParseNode("arrayaccess");
1470 pn.addChild("base").addChild(name);
1471 pn.addChild("index").addChild(exp);
1474 | primary_no_new_array:base LBRACK expression:exp RBRACK {:
1475 ParseNode pn=new ParseNode("arrayaccess");
1476 pn.addChild("base").addChild(base);
1477 pn.addChild("index").addChild(exp);
1480 // | array_creation_init:init LBRACK expression:exp RBRACK {:
1481 // ParseNode pn=new ParseNode("arrayaccess");
1482 // pn.addChild("init").addChild(init);
1483 // pn.addChild("index").addChild(exp);
1487 postfix_expression ::=
1490 | name:exp {: RESULT=exp; :}
1491 | postincrement_expression:exp {: RESULT=exp; :}
1492 | postdecrement_expression:exp {: RESULT=exp; :}
1494 postincrement_expression ::=
1495 postfix_expression:exp PLUSPLUS
1496 {: RESULT=(new ParseNode("postinc")).addChild(exp).getRoot(); :}
1498 postdecrement_expression ::=
1499 postfix_expression:exp MINUSMINUS
1500 {: RESULT=(new ParseNode("postdec")).addChild(exp).getRoot(); :}
1502 unary_expression ::=
1503 preincrement_expression:exp {: RESULT=exp; :}
1504 | predecrement_expression:exp {: RESULT=exp; :}
1505 | PLUS unary_expression:exp
1506 {: RESULT=(new ParseNode("unaryplus")).addChild(exp).getRoot(); :}
1507 | MINUS unary_expression:exp
1508 {: RESULT=(new ParseNode("unaryminus")).addChild(exp).getRoot(); :}
1509 | unary_expression_not_plus_minus:exp {:
1512 preincrement_expression ::=
1513 PLUSPLUS unary_expression:exp
1514 {: RESULT=(new ParseNode("preinc")).addChild(exp).getRoot(); :}
1516 predecrement_expression ::=
1517 MINUSMINUS unary_expression:exp
1518 {: RESULT=(new ParseNode("predec")).addChild(exp).getRoot(); :}
1520 unary_expression_not_plus_minus ::=
1521 postfix_expression:exp {:
1523 // | COMP unary_expression
1524 | NOT unary_expression:exp
1525 {: RESULT=(new ParseNode("not")).addChild(exp).getRoot(); :}
1526 | cast_expression:exp {: RESULT=exp; :}
1529 LPAREN primitive_type:type
1531 RPAREN unary_expression:exp {:
1532 ParseNode pn=new ParseNode("cast1");
1533 pn.addChild("type").addChild(type);
1534 pn.addChild("exp").addChild(exp);
1537 | LPAREN expression:type RPAREN unary_expression_not_plus_minus:exp {:
1538 ParseNode pn=new ParseNode("cast2");
1539 pn.addChild("type").addChild(type);
1540 pn.addChild("exp").addChild(exp);
1544 // | LPAREN name dims RPAREN unary_expression_not_plus_minus
1546 multiplicative_expression ::=
1547 unary_expression:exp {:
1549 | multiplicative_expression:exp1 MULT unary_expression:exp2 {:
1550 ParseNode pn=new ParseNode("mult");
1555 | multiplicative_expression:exp1 DIV unary_expression:exp2 {:
1556 ParseNode pn=new ParseNode("div");
1561 | multiplicative_expression:exp1 MOD unary_expression:exp2 {:
1562 ParseNode pn=new ParseNode("mod");
1568 additive_expression ::=
1569 multiplicative_expression:exp {:
1571 | additive_expression:exp1 PLUS multiplicative_expression:exp2 {:
1572 ParseNode pn=new ParseNode("add");
1577 | additive_expression:exp1 MINUS multiplicative_expression:exp2 {:
1578 ParseNode pn=new ParseNode("sub");
1584 shift_expression ::=
1585 additive_expression:exp {:
1587 | shift_expression:exp1 LSHIFT additive_expression:exp2 {:
1588 ParseNode pn=new ParseNode("leftshift");
1593 | shift_expression:exp1 RSHIFT additive_expression:exp2 {:
1594 ParseNode pn=new ParseNode("rightshift");
1599 // | shift_expression URSHIFT additive_expression
1601 relational_expression ::=
1602 shift_expression:exp {:
1604 | relational_expression:exp1 LT shift_expression:exp2 {:
1605 ParseNode pn=new ParseNode("comp_lt");
1610 | relational_expression:exp1 GT shift_expression:exp2 {:
1611 ParseNode pn=new ParseNode("comp_gt");
1616 | relational_expression:exp1 LTEQ shift_expression:exp2 {:
1617 ParseNode pn=new ParseNode("comp_lte");
1622 | relational_expression:exp1 GTEQ shift_expression:exp2 {:
1623 ParseNode pn=new ParseNode("comp_gte");
1628 // | relational_expression INSTANCEOF reference_type
1631 equality_expression ::=
1632 relational_expression:exp {:
1634 | equality_expression:exp1 EQEQ relational_expression:exp2 {:
1635 ParseNode pn=new ParseNode("equal");
1640 | equality_expression:exp1 NOTEQ relational_expression:exp2 {:
1641 ParseNode pn=new ParseNode("not_equal");
1648 equality_expression:exp {:
1650 | and_expression:exp1 AND equality_expression:exp2 {:
1651 ParseNode pn=new ParseNode("bitwise_and");
1657 exclusive_or_expression ::=
1658 and_expression:expr {:
1661 | exclusive_or_expression:exp1 XOR and_expression:exp2 {:
1662 ParseNode pn=new ParseNode("bitwise_xor");
1668 inclusive_or_expression ::=
1669 exclusive_or_expression:exclor {:
1671 | inclusive_or_expression:exp1 OR exclusive_or_expression:exp2 {:
1672 ParseNode pn=new ParseNode("bitwise_or");
1678 conditional_and_expression ::=
1679 inclusive_or_expression:inclor {:
1681 | conditional_and_expression:exp1 ANDAND inclusive_or_expression:exp2 {:
1682 ParseNode pn=new ParseNode("logical_and");
1688 conditional_or_expression ::=
1689 conditional_and_expression:condand {:
1691 | conditional_or_expression:exp1 OROR conditional_and_expression:exp2 {:
1692 ParseNode pn=new ParseNode("logical_or");
1698 conditional_expression ::=
1699 conditional_or_expression:condor {:
1701 // | conditional_or_expression QUESTION expression
1702 // COLON conditional_expression
1704 assignment_expression ::=
1705 conditional_expression:expr {:
1707 assignment:assign {:
1710 // semantic check necessary here to ensure a valid left-hand side.
1711 // allowing a parenthesized variable here on the lhs was introduced in
1712 // JLS 2; thanks to Eric Blake for pointing this out.
1713 assignment ::= postfix_expression:lvalue assignment_operator:op assignment_expression:rvalue {:
1714 ParseNode pn=new ParseNode("assignment");
1715 pn.addChild("op").addChild(op);
1716 ParseNode pnargs=pn.addChild("args");
1717 pnargs.addChild(lvalue);
1718 pnargs.addChild(rvalue);
1722 assignment_operator ::=
1723 EQ {: RESULT=new ParseNode("eq"); :}
1724 | MULTEQ {: RESULT=new ParseNode("multeq"); :}
1725 | DIVEQ {: RESULT=new ParseNode("diveq"); :}
1726 | MODEQ {: RESULT=new ParseNode("modeq"); :}
1727 | PLUSEQ {: RESULT=new ParseNode("pluseq"); :}
1728 | MINUSEQ {: RESULT=new ParseNode("minuseq"); :}
1729 | LSHIFTEQ {: RESULT=new ParseNode("lshifteq"); :}
1730 | RSHIFTEQ {: RESULT=new ParseNode("rshifteq"); :}
1731 // | URSHIFTEQ {: RESULT=new ParseNode("urshifteq"); :}
1732 | ANDEQ {: RESULT=new ParseNode("andeq"); :}
1733 | XOREQ {: RESULT=new ParseNode("xoreq"); :}
1734 | OREQ {: RESULT=new ParseNode("oreq"); :}
1737 {: RESULT=new ParseNode("empty"); :}
1741 expression ::= assignment_expression:exp {:
1744 //constant_expression ::=