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