update cup file
[IRC.git] / Robust / src / Parse / java14.cup
1 package Parse;
2
3 import java_cup.runtime.*;
4 import Lex.Lexer;
5 import 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 // 19.2) The Syntactic Grammar
107 non terminal ParseNode goal;
108 // 19.3) Lexical Structure
109 non terminal ParseNode literal;
110 // 19.4) Types, Values, and Variables
111 non terminal ParseNode type, primitive_type, numeric_type;
112 non terminal ParseNode integral_type, floating_point_type;
113 non terminal ParseNode reference_type;
114 non terminal ParseNode class_or_interface_type;
115 non terminal ParseNode class_type;
116 //non terminal ParseNode interface_type;
117 //non terminal ParseNode array_type;
118 // 19.5) Names
119 non terminal ParseNode name, simple_name, qualified_name;
120 // 19.6) Packages
121 non terminal ParseNode compilation_unit;
122 //non terminal ParseNode package_declaration_opt, package_declaration;
123 //non terminal ParseNode import_declarations_opt, import_declarations;
124 non terminal ParseNode type_declarations_opt, type_declarations;
125 //non terminal ParseNode import_declaration;
126 //non terminal ParseNode single_type_import_declaration;
127 //non terminal ParseNode type_import_on_demand_declaration;
128 non terminal ParseNode type_declaration;
129 // 19.7) Productions used only in the LALR(1) grammar
130 non terminal ParseNode modifiers_opt, modifiers, modifier;
131 // 19.8.1) Class Declaration
132 non terminal ParseNode class_declaration, super, super_opt;
133 //non terminal interfaces, interfaces_opt, interface_type_list;
134 non terminal ParseNode class_body;
135 non terminal ParseNode class_body_declarations, class_body_declarations_opt;
136 non terminal ParseNode class_body_declaration, class_member_declaration;
137 // 19.8.2) Field Declarations
138 non terminal ParseNode field_declaration, variable_declarators, variable_declarator;
139 non terminal ParseNode variable_declarator_id;
140 non terminal ParseNode variable_initializer;
141 // 19.8.3) Method Declarations
142 non terminal ParseNode method_declaration, method_header, method_declarator;
143 non terminal ParseNode formal_parameter_list_opt, formal_parameter_list;
144 non terminal ParseNode formal_parameter;
145 //non terminal ParseNode throws_opt;
146 //non terminal ParseNode throws;
147 //non terminal ParseNode class_type_list;
148 non terminal ParseNode method_body;
149 // 19.8.4) Static Initializers
150 //non terminal ParseNode static_initializer;
151 // 19.8.5) Constructor Declarations
152 non terminal ParseNode constructor_declaration, constructor_declarator;
153 non terminal ParseNode constructor_body;
154 //non terminal ParseNode explicit_constructor_invocation;
155 // 19.9.1) Interface Declarations
156 //non terminal ParseNode interface_declaration;
157 //non terminal ParseNode extends_interfaces_opt, extends_interfaces;
158 //non terminal ParseNode interface_body;
159 //non terminal ParseNode interface_member_declarations_opt, interface_member_declarations;
160 //non terminal ParseNode interface_member_declaration, constant_declaration;
161 //non terminal ParseNode abstract_method_declaration;
162 // 19.10) Arrays
163 //non terminal ParseNode array_initializer;
164 //non terminal ParseNode variable_initializers;
165 // 19.11) Blocks and Statements
166 non terminal ParseNode block;
167 non terminal ParseNode block_statements_opt, block_statements, block_statement;
168 non terminal ParseNode local_variable_declaration_statement, local_variable_declaration;
169 non terminal ParseNode statement, statement_no_short_if;
170 non terminal ParseNode statement_without_trailing_substatement;
171 non terminal ParseNode empty_statement;
172 //non terminal ParseNode labeled_statement, labeled_statement_no_short_if;
173 non terminal ParseNode expression_statement, statement_expression;
174 non terminal ParseNode if_then_statement;
175 non terminal ParseNode if_then_else_statement, if_then_else_statement_no_short_if;
176 //non terminal ParseNode switch_statement, switch_block;
177 //non terminal ParseNode switch_block_statement_groups;
178 //non terminal ParseNode switch_block_statement_group;
179 //non terminal ParseNode switch_labels, switch_label;
180 non terminal ParseNode while_statement, while_statement_no_short_if;
181 //non terminal ParseNode do_statement;
182 non terminal ParseNode for_statement, for_statement_no_short_if;
183 non terminal ParseNode for_init_opt, for_init;
184 non terminal ParseNode for_update_opt, for_update;
185 non terminal ParseNode statement_expression_list;
186 //non terminal ParseNode identifier_opt;
187 non terminal ParseNode break_statement, continue_statement;
188 non terminal ParseNode return_statement;
189 //non terminal ParseNode throw_statement;
190 //non terminal ParseNode synchronized_statement, try_statement;
191 //non terminal ParseNode catches_opt;
192 //non terminal ParseNode catches, catch_clause;
193 //non terminal ParseNode finally;
194 //non terminal ParseNode assert_statement;
195 // 19.12) Expressions
196 non terminal ParseNode primary, primary_no_new_array;
197 non terminal ParseNode class_instance_creation_expression;
198 non terminal ParseNode argument_list_opt, argument_list;
199 //non terminal ParseNode array_creation_init, array_creation_uninit;
200 //non terminal ParseNode dim_exprs, dim_expr, dims_opt, dims;
201 non terminal ParseNode field_access, method_invocation;
202 //non terminal ParseNode array_access;
203 non terminal ParseNode postfix_expression;
204 non terminal ParseNode postincrement_expression, postdecrement_expression;
205 non terminal ParseNode unary_expression, unary_expression_not_plus_minus;
206 non terminal ParseNode preincrement_expression, predecrement_expression;
207 non terminal ParseNode cast_expression;
208 non terminal ParseNode multiplicative_expression, additive_expression;
209 non terminal ParseNode shift_expression, relational_expression, equality_expression;
210 non terminal ParseNode and_expression, exclusive_or_expression, inclusive_or_expression;
211 non terminal ParseNode conditional_and_expression, conditional_or_expression;
212 non terminal ParseNode conditional_expression;
213 non terminal ParseNode assignment_expression;
214 non terminal ParseNode assignment;
215 non terminal ParseNode assignment_operator;
216 non terminal ParseNode expression_opt, expression;
217 //non terminal ParseNode constant_expression;
218
219 start with goal;
220
221 // 19.2) The Syntactic Grammar
222 goal ::=        compilation_unit:cu
223         {:
224         RESULT = (new ParseNode("goal")).addChild(cu).getRoot();
225         :}
226         ;
227
228 // 19.3) Lexical Structure.
229
230
231 literal ::=     INTEGER_LITERAL:integer_lit
232         {:
233                 ParseNode pn=new ParseNode("literal");
234                 pn.addChild("integer").setLiteral(integer_lit);
235                 RESULT=pn;
236         :}
237         |       FLOATING_POINT_LITERAL:float_lit
238         {:
239                 ParseNode pn=new ParseNode("literal");
240                 pn.addChild("float").setLiteral(float_lit);
241                 RESULT=pn;
242         :}
243         |       BOOLEAN_LITERAL:boolean_lit
244         {:
245                 ParseNode pn=new ParseNode("literal");
246                 pn.addChild("boolean").setLiteral(boolean_lit);
247                 RESULT=pn;
248         :}
249         |       CHARACTER_LITERAL:char_lit
250         {:
251                 ParseNode pn=new ParseNode("literal");
252                 pn.addChild("char").setLiteral(char_lit);
253                 RESULT=pn;
254         :}
255         |       STRING_LITERAL:string_lit
256         {:
257                 ParseNode pn=new ParseNode("literal");
258                 pn.addChild("string").setLiteral(string_lit);
259                 RESULT=pn;
260         :}
261         |       NULL_LITERAL 
262         {:
263                 RESULT=(new ParseNode("literal")).addChild("null").getRoot();
264         :}
265         ;
266
267 // 19.4) Types, Values, and Variables
268 type    ::=     primitive_type:type {: RESULT=type; :}
269         |       reference_type:type {: RESULT=type; :}
270         ;
271 primitive_type ::=
272                 numeric_type:type {: RESULT=type; :}
273         |       BOOLEAN {: RESULT=(new ParseNode("type")).addChild("boolean").getRoot(); :}
274         ;
275 numeric_type::= integral_type:type {: RESULT=type; :}
276         |       floating_point_type:type {: RESULT=type; :}
277         ;
278 integral_type ::= 
279                 BYTE {: RESULT=(new ParseNode("type")).addChild("byte").getRoot(); :}
280         |       SHORT  {: RESULT=(new ParseNode("type")).addChild("short").getRoot(); :}
281         |       INT  {: RESULT=(new ParseNode("type")).addChild("int").getRoot(); :}
282         |       LONG  {: RESULT=(new ParseNode("type")).addChild("long").getRoot(); :}
283         |       CHAR  {: RESULT=(new ParseNode("type")).addChild("char").getRoot(); :}
284         ;
285 floating_point_type ::= 
286                 FLOAT  {: RESULT=(new ParseNode("type")).addChild("float").getRoot(); :}
287         |       DOUBLE  {: RESULT=(new ParseNode("type")).addChild("double").getRoot(); :}
288         ;
289
290 reference_type ::=
291                 class_or_interface_type:type {: RESULT=type; :}
292 //      |       array_type:type {: RESULT=type; :}
293         ;
294 class_or_interface_type ::= name:name {: 
295         RESULT=(new ParseNode("type")).addChild("class").addChild(name).getRoot(); 
296         :};
297
298 class_type ::=  class_or_interface_type:type {: RESULT=type; :};
299 //interface_type ::= class_or_interface_type;
300
301 //array_type ::=        primitive_type dims
302 //      |       name dims
303 //      ;
304
305 // 19.5) Names
306 name    ::=     simple_name:name {: RESULT=name; :}
307         |       qualified_name:name {: RESULT=name; :}
308         ;
309 simple_name ::= IDENTIFIER:id {: 
310         RESULT=(new ParseNode("name")).addChild("identifier").addChild(id).getRoot(); 
311         :}
312         ;
313 qualified_name ::= name:name DOT IDENTIFIER:id {: 
314         ParseNode pn=new ParseNode("name");
315         pn.addChild("base").addChild(name);
316         pn.addChild("identifier").addChild(id);
317         RESULT=pn;
318         :}
319         ;
320
321 // 19.6) Packages
322 compilation_unit ::=
323 //              package_declaration_opt
324 //              import_declarations_opt
325                 type_declarations_opt:tdo {: 
326                 ParseNode pn=new ParseNode("compilation_unit");
327                 pn.addChild("types").addChild(tdo);
328                 RESULT=pn;
329                 :}
330                 ;
331 //package_declaration_opt ::= package_declaration | ;
332 //import_declarations_opt ::= import_declarations | ;
333 type_declarations_opt   ::= type_declarations:tds {:
334                 RESULT=tds;
335                 :}   | 
336         {: RESULT=new ParseNode("empty"); :}
337         ;
338
339 //import_declarations ::=
340 //               import_declaration
341 //       |       import_declarations import_declaration
342 //       ;
343
344 type_declarations ::= 
345                 type_declaration:td {:
346                 ParseNode pn=new ParseNode("type_declaration_list");
347                 pn.addChild(td);
348                 RESULT=pn;
349                 :}
350         |       type_declarations:tds type_declaration:td {:
351                 tds.addChild(td);
352                 RESULT=tds;
353                 :}
354         ;
355
356 //package_declaration ::=
357 //               PACKAGE name SEMICOLON
358 //       ;
359 //import_declaration ::=
360 //               single_type_import_declaration
361 //       |       type_import_on_demand_declaration
362 //       ;
363 //single_type_import_declaration ::=
364 //               IMPORT name SEMICOLON
365 //       ;
366 //type_import_on_demand_declaration ::=
367 //               IMPORT name DOT MULT SEMICOLON
368 //       ;
369
370 type_declaration ::=
371                 class_declaration:cd 
372                 {:
373                 RESULT=(new ParseNode("type_declaration")).addChild("class").addChild(cd);
374                 :}
375 //      |       interface_declaration
376         |       SEMICOLON {: RESULT=new ParseNode("empty"); :}
377         ;
378
379 // 19.7) Productions used only in the LALR(1) grammar
380 modifiers_opt::=
381         {: RESULT=new ParseNode("empty"); :}
382         |       modifiers:mo {: 
383                 RESULT=mo;
384         :}
385         ;
386 modifiers ::=   modifier:mo {: 
387                 ParseNode pn=new ParseNode("modifier_list");
388                 pn.addChild(mo);
389                 RESULT=pn;
390         :}
391         |       modifiers:mos modifier:mo {: 
392                 mos.addChild(mo);
393                 RESULT=mos;
394         :}
395         ;
396 modifier ::=    
397         PUBLIC {: RESULT=new ParseNode("public"); :}|
398         PROTECTED {: RESULT=new ParseNode("protected"); :}|
399         PRIVATE {: RESULT=new ParseNode("private"); :}|
400         STATIC {: RESULT=new ParseNode("static"); :} |
401 //      ABSTRACT |
402         FINAL {: RESULT=new ParseNode("final"); :}|
403         NATIVE {: RESULT=new ParseNode("native"); :}
404 //      SYNCHRONIZED | 
405 //      TRANSIENT | 
406 //      VOLATILE |
407 //      STRICTFP // note that semantic analysis must check that the
408                          // context of the modifier allows strictfp.
409         ;
410
411 // 19.8) Classes
412
413 // 19.8.1) Class Declaration:
414 class_declaration ::= 
415         modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so {:
416         ParseNode pn=new ParseNode("class_declaration");
417         pn.addChild("modifiers").addChild(mo);
418         pn.addChild("name").addChild(id);
419         pn.addChild("super").addChild(so);
420         RESULT=pn;
421         :}
422 //interfaces_opt
423 class_body:body 
424         {:
425         ParseNode pn=new ParseNode("class_declaration");
426         pn.addChild("modifiers").addChild(mo);
427         pn.addChild("name").addChild(id);
428         pn.addChild("super").addChild(so);
429         pn.addChild("body").addChild(body);
430         RESULT=pn;
431         :}
432         ;
433 super ::=       EXTENDS class_type:classtype {: 
434                 ParseNode pn=new ParseNode("super");
435                 pn.addChild(classtype);
436                 RESULT=pn;
437         :}
438         ;
439 super_opt ::=   
440         {: RESULT=new ParseNode("empty"); :}
441         |       super:su {: 
442                 RESULT=su;
443         :}
444         ;
445
446 //interfaces ::= IMPLEMENTS interface_type_list
447 //       ;
448 //interfaces_opt::=
449 //       |       interfaces
450 //       ;
451 //interface_type_list ::=
452 //               interface_type
453 //       |       interface_type_list COMMA interface_type
454 //       ;
455
456 class_body ::=  LBRACE class_body_declarations_opt:cbdo RBRACE {: RESULT=cbdo; :}
457         ;
458
459 class_body_declarations_opt ::= 
460         {: RESULT=new ParseNode("empty"); :}
461         |       class_body_declarations:cbd {: RESULT=cbd; :};
462
463 class_body_declarations ::= 
464                 class_body_declaration:cbd {: 
465                         ParseNode pn=new ParseNode("class_body_declaration_list");
466                         pn.addChild(cbd);
467                         RESULT=pn;
468                 :}
469         |       class_body_declarations:cbds class_body_declaration:cbd {: 
470                         cbds.addChild(cbd);
471                         RESULT=cbds;
472                 :}
473         ;
474
475 class_body_declaration ::=
476                 class_member_declaration:member {: 
477                 RESULT=(new ParseNode("class_body_declaration")).addChild("member").addChild(member).getRoot();
478         :}
479 //      |       static_initializer
480         |       constructor_declaration:constructor {: 
481                 RESULT=(new ParseNode("class_body_declaration")).addChild("constructor").addChild(constructor).getRoot();
482         :}
483         |       block:block {:
484                 RESULT=(new ParseNode("class_body_declaration")).addChild("block").addChild(block).getRoot();
485 :}
486         ;
487 class_member_declaration ::=
488         field_declaration:field {: 
489         RESULT=(new ParseNode("class_member_declaration")).addChild("field").addChild(field).getRoot(); 
490         :}
491         |       method_declaration:method {:
492         RESULT=(new ParseNode("class_member_declaration")).addChild("method").addChild(method).getRoot(); 
493         :}
494         /* repeat the prod for 'class_declaration' here: */
495 //      |       modifiers_opt CLASS IDENTIFIER super_opt class_body
496 //      |       interface_declaration
497         |       SEMICOLON       {: RESULT=new ParseNode("empty"); :}
498         ;
499
500 // 19.8.2) Field Declarations
501 field_declaration ::= 
502                 modifiers_opt:mo type:type variable_declarators:var SEMICOLON {: 
503                 ParseNode pn=new ParseNode("field_declaration");
504                 pn.addChild("modifier").addChild(mo);
505                 pn.addChild("type").addChild(type);
506                 pn.addChild("variables").addChild(var);
507                 RESULT=pn;
508         :}
509         ;
510
511 variable_declarators ::=
512                 variable_declarator:vd {: 
513                 ParseNode pn=new ParseNode("variable_declarators_list");
514                 pn.addChild(vd);
515                 RESULT=pn;
516         :}
517         |       variable_declarators:vds COMMA variable_declarator:vd {:
518                 vds.addChild(vd);
519                 RESULT=vds;
520         :}
521         ;
522 variable_declarator ::=
523                 variable_declarator_id:id {:
524                 ParseNode pn=new ParseNode("variable_declarator");
525                 pn.addChild("identifier").addChild(id);
526                 RESULT=pn;
527         :}
528         |       variable_declarator_id:id EQ variable_initializer:init {: 
529                 ParseNode pn=new ParseNode("variable_declarator");
530                 pn.addChild("identifier").addChild(id);
531                 pn.addChild("initializer").addChild(init);
532                 RESULT=pn;
533         :}
534         ;
535 variable_declarator_id ::=
536                 IDENTIFIER:id {: 
537                 RESULT=(new ParseNode("variable_declarator_id")).addChild("name").addChild(id);:}
538 //      |       variable_declarator_id:id LBRACK RBRACK {:
539 //              RESULT=(new ParseNode("variable_declarator_id")).addChild("array").addChild(id);:}
540         ;
541 variable_initializer ::=
542                 expression:exp {: RESULT=exp; :}
543 //      |       array_initializer
544         ;
545
546 // 19.8.3) Method Declarations
547 method_declaration ::=
548                 method_header:header method_body:body {:
549                 ParseNode pn=new ParseNode("method_declaration");
550                 pn.addChild("header").addChild(header);
551                 pn.addChild("body").addChild(body);
552                 RESULT=pn;
553         :}
554         ;
555 method_header ::=
556                 modifiers_opt:mo type:type method_declarator:decl //throws_opt 
557         {:
558                 ParseNode pn=new ParseNode("method_header");
559                 pn.addChild("modifiers").addChild(mo);
560                 pn.addChild("returntype").addChild(type);
561                 pn.addChild("declarator").addChild(decl);
562                 RESULT=pn;
563         :}
564         |       modifiers_opt:mo VOID method_declarator:decl //throws_opt
565         {:
566                 ParseNode pn=new ParseNode("method_header");
567                 pn.addChild("modifiers").addChild(mo);
568                 pn.addChild("declarator").addChild(decl);
569                 RESULT=pn;
570         :}
571         ;
572 method_declarator ::=
573                 IDENTIFIER:id LPAREN formal_parameter_list_opt:params RPAREN {: 
574                 ParseNode pn=new ParseNode("method_declarator");
575                 pn.addChild("name").addChild(id);
576                 pn.addChild("parameters").addChild(params);
577                 RESULT=pn;
578         :}
579 //      |       method_declarator LBRACK RBRACK // deprecated
580 // be careful; the above production also allows 'void foo() []'
581         ;
582 formal_parameter_list_opt ::=
583         {: RESULT=new ParseNode("empty"); :}
584         |       formal_parameter_list:fpl {: 
585                 RESULT=fpl;
586         :}
587         ;
588 formal_parameter_list ::=
589                 formal_parameter:fp {: 
590                 ParseNode pn=new ParseNode("formal_parameter_list");
591                 pn.addChild(fp);
592                 RESULT=pn;
593         :}
594         |       formal_parameter_list:fpl COMMA formal_parameter:fp {: 
595                 fpl.addChild(fp);
596                 RESULT=fpl;
597         :}
598         ;
599 formal_parameter ::=
600                 type:type variable_declarator_id:name {:
601                 ParseNode pn=new ParseNode("formal_parameter");
602                 pn.addChild("type").addChild(type);
603                 pn.addChild("name").addChild(name);
604                 RESULT=pn;
605         :}
606 //      |       FINAL type variable_declarator_id
607         ;
608 //throws_opt ::=        
609 //      |       throws
610 //      ;
611 //throws ::=    THROWS class_type_list
612 //      ;
613 //class_type_list ::=
614 //              class_type
615 //      |       class_type_list COMMA class_type
616 //      ;
617 method_body ::= block:block {: 
618                 RESULT=block;
619         :}
620         |       SEMICOLON       {: RESULT=new ParseNode("empty"); :}
621         ;
622
623 // 19.8.4) Static Initializers
624 //static_initializer ::=
625 //              STATIC block
626 //      ;
627
628 // 19.8.5) Constructor Declarations
629 constructor_declaration ::=
630                 modifiers_opt:mo constructor_declarator:cd
631 //throws_opt 
632                         constructor_body:body   {:
633                 ParseNode pn=new ParseNode("constructor_declaration");
634                 pn.addChild("modifier").addChild(mo);
635                 pn.addChild("declarator").addChild(cd);
636                 pn.addChild("body").addChild(body);
637                 RESULT=pn;
638         :}
639         ;
640 constructor_declarator ::=
641                 simple_name:name LPAREN formal_parameter_list_opt:fplo RPAREN {: 
642                 ParseNode pn=new ParseNode("constructor_declarator");
643                 pn.addChild("name").addChild(name);
644                 pn.addChild("parameters").addChild(fplo);
645                 RESULT=pn;
646         :}
647         ;
648 constructor_body ::=
649 //              LBRACE explicit_constructor_invocation:eci block_statements:bs RBRACE |
650 //              LBRACE explicit_constructor_invocation RBRACE |
651                 LBRACE block_statements:block RBRACE {: 
652                 ParseNode pn=new ParseNode("constructor_body");
653                 pn.addChild("block").addChild(block);
654                 RESULT=pn;
655         :}
656         |       LBRACE RBRACE {: RESULT=new ParseNode("empty"); :}
657         ;
658 //explicit_constructor_invocation ::=
659 //              THIS LPAREN argument_list_opt RPAREN SEMICOLON
660 //      |       SUPER LPAREN argument_list_opt RPAREN SEMICOLON
661 //      |       primary DOT THIS LPAREN argument_list_opt RPAREN SEMICOLON
662 //      |       primary DOT SUPER LPAREN argument_list_opt RPAREN SEMICOLON
663 //      ;
664
665 // 19.9) Interfaces
666
667 // 19.9.1) Interface Declarations
668 //interface_declaration ::=
669 //               modifiers_opt INTERFACE IDENTIFIER extends_interfaces_opt
670 //                       interface_body
671 //       ;
672 //extends_interfaces_opt ::=
673 //       |       extends_interfaces
674 //       ;
675 //extends_interfaces ::=
676 //               EXTENDS interface_type
677 //       |       extends_interfaces COMMA interface_type
678 //       ;
679 //interface_body ::=
680 //               LBRACE interface_member_declarations_opt RBRACE
681 //       ;
682 //interface_member_declarations_opt ::=
683 //       |       interface_member_declarations
684 //       ;
685 //interface_member_declarations ::=
686 //               interface_member_declaration
687 //       |       interface_member_declarations interface_member_declaration
688 //       ;
689 //interface_member_declaration ::=
690 //               constant_declaration
691 //       |       abstract_method_declaration
692 //       |       class_declaration
693 //       |       interface_declaration
694 //       |       SEMICOLON
695 //       ;
696 //constant_declaration ::=
697 //               field_declaration
698 //       // need to semantically check that modifiers of field declaration
699 //       // include only PUBLIC, STATIC, or FINAL.  Other modifiers are
700 //       // disallowed.
701 //       ;
702 //abstract_method_declaration ::=
703 //               method_header SEMICOLON
704 //       ;
705
706
707 // 19.10) Arrays
708 //array_initializer ::=
709 //              LBRACE variable_initializers COMMA RBRACE
710 //      |       LBRACE variable_initializers RBRACE
711 //      |       LBRACE COMMA RBRACE
712 //      |       LBRACE RBRACE
713 //      ;
714 //variable_initializers ::=
715 //              variable_initializer
716 //      |       variable_initializers COMMA variable_initializer
717 //      ;
718
719 // 19.11) Blocks and Statements
720 block ::=       LBRACE block_statements_opt:bso RBRACE {: 
721         ParseNode pn=new ParseNode("block");
722         pn.addChild("block_statements_opt").addChild(bso);
723         RESULT=pn;
724         :}
725         ;
726 block_statements_opt ::=
727         {: RESULT=new ParseNode("empty"); :}
728         |       block_statements:bs {: 
729         ParseNode pn=new ParseNode("block_statements_opt");
730         pn.addChild("block_statements").addChild(bs);
731         RESULT=pn;
732         :}
733         ;
734 block_statements ::=
735                 block_statement:bs {:
736         ParseNode pn=new ParseNode("block_statement_list");
737         pn.addChild(bs);
738         RESULT=pn;
739         :}
740         |       block_statements:bss block_statement:bs {: 
741         bss.addChild(bs);
742         RESULT=bs;
743         :}
744         ;
745 block_statement ::=
746                 local_variable_declaration_statement:lvds {: 
747                 ParseNode pn=new ParseNode("block_statement");
748                 pn.addChild("local_variable_declaration").addChild(lvds);
749                 RESULT=pn;
750         :}
751         |       statement:statement {: 
752                 ParseNode pn=new ParseNode("statement");
753                 pn.addChild("statement").addChild(statement);
754                 RESULT=pn;
755         :}
756 //      |       class_declaration
757 //      |       interface_declaration
758         ;
759 local_variable_declaration_statement ::=
760                 local_variable_declaration:lvd SEMICOLON {: 
761                 RESULT=lvd;
762         :}
763         ;
764 local_variable_declaration ::=
765                 type:type variable_declarators:var_decls {: 
766                 ParseNode pn=new ParseNode("local_variable_declaration");
767                 pn.addChild("type").addChild(type);
768                 pn.addChild("variables").addChild(var_decls);
769                 RESULT=pn;
770 :}
771 //      |       FINAL type variable_declarators
772         ;
773 statement ::=   statement_without_trailing_substatement:st {: 
774                 RESULT=st;
775         :}
776 //      |       labeled_statement:st {: RESULT=st; :}
777         |       if_then_statement:st {: RESULT=st; :}
778         |       if_then_else_statement:st {: RESULT=st; :}
779         |       while_statement:st {: RESULT=st; :}
780         |       for_statement:st {: RESULT=st; :}
781         ;
782 statement_no_short_if ::=
783                 statement_without_trailing_substatement:st {: RESULT=st; :}
784 //      |       labeled_statement_no_short_if:st {: RESULT=st; :}
785         |       if_then_else_statement_no_short_if:st {: RESULT=st; :}
786         |       while_statement_no_short_if:st {: RESULT=st; :}
787         |       for_statement_no_short_if:st {: RESULT=st; :}
788         ;
789 statement_without_trailing_substatement ::=
790                 block:st {: RESULT=st; :}
791         |       empty_statement:st {: RESULT=st; :}
792         |       expression_statement:st {: RESULT=st; :}
793 //      |       switch_statement
794 //      |       do_statement
795         |       break_statement:st {: RESULT=st; :}
796         |       continue_statement:st {: RESULT=st; :}
797         |       return_statement:st {: RESULT=st; :}
798 //      |       synchronized_statement
799 //      |       throw_statement
800 //      |       try_statement
801 //      |       assert_statement
802         ;
803 empty_statement ::=
804                 SEMICOLON {: RESULT=(new ParseNode("statement")).addChild("nop").getRoot(); :}
805         ;
806 //labeled_statement ::=
807 //              IDENTIFIER COLON statement
808 //      ;
809 //labeled_statement_no_short_if ::=
810 //              IDENTIFIER COLON statement_no_short_if
811 //      ;
812 expression_statement ::=
813                 statement_expression:se SEMICOLON {: RESULT=se; :}
814         ;
815 statement_expression ::=
816                 assignment:st {: RESULT=st; :}
817         |       preincrement_expression:st {: RESULT=st; :}
818         |       predecrement_expression:st {: RESULT=st; :}
819         |       postincrement_expression:st {: RESULT=st; :}
820         |       postdecrement_expression:st {: RESULT=st; :}
821         |       method_invocation:st {: RESULT=st; :}
822         |       class_instance_creation_expression:st {: RESULT=st; :}
823         ;
824 if_then_statement ::=
825                 IF LPAREN expression:exp RPAREN statement:st {: 
826                 ParseNode pn=new ParseNode("ifstatement");
827                 pn.addChild("condition").addChild(exp);
828                 pn.addChild("statement").addChild(st);
829                 RESULT=pn;
830         :}
831         ;
832 if_then_else_statement ::=
833                 IF LPAREN expression:exp RPAREN statement_no_short_if:st
834                         ELSE statement:else_st {:
835                 ParseNode pn=new ParseNode("ifstatement");
836                 pn.addChild("condition").addChild(exp);
837                 pn.addChild("statement").addChild(st);
838                 pn.addChild("else_statement").addChild(else_st);
839                 RESULT=pn;
840         :}
841         ;
842 if_then_else_statement_no_short_if ::=
843                 IF LPAREN expression:exp RPAREN statement_no_short_if:st
844                         ELSE statement_no_short_if:else_st {:
845                 ParseNode pn=new ParseNode("ifstatement");
846                 pn.addChild("condition").addChild(exp);
847                 pn.addChild("statement").addChild(st);
848                 pn.addChild("else_statement").addChild(else_st);
849                 RESULT=pn;
850         :}
851         ;
852 //switch_statement ::=
853 //              SWITCH LPAREN expression RPAREN switch_block
854 //      ;
855 //switch_block ::=
856 //              LBRACE switch_block_statement_groups switch_labels RBRACE
857 //      |       LBRACE switch_block_statement_groups RBRACE
858 //      |       LBRACE switch_labels RBRACE
859 //      |       LBRACE RBRACE
860 //      ;
861 //switch_block_statement_groups ::=
862 //              switch_block_statement_group
863 //      |       switch_block_statement_groups switch_block_statement_group
864 //      ;
865 //switch_block_statement_group ::=
866 //              switch_labels block_statements
867 //      ;
868 //switch_labels ::=
869 //              switch_label
870 //      |       switch_labels switch_label
871 //      ;
872 //switch_label ::=
873 //              CASE constant_expression COLON
874 //      |       DEFAULT COLON
875 //      ;
876
877 while_statement ::=
878                 WHILE LPAREN expression:exp RPAREN statement:st {: 
879                 ParseNode pn=new ParseNode("whilestatement");
880                 pn.addChild("condition").addChild(exp);
881                 pn.addChild("statement").addChild(st);
882                 RESULT=pn;
883         :}
884         ;
885 while_statement_no_short_if ::=
886                 WHILE LPAREN expression:exp RPAREN statement_no_short_if:st {:
887                 ParseNode pn=new ParseNode("whilestatement");
888                 pn.addChild("condition").addChild(exp);
889                 pn.addChild("statement").addChild(st);
890                 RESULT=pn;
891                 :}
892         ;
893 //do_statement ::=
894 //              DO statement WHILE LPAREN expression RPAREN SEMICOLON
895 //      ;
896 for_statement ::=
897                 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
898                         for_update_opt:update RPAREN statement:st {: 
899                 ParseNode pn=new ParseNode("forstatement");
900                 pn.addChild("initializer").addChild(init);
901                 pn.addChild("condition").addChild(exp);
902                 pn.addChild("update").addChild(update);
903                 pn.addChild("statement").addChild(st);
904                 RESULT=pn;
905                 :}
906         ;
907 for_statement_no_short_if ::=
908                 FOR LPAREN for_init_opt:init SEMICOLON expression_opt:exp SEMICOLON
909                         for_update_opt:update RPAREN statement_no_short_if:st {:
910                 ParseNode pn=new ParseNode("forstatement");
911                 pn.addChild("initializer").addChild(init);
912                 pn.addChild("condition").addChild(exp);
913                 pn.addChild("update").addChild(update);
914                 pn.addChild("statement").addChild(st);
915                 RESULT=pn;
916                 :}
917         ;
918 for_init_opt ::=
919         {: RESULT=new ParseNode("empty"); :}
920         |       for_init:init {: RESULT=init; :}
921         ;
922 for_init ::=    statement_expression_list:list {: RESULT=list; :}
923         |       local_variable_declaration:decl {: RESULT=decl; :}
924         ;
925 for_update_opt ::=
926         {: RESULT=new ParseNode("empty"); :}
927         |       for_update:update {: RESULT=update; :}
928         ;
929 for_update ::=  statement_expression_list:list {: RESULT=list; :}
930         ;
931 statement_expression_list ::=
932                 statement_expression:expr {: 
933                 RESULT=(new ParseNode("statement_expression_list")).addChild(expr).getRoot();
934         :}
935         |       statement_expression_list:list COMMA statement_expression:expr {: 
936                 list.addChild(expr);
937                 RESULT=list;
938         :}
939         ;
940
941 //identifier_opt ::= 
942 //      |       IDENTIFIER
943 //      ;
944
945 break_statement ::=
946                 BREAK
947 //identifier_opt 
948 SEMICOLON {: RESULT=new ParseNode("break"); :}
949         ;
950
951 continue_statement ::=
952                 CONTINUE  
953 //identifier_opt 
954 SEMICOLON
955 {: RESULT=new ParseNode("continue"); :}
956         ;
957 return_statement ::=
958                 RETURN expression_opt:exp SEMICOLON {: 
959         RESULT=(new ParseNode("return")).addChild("retvalue").addChild(exp).getRoot(); :}
960         ;
961 //throw_statement ::=
962 //              THROW expression SEMICOLON
963 //      ;
964 //synchronized_statement ::=
965 //              SYNCHRONIZED LPAREN expression RPAREN block
966 //      ;
967 //try_statement ::=
968 //              TRY block catches
969 //      |       TRY block catches_opt finally
970 //      ;
971 //catches_opt ::=
972 //      |       catches
973 //      ;
974 //catches ::=   catch_clause
975 //      |       catches catch_clause
976 //      ;
977 //catch_clause ::=
978 //              CATCH LPAREN formal_parameter RPAREN block
979 //      ;
980 //finally ::=   FINALLY block
981 //      ;
982 //assert_statement ::=
983 //              ASSERT expression SEMICOLON
984 //      |       ASSERT expression COLON expression SEMICOLON
985 //      ;
986
987 // 19.12) Expressions
988 primary ::=     primary_no_new_array:st {: 
989                 RESULT=st; :}
990 //      |       array_creation_init
991 //      |       array_creation_uninit
992         ;
993 primary_no_new_array ::=
994                 literal:lit {: RESULT=lit; :}
995         |       THIS {: RESULT=new ParseNode("this"); :}
996         |       LPAREN expression:exp RPAREN {: RESULT=exp; :}
997         |       class_instance_creation_expression:exp {: RESULT=exp; :}
998         |       field_access:exp {: RESULT=exp; :}
999         |       method_invocation:exp {: RESULT=exp; :}
1000 //      |       array_access
1001 //      |       primitive_type DOT CLASS
1002 //      |       VOID DOT CLASS
1003 //      |       array_type DOT CLASS
1004 //      |       name DOT CLASS
1005 //      |       name DOT THIS
1006         ;
1007 class_instance_creation_expression ::=
1008                 NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {: 
1009                 ParseNode pn=new ParseNode("createobject");
1010                 pn.addChild("type").addChild(type);
1011                 pn.addChild("args").addChild(args);
1012                 RESULT=pn;
1013         :}
1014 //      |       NEW class_or_interface_type LPAREN argument_list_opt RPAREN class_body
1015 //      |       primary DOT NEW IDENTIFIER
1016 //                      LPAREN argument_list_opt RPAREN {: 
1017 //              
1018 //      :}
1019 //      |       primary DOT NEW IDENTIFIER
1020 //                      LPAREN argument_list_opt RPAREN class_body
1021 //      |       name DOT NEW IDENTIFIER
1022 //                      LPAREN argument_list_opt RPAREN
1023 //      |       name DOT NEW IDENTIFIER
1024 //                      LPAREN argument_list_opt RPAREN class_body
1025         ;
1026 argument_list_opt ::=
1027         {: RESULT=new ParseNode("empty"); :}
1028         |       argument_list:args {: RESULT=args; :}
1029         ;
1030 argument_list ::=
1031                 expression:exp {:
1032                 ParseNode pn=new ParseNode("argument_list");
1033                 pn.addChild(exp);
1034                 RESULT=pn;
1035         :}
1036         |       argument_list:list COMMA expression:exp {: 
1037                 list.addChild(exp);
1038                 RESULT=list;
1039         :}
1040         ;
1041 //array_creation_uninit ::=
1042 //              NEW primitive_type dim_exprs dims_opt
1043 //      |       NEW class_or_interface_type dim_exprs dims_opt
1044 //      ;
1045 //array_creation_init ::=
1046 //              NEW primitive_type dims array_initializer
1047 //      |       NEW class_or_interface_type dims array_initializer
1048 //      ;
1049 //dim_exprs ::= dim_expr
1050 //      |       dim_exprs dim_expr
1051 //      ;
1052 //dim_expr ::=  LBRACK expression RBRACK
1053 //      ;
1054 //dims_opt ::=
1055 //      |       dims
1056 //      ;
1057 //dims ::=      LBRACK RBRACK
1058 //      |       dims LBRACK RBRACK
1059 //      ;
1060 field_access ::=
1061                 primary:base DOT IDENTIFIER:id {: 
1062                 ParseNode pn=new ParseNode("fieldaccess");
1063                 pn.addChild("base").addChild(base);
1064                 pn.addChild("field").addChild(id);
1065                 RESULT=pn;
1066 :}
1067 //      |       SUPER DOT IDENTIFIER
1068 //      |       name DOT SUPER DOT IDENTIFIER
1069         ;
1070 method_invocation ::=
1071                 name:name LPAREN argument_list_opt:args RPAREN {: 
1072                 ParseNode pn=new ParseNode("methodinvoke");
1073                 pn.addChild("name").addChild(name);
1074                 pn.addChild("args").addChild(args);
1075                 RESULT=pn;
1076         :}
1077         |       primary:base DOT IDENTIFIER:name LPAREN argument_list_opt:args RPAREN {: 
1078                 ParseNode pn=new ParseNode("methodinvoke");
1079                 pn.addChild("base").addChild(base);
1080                 pn.addChild("name").addChild(name);
1081                 pn.addChild("args").addChild(args);
1082                 RESULT=pn;
1083         :}
1084 //      |       SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
1085 //      |       name DOT SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
1086         ;
1087 //array_access ::=
1088 //              name LBRACK expression RBRACK
1089 //      |       primary_no_new_array LBRACK expression RBRACK
1090 //      |       array_creation_init LBRACK expression RBRACK
1091 //      ;
1092 postfix_expression ::=
1093                 primary:exp {: 
1094         RESULT=exp; :}
1095         |       name:exp {: RESULT=exp; :}
1096         |       postincrement_expression:exp {: RESULT=exp; :}
1097         |       postdecrement_expression:exp {: RESULT=exp; :}
1098         ;
1099 postincrement_expression ::=
1100                 postfix_expression:exp PLUSPLUS 
1101                 {: RESULT=(new ParseNode("postinc")).addChild(exp).getRoot(); :}
1102         ;
1103 postdecrement_expression ::=
1104                 postfix_expression:exp MINUSMINUS
1105                 {: RESULT=(new ParseNode("postdec")).addChild(exp).getRoot(); :}
1106         ;
1107 unary_expression ::=
1108                 preincrement_expression:exp {: RESULT=exp; :}
1109         |       predecrement_expression:exp {: RESULT=exp; :}
1110         |       PLUS unary_expression:exp 
1111         {: RESULT=(new ParseNode("unaryplus")).addChild(exp).getRoot(); :}
1112         |       MINUS unary_expression:exp
1113         {: RESULT=(new ParseNode("unaryminus")).addChild(exp).getRoot(); :}
1114         |       unary_expression_not_plus_minus:exp {: 
1115                         RESULT=exp; :}
1116         ;
1117 preincrement_expression ::=
1118                 PLUSPLUS unary_expression:exp
1119                 {: RESULT=(new ParseNode("preinc")).addChild(exp).getRoot(); :}
1120         ;
1121 predecrement_expression ::=
1122                 MINUSMINUS unary_expression:exp
1123                 {: RESULT=(new ParseNode("predec")).addChild(exp).getRoot(); :}
1124         ;
1125 unary_expression_not_plus_minus ::=
1126                 postfix_expression:exp {: 
1127                 RESULT=exp; :}
1128 //      |       COMP unary_expression
1129         |       NOT unary_expression:exp 
1130                 {: RESULT=(new ParseNode("not")).addChild(exp).getRoot(); :}
1131         |       cast_expression:exp {: RESULT=exp; :}
1132         ;
1133 cast_expression ::=
1134                 LPAREN primitive_type:type
1135         //dims_opt 
1136                 RPAREN unary_expression:exp {: 
1137                 ParseNode pn=new ParseNode("cast");
1138                 pn.addChild("type").addChild(type);
1139                 pn.addChild("exp").addChild(exp);
1140                 RESULT=pn;
1141         :}
1142         |       LPAREN expression:type RPAREN unary_expression_not_plus_minus:exp {: 
1143                 ParseNode pn=new ParseNode("cast");
1144                 pn.addChild("type").addChild(type);
1145                 pn.addChild("exp").addChild(exp);
1146                 RESULT=pn;
1147
1148         :}
1149 //      |       LPAREN name dims RPAREN unary_expression_not_plus_minus
1150         ;
1151 multiplicative_expression ::=
1152                 unary_expression:exp {: 
1153                         RESULT=exp; :}
1154         |       multiplicative_expression:exp1 MULT unary_expression:exp2 {: 
1155                 ParseNode pn=new ParseNode("mult");
1156                 pn.addChild(exp1);
1157                 pn.addChild(exp2);
1158                 RESULT=pn;
1159         :}
1160         |       multiplicative_expression:exp1 DIV unary_expression:exp2 {:
1161                 ParseNode pn=new ParseNode("div");
1162                 pn.addChild(exp1);
1163                 pn.addChild(exp2);
1164                 RESULT=pn;
1165         :}
1166         |       multiplicative_expression:exp1 MOD unary_expression:exp2 {:
1167                 ParseNode pn=new ParseNode("mod");
1168                 pn.addChild(exp1);
1169                 pn.addChild(exp2);
1170                 RESULT=pn;
1171         :}
1172         ;
1173 additive_expression ::=
1174                 multiplicative_expression:exp {: 
1175                         RESULT=exp; :}
1176         |       additive_expression:exp1 PLUS multiplicative_expression:exp2 {: 
1177                 ParseNode pn=new ParseNode("add");
1178                 pn.addChild(exp1);
1179                 pn.addChild(exp2);
1180                 RESULT=pn;
1181         :}
1182         |       additive_expression:exp1 MINUS multiplicative_expression:exp2 {: 
1183                 ParseNode pn=new ParseNode("sub");
1184                 pn.addChild(exp1);
1185                 pn.addChild(exp2);
1186                 RESULT=pn;
1187         :}
1188         ;
1189 shift_expression ::=
1190                 additive_expression:exp {: 
1191                         RESULT=exp; :}
1192         |       shift_expression:exp1 LSHIFT additive_expression:exp2 {: 
1193                 ParseNode pn=new ParseNode("leftshift");
1194                 pn.addChild(exp1);
1195                 pn.addChild(exp2);
1196                 RESULT=pn;
1197         :}
1198         |       shift_expression:exp1 RSHIFT additive_expression:exp2 {: 
1199                 ParseNode pn=new ParseNode("rightshift");
1200                 pn.addChild(exp1);
1201                 pn.addChild(exp2);
1202                 RESULT=pn;
1203         :}
1204 //      |       shift_expression URSHIFT additive_expression
1205         ;
1206 relational_expression ::=
1207                 shift_expression:exp {: 
1208                         RESULT=exp; :}
1209         |       relational_expression:exp1 LT shift_expression:exp2 {:
1210                 ParseNode pn=new ParseNode("comp_lt");
1211                 pn.addChild(exp1);
1212                 pn.addChild(exp2);
1213                 RESULT=pn;
1214         :}
1215         |       relational_expression:exp1 GT shift_expression:exp2 {:
1216                 ParseNode pn=new ParseNode("comp_gt");
1217                 pn.addChild(exp1);
1218                 pn.addChild(exp2);
1219                 RESULT=pn;
1220         :}
1221         |       relational_expression:exp1 LTEQ shift_expression:exp2 {:
1222                 ParseNode pn=new ParseNode("comp_lte");
1223                 pn.addChild(exp1);
1224                 pn.addChild(exp2);
1225                 RESULT=pn;
1226         :}
1227         |       relational_expression:exp1 GTEQ shift_expression:exp2 {:
1228                 ParseNode pn=new ParseNode("comp_gte");
1229                 pn.addChild(exp1);
1230                 pn.addChild(exp2);
1231                 RESULT=pn;
1232         :}
1233 //      |       relational_expression INSTANCEOF reference_type
1234         ;
1235
1236 equality_expression ::=
1237                 relational_expression:exp {: 
1238                         RESULT=exp; :}
1239         |       equality_expression:exp1 EQEQ relational_expression:exp2 {: 
1240                 ParseNode pn=new ParseNode("equal");
1241                 pn.addChild(exp1);
1242                 pn.addChild(exp2);
1243                 RESULT=pn;
1244         :}
1245         |       equality_expression:exp1 NOTEQ relational_expression:exp2 {: 
1246                 ParseNode pn=new ParseNode("not_equal");
1247                 pn.addChild(exp1);
1248                 pn.addChild(exp2);
1249                 RESULT=pn;
1250         :}
1251         ;
1252 and_expression ::=
1253                 equality_expression:exp {: 
1254                 RESULT=exp; :}
1255         |       and_expression:exp1 AND equality_expression:exp2 {: 
1256                 ParseNode pn=new ParseNode("bitwise_and");
1257                 pn.addChild(exp1);
1258                 pn.addChild(exp2);
1259                 RESULT=pn;
1260         :}
1261         ;
1262 exclusive_or_expression ::=
1263                 and_expression:expr {: 
1264                         RESULT=expr;
1265                 :}
1266         |       exclusive_or_expression:exp1 XOR and_expression:exp2 {: 
1267                 ParseNode pn=new ParseNode("bitwise_xor");
1268                 pn.addChild(exp1);
1269                 pn.addChild(exp2);
1270                 RESULT=pn;
1271 :}
1272         ;
1273 inclusive_or_expression ::=
1274                 exclusive_or_expression:exclor {: 
1275                         RESULT=exclor; :}
1276         |       inclusive_or_expression:exp1 OR exclusive_or_expression:exp2 {: 
1277                 ParseNode pn=new ParseNode("bitwise_or");
1278                 pn.addChild(exp1);
1279                 pn.addChild(exp2);
1280                 RESULT=pn;
1281         :}
1282         ;
1283 conditional_and_expression ::=
1284                 inclusive_or_expression:inclor {: 
1285                         RESULT=inclor; :}
1286         |       conditional_and_expression:exp1 ANDAND inclusive_or_expression:exp2 {:
1287                 ParseNode pn=new ParseNode("logical_and");
1288                 pn.addChild(exp1);
1289                 pn.addChild(exp2);
1290                 RESULT=pn;
1291         :}
1292         ;
1293 conditional_or_expression ::=
1294                 conditional_and_expression:condand {: 
1295                         RESULT=condand; :}
1296         |       conditional_or_expression:exp1 OROR conditional_and_expression:exp2 {: 
1297                 ParseNode pn=new ParseNode("logical_or");
1298                 pn.addChild(exp1);
1299                 pn.addChild(exp2);
1300                 RESULT=pn;
1301         :}
1302         ;
1303 conditional_expression ::=
1304                 conditional_or_expression:condor {: 
1305                         RESULT=condor; :}
1306 //      |       conditional_or_expression QUESTION expression 
1307 //                      COLON conditional_expression
1308         ;
1309 assignment_expression ::=
1310                 conditional_expression:expr {: 
1311                         RESULT=expr; :} |
1312                 assignment:assign {: 
1313                         RESULT=assign; :}
1314         ;
1315 // semantic check necessary here to ensure a valid left-hand side.
1316 // allowing a parenthesized variable here on the lhs was introduced in
1317 // JLS 2; thanks to Eric Blake for pointing this out.
1318 assignment ::=  postfix_expression:lvalue assignment_operator:op assignment_expression:rvalue {:
1319                 ParseNode pn=new ParseNode("assignment");
1320                 pn.addChild("op").addChild(op);
1321                 ParseNode pnargs=pn.addChild("args");
1322                 pnargs.addChild(lvalue);
1323                 pnargs.addChild(rvalue);
1324                 RESULT=pn;
1325          :}
1326         ;
1327 assignment_operator ::=
1328                 EQ {: RESULT=(new ParseNode("assignment_operator")).addChild("eq"); :}
1329         |       MULTEQ {: RESULT=(new ParseNode("assignment_operator")).addChild("multeq"); :}
1330         |       DIVEQ {: RESULT=(new ParseNode("assignment_operator")).addChild("diveq"); :}
1331         |       MODEQ {: RESULT=(new ParseNode("assignment_operator")).addChild("modeq"); :}
1332         |       PLUSEQ {: RESULT=(new ParseNode("assignment_operator")).addChild("pluseq"); :}
1333         |       MINUSEQ {: RESULT=(new ParseNode("assignment_operator")).addChild("minuseq"); :}
1334         |       LSHIFTEQ {: RESULT=(new ParseNode("assignment_operator")).addChild("lshifteq"); :}
1335         |       RSHIFTEQ {: RESULT=(new ParseNode("assignment_operator")).addChild("rshifteq"); :}
1336 //      |       URSHIFTEQ {: RESULT=(new ParseNode("assignment_operator")).addChild("urshifteq"); :}
1337         |       ANDEQ {: RESULT=(new ParseNode("assignment_operator")).addChild("andeq"); :}
1338         |       XOREQ {: RESULT=(new ParseNode("assignment_operator")).addChild("xoreq"); :}
1339         |       OREQ {: RESULT=(new ParseNode("assignment_operator")).addChild("oreq"); :}
1340         ;
1341 expression_opt ::=
1342         {:      RESULT=new ParseNode("empty"); :}
1343         |       expression:exp {: 
1344                 RESULT=exp; :}
1345         ;
1346 expression ::=  assignment_expression:exp {: 
1347                 RESULT=exp; :}
1348         ;
1349 //constant_expression ::=
1350 //              expression
1351 //      ;