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