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