add support for scratch memory
[IRC.git] / Robust / src / Parse / java14.cup
1 package Parse;
2
3 import java_cup.runtime.*;
4 import Lex.Lexer;
5 import IR.Tree.*;
6
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.
11  */
12
13 /*
14 JDK 1.4 Features added:
15   assertion statement.
16   statement_without_trailing_substatement ::= ...
17      |          assert_statement ;
18   assert_statement ::=
19                 ASSERT expression SEMICOLON
20         |       ASSERT expression COLON expression SEMICOLON
21         ;
22 */
23 parser code  {: 
24   Lexer lexer;
25
26   public Parser(Lexer l) {
27     this();
28     lexer=l;
29   }
30
31   public void syntax_error(java_cup.runtime.Symbol current) {
32     report_error("Syntax error (" + current.sym + ")", current);
33   }
34   public void report_error(String message, java_cup.runtime.Symbol info) {
35     lexer.errorMsg(message, info);
36   }
37 :};
38
39 scan with {: return lexer.nextToken(); :};
40
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
88
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;
95
96 // Reserved but unused:
97 terminal CONST, GOTO;
98 // strictfp keyword, new in Java 1.2
99 terminal STRICTFP;
100 // assert keyword, new in Java 1.4
101 terminal ASSERT; // assert_statement
102 // lexer compatibility with Java 1.5
103 terminal ELLIPSIS;
104 terminal ENUM;
105
106
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;
119 // 19.5) Names
120 non terminal ParseNode name, simple_name, qualified_name;
121 // 19.6) Packages
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;
163 // 19.10) Arrays
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
223 terminal FLAG;
224 terminal OPTIONAL;
225 terminal ISAVAILABLE;
226 terminal EXTERNAL;
227 terminal TAG;
228 terminal TASK;
229 terminal TASKEXIT;
230 non terminal ParseNode flag_declaration;
231 non terminal ParseNode task_declaration;
232 non terminal ParseNode task_parameter_list;
233 non terminal ParseNode task_parameter;
234 non terminal ParseNode flag_expression;
235 non terminal ParseNode flag_andexpression;
236 non terminal ParseNode flag_notexpression;
237 non terminal ParseNode task_exitstatement;
238 non terminal ParseNode flag_effects_opt;
239 non terminal ParseNode flag_effects;
240 non terminal ParseNode flag_effect;
241 non terminal ParseNode flag_list;
242 non terminal ParseNode flag_list_opt;
243 non terminal ParseNode flag_change;
244
245 non terminal ParseNode cons_checks_opt;
246 non terminal ParseNode cons_checks;
247 non terminal ParseNode cons_check;
248
249 non terminal ParseNode tag_variable_declaration_statement;
250 non terminal ParseNode tag_expression_list;
251 non terminal ParseNode tag_expression;
252 non terminal ParseNode tag_list;
253 non terminal ParseNode tag_list_opt;
254 non terminal ParseNode tag_change;
255
256 //distributed transaction keywords
257 terminal ATOMIC;
258 terminal GLOBAL;
259 terminal SCRATCH;
260 terminal GETOFFSET;
261 non terminal ParseNode atomic_statement;
262 non terminal ParseNode getoffset_expression;
263
264 //disjointness for Java
265 terminal DISJOINT;
266
267 //coarse-grain parallelization
268 terminal SESE;
269 non terminal ParseNode sese_statement;
270
271
272 start with goal;
273
274
275 // Task declarations
276 task_declaration ::= 
277         TASK IDENTIFIER:id LPAREN task_parameter_list:tpl RPAREN 
278         flag_effects_opt:feo
279         method_body:body 
280         {: 
281         ParseNode pn=new ParseNode("task_declaration");
282         pn.addChild("name").addChild(id);
283         pn.addChild(tpl);
284         pn.addChild(feo);
285         pn.addChild("body").addChild(body);     
286         RESULT=pn;
287         :};
288
289 task_parameter_list ::=
290                 task_parameter:fp {: 
291                 ParseNode pn=new ParseNode("task_parameter_list");
292                 pn.addChild(fp);
293                 RESULT=pn;
294         :}
295         |       task_parameter_list:fpl COMMA task_parameter:fp {: 
296                 fpl.addChild(fp);
297                 RESULT=fpl;
298         :}
299         ;
300
301 task_parameter ::=
302                 type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE {:
303                 ParseNode pn=new ParseNode("task_parameter");
304                 pn.addChild(type);
305                 pn.addChild(name);
306                 pn.addChild("flag").addChild(exp);
307                 RESULT=pn;
308         :} 
309         | type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE LBRACE tag_expression_list:texp RBRACE {:
310                 ParseNode pn=new ParseNode("task_parameter");
311                 pn.addChild(type);
312                 pn.addChild(name);
313                 pn.addChild("flag").addChild(exp);
314                 pn.addChild("tag").addChild(texp);
315                 RESULT=pn;
316         :}
317         | type:type variable_declarator_id:name LBRACE RBRACE LBRACE tag_expression_list:texp RBRACE {:
318                 ParseNode pn=new ParseNode("task_parameter");
319                 pn.addChild(type);
320                 pn.addChild(name);
321                 pn.addChild("tag").addChild(texp);
322                 RESULT=pn;
323         :}
324         | OPTIONAL task_parameter:fp {:
325                 ParseNode pn=new ParseNode("task_parameter");
326                 pn.addChild("optional").addChild(fp);
327                 RESULT=pn;
328         :}              
329         
330         ;
331
332 tag_expression_list ::= tag_expression:te {: 
333         ParseNode pn=new ParseNode("tag_expression_list");
334         pn.addChild(te);
335         RESULT=pn;
336         :}
337         | tag_expression_list:tel COMMA tag_expression:te {: 
338         tel.addChild(te);
339         RESULT=tel;
340         :}
341         ;
342
343 tag_expression ::= IDENTIFIER:type IDENTIFIER:id {: 
344                 ParseNode pn=new ParseNode("tag_expression");
345                 pn.addChild("type").addChild(type);
346                 pn.addChild("single").addChild(id);
347                 RESULT=pn;
348         :}
349         ;
350
351 tag_list_opt ::= LBRACE tag_list:fl RBRACE {:RESULT=fl;:}
352         | LBRACE RBRACE {: RESULT = new ParseNode("empty"); :}  
353         | {: RESULT = new ParseNode("empty"); :}
354         ;
355
356 tag_list ::= tag_change:fc {: 
357                 ParseNode pn=new ParseNode("tag_list");
358                 pn.addChild(fc);
359                 RESULT=pn;
360         :}
361         | tag_list:fl COMMA tag_change:fc {: 
362                 fl.addChild(fc);
363                 RESULT=fl;
364         :};
365
366 tag_change ::= IDENTIFIER:id {: 
367                 RESULT=new ParseNode("name").addChild(id).getRoot();
368         :}
369         | NOT IDENTIFIER:id {: 
370                 RESULT=new ParseNode("not").addChild("name").addChild(id).getRoot();
371         :};
372
373 flag_expression ::= 
374         flag_andexpression:exp {: 
375                 RESULT=exp;
376         :}
377         | flag_expression:exp1 OROR flag_andexpression:exp2 {: 
378                 ParseNode pn=new ParseNode("or");
379                 pn.addChild(exp1);
380                 pn.addChild(exp2);
381                 RESULT=pn;
382         :}
383         ;
384
385 flag_andexpression ::= 
386         flag_notexpression:exp {: RESULT=exp; :}
387         | flag_notexpression:exp1 ANDAND flag_andexpression:exp2 {: 
388                 ParseNode pn=new ParseNode("and");
389                 pn.addChild(exp1);
390                 pn.addChild(exp2);
391                 RESULT=pn;
392         :}
393         ;
394
395 flag_notexpression ::=
396         NOT flag_notexpression:exp {: 
397                 ParseNode pn=new ParseNode("not");
398                 pn.addChild(exp);
399                 RESULT=pn;
400         :}
401         | LPAREN flag_expression:exp RPAREN {: 
402                 RESULT=exp;
403         :}
404         | IDENTIFIER:id {:
405                 ParseNode pn=new ParseNode("name");
406                 pn.addChild(id);
407                 RESULT=pn;
408         :}
409         ;
410
411 task_exitstatement ::= TASKEXIT flag_effects_opt:opt cons_checks_opt:cco SEMICOLON {: 
412                 RESULT=(new ParseNode("taskexit")).addChild(opt).getRoot().addChild(cco).getRoot();
413         :};
414
415 cons_checks_opt ::= ASSERT LPAREN cons_checks:cc RPAREN {: RESULT=cc; :}
416         | {: RESULT = new ParseNode("empty"); :}
417         ;
418
419 cons_checks ::= cons_check:cc {: 
420                 ParseNode pn=new ParseNode("cons_checks");
421                 pn.addChild(cc);
422                 RESULT=pn;
423         :}
424         |       cons_checks:ccs COMMA cons_check:cc {: 
425                 ccs.addChild(cc);
426                 RESULT=ccs;
427         :};
428
429 cons_check ::=  IDENTIFIER:name LPAREN cons_argument_list_opt:args RPAREN {: 
430                 ParseNode pn=new ParseNode("cons_check");
431                 pn.addChild("name").addChild("identifier").addChild(name);
432                 pn.addChild(args);
433                 RESULT=pn;
434         :};
435
436 flag_effects_opt ::= LPAREN flag_effects:fe RPAREN {:RESULT=fe;:}
437         | {: RESULT = new ParseNode("empty"); :}
438         ;
439
440 flag_effects ::= flag_effect:fe {: 
441                 ParseNode pn=new ParseNode("flag_effects_list");
442                 pn.addChild(fe);
443                 RESULT=pn;
444         :}
445         |       flag_effects:fes COMMA flag_effect:fe {: 
446                 fes.addChild(fe);
447                 RESULT=fes;
448         :};
449
450 flag_effect ::= IDENTIFIER:id LBRACE flag_list:fl RBRACE tag_list_opt:tlo {: 
451                 ParseNode pn=new ParseNode("flag_effect");
452                 pn.addChild("name").addChild(id);
453                 pn.addChild(fl);
454                 pn.addChild(tlo);
455                 RESULT=pn;
456         :}
457         | IDENTIFIER:id LBRACE RBRACE LBRACE tag_list:tl RBRACE {: 
458                 ParseNode pn=new ParseNode("flag_effect");
459                 pn.addChild("name").addChild(id);
460                 pn.addChild(tl);
461                 RESULT=pn;
462         :};
463
464 flag_list_opt ::= LBRACE flag_list:fl RBRACE {:RESULT=fl;:}
465         | LBRACE RBRACE {: RESULT = new ParseNode("empty"); :}  
466         | 
467         {: RESULT = new ParseNode("empty"); :}
468         ;
469
470 flag_list ::= flag_change:fc {: 
471                 ParseNode pn=new ParseNode("flag_list");
472                 pn.addChild(fc);
473                 RESULT=pn;
474         :}
475         |       flag_list:fl COMMA flag_change:fc {: 
476                 fl.addChild(fc);
477                 RESULT=fl;
478         :};
479
480 flag_change ::= IDENTIFIER:id {: 
481                 RESULT=new ParseNode("name").addChild(id).getRoot();
482         :} |
483         NOT IDENTIFIER:id {: 
484                 RESULT=new ParseNode("not").addChild("name").addChild(id).getRoot();
485         :};
486
487 // 19.2) The Syntactic Grammar
488 goal ::=        compilation_unit:cu
489         {:
490         RESULT = cu;
491         :}
492         ;
493
494 // 19.3) Lexical Structure.
495
496
497 literal ::=     INTEGER_LITERAL:integer_lit
498         {:
499                 ParseNode pn=new ParseNode("literal");
500                 pn.addChild("integer").setLiteral(integer_lit);
501                 RESULT=pn;
502         :}
503         |       FLOATING_POINT_LITERAL:float_lit
504         {:
505                 ParseNode pn=new ParseNode("literal");
506                 pn.addChild("float").setLiteral(float_lit);
507                 RESULT=pn;
508         :}
509         |       BOOLEAN_LITERAL:boolean_lit
510         {:
511                 ParseNode pn=new ParseNode("literal");
512                 pn.addChild("boolean").setLiteral(boolean_lit);
513                 RESULT=pn;
514         :}
515         |       CHARACTER_LITERAL:char_lit
516         {:
517                 ParseNode pn=new ParseNode("literal");
518                 pn.addChild("char").setLiteral(char_lit);
519                 RESULT=pn;
520         :}
521         |       STRING_LITERAL:string_lit
522         {:
523                 ParseNode pn=new ParseNode("literal");
524                 pn.addChild("string").setLiteral(string_lit);
525                 RESULT=pn;
526         :}
527         |       NULL_LITERAL 
528         {:
529                 RESULT=(new ParseNode("literal")).addChild("null").getRoot();
530         :}
531         ;
532
533 // 19.4) Types, Values, and Variables
534 type    ::=     primitive_type:type {: RESULT=type; :}
535         |       reference_type:type {: RESULT=type; :}
536         ;
537
538 primitive_type ::=
539                 numeric_type:type {: RESULT=type; :}
540         |       BOOLEAN {: RESULT=(new ParseNode("type")).addChild("boolean").getRoot(); :}
541         ;
542 numeric_type::= integral_type:type {: RESULT=type; :}
543         |       floating_point_type:type {: RESULT=type; :}
544         ;
545 integral_type ::= 
546                 BYTE {: RESULT=(new ParseNode("type")).addChild("byte").getRoot(); :}
547         |       SHORT  {: RESULT=(new ParseNode("type")).addChild("short").getRoot(); :}
548         |       INT  {: RESULT=(new ParseNode("type")).addChild("int").getRoot(); :}
549         |       LONG  {: RESULT=(new ParseNode("type")).addChild("long").getRoot(); :}
550         |       CHAR  {: RESULT=(new ParseNode("type")).addChild("char").getRoot(); :}
551         ;
552 floating_point_type ::= 
553                 FLOAT  {: RESULT=(new ParseNode("type")).addChild("float").getRoot(); :}
554         |       DOUBLE  {: RESULT=(new ParseNode("type")).addChild("double").getRoot(); :}
555         ;
556
557 reference_type ::=
558                 class_or_interface_type:type {: RESULT=type; :}
559         |       array_type:type {: RESULT=type; :}
560         ;
561 class_or_interface_type ::= name:name {: 
562         RESULT=(new ParseNode("type")).addChild("class").addChild(name).getRoot(); 
563         :};
564
565 class_type ::=  class_or_interface_type:type {: RESULT=type; :};
566 //interface_type ::= class_or_interface_type;
567
568 array_type ::=  primitive_type:prim dims:dims {: 
569                 ParseNode pn=(new ParseNode("type")).addChild("array");
570                 pn.addChild("basetype").addChild(prim);
571                 pn.addChild("dims").setLiteral(dims);
572                 RESULT=pn.getRoot();
573         :}
574         |       name:name dims:dims {: 
575                 ParseNode pn=(new ParseNode("type")).addChild("array");
576                 pn.addChild("basetype").addChild("type").addChild("class").addChild(name);
577                 pn.addChild("dims").setLiteral(dims);
578                 RESULT=pn.getRoot();
579         :}
580         ;
581
582 // 19.5) Names
583 name    ::=     simple_name:name {: RESULT=name; :}
584         |       qualified_name:name {: RESULT=name; :}
585         ;
586 simple_name ::= IDENTIFIER:id {: 
587         RESULT=(new ParseNode("name")).addChild("identifier").addChild(id).getRoot(); 
588         :}
589         ;
590 qualified_name ::= name:name DOT IDENTIFIER:id {: 
591         ParseNode pn=new ParseNode("name");
592         pn.addChild("base").addChild(name);
593         pn.addChild("identifier").addChild(id);
594         RESULT=pn;
595         :}
596         ;
597
598 // 19.6) Packages
599 compilation_unit ::=
600                 package_declaration_opt:pdo
601                 import_declarations_opt:ido
602                 type_declarations_opt:tdo {: 
603                 ParseNode pn=new ParseNode("compilation_unit");
604                 pn.addChild(tdo);
605                 pn.addChild("packages").addChild(pdo);
606                 pn.addChild("imports").addChild(ido);
607                 RESULT=pn;
608                 :}
609                 ;
610 package_declaration_opt ::= package_declaration:pdo {:
611                 RESULT=pdo;
612         :} |
613         {: RESULT=new ParseNode("empty"); :}
614 ;
615
616 import_declarations_opt ::= import_declarations:ido {: 
617                 RESULT=ido;
618         :} | 
619         {: RESULT=new ParseNode("empty"); :}
620 ;
621 type_declarations_opt   ::= type_declarations:tds {:
622                 RESULT=tds;
623                 :}   | 
624         {: RESULT=new ParseNode("empty"); :}
625         ;
626
627 import_declarations ::=
628                import_declaration:id {: 
629                 ParseNode pn=new ParseNode("import_decls_list");
630                 pn.addChild(id);
631                 RESULT=pn;
632         :}
633        |       import_declarations:ids import_declaration:id {: 
634                 ids.addChild(id);
635                 RESULT=ids;
636         :}
637        ;
638
639 type_declarations ::= 
640                 type_declaration:td {:
641                 ParseNode pn=new ParseNode("type_declaration_list");
642                 pn.addChild(td);
643                 RESULT=pn;
644                 :}
645         |       type_declarations:tds type_declaration:td {:
646                 tds.addChild(td);
647                 RESULT=tds;
648                 :}
649         ;
650
651 package_declaration ::=
652                PACKAGE name:name SEMICOLON {: 
653         ParseNode pn=new ParseNode("package");
654         pn.addChild(name);
655         RESULT=pn;
656         :}
657        ;
658 import_declaration ::=
659                single_type_import_declaration:sid {: RESULT=sid; :}
660        |       type_import_on_demand_declaration:iod {: RESULT=iod; :}
661        ;
662 single_type_import_declaration ::=
663                IMPORT name:name SEMICOLON {: 
664         ParseNode pn=new ParseNode("import_single");
665         pn.addChild(name);
666         RESULT=pn;
667 :}
668        ;
669 type_import_on_demand_declaration ::=
670                IMPORT name:name DOT MULT SEMICOLON {:
671         ParseNode pn=new ParseNode("import_ondemand");
672         pn.addChild(name);
673         RESULT=pn;
674         :}       
675         ;
676
677 type_declaration ::=
678                 class_declaration:cd 
679                 {:
680                         RESULT=cd;
681                 :}
682         |       task_declaration:td 
683                 {:
684                         RESULT=td;
685                 :}
686 //      |       interface_declaration
687         |       SEMICOLON {: RESULT=new ParseNode("empty"); :}
688         ;
689
690 // 19.7) Productions used only in the LALR(1) grammar
691 modifiers_opt::=
692         {: RESULT=new ParseNode("empty"); :}
693         |       modifiers:mo {: 
694                 RESULT=mo;
695         :}
696         ;
697 modifiers ::=   modifier:mo {: 
698                 ParseNode pn=new ParseNode("modifier_list");
699                 pn.addChild(mo);
700                 RESULT=pn;
701         :}
702         |       modifiers:mos modifier:mo {: 
703                 mos.addChild(mo);
704                 RESULT=mos;
705         :}
706         ;
707 modifier ::=    
708         PUBLIC {: RESULT=new ParseNode("public"); :}|
709         PROTECTED {: RESULT=new ParseNode("protected"); :}|
710         PRIVATE {: RESULT=new ParseNode("private"); :}|
711         STATIC {: RESULT=new ParseNode("static"); :} |
712 //      ABSTRACT |
713         FINAL {: RESULT=new ParseNode("final"); :}|
714         NATIVE {: RESULT=new ParseNode("native"); :} |
715         SYNCHRONIZED {: RESULT=new ParseNode("synchronized"); :} |
716         ATOMIC {: RESULT=new ParseNode("atomic"); :}
717 //      TRANSIENT | 
718 //      VOLATILE |
719 //      STRICTFP // note that semantic analysis must check that the
720                          // context of the modifier allows strictfp.
721         ;
722
723 // 19.8) Classes
724
725 // 19.8.1) Class Declaration:
726 class_declaration ::= 
727         modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so //interfaces_opt
728 class_body:body 
729         {:
730         ParseNode pn=new ParseNode("class_declaration");
731         pn.addChild("modifiers").addChild(mo);
732         pn.addChild("name").addChild(id);
733         pn.addChild("super").addChild(so);
734         pn.addChild("classbody").addChild(body);
735         RESULT=pn;
736         :}
737         ;
738 super ::=       EXTENDS class_type:classtype {: 
739                 RESULT=classtype;
740         :}
741         ;
742 super_opt ::=   
743         {: RESULT=new ParseNode("empty"); :}
744         |       super:su {: 
745                 RESULT=su;
746         :}
747         ;
748
749 //interfaces ::= IMPLEMENTS interface_type_list
750 //       ;
751 //interfaces_opt::=
752 //       |       interfaces
753 //       ;
754 //interface_type_list ::=
755 //               interface_type
756 //       |       interface_type_list COMMA interface_type
757 //       ;
758
759 class_body ::=  LBRACE class_body_declarations_opt:cbdo RBRACE {: RESULT=cbdo; :}
760         ;
761
762 class_body_declarations_opt ::= 
763         {: RESULT=new ParseNode("empty"); :}
764         |       class_body_declarations:cbd {: RESULT=cbd; :};
765
766 class_body_declarations ::= 
767                 class_body_declaration:cbd {: 
768                         ParseNode pn=new ParseNode("class_body_declaration_list");
769                         pn.addChild(cbd);
770                         RESULT=pn;
771                 :}
772         |       class_body_declarations:cbds class_body_declaration:cbd {: 
773                         cbds.addChild(cbd);
774                         RESULT=cbds;
775                 :}
776         ;
777
778 class_body_declaration ::=
779                 class_member_declaration:member {: 
780                 RESULT=(new ParseNode("member")).addChild(member).getRoot();
781         :}
782 //      |       static_initializer
783         |       constructor_declaration:constructor {: 
784                 RESULT=(new ParseNode("constructor")).addChild(constructor).getRoot();
785         :}
786         |       block:block {:
787                 RESULT=(new ParseNode("block")).addChild(block).getRoot();
788 :}
789         ;
790 class_member_declaration ::=
791         //failure aware computation
792         flag_declaration:flag {: 
793         RESULT=(new ParseNode("flag")).addChild(flag).getRoot(); 
794         :}
795         |
796         field_declaration:field {: 
797         RESULT=(new ParseNode("field")).addChild(field).getRoot(); 
798         :}
799         |       method_declaration:method {:
800         RESULT=(new ParseNode("method")).addChild(method).getRoot(); 
801         :}
802         /* repeat the prod for 'class_declaration' here: */
803 //      |       modifiers_opt CLASS IDENTIFIER super_opt class_body
804 //      |       interface_declaration
805         |       SEMICOLON       {: RESULT=new ParseNode("empty"); :}
806         ;
807
808 //Failure aware computation
809 flag_declaration ::= 
810                 FLAG IDENTIFIER:id SEMICOLON {: 
811                 ParseNode pn=new ParseNode("flag_declaration");
812                 pn.addChild("name").addChild(id);
813                 RESULT=pn;
814         :}      |
815                 EXTERNAL FLAG IDENTIFIER:id SEMICOLON {: 
816                 ParseNode pn=new ParseNode("flag_declaration");
817                 pn.addChild("name").addChild(id);
818                 pn.addChild("external");
819                 RESULT=pn;
820         :}
821         ;
822
823 // 19.8.2) Field Declarations
824 field_declaration ::= 
825                 modifiers_opt:mo type:type variable_declarators:var SEMICOLON {: 
826                 ParseNode pn=new ParseNode("field_declaration");
827                 pn.addChild("modifier").addChild(mo);
828                 pn.addChild("type").addChild(type);
829                 pn.addChild("variables").addChild(var);
830                 RESULT=pn;
831         :} |
832                 modifiers_opt:mo GLOBAL type:type variable_declarators:var SEMICOLON {: 
833                 ParseNode pn=new ParseNode("field_declaration");
834                 pn.addChild("modifier").addChild(mo);
835                 pn.addChild("type").addChild(type);
836                 pn.addChild("variables").addChild(var);
837                 pn.addChild("global");
838                 RESULT=pn;
839         :}
840         ;
841
842 variable_declarators ::=
843                 variable_declarator:vd {: 
844                 ParseNode pn=new ParseNode("variable_declarators_list");
845                 pn.addChild(vd);
846                 RESULT=pn;
847         :}
848         |       variable_declarators:vds COMMA variable_declarator:vd {:
849                 vds.addChild(vd);
850                 RESULT=vds;
851         :}
852         ;
853 variable_declarator ::=
854                 variable_declarator_id:id {:
855                 ParseNode pn=new ParseNode("variable_declarator");
856                 pn.addChild(id);
857                 RESULT=pn;
858         :}
859         |       variable_declarator_id:id EQ variable_initializer:init {: 
860                 ParseNode pn=new ParseNode("variable_declarator");
861                 pn.addChild(id);
862                 pn.addChild("initializer").addChild(init);
863                 RESULT=pn;
864         :}
865         ;
866 variable_declarator_id ::=
867                 IDENTIFIER:id {: 
868                 RESULT=(new ParseNode("single")).addChild(id).getRoot();:}
869         |       variable_declarator_id:id LBRACK RBRACK {:
870                 RESULT=(new ParseNode("array")).addChild(id).getRoot();:}
871         ;
872 variable_initializer ::=
873                 expression:exp {: RESULT=exp; :}
874         |       array_initializer {: RESULT=new ParseNode("array_initializer"); :}
875         ;
876
877 // 19.8.3) Method Declarations
878 method_declaration ::=
879                 method_header:header method_body:body {:
880                 ParseNode pn=new ParseNode("method_declaration");
881                 pn.addChild(header);
882                 pn.addChild("body").addChild(body);
883                 RESULT=pn;
884         :}
885         ;
886 method_header ::=
887                 modifiers_opt:mo type:type method_declarator:decl //throws_opt 
888         {:
889                 ParseNode pn=new ParseNode("method_header");
890                 pn.addChild("modifiers").addChild(mo);
891                 pn.addChild("returntype").addChild(type);
892                 pn.addChild(decl);
893                 RESULT=pn;
894         :}
895         |       modifiers_opt:mo VOID method_declarator:decl //throws_opt
896         {:
897                 ParseNode pn=new ParseNode("method_header");
898                 pn.addChild("modifiers").addChild(mo);
899                 pn.addChild(decl);
900                 RESULT=pn;
901         :}
902         ;
903 method_declarator ::=
904                 IDENTIFIER:id LPAREN formal_parameter_list_opt:params RPAREN {: 
905                 ParseNode pn=new ParseNode("method_declarator");
906                 pn.addChild("name").addChild(id);
907                 pn.addChild("parameters").addChild(params);
908                 RESULT=pn;
909         :}
910 //      |       method_declarator LBRACK RBRACK // deprecated
911 // be careful; the above production also allows 'void foo() []'
912         ;
913 formal_parameter_list_opt ::=
914         {: RESULT=new ParseNode("empty"); :}
915         |       formal_parameter_list:fpl {: 
916                 RESULT=fpl;
917         :}
918         ;
919 formal_parameter_list ::=
920                 formal_parameter:fp {: 
921                 ParseNode pn=new ParseNode("formal_parameter_list");
922                 pn.addChild(fp);
923                 RESULT=pn;
924         :}
925         |       formal_parameter_list:fpl COMMA formal_parameter:fp {: 
926                 fpl.addChild(fp);
927                 RESULT=fpl;
928         :}
929         ;
930 formal_parameter ::=
931                 type:type variable_declarator_id:name {:
932                 ParseNode pn=new ParseNode("formal_parameter");
933                 pn.addChild(type);
934                 pn.addChild(name);
935                 RESULT=pn;
936         :}
937         |
938                 TAG variable_declarator_id:name {:
939                 ParseNode pn=new ParseNode("tag_parameter");
940                 pn.addChild(name);
941                 RESULT=pn;
942         :}
943         |       FINAL type:type variable_declarator_id:name {:
944                 ParseNode pn=new ParseNode("formal_parameter");
945                 pn.addChild(type);
946                 pn.addChild(name);
947                 RESULT=pn;
948         :}
949         ;
950 //throws_opt ::=        
951 //      |       throws
952 //      ;
953 //throws ::=    THROWS class_type_list
954 //      ;
955 //class_type_list ::=
956 //              class_type
957 //      |       class_type_list COMMA class_type
958 //      ;
959 method_body ::= block:block {: 
960                 RESULT=block;
961         :}
962         |       SEMICOLON       {: RESULT=new ParseNode("empty"); :}
963         ;
964
965 // 19.8.4) Static Initializers
966 //static_initializer ::=
967 //              STATIC block
968 //      ;
969
970 // 19.8.5) Constructor Declarations
971 constructor_declaration ::=
972                 modifiers_opt:mo constructor_declarator:cd
973 //throws_opt 
974                         constructor_body:body   {:
975                 ParseNode pn=new ParseNode("constructor_declaration");
976                 pn.addChild("modifiers").addChild(mo);
977                 pn.addChild(cd);
978                 pn.addChild("body").addChild(body);
979                 RESULT=pn;
980         :} |
981                 modifiers_opt:mo GLOBAL constructor_declarator:cd
982 //throws_opt 
983                         constructor_body:body   {:
984                 ParseNode pn=new ParseNode("constructor_declaration");
985                 pn.addChild("global");
986                 pn.addChild("modifiers").addChild(mo);
987                 pn.addChild(cd);
988                 pn.addChild("body").addChild(body);
989                 RESULT=pn;
990         :}
991 ;
992
993 constructor_declarator ::=
994                 simple_name:name LPAREN formal_parameter_list_opt:fplo RPAREN {: 
995                 ParseNode pn=new ParseNode("constructor_declarator");
996                 pn.addChild(name);
997                 pn.addChild("parameters").addChild(fplo);
998                 RESULT=pn;
999         :}
1000         ;
1001 constructor_body ::=
1002                 LBRACE explicit_constructor_invocation:eci block_statements:bs RBRACE {: 
1003                         ParseNode pn=new ParseNode("constructor_body");
1004                         pn.addChild(eci);
1005                         pn.addChild(bs);
1006                         RESULT=pn;
1007         :} |
1008                 LBRACE explicit_constructor_invocation:eci RBRACE {: 
1009                         ParseNode pn=new ParseNode("constructor_body");
1010                         pn.addChild(eci);
1011                         RESULT=pn;
1012         :} |
1013                 LBRACE block_statements:block RBRACE {: 
1014                 ParseNode pn=new ParseNode("constructor_body");
1015                 pn.addChild(block);
1016                 RESULT=pn;
1017         :}
1018         |       LBRACE RBRACE {: RESULT=new ParseNode("empty"); :}
1019         ;
1020 explicit_constructor_invocation ::=
1021 //              THIS LPAREN argument_list_opt RPAREN SEMICOLON
1022 //      |       
1023 SUPER LPAREN argument_list_opt:alo RPAREN SEMICOLON {: 
1024         ParseNode pn=new ParseNode("superinvoke");
1025         pn.addChild(alo);
1026         RESULT=pn;
1027 :}
1028 //      |       primary DOT THIS LPAREN argument_list_opt RPAREN SEMICOLON
1029 //      |       primary DOT SUPER LPAREN argument_list_opt RPAREN SEMICOLON
1030         ;
1031
1032 // 19.9) Interfaces
1033
1034 // 19.9.1) Interface Declarations
1035 //interface_declaration ::=
1036 //               modifiers_opt INTERFACE IDENTIFIER extends_interfaces_opt
1037 //                       interface_body
1038 //       ;
1039 //extends_interfaces_opt ::=
1040 //       |       extends_interfaces
1041 //       ;
1042 //extends_interfaces ::=
1043 //               EXTENDS interface_type
1044 //       |       extends_interfaces COMMA interface_type
1045 //       ;
1046 //interface_body ::=
1047 //               LBRACE interface_member_declarations_opt RBRACE
1048 //       ;
1049 //interface_member_declarations_opt ::=
1050 //       |       interface_member_declarations
1051 //       ;
1052 //interface_member_declarations ::=
1053 //               interface_member_declaration
1054 //       |       interface_member_declarations interface_member_declaration
1055 //       ;
1056 //interface_member_declaration ::=
1057 //               constant_declaration
1058 //       |       abstract_method_declaration
1059 //       |       class_declaration
1060 //       |       interface_declaration
1061 //       |       SEMICOLON
1062 //       ;
1063 //constant_declaration ::=
1064 //               field_declaration
1065 //       // need to semantically check that modifiers of field declaration
1066 //       // include only PUBLIC, STATIC, or FINAL.  Other modifiers are
1067 //       // disallowed.
1068 //       ;
1069 //abstract_method_declaration ::=
1070 //               method_header SEMICOLON
1071 //       ;
1072
1073
1074 // 19.10) Arrays
1075 array_initializer ::=
1076                 LBRACE variable_initializers:var_init_list COMMA RBRACE {:
1077                        RESULT=var_init_list;
1078                 :}
1079         |       LBRACE variable_initializers:var_init_list RBRACE {:
1080                        RESULT=var_init_list;
1081                 :}
1082         |       LBRACE COMMA RBRACE {:
1083                        RESULT=new ParseNode("empty");                  
1084                 :}
1085         |       LBRACE RBRACE {:
1086                        RESULT=new ParseNode("empty");
1087                 :}
1088         ;
1089 variable_initializers ::=
1090                 variable_initializer:var_init {:
1091                        ParseNode pn=new ParseNode("var_init_list");
1092                        pn.addChild(var_init);
1093                        RESULT=pn;
1094                 :}
1095         |       variable_initializers:var_init_list COMMA variable_initializer:var_init {:
1096                        var_init_list.addChild(var_init);
1097                        RESULT=var_init_list;
1098                 :}
1099         ;
1100
1101 // 19.11) Blocks and Statements
1102 block ::=       LBRACE block_statements_opt:bso RBRACE {: 
1103         RESULT=bso;
1104         :}
1105         ;
1106 block_statements_opt ::=
1107         {: RESULT=new ParseNode("empty"); :}
1108         |       block_statements:bs {: 
1109         RESULT=bs;
1110         :}
1111         ;
1112 block_statements ::=
1113                 block_statement:bs {:
1114         ParseNode pn=new ParseNode("block_statement_list");
1115         pn.addChild(bs);
1116         RESULT=pn;
1117         :}
1118         |       block_statements:bss block_statement:bs {: 
1119         bss.addChild(bs);
1120         RESULT=bss;
1121         :}
1122         ;
1123 block_statement ::=
1124         tag_variable_declaration_statement:tvds {:
1125                 RESULT=tvds;
1126         :}              
1127         |       local_variable_declaration_statement:lvds {: 
1128                 RESULT=lvds;
1129         :}
1130         |       statement:statement {: 
1131                 RESULT=statement;
1132         :}
1133 //      |       class_declaration
1134 //      |       interface_declaration
1135         ;
1136 tag_variable_declaration_statement ::=
1137                 TAG IDENTIFIER:id EQ NEW TAG LPAREN IDENTIFIER:type RPAREN SEMICOLON {: 
1138                 ParseNode pn=new ParseNode("tag_declaration");
1139                 pn.addChild("single").addChild(id);
1140                 pn.addChild("type").addChild(type);
1141                 RESULT=pn;
1142         :}
1143         ;
1144 local_variable_declaration_statement ::=
1145                 local_variable_declaration:lvd SEMICOLON {: 
1146                 RESULT=lvd;
1147         :}
1148         ;
1149 local_variable_declaration ::=
1150                 type:type variable_declarators:var {: 
1151                 ParseNode pn=new ParseNode("local_variable_declaration");
1152                 pn.addChild(type);
1153                 pn.addChild(var);
1154                 RESULT=pn;
1155         :}
1156         |       FINAL type:type variable_declarators:var {: 
1157                 ParseNode pn=new ParseNode("local_variable_declaration");
1158                 pn.addChild(type);
1159                 pn.addChild(var);
1160                 RESULT=pn;
1161         :}
1162         ;
1163 statement ::=   statement_without_trailing_substatement:st {: 
1164                 RESULT=st;
1165         :}
1166 //      |       labeled_statement:st {: RESULT=st; :}
1167         |       if_then_statement:st {: RESULT=st; :}
1168         |       if_then_else_statement:st {: RESULT=st; :}
1169         |       while_statement:st {: RESULT=st; :}
1170         |       for_statement:st {: RESULT=st; :}
1171         ;
1172 statement_no_short_if ::=
1173                 statement_without_trailing_substatement:st {: RESULT=st; :}
1174 //      |       labeled_statement_no_short_if:st {: RESULT=st; :}
1175         |       if_then_else_statement_no_short_if:st {: RESULT=st; :}
1176         |       while_statement_no_short_if:st {: RESULT=st; :}
1177         |       for_statement_no_short_if:st {: RESULT=st; :}
1178         ;
1179 statement_without_trailing_substatement ::=
1180                 block:st {: RESULT=st; :}
1181         |       empty_statement:st {: RESULT=st; :}
1182         |       expression_statement:st {: RESULT=st; :}
1183 //      |       switch_statement
1184         |       do_statement:dos {:RESULT=dos; :}
1185         |       break_statement:st {: RESULT=st; :}
1186         |       continue_statement:st {: RESULT=st; :}
1187         |       return_statement:st {: RESULT=st; :}
1188         |       task_exitstatement:st {: RESULT=st; :}
1189         |       atomic_statement:st {: RESULT=st; :}
1190         |       sese_statement:st {: RESULT=st; :}
1191 //      |       synchronized_statement
1192 //      |       throw_statement
1193 //      |       try_statement
1194 //      |       assert_statement
1195         ;
1196 empty_statement ::=
1197                 SEMICOLON {: RESULT=new ParseNode("nop"); :}
1198         ;
1199 //labeled_statement ::=
1200 //              IDENTIFIER COLON statement
1201 //      ;
1202 //labeled_statement_no_short_if ::=
1203 //              IDENTIFIER COLON statement_no_short_if
1204 //      ;
1205 expression_statement ::=
1206                 statement_expression:se SEMICOLON {: 
1207                 ParseNode pn=new ParseNode("expression");
1208                 pn.addChild(se);
1209                 RESULT=pn; :}
1210         ;
1211 statement_expression ::=
1212                 assignment:st {: RESULT=st; :}
1213         |       preincrement_expression:st {: RESULT=st; :}
1214         |       predecrement_expression:st {: RESULT=st; :}
1215         |       postincrement_expression:st {: RESULT=st; :}
1216         |       postdecrement_expression:st {: RESULT=st; :}
1217         |       method_invocation:st {: RESULT=st; :}
1218         |       class_instance_creation_expression:st {: RESULT=st; :}
1219         ;
1220 if_then_statement ::=
1221                 IF LPAREN expression:exp RPAREN statement:st {: 
1222                 ParseNode pn=new ParseNode("ifstatement");
1223                 pn.addChild("condition").addChild(exp);
1224                 pn.addChild("statement").addChild(st);
1225                 RESULT=pn;
1226         :}
1227         ;
1228 if_then_else_statement ::=
1229                 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1230                         ELSE statement:else_st {:
1231                 ParseNode pn=new ParseNode("ifstatement");
1232                 pn.addChild("condition").addChild(exp);
1233                 pn.addChild("statement").addChild(st);
1234                 pn.addChild("else_statement").addChild(else_st);
1235                 RESULT=pn;
1236         :}
1237         ;
1238 if_then_else_statement_no_short_if ::=
1239                 IF LPAREN expression:exp RPAREN statement_no_short_if:st
1240                         ELSE statement_no_short_if:else_st {:
1241                 ParseNode pn=new ParseNode("ifstatement");
1242                 pn.addChild("condition").addChild(exp);
1243                 pn.addChild("statement").addChild(st);
1244                 pn.addChild("else_statement").addChild(else_st);
1245                 RESULT=pn;
1246         :}
1247         ;
1248 //switch_statement ::=
1249 //              SWITCH LPAREN expression RPAREN switch_block
1250 //      ;
1251 //switch_block ::=
1252 //              LBRACE switch_block_statement_groups switch_labels RBRACE
1253 //      |       LBRACE switch_block_statement_groups RBRACE
1254 //      |       LBRACE switch_labels RBRACE
1255 //      |       LBRACE RBRACE
1256 //      ;
1257 //switch_block_statement_groups ::=
1258 //              switch_block_statement_group
1259 //      |       switch_block_statement_groups switch_block_statement_group
1260 //      ;
1261 //switch_block_statement_group ::=
1262 //              switch_labels block_statements
1263 //      ;
1264 //switch_labels ::=
1265 //              switch_label
1266 //      |       switch_labels switch_label
1267 //      ;
1268 //switch_label ::=
1269 //              CASE constant_expression COLON
1270 //      |       DEFAULT COLON
1271 //      ;
1272
1273 while_statement ::=
1274                 WHILE LPAREN expression:exp RPAREN statement:st {: 
1275                 ParseNode pn=new ParseNode("whilestatement");
1276                 pn.addChild("condition").addChild(exp);
1277                 pn.addChild("statement").addChild(st);
1278                 RESULT=pn;
1279         :}
1280         ;
1281 while_statement_no_short_if ::=
1282                 WHILE LPAREN expression:exp RPAREN statement_no_short_if:st {:
1283                 ParseNode pn=new ParseNode("whilestatement");
1284                 pn.addChild("condition").addChild(exp);
1285                 pn.addChild("statement").addChild(st);
1286                 RESULT=pn;
1287                 :}
1288         ;
1289 do_statement ::=
1290                 DO statement:st WHILE LPAREN expression:exp RPAREN SEMICOLON {: 
1291                 ParseNode pn=new ParseNode("dowhilestatement");
1292                 pn.addChild("condition").addChild(exp);
1293                 pn.addChild("statement").addChild(st);
1294                 RESULT=pn;
1295         :}
1296         ;
1297 for_statement ::=
1298                 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1299                         for_update_opt:update RPAREN statement:st {: 
1300                 ParseNode pn=new ParseNode("forstatement");
1301                 pn.addChild("initializer").addChild(init);
1302                 pn.addChild("condition").addChild(exp);
1303                 pn.addChild("update").addChild(update);
1304                 pn.addChild("statement").addChild(st);
1305                 RESULT=pn;
1306                 :}
1307         ;
1308 for_statement_no_short_if ::=
1309                 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
1310                         for_update_opt:update RPAREN statement_no_short_if:st {:
1311                 ParseNode pn=new ParseNode("forstatement");
1312                 pn.addChild("initializer").addChild(init);
1313                 pn.addChild("condition").addChild(exp);
1314                 pn.addChild("update").addChild(update);
1315                 pn.addChild("statement").addChild(st);
1316                 RESULT=pn;
1317                 :}
1318         ;
1319 for_init_opt ::=
1320         {: RESULT=new ParseNode("empty"); :}
1321         |       for_init:init {: RESULT=init; :}
1322         ;
1323 for_init ::=    statement_expression_list:list {: RESULT=list; :}
1324         |       local_variable_declaration:decl {: RESULT=decl; :}
1325         ;
1326 for_update_opt ::=
1327         {: RESULT=new ParseNode("empty"); :}
1328         |       for_update:update {: RESULT=update; :}
1329         ;
1330 for_update ::=  statement_expression_list:list {: RESULT=list; :}
1331         ;
1332 statement_expression_list ::=
1333                 statement_expression:expr {: 
1334                 RESULT=(new ParseNode("statement_expression_list")).addChild(expr).getRoot();
1335         :}
1336         |       statement_expression_list:list COMMA statement_expression:expr {: 
1337                 list.addChild(expr);
1338                 RESULT=list;
1339         :}
1340         ;
1341
1342 //identifier_opt ::= 
1343 //      |       IDENTIFIER
1344 //      ;
1345
1346 break_statement ::=
1347                 BREAK
1348 //identifier_opt 
1349 SEMICOLON {: RESULT=new ParseNode("break"); :}
1350         ;
1351
1352 continue_statement ::=
1353                 CONTINUE  
1354 //identifier_opt 
1355 SEMICOLON
1356 {: RESULT=new ParseNode("continue"); :}
1357         ;
1358 return_statement ::=
1359                 RETURN expression_opt:exp SEMICOLON {: 
1360         RESULT=(new ParseNode("return")).addChild(exp).getRoot(); :}
1361         ;
1362 //throw_statement ::=
1363 //              THROW expression SEMICOLON
1364 //      ;
1365 //synchronized_statement ::=
1366 //              SYNCHRONIZED LPAREN expression RPAREN block
1367 //      ;
1368 atomic_statement ::=
1369                 ATOMIC block:blk {: 
1370         RESULT=(new ParseNode("atomic")).addChild(blk).getRoot();
1371         :}
1372         ;
1373 sese_statement ::=
1374                SESE block:blk {: 
1375                ParseNode pn = new ParseNode("sese");
1376                pn.addChild("body").addChild(blk);
1377                RESULT=pn;
1378         :}
1379         |      SESE variable_declarator_id:id block:blk {: 
1380                ParseNode pn = new ParseNode("sese");
1381                pn.addChild("body").addChild(blk);
1382                pn.addChild("identifier").addChild(id);
1383                RESULT=pn;
1384         :}
1385         ;
1386 //try_statement ::=
1387 //              TRY block catches
1388 //      |       TRY block catches_opt finally
1389 //      ;
1390 //catches_opt ::=
1391 //      |       catches
1392 //      ;
1393 //catches ::=   catch_clause
1394 //      |       catches catch_clause
1395 //      ;
1396 //catch_clause ::=
1397 //              CATCH LPAREN formal_parameter RPAREN block
1398 //      ;
1399 //finally ::=   FINALLY block
1400 //      ;
1401 //assert_statement ::=
1402 //              ASSERT expression SEMICOLON
1403 //      |       ASSERT expression COLON expression SEMICOLON
1404 //      ;
1405
1406 // 19.12) Expressions
1407 primary ::=     primary_no_new_array:st {: 
1408                 RESULT=st; :}
1409 //      |       array_creation_init:st {: 
1410 //              RESULT=st;
1411 //      :}
1412         |       array_creation_uninit:st {:
1413                 RESULT=st;
1414         :}
1415         ;
1416 primary_no_new_array ::=
1417                 literal:lit {: RESULT=lit; :}
1418         |       THIS {: RESULT=new ParseNode("this"); :}
1419         |       LPAREN expression:exp RPAREN {: RESULT=exp; :}
1420         |       class_instance_creation_expression:exp {: RESULT=exp; :}
1421         |       field_access:exp {: RESULT=exp; :}
1422         |       method_invocation:exp {: RESULT=exp; :}
1423         |       array_access:exp {: RESULT=exp; :}
1424         |       ISAVAILABLE LPAREN IDENTIFIER:id RPAREN {: 
1425                 ParseNode pn=new ParseNode("isavailable");
1426                 pn.addChild(id);
1427                 RESULT=pn;
1428         :}
1429 //      |       primitive_type DOT CLASS
1430 //      |       VOID DOT CLASS
1431 //      |       array_type DOT CLASS
1432 //      |       name DOT CLASS
1433 //      |       name DOT THIS
1434         ;
1435 class_instance_creation_expression ::=
1436                 NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: 
1437                 ParseNode pn=new ParseNode("createobject");
1438                 pn.addChild(type);
1439                 pn.addChild(args);
1440                 pn.addChild(feo);
1441                 RESULT=pn;
1442         :} 
1443         //Global object
1444         | GLOBAL NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: 
1445                 ParseNode pn=new ParseNode("createobject");
1446                 pn.addChild(type);
1447                 pn.addChild(args);
1448                 pn.addChild(feo);
1449                 pn.addChild("global");
1450                 RESULT=pn;
1451         :}
1452         | SCRATCH NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: 
1453                 ParseNode pn=new ParseNode("createobject");
1454                 pn.addChild(type);
1455                 pn.addChild(args);
1456                 pn.addChild(feo);
1457                 pn.addChild("scratch");
1458                 RESULT=pn;
1459         :}
1460         // Objects we want to track in disjointness analysis
1461         | DISJOINT IDENTIFIER:id NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: 
1462                 ParseNode pn=new ParseNode("createobject");
1463                 pn.addChild(type);
1464                 pn.addChild(args);
1465                 pn.addChild(feo);
1466                 pn.addChild("disjoint").addChild(id);
1467                 RESULT=pn;
1468         :}
1469         | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE RBRACE LBRACE tag_list:tl RBRACE {: 
1470                 ParseNode pn=new ParseNode("createobject");
1471                 pn.addChild(type);
1472                 pn.addChild(args);
1473                 pn.addChild(tl);
1474                 RESULT=pn;
1475         :}
1476         | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE flag_list:fl RBRACE LBRACE tag_list:tl RBRACE {: 
1477                 ParseNode pn=new ParseNode("createobject");
1478                 pn.addChild(type);
1479                 pn.addChild(args);
1480                 pn.addChild(fl);
1481                 pn.addChild(tl);
1482                 RESULT=pn;
1483         :}
1484
1485 //      |       NEW class_or_interface_type LPAREN argument_list_opt RPAREN class_body
1486 //      |       primary DOT NEW IDENTIFIER
1487 //                      LPAREN argument_list_opt RPAREN {: 
1488 //              
1489 //      :}
1490 //      |       primary DOT NEW IDENTIFIER
1491 //                      LPAREN argument_list_opt RPAREN class_body
1492 //      |       name DOT NEW IDENTIFIER
1493 //                      LPAREN argument_list_opt RPAREN
1494 //      |       name DOT NEW IDENTIFIER
1495 //                      LPAREN argument_list_opt RPAREN class_body
1496         ;
1497 cons_argument_list_opt ::=
1498         {: RESULT=new ParseNode("empty"); :}
1499         |       cons_argument_list:args {: RESULT=args; :}
1500         ;
1501
1502 cons_argument_list ::=
1503                 IDENTIFIER:id COLON expression:exp {:
1504                 ParseNode pn=new ParseNode("cons_argument_list");
1505                 ParseNode pnarg=pn.addChild("binding");
1506                 pnarg.addChild("var").addChild(id);
1507                 pnarg.addChild("exp").addChild(exp);
1508                 RESULT=pn;
1509         :}
1510         |       argument_list:list COMMA IDENTIFIER:id COLON expression:exp {:
1511                 ParseNode pnarg=new ParseNode("binding");
1512                 pnarg.addChild("var").addChild(id);
1513                 pnarg.addChild("exp").addChild(exp);
1514                 list.addChild(pnarg);
1515                 RESULT=list;
1516         :}
1517         ;
1518
1519 argument_list_opt ::=
1520         {: RESULT=new ParseNode("empty"); :}
1521         |       argument_list:args {: RESULT=args; :}
1522         ;
1523
1524 argument_list ::=
1525                 expression:exp {:
1526                 ParseNode pn=new ParseNode("argument_list");
1527                 pn.addChild(exp);
1528                 RESULT=pn;
1529         :}
1530         |       argument_list:list COMMA expression:exp {:
1531                 list.addChild(exp);
1532                 RESULT=list;
1533         :}
1534         ;
1535 array_creation_uninit ::=
1536                 NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {: 
1537                 ParseNode pn=new ParseNode("createarray");
1538                 pn.addChild(type);
1539                 pn.addChild(dimexpr);
1540                 pn.addChild("dims_opt").setLiteral(dims);
1541                 RESULT=pn;
1542                 :}
1543         |       NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {: 
1544                 ParseNode pn=new ParseNode("createarray");
1545                 pn.addChild(type);
1546                 pn.addChild(dimexpr);
1547                 pn.addChild("dims_opt").setLiteral(dims);
1548                 RESULT=pn;
1549         :}
1550         |       GLOBAL NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {: 
1551                 ParseNode pn=new ParseNode("createarray");
1552                 pn.addChild(type);
1553                 pn.addChild(dimexpr);
1554                 pn.addChild("dims_opt").setLiteral(dims);
1555                 pn.addChild("global");
1556                 RESULT=pn;
1557                 :}
1558         |       SCRATCH NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {: 
1559                 ParseNode pn=new ParseNode("createarray");
1560                 pn.addChild(type);
1561                 pn.addChild(dimexpr);
1562                 pn.addChild("dims_opt").setLiteral(dims);
1563                 pn.addChild("scratch");
1564                 RESULT=pn;
1565                 :}
1566         |       DISJOINT IDENTIFIER:id NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {: 
1567                 ParseNode pn=new ParseNode("createarray");
1568                 pn.addChild(type);
1569                 pn.addChild(dimexpr);
1570                 pn.addChild("dims_opt").setLiteral(dims);
1571                 pn.addChild("disjoint").addChild(id);
1572                 RESULT=pn;
1573                 :}
1574         |       GLOBAL NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {: 
1575                 ParseNode pn=new ParseNode("createarray");
1576                 pn.addChild(type);
1577                 pn.addChild(dimexpr);
1578                 pn.addChild("dims_opt").setLiteral(dims);
1579                 pn.addChild("global");
1580                 RESULT=pn;
1581                 :}
1582         |       SCRATCH NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {: 
1583                 ParseNode pn=new ParseNode("createarray");
1584                 pn.addChild(type);
1585                 pn.addChild(dimexpr);
1586                 pn.addChild("dims_opt").setLiteral(dims);
1587                 pn.addChild("scratch");
1588                 RESULT=pn;
1589                 :}
1590         |       DISJOINT IDENTIFIER:id NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {: 
1591                 ParseNode pn=new ParseNode("createarray");
1592                 pn.addChild(type);
1593                 pn.addChild(dimexpr);
1594                 pn.addChild("dims_opt").setLiteral(dims);
1595                 pn.addChild("disjoint").addChild(id);           
1596                 RESULT=pn;
1597                 :}
1598         ;
1599 //array_creation_init ::=
1600 //              NEW primitive_type dims array_initializer
1601 //      |       NEW class_or_interface_type dims array_initializer
1602 //      ;
1603 dim_exprs ::=   dim_expr:exp {: 
1604                 ParseNode pn=new ParseNode("dim_exprs");
1605                 pn.addChild(exp);
1606                 RESULT=pn; :}
1607         |       dim_exprs:base dim_expr:exp {: 
1608                 base.addChild(exp);
1609                 RESULT=base;
1610         :}
1611         ;
1612 dim_expr ::=    LBRACK expression:exp RBRACK {: RESULT=exp; :}
1613         ;
1614 dims_opt ::= {: RESULT=new Integer(0); :}
1615         |       dims:dims {: RESULT = dims; :}
1616         ;
1617
1618 dims ::=        LBRACK RBRACK {: RESULT=new Integer(1); :}
1619         |       dims:dims LBRACK RBRACK {: RESULT=new Integer(dims.intValue()+1); :}
1620         ;
1621
1622 field_access ::=
1623                 primary:base DOT IDENTIFIER:id {: 
1624                 ParseNode pn=new ParseNode("fieldaccess");
1625                 pn.addChild("base").addChild(base);
1626                 pn.addChild("field").addChild(id);
1627                 RESULT=pn;
1628 :}
1629 //      |       SUPER DOT IDENTIFIER
1630 //      |       name DOT SUPER DOT IDENTIFIER
1631         ;
1632 method_invocation ::=
1633                 name:name LPAREN argument_list_opt:args RPAREN {: 
1634                 ParseNode pn=new ParseNode("methodinvoke1");
1635                 pn.addChild(name);
1636                 pn.addChild(args);
1637                 RESULT=pn;
1638         :}
1639         |       primary:base DOT IDENTIFIER:name LPAREN argument_list_opt:args RPAREN {: 
1640                 ParseNode pn=new ParseNode("methodinvoke2");
1641                 pn.addChild("base").addChild(base);
1642                 pn.addChild("id").addChild(name);
1643                 pn.addChild(args);
1644                 RESULT=pn;
1645         :}
1646         |       SUPER DOT IDENTIFIER:id LPAREN argument_list_opt:args RPAREN {: 
1647                 ParseNode name=new ParseNode("name");
1648                 name.addChild("base").addChild("name").addChild("identifier").addChild("super");
1649                 name.addChild("identifier").addChild(id);
1650                 ParseNode pn=new ParseNode("methodinvoke1");
1651                 pn.addChild(name);
1652                 pn.addChild(args);
1653                 RESULT=pn;
1654         :}
1655 //      |       name DOT SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
1656         ;
1657 array_access ::=
1658                 name:name LBRACK expression:exp RBRACK {: 
1659                 ParseNode pn=new ParseNode("arrayaccess");
1660                 pn.addChild("base").addChild(name);
1661                 pn.addChild("index").addChild(exp);
1662                 RESULT=pn;
1663         :}
1664         |       primary_no_new_array:base LBRACK expression:exp RBRACK {: 
1665                 ParseNode pn=new ParseNode("arrayaccess");
1666                 pn.addChild("base").addChild(base);
1667                 pn.addChild("index").addChild(exp);
1668                 RESULT=pn;
1669         :}
1670 //      |       array_creation_init:init LBRACK expression:exp RBRACK {: 
1671 //              ParseNode pn=new ParseNode("arrayaccess");
1672 //              pn.addChild("init").addChild(init);
1673 //              pn.addChild("index").addChild(exp);
1674 //              RESULT=pn;
1675 //      :}
1676         ;
1677
1678 postfix_expression ::=
1679                 primary:exp {: 
1680         RESULT=exp; :}
1681         |       name:exp {: RESULT=exp; :}
1682         |       postincrement_expression:exp {: RESULT=exp; :}
1683         |       postdecrement_expression:exp {: RESULT=exp; :}
1684         ;
1685 postincrement_expression ::=
1686                 postfix_expression:exp PLUSPLUS 
1687                 {: RESULT=(new ParseNode("postinc")).addChild(exp).getRoot(); :}
1688         ;
1689 postdecrement_expression ::=
1690                 postfix_expression:exp MINUSMINUS
1691                 {: RESULT=(new ParseNode("postdec")).addChild(exp).getRoot(); :}
1692         ;
1693 unary_expression ::=
1694                 preincrement_expression:exp {: RESULT=exp; :}
1695         |       predecrement_expression:exp {: RESULT=exp; :}
1696         |       PLUS unary_expression:exp 
1697         {: RESULT=(new ParseNode("unaryplus")).addChild(exp).getRoot(); :}
1698         |       MINUS unary_expression:exp
1699         {: RESULT=(new ParseNode("unaryminus")).addChild(exp).getRoot(); :}
1700         |       unary_expression_not_plus_minus:exp {: 
1701                         RESULT=exp; :}
1702         ;
1703 preincrement_expression ::=
1704                 PLUSPLUS unary_expression:exp
1705                 {: RESULT=(new ParseNode("preinc")).addChild(exp).getRoot(); :}
1706         ;
1707 predecrement_expression ::=
1708                 MINUSMINUS unary_expression:exp
1709                 {: RESULT=(new ParseNode("predec")).addChild(exp).getRoot(); :}
1710         ;
1711 unary_expression_not_plus_minus ::=
1712                 postfix_expression:exp {: 
1713                 RESULT=exp; :}
1714         |       COMP unary_expression:exp
1715                 {: RESULT=(new ParseNode("comp")).addChild(exp).getRoot(); :}
1716         |       NOT unary_expression:exp 
1717                 {: RESULT=(new ParseNode("not")).addChild(exp).getRoot(); :}
1718         |       cast_expression:exp {: RESULT=exp; :}
1719         ;
1720 cast_expression ::=
1721                 LPAREN primitive_type:type
1722         //dims_opt 
1723                 RPAREN unary_expression:exp {: 
1724                 ParseNode pn=new ParseNode("cast1");
1725                 pn.addChild("type").addChild(type);
1726                 pn.addChild("exp").addChild(exp);
1727                 RESULT=pn;
1728         :}
1729         |       LPAREN expression:type RPAREN unary_expression_not_plus_minus:exp {: 
1730                 ParseNode pn=new ParseNode("cast2");
1731                 pn.addChild("type").addChild(type);
1732                 pn.addChild("exp").addChild(exp);
1733                 RESULT=pn;
1734
1735         :}
1736 //      |       LPAREN name dims RPAREN unary_expression_not_plus_minus
1737         ;
1738 multiplicative_expression ::=
1739                 unary_expression:exp {: 
1740                         RESULT=exp; :}
1741         |       multiplicative_expression:exp1 MULT unary_expression:exp2 {: 
1742                 ParseNode pn=new ParseNode("mult");
1743                 pn.addChild(exp1);
1744                 pn.addChild(exp2);
1745                 RESULT=pn;
1746         :}
1747         |       multiplicative_expression:exp1 DIV unary_expression:exp2 {:
1748                 ParseNode pn=new ParseNode("div");
1749                 pn.addChild(exp1);
1750                 pn.addChild(exp2);
1751                 RESULT=pn;
1752         :}
1753         |       multiplicative_expression:exp1 MOD unary_expression:exp2 {:
1754                 ParseNode pn=new ParseNode("mod");
1755                 pn.addChild(exp1);
1756                 pn.addChild(exp2);
1757                 RESULT=pn;
1758         :}
1759         ;
1760 additive_expression ::=
1761                 multiplicative_expression:exp {: 
1762                         RESULT=exp; :}
1763         |       additive_expression:exp1 PLUS multiplicative_expression:exp2 {: 
1764                 ParseNode pn=new ParseNode("add");
1765                 pn.addChild(exp1);
1766                 pn.addChild(exp2);
1767                 RESULT=pn;
1768         :}
1769         |       additive_expression:exp1 MINUS multiplicative_expression:exp2 {: 
1770                 ParseNode pn=new ParseNode("sub");
1771                 pn.addChild(exp1);
1772                 pn.addChild(exp2);
1773                 RESULT=pn;
1774         :}
1775         ;
1776 shift_expression ::=
1777                 additive_expression:exp {: 
1778                         RESULT=exp; :}
1779         |       shift_expression:exp1 LSHIFT additive_expression:exp2 {: 
1780                 ParseNode pn=new ParseNode("leftshift");
1781                 pn.addChild(exp1);
1782                 pn.addChild(exp2);
1783                 RESULT=pn;
1784         :}
1785         |       shift_expression:exp1 RSHIFT additive_expression:exp2 {: 
1786                 ParseNode pn=new ParseNode("rightshift");
1787                 pn.addChild(exp1);
1788                 pn.addChild(exp2);
1789                 RESULT=pn;
1790         :}
1791         |       shift_expression:exp1 URSHIFT additive_expression:exp2 {:
1792                 ParseNode pn=new ParseNode("urightshift");
1793                 pn.addChild(exp1);      
1794                 pn.addChild(exp2);      
1795                 RESULT=pn;
1796         :}
1797         ;
1798 relational_expression ::=
1799                 shift_expression:exp {: 
1800                         RESULT=exp; :}
1801         |       relational_expression:exp1 LT shift_expression:exp2 {:
1802                 ParseNode pn=new ParseNode("comp_lt");
1803                 pn.addChild(exp1);
1804                 pn.addChild(exp2);
1805                 RESULT=pn;
1806         :}
1807         |       relational_expression:exp1 GT shift_expression:exp2 {:
1808                 ParseNode pn=new ParseNode("comp_gt");
1809                 pn.addChild(exp1);
1810                 pn.addChild(exp2);
1811                 RESULT=pn;
1812         :}
1813         |       relational_expression:exp1 LTEQ shift_expression:exp2 {:
1814                 ParseNode pn=new ParseNode("comp_lte");
1815                 pn.addChild(exp1);
1816                 pn.addChild(exp2);
1817                 RESULT=pn;
1818         :}
1819         |       relational_expression:exp1 GTEQ shift_expression:exp2 {:
1820                 ParseNode pn=new ParseNode("comp_gte");
1821                 pn.addChild(exp1);
1822                 pn.addChild(exp2);
1823                 RESULT=pn;
1824         :}
1825         |       relational_expression:exp INSTANCEOF reference_type:type {: 
1826                 ParseNode pn=new ParseNode("instanceof");
1827                 pn.addChild("exp").addChild(exp);
1828                 pn.addChild(type);
1829                 RESULT=pn;
1830         :}
1831         ;
1832
1833 equality_expression ::=
1834                 relational_expression:exp {: 
1835                         RESULT=exp; :}
1836         |       equality_expression:exp1 EQEQ relational_expression:exp2 {: 
1837                 ParseNode pn=new ParseNode("equal");
1838                 pn.addChild(exp1);
1839                 pn.addChild(exp2);
1840                 RESULT=pn;
1841         :}
1842         |       equality_expression:exp1 NOTEQ relational_expression:exp2 {: 
1843                 ParseNode pn=new ParseNode("not_equal");
1844                 pn.addChild(exp1);
1845                 pn.addChild(exp2);
1846                 RESULT=pn;
1847         :}
1848         ;
1849 and_expression ::=
1850                 equality_expression:exp {: 
1851                 RESULT=exp; :}
1852         |       and_expression:exp1 AND equality_expression:exp2 {: 
1853                 ParseNode pn=new ParseNode("bitwise_and");
1854                 pn.addChild(exp1);
1855                 pn.addChild(exp2);
1856                 RESULT=pn;
1857         :}
1858         ;
1859 exclusive_or_expression ::=
1860                 and_expression:expr {: 
1861                         RESULT=expr;
1862                 :}
1863         |       exclusive_or_expression:exp1 XOR and_expression:exp2 {: 
1864                 ParseNode pn=new ParseNode("bitwise_xor");
1865                 pn.addChild(exp1);
1866                 pn.addChild(exp2);
1867                 RESULT=pn;
1868 :}
1869         ;
1870 inclusive_or_expression ::=
1871                 exclusive_or_expression:exclor {: 
1872                         RESULT=exclor; :}
1873         |       inclusive_or_expression:exp1 OR exclusive_or_expression:exp2 {: 
1874                 ParseNode pn=new ParseNode("bitwise_or");
1875                 pn.addChild(exp1);
1876                 pn.addChild(exp2);
1877                 RESULT=pn;
1878         :}
1879         ;
1880 conditional_and_expression ::=
1881                 inclusive_or_expression:inclor {: 
1882                         RESULT=inclor; :}
1883         |       conditional_and_expression:exp1 ANDAND inclusive_or_expression:exp2 {:
1884                 ParseNode pn=new ParseNode("logical_and");
1885                 pn.addChild(exp1);
1886                 pn.addChild(exp2);
1887                 RESULT=pn;
1888         :}
1889         ;
1890 conditional_or_expression ::=
1891                 conditional_and_expression:condand {: 
1892                         RESULT=condand; :}
1893         |       conditional_or_expression:exp1 OROR conditional_and_expression:exp2 {: 
1894                 ParseNode pn=new ParseNode("logical_or");
1895                 pn.addChild(exp1);
1896                 pn.addChild(exp2);
1897                 RESULT=pn;
1898         :}
1899         ;
1900 conditional_expression ::=
1901                 conditional_or_expression:condor {: 
1902                         RESULT=condor; :}
1903         |       conditional_or_expression:condor QUESTION expression:exptrue
1904                         COLON conditional_expression:expfalse {: 
1905                         ParseNode pn=new ParseNode("tert");
1906                         pn.addChild("cond").addChild(condor);
1907                         pn.addChild("trueexpr").addChild(exptrue);
1908                         pn.addChild("falseexpr").addChild(expfalse);
1909                         RESULT=pn;
1910                         :}
1911         ;
1912 getoffset_expression ::=
1913         GETOFFSET LBRACE class_or_interface_type:type COMMA IDENTIFIER:id RBRACE {:
1914         ParseNode pn = new ParseNode("getoffset");
1915         pn.addChild(type);
1916         pn.addChild("field").addChild(id);
1917         RESULT = pn;
1918       :}
1919    ;
1920  
1921 assignment_expression ::=
1922                 conditional_expression:expr {: 
1923                         RESULT=expr; :} |
1924                 assignment:assign {: 
1925                         RESULT=assign; :}             |
1926         getoffset_expression:expr {:
1927             RESULT=expr; :}
1928         ;
1929 // semantic check necessary here to ensure a valid left-hand side.
1930 // allowing a parenthesized variable here on the lhs was introduced in
1931 // JLS 2; thanks to Eric Blake for pointing this out.
1932 assignment ::=  postfix_expression:lvalue assignment_operator:op assignment_expression:rvalue {:
1933                 ParseNode pn=new ParseNode("assignment");
1934                 pn.addChild("op").addChild(op);
1935                 ParseNode pnargs=pn.addChild("args");
1936                 pnargs.addChild(lvalue);
1937                 pnargs.addChild(rvalue);
1938                 RESULT=pn;
1939          :}
1940         ;
1941 assignment_operator ::=
1942                 EQ {: RESULT=new ParseNode("eq"); :}
1943         |       MULTEQ {: RESULT=new ParseNode("multeq"); :}
1944         |       DIVEQ {: RESULT=new ParseNode("diveq"); :}
1945         |       MODEQ {: RESULT=new ParseNode("modeq"); :}
1946         |       PLUSEQ {: RESULT=new ParseNode("pluseq"); :}
1947         |       MINUSEQ {: RESULT=new ParseNode("minuseq"); :}
1948         |       LSHIFTEQ {: RESULT=new ParseNode("lshifteq"); :}
1949         |       RSHIFTEQ {: RESULT=new ParseNode("rshifteq"); :}
1950         |       URSHIFTEQ {: RESULT=new ParseNode("urshifteq"); :}
1951         |       ANDEQ {: RESULT=new ParseNode("andeq"); :}
1952         |       XOREQ {: RESULT=new ParseNode("xoreq"); :}
1953         |       OREQ {: RESULT=new ParseNode("oreq"); :}
1954         ;
1955 expression_opt ::=
1956         {:      RESULT=new ParseNode("empty"); :}
1957         |       expression:exp {: 
1958                 RESULT=exp; :}
1959         ;
1960 expression ::=  assignment_expression:exp {: 
1961                 RESULT=exp; :}
1962         ;
1963 //constant_expression ::=
1964 //              expression
1965 //      ;