adding a test case
[IRC.git] / Robust / JavaGrammar / Parse / java10.cup
1 package Parse;
2
3 import java_cup.runtime.*;
4
5 /* Java 1.0 parser for CUP.  
6  * Copyright (C) 1998 C. Scott Ananian <cananian@alumni.princeton.edu>
7  * This program is released under the terms of the GPL; see the file
8  * COPYING for more details.  There is NO WARRANTY on this code.
9  */
10
11 parser code  {: 
12   Lexer lexer;
13
14   public Grm10(Lexer l) {
15     this();
16     lexer=l;
17   }
18
19   public void syntax_error(java_cup.runtime.Symbol current) {
20     report_error("Syntax error (" + current.sym + ")", current);
21   }
22   public void report_error(String message, java_cup.runtime.Symbol info) {
23     lexer.errorMsg(message, info);
24   }
25 :};
26
27 scan with {: return lexer.nextToken(); :};
28
29 terminal BOOLEAN; // primitive_type
30 terminal BYTE, SHORT, INT, LONG, CHAR; // integral_type
31 terminal FLOAT, DOUBLE; // floating_point_type
32 terminal LBRACK, RBRACK; // array_type
33 terminal java.lang.String IDENTIFIER; // name
34 terminal DOT; // qualified_name
35 terminal SEMICOLON, MULT, COMMA, LBRACE, RBRACE, EQ, LPAREN, RPAREN, COLON;
36 terminal PACKAGE; // package_declaration
37 terminal IMPORT; // import_declaration
38 terminal PUBLIC, PROTECTED, PRIVATE; // modifier
39 terminal STATIC; // modifier
40 terminal ABSTRACT, FINAL, NATIVE, SYNCHRONIZED, TRANSIENT, VOLATILE;
41 terminal CLASS; // class_declaration
42 terminal EXTENDS; // super
43 terminal IMPLEMENTS; // interfaces
44 terminal VOID; // method_header
45 terminal THROWS; // throws
46 terminal THIS, SUPER; // explicit_constructor_invocation
47 terminal INTERFACE; // interface_declaration
48 terminal IF, ELSE; // if_then_statement, if_then_else_statement
49 terminal SWITCH; // switch_statement
50 terminal CASE, DEFAULT; // switch_label
51 terminal DO, WHILE; // while_statement, do_statement
52 terminal FOR; // for_statement
53 terminal BREAK; // break_statement
54 terminal CONTINUE; // continue_statement
55 terminal RETURN; // return_statement
56 terminal THROW; // throw_statement
57 terminal TRY; // try_statement
58 terminal CATCH; // catch_clause
59 terminal FINALLY; // finally
60 terminal NEW; // class_instance_creation_expression
61 terminal PLUSPLUS; // postincrement_expression
62 terminal MINUSMINUS; // postdecrement_expression
63 terminal PLUS, MINUS, COMP, NOT, DIV, MOD;
64 terminal LSHIFT, RSHIFT, URSHIFT; // shift_expression
65 terminal LT, GT, LTEQ, GTEQ, INSTANCEOF; // relational_expression
66 terminal EQEQ, NOTEQ; // equality_expression
67 terminal AND; // and_expression
68 terminal XOR; // exclusive_or_expression
69 terminal OR;  // inclusive_or_expression
70 terminal ANDAND; // conditional_and_expression
71 terminal OROR; // conditional_or_expression
72 terminal QUESTION; // conditional_expression
73 terminal MULTEQ, DIVEQ, MODEQ, PLUSEQ, MINUSEQ; // assignment_operator
74 terminal LSHIFTEQ, RSHIFTEQ, URSHIFTEQ; // assignment_operator
75 terminal ANDEQ, XOREQ, OREQ; // assignment_operator
76
77 terminal java.lang.Number INTEGER_LITERAL;
78 terminal java.lang.Number FLOATING_POINT_LITERAL;
79 terminal java.lang.Boolean BOOLEAN_LITERAL;
80 terminal java.lang.Character CHARACTER_LITERAL;
81 terminal java.lang.String STRING_LITERAL;
82 terminal NULL_LITERAL;
83
84 // Reserved but unused:
85 terminal CONST, GOTO;
86 // lexer compatibility with Java 1.2:
87 terminal STRICTFP;
88 // lexer compatibility with Java 1.4
89 terminal ASSERT;
90 // lexer compatibility with Java 1.5
91 terminal ELLIPSIS;
92 terminal ENUM;
93
94 // 19.2) The Syntactic Grammar
95 non terminal goal;
96 // 19.3) Lexical Structure
97 non terminal literal;
98 // 19.4) Types, Values, and Variables
99 non terminal type, primitive_type, numeric_type;
100 non terminal integral_type, floating_point_type;
101 non terminal reference_type;
102 non terminal class_or_interface_type;
103 non terminal class_type, interface_type;
104 non terminal array_type;
105 // 19.5) Names
106 non terminal name, simple_name, qualified_name;
107 // 19.6) Packages
108 non terminal compilation_unit;
109 non terminal package_declaration_opt, package_declaration;
110 non terminal import_declarations_opt, import_declarations;
111 non terminal type_declarations_opt, type_declarations;
112 non terminal import_declaration;
113 non terminal single_type_import_declaration;
114 non terminal type_import_on_demand_declaration;
115 non terminal type_declaration;
116 // 19.7) Productions used only in the LALR(1) grammar
117 non terminal modifiers_opt, modifiers, modifier;
118 // 19.8.1) Class Declaration
119 non terminal class_declaration, super, super_opt;
120 non terminal interfaces, interfaces_opt, interface_type_list;
121 non terminal class_body;
122 non terminal class_body_declarations, class_body_declarations_opt;
123 non terminal class_body_declaration, class_member_declaration;
124 // 19.8.2) Field Declarations
125 non terminal field_declaration, variable_declarators, variable_declarator;
126 non terminal variable_declarator_id, variable_initializer;
127 // 19.8.3) Method Declarations
128 non terminal method_declaration, method_header, method_declarator;
129 non terminal formal_parameter_list_opt, formal_parameter_list;
130 non terminal formal_parameter;
131 non terminal throws_opt, throws;
132 non terminal class_type_list, method_body;
133 // 19.8.4) Static Initializers
134 non terminal static_initializer;
135 // 19.8.5) Constructor Declarations
136 non terminal constructor_declaration, constructor_declarator;
137 non terminal constructor_body;
138 non terminal explicit_constructor_invocation;
139 // 19.9.1) Interface Declarations
140 non terminal interface_declaration;
141 non terminal extends_interfaces_opt, extends_interfaces;
142 non terminal interface_body;
143 non terminal interface_member_declarations_opt, interface_member_declarations;
144 non terminal interface_member_declaration, constant_declaration;
145 non terminal abstract_method_declaration;
146 // 19.10) Arrays
147 non terminal array_initializer;
148 non terminal variable_initializers;
149 // 19.11) Blocks and Statements
150 non terminal block;
151 non terminal block_statements_opt, block_statements, block_statement;
152 non terminal local_variable_declaration_statement, local_variable_declaration;
153 non terminal statement, statement_no_short_if;
154 non terminal statement_without_trailing_substatement;
155 non terminal empty_statement;
156 non terminal labeled_statement, labeled_statement_no_short_if;
157 non terminal expression_statement, statement_expression;
158 non terminal if_then_statement;
159 non terminal if_then_else_statement, if_then_else_statement_no_short_if;
160 non terminal switch_statement, switch_block;
161 non terminal switch_block_statement_groups;
162 non terminal switch_block_statement_group;
163 non terminal switch_labels, switch_label;
164 non terminal while_statement, while_statement_no_short_if;
165 non terminal do_statement;
166 non terminal for_statement, for_statement_no_short_if;
167 non terminal for_init_opt, for_init;
168 non terminal for_update_opt, for_update;
169 non terminal statement_expression_list;
170 non terminal identifier_opt;
171 non terminal break_statement, continue_statement;
172 non terminal return_statement, throw_statement;
173 non terminal synchronized_statement, try_statement;
174 non terminal catches_opt, catches, catch_clause;
175 non terminal finally;
176 // 19.12) Expressions
177 non terminal primary, primary_no_new_array;
178 non terminal class_instance_creation_expression;
179 non terminal argument_list_opt, argument_list;
180 non terminal array_creation_expression;
181 non terminal dim_exprs, dim_expr, dims_opt, dims;
182 non terminal field_access, method_invocation, array_access;
183 non terminal postfix_expression;
184 non terminal postincrement_expression, postdecrement_expression;
185 non terminal unary_expression, unary_expression_not_plus_minus;
186 non terminal preincrement_expression, predecrement_expression;
187 non terminal cast_expression;
188 non terminal multiplicative_expression, additive_expression;
189 non terminal shift_expression, relational_expression, equality_expression;
190 non terminal and_expression, exclusive_or_expression, inclusive_or_expression;
191 non terminal conditional_and_expression, conditional_or_expression;
192 non terminal conditional_expression, assignment_expression;
193 non terminal assignment;
194 non terminal left_hand_side;
195 non terminal assignment_operator;
196 non terminal expression_opt, expression;
197 non terminal constant_expression;
198
199 start with goal;
200
201 // 19.2) The Syntactic Grammar
202 goal ::=        compilation_unit
203         ;
204
205 // 19.3) Lexical Structure.
206 literal ::=     INTEGER_LITERAL
207         |       FLOATING_POINT_LITERAL
208         |       BOOLEAN_LITERAL
209         |       CHARACTER_LITERAL
210         |       STRING_LITERAL
211         |       NULL_LITERAL
212         ;
213
214 // 19.4) Types, Values, and Variables
215 type    ::=     primitive_type
216         |       reference_type
217         ;
218 primitive_type ::=
219                 numeric_type
220         |       BOOLEAN
221         ;
222 numeric_type::= integral_type
223         |       floating_point_type
224         ;
225 integral_type ::= 
226                 BYTE 
227         |       SHORT 
228         |       INT 
229         |       LONG 
230         |       CHAR 
231         ;
232 floating_point_type ::= 
233                 FLOAT 
234         |       DOUBLE
235         ;
236
237 reference_type ::=
238                 class_or_interface_type
239         |       array_type
240         ;
241 class_or_interface_type ::= name;
242
243 class_type ::=  class_or_interface_type;
244 interface_type ::= class_or_interface_type;             
245
246 array_type ::=  primitive_type LBRACK RBRACK
247         |       name LBRACK RBRACK
248         |       array_type LBRACK RBRACK
249         ;
250
251 // 19.5) Names
252 name    ::=     simple_name
253         |       qualified_name
254         ;
255 simple_name ::= IDENTIFIER
256         ;
257 qualified_name ::=
258                 name DOT IDENTIFIER
259         ;
260
261 // 19.6) Packages
262 compilation_unit ::=
263                 package_declaration_opt 
264                 import_declarations_opt
265                 type_declarations_opt
266                 ;
267 package_declaration_opt ::= package_declaration | ;
268 import_declarations_opt ::= import_declarations | ;
269 type_declarations_opt   ::= type_declarations   | ;
270
271 import_declarations ::= 
272                 import_declaration
273         |       import_declarations import_declaration
274         ;
275 type_declarations ::= 
276                 type_declaration
277         |       type_declarations type_declaration
278         ;
279 package_declaration ::= 
280                 PACKAGE name SEMICOLON
281         ;
282 import_declaration ::= 
283                 single_type_import_declaration
284         |       type_import_on_demand_declaration
285         ;
286 single_type_import_declaration ::= 
287                 IMPORT name SEMICOLON
288         ;
289 type_import_on_demand_declaration ::=
290                 IMPORT name DOT MULT SEMICOLON
291         ;
292 type_declaration ::=
293                 class_declaration
294         |       interface_declaration
295         |       SEMICOLON
296         ;
297
298 // 19.7) Productions used only in the LALR(1) grammar
299 modifiers_opt::=
300         |       modifiers
301         ;
302 modifiers ::=   modifier
303         |       modifiers modifier
304         ;
305 modifier ::=    PUBLIC | PROTECTED | PRIVATE
306         |       STATIC
307         |       ABSTRACT | FINAL | NATIVE | SYNCHRONIZED | TRANSIENT | VOLATILE
308         ;
309
310 // 19.8) Classes
311
312 // 19.8.1) Class Declaration:
313 class_declaration ::= 
314         modifiers_opt CLASS IDENTIFIER super_opt interfaces_opt class_body
315         ;
316 super ::=       EXTENDS class_type
317         ;
318 super_opt ::=   
319         |       super
320         ;
321 interfaces ::=  IMPLEMENTS interface_type_list
322         ;
323 interfaces_opt::=
324         |       interfaces 
325         ;
326 interface_type_list ::= 
327                 interface_type
328         |       interface_type_list COMMA interface_type
329         ;
330 class_body ::=  LBRACE class_body_declarations_opt RBRACE 
331         ;
332 class_body_declarations_opt ::= 
333         |       class_body_declarations ;
334 class_body_declarations ::= 
335                 class_body_declaration
336         |       class_body_declarations class_body_declaration
337         ;
338 class_body_declaration ::=
339                 class_member_declaration
340         |       static_initializer
341         |       constructor_declaration
342         ;
343 class_member_declaration ::=
344                 field_declaration
345         |       method_declaration
346         |       SEMICOLON
347         ;
348
349 // 19.8.2) Field Declarations
350 field_declaration ::= 
351                 modifiers_opt type variable_declarators SEMICOLON
352         ;
353 variable_declarators ::=
354                 variable_declarator
355         |       variable_declarators COMMA variable_declarator
356         ;
357 variable_declarator ::=
358                 variable_declarator_id
359         |       variable_declarator_id EQ variable_initializer
360         ;
361 variable_declarator_id ::=
362                 IDENTIFIER
363         |       variable_declarator_id LBRACK RBRACK
364         ;
365 variable_initializer ::=
366                 expression
367         |       array_initializer
368         ;
369
370 // 19.8.3) Method Declarations
371 method_declaration ::=
372                 method_header method_body
373         ;
374 method_header ::=
375                 modifiers_opt type method_declarator throws_opt
376         |       modifiers_opt VOID method_declarator throws_opt
377         ;
378 method_declarator ::=
379                 IDENTIFIER LPAREN formal_parameter_list_opt RPAREN
380         |       method_declarator LBRACK RBRACK
381         ;
382 formal_parameter_list_opt ::=
383         |       formal_parameter_list
384         ;
385 formal_parameter_list ::=
386                 formal_parameter
387         |       formal_parameter_list COMMA formal_parameter
388         ;
389 formal_parameter ::=
390                 type variable_declarator_id
391         ;
392 throws_opt ::=  
393         |       throws
394         ;
395 throws ::=      THROWS class_type_list
396         ;
397 class_type_list ::=
398                 class_type
399         |       class_type_list COMMA class_type
400         ;
401 method_body ::= block
402         |       SEMICOLON
403         ;
404
405 // 19.8.4) Static Initializers
406 static_initializer ::=
407                 STATIC block
408         ;
409
410 // 19.8.5) Constructor Declarations
411 constructor_declaration ::=
412                 modifiers_opt constructor_declarator throws_opt 
413                         constructor_body
414         ;
415 constructor_declarator ::=
416                 simple_name LPAREN formal_parameter_list_opt RPAREN
417         ;
418 constructor_body ::=
419                 LBRACE explicit_constructor_invocation
420                         block_statements RBRACE
421         |       LBRACE explicit_constructor_invocation RBRACE
422         |       LBRACE block_statements RBRACE
423         |       LBRACE RBRACE
424         ;
425 explicit_constructor_invocation ::=
426                 THIS LPAREN argument_list_opt RPAREN SEMICOLON
427         |       SUPER LPAREN argument_list_opt RPAREN SEMICOLON
428         ;
429
430 // 19.9) Interfaces
431
432 // 19.9.1) Interface Declarations
433 interface_declaration ::=
434                 modifiers_opt INTERFACE IDENTIFIER extends_interfaces_opt 
435                         interface_body
436         ;
437 extends_interfaces_opt ::=
438         |       extends_interfaces
439         ;
440 extends_interfaces ::=
441                 EXTENDS interface_type
442         |       extends_interfaces COMMA interface_type
443         ;
444 interface_body ::=
445                 LBRACE interface_member_declarations_opt RBRACE
446         ;
447 interface_member_declarations_opt ::=
448         |       interface_member_declarations
449         ;
450 interface_member_declarations ::=
451                 interface_member_declaration
452         |       interface_member_declarations interface_member_declaration
453         ;
454 interface_member_declaration ::=
455                 constant_declaration
456         |       abstract_method_declaration
457         |       SEMICOLON
458         ;
459 constant_declaration ::=
460                 field_declaration
461         ;
462 abstract_method_declaration ::=
463                 method_header SEMICOLON
464         ;
465
466 // 19.10) Arrays
467 array_initializer ::=
468                 LBRACE variable_initializers COMMA RBRACE
469         |       LBRACE variable_initializers RBRACE
470         |       LBRACE COMMA RBRACE
471         |       LBRACE RBRACE
472         ;
473 variable_initializers ::=
474                 variable_initializer
475         |       variable_initializers COMMA variable_initializer
476         ;
477
478 // 19.11) Blocks and Statements
479 block ::=       LBRACE block_statements_opt RBRACE
480         ;
481 block_statements_opt ::=
482         |       block_statements
483         ;
484 block_statements ::=
485                 block_statement
486         |       block_statements block_statement
487         ;
488 block_statement ::=
489                 local_variable_declaration_statement
490         |       statement
491         ;
492 local_variable_declaration_statement ::=
493                 local_variable_declaration SEMICOLON
494         ;
495 local_variable_declaration ::=
496                 type variable_declarators
497         ;
498 statement ::=   statement_without_trailing_substatement
499         |       labeled_statement
500         |       if_then_statement
501         |       if_then_else_statement
502         |       while_statement
503         |       for_statement
504         ;
505 statement_no_short_if ::=
506                 statement_without_trailing_substatement
507         |       labeled_statement_no_short_if
508         |       if_then_else_statement_no_short_if
509         |       while_statement_no_short_if
510         |       for_statement_no_short_if
511         ;
512 statement_without_trailing_substatement ::=
513                 block
514         |       empty_statement
515         |       expression_statement
516         |       switch_statement
517         |       do_statement
518         |       break_statement
519         |       continue_statement
520         |       return_statement
521         |       synchronized_statement
522         |       throw_statement
523         |       try_statement
524         ;
525 empty_statement ::=
526                 SEMICOLON
527         ;
528 labeled_statement ::=
529                 IDENTIFIER COLON statement
530         ;
531 labeled_statement_no_short_if ::=
532                 IDENTIFIER COLON statement_no_short_if
533         ;
534 expression_statement ::=
535                 statement_expression SEMICOLON
536         ;
537 statement_expression ::=
538                 assignment
539         |       preincrement_expression
540         |       predecrement_expression
541         |       postincrement_expression
542         |       postdecrement_expression
543         |       method_invocation
544         |       class_instance_creation_expression
545         ;
546 if_then_statement ::=
547                 IF LPAREN expression RPAREN statement
548         ;
549 if_then_else_statement ::=
550                 IF LPAREN expression RPAREN statement_no_short_if 
551                         ELSE statement
552         ;
553 if_then_else_statement_no_short_if ::=
554                 IF LPAREN expression RPAREN statement_no_short_if
555                         ELSE statement_no_short_if
556         ;
557 switch_statement ::=
558                 SWITCH LPAREN expression RPAREN switch_block
559         ;
560 switch_block ::=
561                 LBRACE switch_block_statement_groups switch_labels RBRACE
562         |       LBRACE switch_block_statement_groups RBRACE
563         |       LBRACE switch_labels RBRACE
564         |       LBRACE RBRACE
565         ;
566 switch_block_statement_groups ::=
567                 switch_block_statement_group
568         |       switch_block_statement_groups switch_block_statement_group
569         ;
570 switch_block_statement_group ::=
571                 switch_labels block_statements
572         ;
573 switch_labels ::=
574                 switch_label
575         |       switch_labels switch_label
576         ;
577 switch_label ::=
578                 CASE constant_expression COLON
579         |       DEFAULT COLON
580         ;
581
582 while_statement ::=
583                 WHILE LPAREN expression RPAREN statement
584         ;
585 while_statement_no_short_if ::=
586                 WHILE LPAREN expression RPAREN statement_no_short_if
587         ;
588 do_statement ::=
589                 DO statement WHILE LPAREN expression RPAREN SEMICOLON
590         ;
591 for_statement ::=
592                 FOR LPAREN for_init_opt SEMICOLON expression_opt SEMICOLON
593                         for_update_opt RPAREN statement
594         ;
595 for_statement_no_short_if ::=
596                 FOR LPAREN for_init_opt SEMICOLON expression_opt SEMICOLON
597                         for_update_opt RPAREN statement_no_short_if
598         ;
599 for_init_opt ::=
600         |       for_init
601         ;
602 for_init ::=    statement_expression_list
603         |       local_variable_declaration
604         ;
605 for_update_opt ::=
606         |       for_update
607         ;
608 for_update ::=  statement_expression_list
609         ;
610 statement_expression_list ::=
611                 statement_expression
612         |       statement_expression_list COMMA statement_expression
613         ;
614
615 identifier_opt ::= 
616         |       IDENTIFIER
617         ;
618
619 break_statement ::=
620                 BREAK identifier_opt SEMICOLON
621         ;
622
623 continue_statement ::=
624                 CONTINUE identifier_opt SEMICOLON
625         ;
626 return_statement ::=
627                 RETURN expression_opt SEMICOLON
628         ;
629 throw_statement ::=
630                 THROW expression SEMICOLON
631         ;
632 synchronized_statement ::=
633                 SYNCHRONIZED LPAREN expression RPAREN block
634         ;
635 try_statement ::=
636                 TRY block catches
637         |       TRY block catches_opt finally
638         ;
639 catches_opt ::=
640         |       catches
641         ;
642 catches ::=     catch_clause
643         |       catches catch_clause
644         ;
645 catch_clause ::=
646                 CATCH LPAREN formal_parameter RPAREN block
647         ;
648 finally ::=     FINALLY block
649         ;
650
651 // 19.12) Expressions
652 primary ::=     primary_no_new_array
653         |       array_creation_expression
654         ;
655 primary_no_new_array ::=
656                 literal
657         |       THIS
658         |       LPAREN expression RPAREN
659         |       class_instance_creation_expression
660         |       field_access
661         |       method_invocation
662         |       array_access
663         ;
664 class_instance_creation_expression ::=
665                 NEW class_type LPAREN argument_list_opt RPAREN
666         ;
667 argument_list_opt ::=
668         |       argument_list
669         ;
670 argument_list ::=
671                 expression
672         |       argument_list COMMA expression
673         ;
674 array_creation_expression ::=
675                 NEW primitive_type dim_exprs dims_opt
676         |       NEW class_or_interface_type dim_exprs dims_opt
677         ;
678 dim_exprs ::=   dim_expr
679         |       dim_exprs dim_expr
680         ;
681 dim_expr ::=    LBRACK expression RBRACK
682         ;
683 dims_opt ::=
684         |       dims
685         ;
686 dims ::=        LBRACK RBRACK
687         |       dims LBRACK RBRACK
688         ;
689 field_access ::=
690                 primary DOT IDENTIFIER
691         |       SUPER DOT IDENTIFIER
692         ;
693 method_invocation ::=
694                 name LPAREN argument_list_opt RPAREN
695         |       primary DOT IDENTIFIER LPAREN argument_list_opt RPAREN
696         |       SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
697         ;
698 array_access ::=
699                 name LBRACK expression RBRACK
700         |       primary_no_new_array LBRACK expression RBRACK
701         ;
702 postfix_expression ::=
703                 primary
704         |       name
705         |       postincrement_expression
706         |       postdecrement_expression
707         ;
708 postincrement_expression ::=
709                 postfix_expression PLUSPLUS
710         ;
711 postdecrement_expression ::=
712                 postfix_expression MINUSMINUS
713         ;
714 unary_expression ::=
715                 preincrement_expression
716         |       predecrement_expression
717         |       PLUS unary_expression
718         |       MINUS unary_expression
719         |       unary_expression_not_plus_minus
720         ;
721 preincrement_expression ::=
722                 PLUSPLUS unary_expression
723         ;
724 predecrement_expression ::=
725                 MINUSMINUS unary_expression
726         ;
727 unary_expression_not_plus_minus ::=
728                 postfix_expression
729         |       COMP unary_expression
730         |       NOT unary_expression
731         |       cast_expression
732         ;
733 cast_expression ::=
734                 LPAREN primitive_type dims_opt RPAREN unary_expression
735         |       LPAREN expression RPAREN unary_expression_not_plus_minus
736         |       LPAREN name dims RPAREN unary_expression_not_plus_minus
737         ;
738 multiplicative_expression ::=
739                 unary_expression
740         |       multiplicative_expression MULT unary_expression
741         |       multiplicative_expression DIV unary_expression
742         |       multiplicative_expression MOD unary_expression
743         ;
744 additive_expression ::=
745                 multiplicative_expression
746         |       additive_expression PLUS multiplicative_expression
747         |       additive_expression MINUS multiplicative_expression
748         ;
749 shift_expression ::=
750                 additive_expression
751         |       shift_expression LSHIFT additive_expression
752         |       shift_expression RSHIFT additive_expression
753         |       shift_expression URSHIFT additive_expression
754         ;
755 relational_expression ::=
756                 shift_expression
757         |       relational_expression LT shift_expression
758         |       relational_expression GT shift_expression
759         |       relational_expression LTEQ shift_expression
760         |       relational_expression GTEQ shift_expression
761         |       relational_expression INSTANCEOF reference_type
762         ;
763 equality_expression ::=
764                 relational_expression
765         |       equality_expression EQEQ relational_expression
766         |       equality_expression NOTEQ relational_expression
767         ;
768 and_expression ::=
769                 equality_expression
770         |       and_expression AND equality_expression
771         ;
772 exclusive_or_expression ::=
773                 and_expression
774         |       exclusive_or_expression XOR and_expression
775         ;
776 inclusive_or_expression ::=
777                 exclusive_or_expression
778         |       inclusive_or_expression OR exclusive_or_expression
779         ;
780 conditional_and_expression ::=
781                 inclusive_or_expression
782         |       conditional_and_expression ANDAND inclusive_or_expression
783         ;
784 conditional_or_expression ::=
785                 conditional_and_expression
786         |       conditional_or_expression OROR conditional_and_expression
787         ;
788 conditional_expression ::=
789                 conditional_or_expression
790         |       conditional_or_expression QUESTION expression 
791                         COLON conditional_expression
792         ;
793 assignment_expression ::=
794                 conditional_expression
795         |       assignment
796         ;
797 assignment ::=  left_hand_side assignment_operator assignment_expression
798         ;
799 left_hand_side ::=
800                 name
801         |       field_access
802         |       array_access
803         ;
804 assignment_operator ::=
805                 EQ
806         |       MULTEQ
807         |       DIVEQ
808         |       MODEQ
809         |       PLUSEQ
810         |       MINUSEQ
811         |       LSHIFTEQ
812         |       RSHIFTEQ
813         |       URSHIFTEQ
814         |       ANDEQ
815         |       XOREQ
816         |       OREQ
817         ;
818 expression_opt ::=
819         |       expression
820         ;
821 expression ::=  assignment_expression
822         ;
823 constant_expression ::=
824                 expression
825         ;