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;
255 //distributed transaction keywords
258 non terminal ParseNode atomic_statement;
266 TASK IDENTIFIER:id LPAREN task_parameter_list:tpl RPAREN
270 ParseNode pn=new ParseNode("task_declaration");
271 pn.addChild("name").addChild(id);
274 pn.addChild("body").addChild(body);
278 task_parameter_list ::=
280 ParseNode pn=new ParseNode("task_parameter_list");
284 | task_parameter_list:fpl COMMA task_parameter:fp {:
291 type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE {:
292 ParseNode pn=new ParseNode("task_parameter");
295 pn.addChild("flag").addChild(exp);
298 | type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE LBRACE tag_expression_list:texp RBRACE {:
299 ParseNode pn=new ParseNode("task_parameter");
302 pn.addChild("flag").addChild(exp);
303 pn.addChild("tag").addChild(texp);
306 | type:type variable_declarator_id:name LBRACE RBRACE LBRACE tag_expression_list:texp RBRACE {:
307 ParseNode pn=new ParseNode("task_parameter");
310 pn.addChild("tag").addChild(texp);
313 | OPTIONAL task_parameter:fp {:
314 ParseNode pn=new ParseNode("task_parameter");
315 pn.addChild("optional").addChild(fp);
321 tag_expression_list ::= tag_expression:te {:
322 ParseNode pn=new ParseNode("tag_expression_list");
326 | tag_expression_list:tel COMMA tag_expression:te {:
332 tag_expression ::= IDENTIFIER:type IDENTIFIER:id {:
333 ParseNode pn=new ParseNode("tag_expression");
334 pn.addChild("type").addChild(type);
335 pn.addChild("single").addChild(id);
340 tag_list_opt ::= LBRACE tag_list:fl RBRACE {:RESULT=fl;:}
341 | LBRACE RBRACE {: RESULT = new ParseNode("empty"); :}
342 | {: RESULT = new ParseNode("empty"); :}
345 tag_list ::= tag_change:fc {:
346 ParseNode pn=new ParseNode("tag_list");
350 | tag_list:fl COMMA tag_change:fc {:
355 tag_change ::= IDENTIFIER:id {:
356 RESULT=new ParseNode("name").addChild(id).getRoot();
358 | NOT IDENTIFIER:id {:
359 RESULT=new ParseNode("not").addChild("name").addChild(id).getRoot();
363 flag_andexpression:exp {:
366 | flag_expression:exp1 OROR flag_andexpression:exp2 {:
367 ParseNode pn=new ParseNode("or");
374 flag_andexpression ::=
375 flag_notexpression:exp {: RESULT=exp; :}
376 | flag_notexpression:exp1 ANDAND flag_andexpression:exp2 {:
377 ParseNode pn=new ParseNode("and");
384 flag_notexpression ::=
385 NOT flag_notexpression:exp {:
386 ParseNode pn=new ParseNode("not");
390 | LPAREN flag_expression:exp RPAREN {:
394 ParseNode pn=new ParseNode("name");
400 task_exitstatement ::= TASKEXIT flag_effects_opt:opt cons_checks_opt:cco SEMICOLON {:
401 RESULT=(new ParseNode("taskexit")).addChild(opt).getRoot().addChild(cco).getRoot();
404 cons_checks_opt ::= ASSERT LPAREN cons_checks:cc RPAREN {: RESULT=cc; :}
405 | {: RESULT = new ParseNode("empty"); :}
408 cons_checks ::= cons_check:cc {:
409 ParseNode pn=new ParseNode("cons_checks");
413 | cons_checks:ccs COMMA cons_check:cc {:
418 cons_check ::= IDENTIFIER:name LPAREN cons_argument_list_opt:args RPAREN {:
419 ParseNode pn=new ParseNode("cons_check");
420 pn.addChild("name").addChild("identifier").addChild(name);
425 flag_effects_opt ::= LPAREN flag_effects:fe RPAREN {:RESULT=fe;:}
426 | {: RESULT = new ParseNode("empty"); :}
429 flag_effects ::= flag_effect:fe {:
430 ParseNode pn=new ParseNode("flag_effects_list");
434 | flag_effects:fes COMMA flag_effect:fe {:
439 flag_effect ::= IDENTIFIER:id LBRACE flag_list:fl RBRACE tag_list_opt:tlo {:
440 ParseNode pn=new ParseNode("flag_effect");
441 pn.addChild("name").addChild(id);
446 | IDENTIFIER:id LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
447 ParseNode pn=new ParseNode("flag_effect");
448 pn.addChild("name").addChild(id);
453 flag_list_opt ::= LBRACE flag_list:fl RBRACE {:RESULT=fl;:}
454 | LBRACE RBRACE {: RESULT = new ParseNode("empty"); :}
456 {: RESULT = new ParseNode("empty"); :}
459 flag_list ::= flag_change:fc {:
460 ParseNode pn=new ParseNode("flag_list");
464 | flag_list:fl COMMA flag_change:fc {:
469 flag_change ::= IDENTIFIER:id {:
470 RESULT=new ParseNode("name").addChild(id).getRoot();
473 RESULT=new ParseNode("not").addChild("name").addChild(id).getRoot();
476 // 19.2) The Syntactic Grammar
477 goal ::= compilation_unit:cu
483 // 19.3) Lexical Structure.
486 literal ::= INTEGER_LITERAL:integer_lit
488 ParseNode pn=new ParseNode("literal");
489 pn.addChild("integer").setLiteral(integer_lit);
492 | FLOATING_POINT_LITERAL:float_lit
494 ParseNode pn=new ParseNode("literal");
495 pn.addChild("float").setLiteral(float_lit);
498 | BOOLEAN_LITERAL:boolean_lit
500 ParseNode pn=new ParseNode("literal");
501 pn.addChild("boolean").setLiteral(boolean_lit);
504 | CHARACTER_LITERAL:char_lit
506 ParseNode pn=new ParseNode("literal");
507 pn.addChild("char").setLiteral(char_lit);
510 | STRING_LITERAL:string_lit
512 ParseNode pn=new ParseNode("literal");
513 pn.addChild("string").setLiteral(string_lit);
518 RESULT=(new ParseNode("literal")).addChild("null").getRoot();
522 // 19.4) Types, Values, and Variables
523 type ::= primitive_type:type {: RESULT=type; :}
524 | reference_type:type {: RESULT=type; :}
528 numeric_type:type {: RESULT=type; :}
529 | BOOLEAN {: RESULT=(new ParseNode("type")).addChild("boolean").getRoot(); :}
531 numeric_type::= integral_type:type {: RESULT=type; :}
532 | floating_point_type:type {: RESULT=type; :}
535 BYTE {: RESULT=(new ParseNode("type")).addChild("byte").getRoot(); :}
536 | SHORT {: RESULT=(new ParseNode("type")).addChild("short").getRoot(); :}
537 | INT {: RESULT=(new ParseNode("type")).addChild("int").getRoot(); :}
538 | LONG {: RESULT=(new ParseNode("type")).addChild("long").getRoot(); :}
539 | CHAR {: RESULT=(new ParseNode("type")).addChild("char").getRoot(); :}
541 floating_point_type ::=
542 FLOAT {: RESULT=(new ParseNode("type")).addChild("float").getRoot(); :}
543 | DOUBLE {: RESULT=(new ParseNode("type")).addChild("double").getRoot(); :}
547 class_or_interface_type:type {: RESULT=type; :}
548 | array_type:type {: RESULT=type; :}
550 class_or_interface_type ::= name:name {:
551 RESULT=(new ParseNode("type")).addChild("class").addChild(name).getRoot();
554 class_type ::= class_or_interface_type:type {: RESULT=type; :};
555 //interface_type ::= class_or_interface_type;
557 array_type ::= primitive_type:prim dims:dims {:
558 ParseNode pn=(new ParseNode("type")).addChild("array");
559 pn.addChild("basetype").addChild(prim);
560 pn.addChild("dims").setLiteral(dims);
563 | name:name dims:dims {:
564 ParseNode pn=(new ParseNode("type")).addChild("array");
565 pn.addChild("basetype").addChild("type").addChild("class").addChild(name);
566 pn.addChild("dims").setLiteral(dims);
572 name ::= simple_name:name {: RESULT=name; :}
573 | qualified_name:name {: RESULT=name; :}
575 simple_name ::= IDENTIFIER:id {:
576 RESULT=(new ParseNode("name")).addChild("identifier").addChild(id).getRoot();
579 qualified_name ::= name:name DOT IDENTIFIER:id {:
580 ParseNode pn=new ParseNode("name");
581 pn.addChild("base").addChild(name);
582 pn.addChild("identifier").addChild(id);
589 package_declaration_opt:pdo
590 import_declarations_opt:ido
591 type_declarations_opt:tdo {:
592 ParseNode pn=new ParseNode("compilation_unit");
594 pn.addChild("packages").addChild(pdo);
595 pn.addChild("imports").addChild(ido);
599 package_declaration_opt ::= package_declaration:pdo {:
602 {: RESULT=new ParseNode("empty"); :}
605 import_declarations_opt ::= import_declarations:ido {:
608 {: RESULT=new ParseNode("empty"); :}
610 type_declarations_opt ::= type_declarations:tds {:
613 {: RESULT=new ParseNode("empty"); :}
616 import_declarations ::=
617 import_declaration:id {:
618 ParseNode pn=new ParseNode("import_decls_list");
622 | import_declarations:ids import_declaration:id {:
628 type_declarations ::=
629 type_declaration:td {:
630 ParseNode pn=new ParseNode("type_declaration_list");
634 | type_declarations:tds type_declaration:td {:
640 package_declaration ::=
641 PACKAGE name:name SEMICOLON {:
642 ParseNode pn=new ParseNode("package");
647 import_declaration ::=
648 single_type_import_declaration:sid {: RESULT=sid; :}
649 | type_import_on_demand_declaration:iod {: RESULT=iod; :}
651 single_type_import_declaration ::=
652 IMPORT name:name SEMICOLON {:
653 ParseNode pn=new ParseNode("import_single");
658 type_import_on_demand_declaration ::=
659 IMPORT name:name DOT MULT SEMICOLON {:
660 ParseNode pn=new ParseNode("import_ondemand");
671 | task_declaration:td
675 // | interface_declaration
676 | SEMICOLON {: RESULT=new ParseNode("empty"); :}
679 // 19.7) Productions used only in the LALR(1) grammar
681 {: RESULT=new ParseNode("empty"); :}
686 modifiers ::= modifier:mo {:
687 ParseNode pn=new ParseNode("modifier_list");
691 | modifiers:mos modifier:mo {:
697 PUBLIC {: RESULT=new ParseNode("public"); :}|
698 PROTECTED {: RESULT=new ParseNode("protected"); :}|
699 PRIVATE {: RESULT=new ParseNode("private"); :}|
700 STATIC {: RESULT=new ParseNode("static"); :} |
702 FINAL {: RESULT=new ParseNode("final"); :}|
703 NATIVE {: RESULT=new ParseNode("native"); :} |
704 SYNCHRONIZED {: RESULT=new ParseNode("synchronized"); :} |
705 ATOMIC {: RESULT=new ParseNode("atomic"); :}
708 // STRICTFP // note that semantic analysis must check that the
709 // context of the modifier allows strictfp.
714 // 19.8.1) Class Declaration:
715 class_declaration ::=
716 modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so //interfaces_opt
719 ParseNode pn=new ParseNode("class_declaration");
720 pn.addChild("modifiers").addChild(mo);
721 pn.addChild("name").addChild(id);
722 pn.addChild("super").addChild(so);
723 pn.addChild("classbody").addChild(body);
727 super ::= EXTENDS class_type:classtype {:
732 {: RESULT=new ParseNode("empty"); :}
738 //interfaces ::= IMPLEMENTS interface_type_list
743 //interface_type_list ::=
745 // | interface_type_list COMMA interface_type
748 class_body ::= LBRACE class_body_declarations_opt:cbdo RBRACE {: RESULT=cbdo; :}
751 class_body_declarations_opt ::=
752 {: RESULT=new ParseNode("empty"); :}
753 | class_body_declarations:cbd {: RESULT=cbd; :};
755 class_body_declarations ::=
756 class_body_declaration:cbd {:
757 ParseNode pn=new ParseNode("class_body_declaration_list");
761 | class_body_declarations:cbds class_body_declaration:cbd {:
767 class_body_declaration ::=
768 class_member_declaration:member {:
769 RESULT=(new ParseNode("member")).addChild(member).getRoot();
771 // | static_initializer
772 | constructor_declaration:constructor {:
773 RESULT=(new ParseNode("constructor")).addChild(constructor).getRoot();
776 RESULT=(new ParseNode("block")).addChild(block).getRoot();
779 class_member_declaration ::=
780 //failure aware computation
781 flag_declaration:flag {:
782 RESULT=(new ParseNode("flag")).addChild(flag).getRoot();
785 field_declaration:field {:
786 RESULT=(new ParseNode("field")).addChild(field).getRoot();
788 | method_declaration:method {:
789 RESULT=(new ParseNode("method")).addChild(method).getRoot();
791 /* repeat the prod for 'class_declaration' here: */
792 // | modifiers_opt CLASS IDENTIFIER super_opt class_body
793 // | interface_declaration
794 | SEMICOLON {: RESULT=new ParseNode("empty"); :}
797 //Failure aware computation
799 FLAG IDENTIFIER:id SEMICOLON {:
800 ParseNode pn=new ParseNode("flag_declaration");
801 pn.addChild("name").addChild(id);
804 EXTERNAL FLAG IDENTIFIER:id SEMICOLON {:
805 ParseNode pn=new ParseNode("flag_declaration");
806 pn.addChild("name").addChild(id);
807 pn.addChild("external");
812 // 19.8.2) Field Declarations
813 field_declaration ::=
814 modifiers_opt:mo type:type variable_declarators:var SEMICOLON {:
815 ParseNode pn=new ParseNode("field_declaration");
816 pn.addChild("modifier").addChild(mo);
817 pn.addChild("type").addChild(type);
818 pn.addChild("variables").addChild(var);
821 modifiers_opt:mo GLOBAL type:type variable_declarators:var SEMICOLON {:
822 ParseNode pn=new ParseNode("field_declaration");
823 pn.addChild("modifier").addChild(mo);
824 pn.addChild("type").addChild(type);
825 pn.addChild("variables").addChild(var);
826 pn.addChild("global");
831 variable_declarators ::=
832 variable_declarator:vd {:
833 ParseNode pn=new ParseNode("variable_declarators_list");
837 | variable_declarators:vds COMMA variable_declarator:vd {:
842 variable_declarator ::=
843 variable_declarator_id:id {:
844 ParseNode pn=new ParseNode("variable_declarator");
848 | variable_declarator_id:id EQ variable_initializer:init {:
849 ParseNode pn=new ParseNode("variable_declarator");
851 pn.addChild("initializer").addChild(init);
855 variable_declarator_id ::=
857 RESULT=(new ParseNode("single")).addChild(id).getRoot();:}
858 | variable_declarator_id:id LBRACK RBRACK {:
859 RESULT=(new ParseNode("array")).addChild(id).getRoot();:}
861 variable_initializer ::=
862 expression:exp {: RESULT=exp; :}
863 // | array_initializer
866 // 19.8.3) Method Declarations
867 method_declaration ::=
868 method_header:header method_body:body {:
869 ParseNode pn=new ParseNode("method_declaration");
871 pn.addChild("body").addChild(body);
876 modifiers_opt:mo type:type method_declarator:decl //throws_opt
878 ParseNode pn=new ParseNode("method_header");
879 pn.addChild("modifiers").addChild(mo);
880 pn.addChild("returntype").addChild(type);
884 | modifiers_opt:mo VOID method_declarator:decl //throws_opt
886 ParseNode pn=new ParseNode("method_header");
887 pn.addChild("modifiers").addChild(mo);
892 method_declarator ::=
893 IDENTIFIER:id LPAREN formal_parameter_list_opt:params RPAREN {:
894 ParseNode pn=new ParseNode("method_declarator");
895 pn.addChild("name").addChild(id);
896 pn.addChild("parameters").addChild(params);
899 // | method_declarator LBRACK RBRACK // deprecated
900 // be careful; the above production also allows 'void foo() []'
902 formal_parameter_list_opt ::=
903 {: RESULT=new ParseNode("empty"); :}
904 | formal_parameter_list:fpl {:
908 formal_parameter_list ::=
909 formal_parameter:fp {:
910 ParseNode pn=new ParseNode("formal_parameter_list");
914 | formal_parameter_list:fpl COMMA formal_parameter:fp {:
920 type:type variable_declarator_id:name {:
921 ParseNode pn=new ParseNode("formal_parameter");
927 TAG variable_declarator_id:name {:
928 ParseNode pn=new ParseNode("tag_parameter");
932 // | FINAL type variable_declarator_id
937 //throws ::= THROWS class_type_list
939 //class_type_list ::=
941 // | class_type_list COMMA class_type
943 method_body ::= block:block {:
946 | SEMICOLON {: RESULT=new ParseNode("empty"); :}
949 // 19.8.4) Static Initializers
950 //static_initializer ::=
954 // 19.8.5) Constructor Declarations
955 constructor_declaration ::=
956 modifiers_opt:mo constructor_declarator:cd
958 constructor_body:body {:
959 ParseNode pn=new ParseNode("constructor_declaration");
960 pn.addChild("modifiers").addChild(mo);
962 pn.addChild("body").addChild(body);
965 modifiers_opt:mo GLOBAL constructor_declarator:cd
967 constructor_body:body {:
968 ParseNode pn=new ParseNode("constructor_declaration");
969 pn.addChild("global");
970 pn.addChild("modifiers").addChild(mo);
972 pn.addChild("body").addChild(body);
976 constructor_declarator ::=
977 simple_name:name LPAREN formal_parameter_list_opt:fplo RPAREN {:
978 ParseNode pn=new ParseNode("constructor_declarator");
980 pn.addChild("parameters").addChild(fplo);
985 // LBRACE explicit_constructor_invocation:eci block_statements:bs RBRACE |
986 // LBRACE explicit_constructor_invocation RBRACE |
987 LBRACE block_statements:block RBRACE {:
988 ParseNode pn=new ParseNode("constructor_body");
992 | LBRACE RBRACE {: RESULT=new ParseNode("empty"); :}
994 //explicit_constructor_invocation ::=
995 // THIS LPAREN argument_list_opt RPAREN SEMICOLON
996 // | SUPER LPAREN argument_list_opt RPAREN SEMICOLON
997 // | primary DOT THIS LPAREN argument_list_opt RPAREN SEMICOLON
998 // | primary DOT SUPER LPAREN argument_list_opt RPAREN SEMICOLON
1003 // 19.9.1) Interface Declarations
1004 //interface_declaration ::=
1005 // modifiers_opt INTERFACE IDENTIFIER extends_interfaces_opt
1008 //extends_interfaces_opt ::=
1009 // | extends_interfaces
1011 //extends_interfaces ::=
1012 // EXTENDS interface_type
1013 // | extends_interfaces COMMA interface_type
1015 //interface_body ::=
1016 // LBRACE interface_member_declarations_opt RBRACE
1018 //interface_member_declarations_opt ::=
1019 // | interface_member_declarations
1021 //interface_member_declarations ::=
1022 // interface_member_declaration
1023 // | interface_member_declarations interface_member_declaration
1025 //interface_member_declaration ::=
1026 // constant_declaration
1027 // | abstract_method_declaration
1028 // | class_declaration
1029 // | interface_declaration
1032 //constant_declaration ::=
1033 // field_declaration
1034 // // need to semantically check that modifiers of field declaration
1035 // // include only PUBLIC, STATIC, or FINAL. Other modifiers are
1038 //abstract_method_declaration ::=
1039 // method_header SEMICOLON
1044 //array_initializer ::=
1045 // LBRACE variable_initializers COMMA RBRACE
1046 // | LBRACE variable_initializers RBRACE
1047 // | LBRACE COMMA RBRACE
1050 //variable_initializers ::=
1051 // variable_initializer
1052 // | variable_initializers COMMA variable_initializer
1055 // 19.11) Blocks and Statements
1056 block ::= LBRACE block_statements_opt:bso RBRACE {:
1060 block_statements_opt ::=
1061 {: RESULT=new ParseNode("empty"); :}
1062 | block_statements:bs {:
1066 block_statements ::=
1067 block_statement:bs {:
1068 ParseNode pn=new ParseNode("block_statement_list");
1072 | block_statements:bss block_statement:bs {:
1078 tag_variable_declaration_statement:tvds {:
1081 | local_variable_declaration_statement:lvds {:
1084 | statement:statement {:
1087 // | class_declaration
1088 // | interface_declaration
1090 tag_variable_declaration_statement ::=
1091 TAG IDENTIFIER:id EQ NEW TAG LPAREN IDENTIFIER:type RPAREN SEMICOLON {:
1092 ParseNode pn=new ParseNode("tag_declaration");
1093 pn.addChild("single").addChild(id);
1094 pn.addChild("type").addChild(type);
1098 local_variable_declaration_statement ::=
1099 local_variable_declaration:lvd SEMICOLON {:
1103 local_variable_declaration ::=
1104 type:type variable_declarators:var {:
1105 ParseNode pn=new ParseNode("local_variable_declaration");
1110 // | FINAL type variable_declarators
1112 statement ::= statement_without_trailing_substatement:st {:
1115 // | labeled_statement:st {: RESULT=st; :}
1116 | if_then_statement:st {: RESULT=st; :}
1117 | if_then_else_statement:st {: RESULT=st; :}
1118 | while_statement:st {: RESULT=st; :}
1119 | for_statement:st {: RESULT=st; :}
1121 statement_no_short_if ::=
1122 statement_without_trailing_substatement:st {: RESULT=st; :}
1123 // | labeled_statement_no_short_if:st {: RESULT=st; :}
1124 | if_then_else_statement_no_short_if:st {: RESULT=st; :}
1125 | while_statement_no_short_if:st {: RESULT=st; :}
1126 | for_statement_no_short_if:st {: RESULT=st; :}
1128 statement_without_trailing_substatement ::=
1129 block:st {: RESULT=st; :}
1130 | empty_statement:st {: RESULT=st; :}
1131 | expression_statement:st {: RESULT=st; :}
1132 // | switch_statement
1133 | do_statement:dos {:RESULT=dos; :}
1134 | break_statement:st {: RESULT=st; :}
1135 | continue_statement:st {: RESULT=st; :}
1136 | return_statement:st {: RESULT=st; :}
1137 | task_exitstatement:st {: RESULT=st; :}
1138 | atomic_statement:st {: RESULT=st; :}
1139 // | synchronized_statement
1140 // | throw_statement
1142 // | assert_statement
1145 SEMICOLON {: RESULT=new ParseNode("nop"); :}
1147 //labeled_statement ::=
1148 // IDENTIFIER COLON statement
1150 //labeled_statement_no_short_if ::=
1151 // IDENTIFIER COLON statement_no_short_if
1153 expression_statement ::=
1154 statement_expression:se SEMICOLON {:
1155 ParseNode pn=new ParseNode("expression");
1159 statement_expression ::=
1160 assignment:st {: RESULT=st; :}
1161 | preincrement_expression:st {: RESULT=st; :}
1162 | predecrement_expression:st {: RESULT=st; :}
1163 | postincrement_expression:st {: RESULT=st; :}
1164 | postdecrement_expression:st {: RESULT=st; :}
1165 | method_invocation:st {: RESULT=st; :}
1166 | class_instance_creation_expression:st {: RESULT=st; :}
1168 if_then_statement ::=
1169 IF LPAREN expression:exp RPAREN statement:st {:
1170 ParseNode pn=new ParseNode("ifstatement");
1171 pn.addChild("condition").addChild(exp);
1172 pn.addChild("statement").addChild(st);
1176 if_then_else_statement ::=
1177 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1178 ELSE statement:else_st {:
1179 ParseNode pn=new ParseNode("ifstatement");
1180 pn.addChild("condition").addChild(exp);
1181 pn.addChild("statement").addChild(st);
1182 pn.addChild("else_statement").addChild(else_st);
1186 if_then_else_statement_no_short_if ::=
1187 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1188 ELSE statement_no_short_if:else_st {:
1189 ParseNode pn=new ParseNode("ifstatement");
1190 pn.addChild("condition").addChild(exp);
1191 pn.addChild("statement").addChild(st);
1192 pn.addChild("else_statement").addChild(else_st);
1196 //switch_statement ::=
1197 // SWITCH LPAREN expression RPAREN switch_block
1200 // LBRACE switch_block_statement_groups switch_labels RBRACE
1201 // | LBRACE switch_block_statement_groups RBRACE
1202 // | LBRACE switch_labels RBRACE
1205 //switch_block_statement_groups ::=
1206 // switch_block_statement_group
1207 // | switch_block_statement_groups switch_block_statement_group
1209 //switch_block_statement_group ::=
1210 // switch_labels block_statements
1214 // | switch_labels switch_label
1217 // CASE constant_expression COLON
1222 WHILE LPAREN expression:exp RPAREN statement:st {:
1223 ParseNode pn=new ParseNode("whilestatement");
1224 pn.addChild("condition").addChild(exp);
1225 pn.addChild("statement").addChild(st);
1229 while_statement_no_short_if ::=
1230 WHILE LPAREN expression:exp RPAREN statement_no_short_if:st {:
1231 ParseNode pn=new ParseNode("whilestatement");
1232 pn.addChild("condition").addChild(exp);
1233 pn.addChild("statement").addChild(st);
1238 DO statement:st WHILE LPAREN expression:exp RPAREN SEMICOLON {:
1239 ParseNode pn=new ParseNode("dowhilestatement");
1240 pn.addChild("condition").addChild(exp);
1241 pn.addChild("statement").addChild(st);
1246 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1247 for_update_opt:update RPAREN statement:st {:
1248 ParseNode pn=new ParseNode("forstatement");
1249 pn.addChild("initializer").addChild(init);
1250 pn.addChild("condition").addChild(exp);
1251 pn.addChild("update").addChild(update);
1252 pn.addChild("statement").addChild(st);
1256 for_statement_no_short_if ::=
1257 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1258 for_update_opt:update RPAREN statement_no_short_if:st {:
1259 ParseNode pn=new ParseNode("forstatement");
1260 pn.addChild("initializer").addChild(init);
1261 pn.addChild("condition").addChild(exp);
1262 pn.addChild("update").addChild(update);
1263 pn.addChild("statement").addChild(st);
1268 {: RESULT=new ParseNode("empty"); :}
1269 | for_init:init {: RESULT=init; :}
1271 for_init ::= statement_expression_list:list {: RESULT=list; :}
1272 | local_variable_declaration:decl {: RESULT=decl; :}
1275 {: RESULT=new ParseNode("empty"); :}
1276 | for_update:update {: RESULT=update; :}
1278 for_update ::= statement_expression_list:list {: RESULT=list; :}
1280 statement_expression_list ::=
1281 statement_expression:expr {:
1282 RESULT=(new ParseNode("statement_expression_list")).addChild(expr).getRoot();
1284 | statement_expression_list:list COMMA statement_expression:expr {:
1285 list.addChild(expr);
1290 //identifier_opt ::=
1297 SEMICOLON {: RESULT=new ParseNode("break"); :}
1300 continue_statement ::=
1304 {: RESULT=new ParseNode("continue"); :}
1306 return_statement ::=
1307 RETURN expression_opt:exp SEMICOLON {:
1308 RESULT=(new ParseNode("return")).addChild(exp).getRoot(); :}
1310 //throw_statement ::=
1311 // THROW expression SEMICOLON
1313 //synchronized_statement ::=
1314 // SYNCHRONIZED LPAREN expression RPAREN block
1316 atomic_statement ::=
1318 RESULT=(new ParseNode("atomic")).addChild(blk).getRoot();
1322 // TRY block catches
1323 // | TRY block catches_opt finally
1328 //catches ::= catch_clause
1329 // | catches catch_clause
1332 // CATCH LPAREN formal_parameter RPAREN block
1334 //finally ::= FINALLY block
1336 //assert_statement ::=
1337 // ASSERT expression SEMICOLON
1338 // | ASSERT expression COLON expression SEMICOLON
1341 // 19.12) Expressions
1342 primary ::= primary_no_new_array:st {:
1344 // | array_creation_init:st {:
1347 | array_creation_uninit:st {:
1351 primary_no_new_array ::=
1352 literal:lit {: RESULT=lit; :}
1353 | THIS {: RESULT=new ParseNode("this"); :}
1354 | LPAREN expression:exp RPAREN {: RESULT=exp; :}
1355 | class_instance_creation_expression:exp {: RESULT=exp; :}
1356 | field_access:exp {: RESULT=exp; :}
1357 | method_invocation:exp {: RESULT=exp; :}
1358 | array_access:exp {: RESULT=exp; :}
1359 // | primitive_type DOT CLASS
1361 // | array_type DOT CLASS
1365 class_instance_creation_expression ::=
1366 NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {:
1367 ParseNode pn=new ParseNode("createobject");
1374 | GLOBAL NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {:
1375 ParseNode pn=new ParseNode("createobject");
1379 pn.addChild("global");
1382 | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE RBRACE LBRACE tag_list:tl RBRACE {:
1383 ParseNode pn=new ParseNode("createobject");
1389 | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE flag_list:fl RBRACE LBRACE tag_list:tl RBRACE {:
1390 ParseNode pn=new ParseNode("createobject");
1398 // | NEW class_or_interface_type LPAREN argument_list_opt RPAREN class_body
1399 // | primary DOT NEW IDENTIFIER
1400 // LPAREN argument_list_opt RPAREN {:
1403 // | primary DOT NEW IDENTIFIER
1404 // LPAREN argument_list_opt RPAREN class_body
1405 // | name DOT NEW IDENTIFIER
1406 // LPAREN argument_list_opt RPAREN
1407 // | name DOT NEW IDENTIFIER
1408 // LPAREN argument_list_opt RPAREN class_body
1410 cons_argument_list_opt ::=
1411 {: RESULT=new ParseNode("empty"); :}
1412 | cons_argument_list:args {: RESULT=args; :}
1415 cons_argument_list ::=
1416 IDENTIFIER:id COLON expression:exp {:
1417 ParseNode pn=new ParseNode("cons_argument_list");
1418 ParseNode pnarg=pn.addChild("binding");
1419 pnarg.addChild("var").addChild(id);
1420 pnarg.addChild("exp").addChild(exp);
1423 | argument_list:list COMMA IDENTIFIER:id COLON expression:exp {:
1424 ParseNode pnarg=new ParseNode("binding");
1425 pnarg.addChild("var").addChild(id);
1426 pnarg.addChild("exp").addChild(exp);
1427 list.addChild(pnarg);
1432 argument_list_opt ::=
1433 {: RESULT=new ParseNode("empty"); :}
1434 | argument_list:args {: RESULT=args; :}
1439 ParseNode pn=new ParseNode("argument_list");
1443 | argument_list:list COMMA expression:exp {:
1448 array_creation_uninit ::=
1449 NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
1450 ParseNode pn=new ParseNode("createarray");
1452 pn.addChild(dimexpr);
1453 pn.addChild("dims_opt").setLiteral(dims);
1456 | NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
1457 ParseNode pn=new ParseNode("createarray");
1459 pn.addChild(dimexpr);
1460 pn.addChild("dims_opt").setLiteral(dims);
1463 | NEW GLOBAL primitive_type:type dim_exprs:dimexpr dims_opt:dims {:
1464 ParseNode pn=new ParseNode("createarray");
1466 pn.addChild(dimexpr);
1467 pn.addChild("dims_opt").setLiteral(dims);
1468 pn.addChild("global");
1471 | NEW GLOBAL class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {:
1472 ParseNode pn=new ParseNode("createarray");
1474 pn.addChild(dimexpr);
1475 pn.addChild("dims_opt").setLiteral(dims);
1476 pn.addChild("global");
1480 //array_creation_init ::=
1481 // NEW primitive_type dims array_initializer
1482 // | NEW class_or_interface_type dims array_initializer
1484 dim_exprs ::= dim_expr:exp {:
1485 ParseNode pn=new ParseNode("dim_exprs");
1488 | dim_exprs:base dim_expr:exp {:
1493 dim_expr ::= LBRACK expression:exp RBRACK {: RESULT=exp; :}
1495 dims_opt ::= {: RESULT=new Integer(0); :}
1496 | dims:dims {: RESULT = dims; :}
1499 dims ::= LBRACK RBRACK {: RESULT=new Integer(1); :}
1500 | dims:dims LBRACK RBRACK {: RESULT=new Integer(dims.intValue()+1); :}
1504 primary:base DOT IDENTIFIER:id {:
1505 ParseNode pn=new ParseNode("fieldaccess");
1506 pn.addChild("base").addChild(base);
1507 pn.addChild("field").addChild(id);
1510 // | SUPER DOT IDENTIFIER
1511 // | name DOT SUPER DOT IDENTIFIER
1513 method_invocation ::=
1514 name:name LPAREN argument_list_opt:args RPAREN {:
1515 ParseNode pn=new ParseNode("methodinvoke1");
1520 | primary:base DOT IDENTIFIER:name LPAREN argument_list_opt:args RPAREN {:
1521 ParseNode pn=new ParseNode("methodinvoke2");
1522 pn.addChild("base").addChild(base);
1523 pn.addChild("id").addChild(name);
1527 // | SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
1528 // | name DOT SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
1531 name:name LBRACK expression:exp RBRACK {:
1532 ParseNode pn=new ParseNode("arrayaccess");
1533 pn.addChild("base").addChild(name);
1534 pn.addChild("index").addChild(exp);
1537 | primary_no_new_array:base LBRACK expression:exp RBRACK {:
1538 ParseNode pn=new ParseNode("arrayaccess");
1539 pn.addChild("base").addChild(base);
1540 pn.addChild("index").addChild(exp);
1543 // | array_creation_init:init LBRACK expression:exp RBRACK {:
1544 // ParseNode pn=new ParseNode("arrayaccess");
1545 // pn.addChild("init").addChild(init);
1546 // pn.addChild("index").addChild(exp);
1550 postfix_expression ::=
1553 | name:exp {: RESULT=exp; :}
1554 | postincrement_expression:exp {: RESULT=exp; :}
1555 | postdecrement_expression:exp {: RESULT=exp; :}
1557 postincrement_expression ::=
1558 postfix_expression:exp PLUSPLUS
1559 {: RESULT=(new ParseNode("postinc")).addChild(exp).getRoot(); :}
1561 postdecrement_expression ::=
1562 postfix_expression:exp MINUSMINUS
1563 {: RESULT=(new ParseNode("postdec")).addChild(exp).getRoot(); :}
1565 unary_expression ::=
1566 preincrement_expression:exp {: RESULT=exp; :}
1567 | predecrement_expression:exp {: RESULT=exp; :}
1568 | PLUS unary_expression:exp
1569 {: RESULT=(new ParseNode("unaryplus")).addChild(exp).getRoot(); :}
1570 | MINUS unary_expression:exp
1571 {: RESULT=(new ParseNode("unaryminus")).addChild(exp).getRoot(); :}
1572 | unary_expression_not_plus_minus:exp {:
1575 preincrement_expression ::=
1576 PLUSPLUS unary_expression:exp
1577 {: RESULT=(new ParseNode("preinc")).addChild(exp).getRoot(); :}
1579 predecrement_expression ::=
1580 MINUSMINUS unary_expression:exp
1581 {: RESULT=(new ParseNode("predec")).addChild(exp).getRoot(); :}
1583 unary_expression_not_plus_minus ::=
1584 postfix_expression:exp {:
1586 // | COMP unary_expression
1587 | NOT unary_expression:exp
1588 {: RESULT=(new ParseNode("not")).addChild(exp).getRoot(); :}
1589 | cast_expression:exp {: RESULT=exp; :}
1592 LPAREN primitive_type:type
1594 RPAREN unary_expression:exp {:
1595 ParseNode pn=new ParseNode("cast1");
1596 pn.addChild("type").addChild(type);
1597 pn.addChild("exp").addChild(exp);
1600 | LPAREN expression:type RPAREN unary_expression_not_plus_minus:exp {:
1601 ParseNode pn=new ParseNode("cast2");
1602 pn.addChild("type").addChild(type);
1603 pn.addChild("exp").addChild(exp);
1607 // | LPAREN name dims RPAREN unary_expression_not_plus_minus
1609 multiplicative_expression ::=
1610 unary_expression:exp {:
1612 | multiplicative_expression:exp1 MULT unary_expression:exp2 {:
1613 ParseNode pn=new ParseNode("mult");
1618 | multiplicative_expression:exp1 DIV unary_expression:exp2 {:
1619 ParseNode pn=new ParseNode("div");
1624 | multiplicative_expression:exp1 MOD unary_expression:exp2 {:
1625 ParseNode pn=new ParseNode("mod");
1631 additive_expression ::=
1632 multiplicative_expression:exp {:
1634 | additive_expression:exp1 PLUS multiplicative_expression:exp2 {:
1635 ParseNode pn=new ParseNode("add");
1640 | additive_expression:exp1 MINUS multiplicative_expression:exp2 {:
1641 ParseNode pn=new ParseNode("sub");
1647 shift_expression ::=
1648 additive_expression:exp {:
1650 | shift_expression:exp1 LSHIFT additive_expression:exp2 {:
1651 ParseNode pn=new ParseNode("leftshift");
1656 | shift_expression:exp1 RSHIFT additive_expression:exp2 {:
1657 ParseNode pn=new ParseNode("rightshift");
1662 // | shift_expression URSHIFT additive_expression
1664 relational_expression ::=
1665 shift_expression:exp {:
1667 | relational_expression:exp1 LT shift_expression:exp2 {:
1668 ParseNode pn=new ParseNode("comp_lt");
1673 | relational_expression:exp1 GT shift_expression:exp2 {:
1674 ParseNode pn=new ParseNode("comp_gt");
1679 | relational_expression:exp1 LTEQ shift_expression:exp2 {:
1680 ParseNode pn=new ParseNode("comp_lte");
1685 | relational_expression:exp1 GTEQ shift_expression:exp2 {:
1686 ParseNode pn=new ParseNode("comp_gte");
1691 // | relational_expression INSTANCEOF reference_type
1694 equality_expression ::=
1695 relational_expression:exp {:
1697 | equality_expression:exp1 EQEQ relational_expression:exp2 {:
1698 ParseNode pn=new ParseNode("equal");
1703 | equality_expression:exp1 NOTEQ relational_expression:exp2 {:
1704 ParseNode pn=new ParseNode("not_equal");
1711 equality_expression:exp {:
1713 | and_expression:exp1 AND equality_expression:exp2 {:
1714 ParseNode pn=new ParseNode("bitwise_and");
1720 exclusive_or_expression ::=
1721 and_expression:expr {:
1724 | exclusive_or_expression:exp1 XOR and_expression:exp2 {:
1725 ParseNode pn=new ParseNode("bitwise_xor");
1731 inclusive_or_expression ::=
1732 exclusive_or_expression:exclor {:
1734 | inclusive_or_expression:exp1 OR exclusive_or_expression:exp2 {:
1735 ParseNode pn=new ParseNode("bitwise_or");
1741 conditional_and_expression ::=
1742 inclusive_or_expression:inclor {:
1744 | conditional_and_expression:exp1 ANDAND inclusive_or_expression:exp2 {:
1745 ParseNode pn=new ParseNode("logical_and");
1751 conditional_or_expression ::=
1752 conditional_and_expression:condand {:
1754 | conditional_or_expression:exp1 OROR conditional_and_expression:exp2 {:
1755 ParseNode pn=new ParseNode("logical_or");
1761 conditional_expression ::=
1762 conditional_or_expression:condor {:
1764 // | conditional_or_expression QUESTION expression
1765 // COLON conditional_expression
1767 assignment_expression ::=
1768 conditional_expression:expr {:
1770 assignment:assign {:
1773 // semantic check necessary here to ensure a valid left-hand side.
1774 // allowing a parenthesized variable here on the lhs was introduced in
1775 // JLS 2; thanks to Eric Blake for pointing this out.
1776 assignment ::= postfix_expression:lvalue assignment_operator:op assignment_expression:rvalue {:
1777 ParseNode pn=new ParseNode("assignment");
1778 pn.addChild("op").addChild(op);
1779 ParseNode pnargs=pn.addChild("args");
1780 pnargs.addChild(lvalue);
1781 pnargs.addChild(rvalue);
1785 assignment_operator ::=
1786 EQ {: RESULT=new ParseNode("eq"); :}
1787 | MULTEQ {: RESULT=new ParseNode("multeq"); :}
1788 | DIVEQ {: RESULT=new ParseNode("diveq"); :}
1789 | MODEQ {: RESULT=new ParseNode("modeq"); :}
1790 | PLUSEQ {: RESULT=new ParseNode("pluseq"); :}
1791 | MINUSEQ {: RESULT=new ParseNode("minuseq"); :}
1792 | LSHIFTEQ {: RESULT=new ParseNode("lshifteq"); :}
1793 | RSHIFTEQ {: RESULT=new ParseNode("rshifteq"); :}
1794 // | URSHIFTEQ {: RESULT=new ParseNode("urshifteq"); :}
1795 | ANDEQ {: RESULT=new ParseNode("andeq"); :}
1796 | XOREQ {: RESULT=new ParseNode("xoreq"); :}
1797 | OREQ {: RESULT=new ParseNode("oreq"); :}
1800 {: RESULT=new ParseNode("empty"); :}
1804 expression ::= assignment_expression:exp {:
1807 //constant_expression ::=