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