752
|
1 |
%id <LT> ;
|
|
2 |
%id <GT> ;
|
|
3 |
%id <IDENTIFIER> ;
|
|
4 |
|
|
5 |
goal : compilation_unit
|
|
6 |
;
|
|
7 |
|
|
8 |
# 19.3) Lexical Structure.
|
|
9 |
literal : <INTEGER_LITERAL>
|
|
10 |
| <FLOATING_POINT_LITERAL>
|
|
11 |
| <BOOLEAN_LITERAL>
|
|
12 |
# | "true"
|
|
13 |
# | "false"
|
|
14 |
| <CHARACTER_LITERAL>
|
|
15 |
| <STRING_LITERAL>
|
|
16 |
| <NULL_LITERAL>
|
|
17 |
;
|
|
18 |
|
|
19 |
# 19.4) Types, Values, and Variables
|
|
20 |
type : primitive_type
|
|
21 |
{
|
|
22 |
'1' first
|
|
23 |
}
|
|
24 |
| reference_type
|
|
25 |
{
|
|
26 |
'1' first
|
|
27 |
}
|
|
28 |
;
|
|
29 |
primitive_type :
|
|
30 |
numeric_type
|
|
31 |
| "boolean"
|
|
32 |
{
|
|
33 |
Array with:
|
|
34 |
(JavaBooleanTypeNode new
|
|
35 |
token: '1').
|
|
36 |
}
|
|
37 |
;
|
|
38 |
numeric_type: integral_type
|
|
39 |
| floating_point_type
|
|
40 |
;
|
|
41 |
integral_type :
|
|
42 |
"byte"
|
|
43 |
{
|
|
44 |
JavaByteTypeNode new
|
|
45 |
token: '1'.
|
|
46 |
}
|
|
47 |
| "short"
|
|
48 |
{
|
|
49 |
JavaShortTypeNode new
|
|
50 |
token: '1'.
|
|
51 |
}
|
|
52 |
| "int"
|
|
53 |
{
|
|
54 |
JavaIntTypeNode new
|
|
55 |
token: '1'.
|
|
56 |
}
|
|
57 |
| "long"
|
|
58 |
{
|
|
59 |
JavaLongTypeNode new
|
|
60 |
token: '1'.
|
|
61 |
}
|
|
62 |
| "char"
|
|
63 |
{
|
|
64 |
JavaCharTypeNode new
|
|
65 |
token: '1'.
|
|
66 |
}
|
|
67 |
;
|
|
68 |
floating_point_type :
|
|
69 |
"float"
|
|
70 |
{
|
|
71 |
JavaFloatTypeNode new
|
|
72 |
token: '1'.
|
|
73 |
}
|
|
74 |
| "double"
|
|
75 |
{
|
|
76 |
JavaDoubleTypeNode new
|
|
77 |
token: '1'.
|
|
78 |
}
|
|
79 |
;
|
|
80 |
|
|
81 |
reference_type :
|
|
82 |
class_or_interface_type
|
|
83 |
| array_type
|
|
84 |
;
|
|
85 |
class_or_interface_type :
|
|
86 |
name
|
|
87 |
{
|
|
88 |
JavaClassOrInterfaceTypeNode new
|
|
89 |
token: '1'.
|
|
90 |
}
|
|
91 |
|
|
|
92 |
name "<?>"
|
|
93 |
{
|
|
94 |
JavaClassOrInterfaceTypeNode new
|
|
95 |
token: '1'.
|
|
96 |
}
|
|
97 |
|
|
|
98 |
name "<T>"
|
|
99 |
{
|
|
100 |
JavaClassOrInterfaceTypeNode new
|
|
101 |
token: '1'.
|
|
102 |
}
|
|
103 |
|
|
|
104 |
name "<Class<T>>"
|
|
105 |
{
|
|
106 |
JavaClassOrInterfaceTypeNode new
|
|
107 |
token: '1'.
|
|
108 |
}
|
|
109 |
;
|
|
110 |
|
|
111 |
|
|
112 |
class_type : class_or_interface_type;
|
|
113 |
interface_type : class_or_interface_type;
|
|
114 |
|
|
115 |
array_type : primitive_type dims
|
|
116 |
{
|
|
117 |
JavaArrayTypeNode new
|
|
118 |
token: '1'
|
|
119 |
}
|
|
120 |
| name dims
|
|
121 |
{
|
|
122 |
JavaArrayTypeNode new
|
|
123 |
token: '1'
|
|
124 |
}
|
|
125 |
| name "<T>" dims
|
|
126 |
{
|
|
127 |
JavaArrayTypeNode new
|
|
128 |
token: '1'
|
|
129 |
}
|
|
130 |
| name "<Class<T>>" dims
|
|
131 |
{
|
|
132 |
JavaArrayTypeNode new
|
|
133 |
token: '1'
|
|
134 |
}
|
|
135 |
| name "<Class<?>>" dims
|
|
136 |
{
|
|
137 |
JavaArrayTypeNode new
|
|
138 |
token: '1'
|
|
139 |
}
|
|
140 |
;
|
|
141 |
|
|
142 |
# 19.5) Names
|
|
143 |
name : simple_name
|
|
144 |
| qualified_name
|
|
145 |
;
|
|
146 |
simple_name : <IDENTIFIER>
|
|
147 |
;
|
|
148 |
qualified_name :
|
|
149 |
name "." <IDENTIFIER>
|
|
150 |
;
|
|
151 |
|
|
152 |
# 19.6) "package"s
|
|
153 |
compilation_unit :
|
|
154 |
package_declaration_opt
|
|
155 |
import_declarations_opt
|
|
156 |
type_declarations_opt
|
|
157 |
;
|
|
158 |
package_declaration_opt : package_declaration | ;
|
|
159 |
import_declarations_opt : import_declarations | ;
|
|
160 |
type_declarations_opt : type_declarations | ;
|
|
161 |
|
|
162 |
import_declarations :
|
|
163 |
import_declaration
|
|
164 |
| import_declarations import_declaration
|
|
165 |
;
|
|
166 |
type_declarations :
|
|
167 |
type_declaration
|
|
168 |
| type_declarations type_declaration
|
|
169 |
;
|
|
170 |
package_declaration :
|
|
171 |
"package" name ";"
|
|
172 |
;
|
|
173 |
import_declaration :
|
|
174 |
single_type_import_declaration
|
|
175 |
| type_import_on_demand_declaration
|
|
176 |
;
|
|
177 |
single_type_import_declaration :
|
|
178 |
"import" name ";"
|
|
179 |
;
|
|
180 |
type_import_on_demand_declaration :
|
|
181 |
"import" name "." "*" ";"
|
|
182 |
;
|
|
183 |
type_declaration :
|
|
184 |
class_declaration
|
|
185 |
| interface_declaration
|
|
186 |
| ";"
|
|
187 |
;
|
|
188 |
|
|
189 |
# 19.7) Productions used only in the LALR(1) grammar
|
|
190 |
modifiers_opt:
|
|
191 |
| modifiers
|
|
192 |
;
|
|
193 |
modifiers : modifier
|
|
194 |
| modifiers modifier
|
|
195 |
;
|
|
196 |
modifier : "public" | "protected" | "private"
|
|
197 |
| "static"
|
|
198 |
| "abstract" | "final" | "native" | "synchronized" | "transient" | "volatile"
|
|
199 |
| "strictfp" # note that semantic analysis must check that the
|
|
200 |
# context of the modifier allows strictfp.
|
|
201 |
;
|
|
202 |
|
|
203 |
# 19.8) Classes
|
|
204 |
|
|
205 |
# 19.8.1) Class Declaration:
|
|
206 |
class_declaration :
|
|
207 |
modifiers_opt "class" <IDENTIFIER> super_opt interfaces_opt class_body
|
|
208 |
|
|
|
209 |
modifiers_opt "class" <IDENTIFIER> "<T>" super_opt interfaces_opt class_body
|
|
210 |
;
|
|
211 |
super : "extends" class_type
|
|
212 |
;
|
|
213 |
super_opt :
|
|
214 |
| super
|
|
215 |
;
|
|
216 |
interfaces : "implements" interface_type_list
|
|
217 |
;
|
|
218 |
interfaces_opt:
|
|
219 |
| interfaces
|
|
220 |
;
|
|
221 |
interface_type_list :
|
|
222 |
interface_type
|
|
223 |
| interface_type_list "," interface_type
|
|
224 |
;
|
|
225 |
class_body : "{" class_body_declarations_opt "}"
|
|
226 |
;
|
|
227 |
class_body_declarations_opt :
|
|
228 |
| class_body_declarations ;
|
|
229 |
class_body_declarations :
|
|
230 |
class_body_declaration
|
|
231 |
| class_body_declarations class_body_declaration
|
|
232 |
;
|
|
233 |
class_body_declaration :
|
|
234 |
class_member_declaration
|
|
235 |
| static_initializer
|
|
236 |
| constructor_declaration
|
|
237 |
| block
|
|
238 |
;
|
|
239 |
class_member_declaration :
|
|
240 |
field_declaration
|
|
241 |
| method_declaration
|
|
242 |
# repeat the prod for 'class_declaration' here:
|
|
243 |
| modifiers_opt "class" <IDENTIFIER> super_opt interfaces_opt class_body
|
|
244 |
| interface_declaration
|
|
245 |
| ";"
|
|
246 |
;
|
|
247 |
|
|
248 |
# 19.8.2) Field Declarations
|
|
249 |
field_declaration :
|
|
250 |
modifiers_opt type variable_declarators ";"
|
|
251 |
;
|
|
252 |
variable_declarators :
|
|
253 |
variable_declarator
|
|
254 |
| variable_declarators "," variable_declarator
|
|
255 |
;
|
|
256 |
variable_declarator :
|
|
257 |
variable_declarator_id
|
|
258 |
| variable_declarator_id "=" variable_initializer
|
|
259 |
;
|
|
260 |
variable_declarator_id :
|
|
261 |
<IDENTIFIER>
|
|
262 |
| variable_declarator_id "[" "]"
|
|
263 |
;
|
|
264 |
variable_initializer :
|
|
265 |
expression
|
|
266 |
| array_initializer
|
|
267 |
;
|
|
268 |
|
|
269 |
# 19.8.3) Method Declarations
|
|
270 |
method_declaration :
|
|
271 |
method_header method_body
|
|
272 |
;
|
|
273 |
method_header :
|
|
274 |
modifiers_opt type method_declarator throws_opt
|
|
275 |
{
|
|
276 |
JavaMethodNode new
|
|
277 |
javadoc: self scanner lastJavadoc;
|
|
278 |
modifiers: '1' ;
|
|
279 |
type: '2';
|
|
280 |
declarator: '3'
|
|
281 |
}
|
|
282 |
| modifiers_opt "void" method_declarator throws_opt
|
|
283 |
{
|
|
284 |
JavaMethodNode new
|
|
285 |
javadoc: self scanner lastJavadoc;
|
|
286 |
modifiers: '1' ;
|
|
287 |
type: JavaVoidTypeNode new ;
|
|
288 |
declarator: '3'
|
|
289 |
}
|
|
290 |
;
|
|
291 |
|
|
292 |
method_declarator :
|
|
293 |
method_identifier "(" formal_parameter_list_opt ")"
|
|
294 |
{
|
|
295 |
JavaMethodDeclaratorNode new
|
|
296 |
identifier: '1' first value;
|
|
297 |
formalParameterList: '3'
|
|
298 |
}
|
|
299 |
| method_declarator "[" "]" # deprecated
|
|
300 |
# be careful; the above production also allows 'void foo() []'
|
|
301 |
;
|
|
302 |
|
|
303 |
method_identifier :
|
|
304 |
<IDENTIFIER>
|
|
305 |
;
|
|
306 |
formal_parameter_list_opt :
|
|
307 |
| formal_parameter_list
|
|
308 |
;
|
|
309 |
formal_parameter_list :
|
|
310 |
formal_parameter
|
|
311 |
{
|
|
312 |
OrderedCollection new
|
|
313 |
add: '1';
|
|
314 |
yourself
|
|
315 |
}
|
|
316 |
| formal_parameter_list "," formal_parameter
|
|
317 |
{
|
|
318 |
'1'
|
|
319 |
add: '3';
|
|
320 |
yourself
|
|
321 |
}
|
|
322 |
;
|
|
323 |
formal_parameter :
|
|
324 |
type variable_declarator_id
|
|
325 |
{
|
|
326 |
JavaFormalParameterNode new
|
|
327 |
type: '1';
|
|
328 |
variableDeclaratorId: '2'
|
|
329 |
}
|
|
330 |
| "final" type variable_declarator_id
|
|
331 |
{
|
|
332 |
JavaFormalParameterNode new
|
|
333 |
type: '1';
|
|
334 |
variableDeclaratorId: '2'
|
|
335 |
}
|
|
336 |
;
|
|
337 |
throws_opt :
|
|
338 |
| throws
|
|
339 |
;
|
|
340 |
throws : "throws" class_type_list
|
|
341 |
;
|
|
342 |
class_type_list :
|
|
343 |
class_type
|
|
344 |
| class_type_list "," class_type
|
|
345 |
;
|
|
346 |
method_body : block
|
|
347 |
| ";"
|
|
348 |
;
|
|
349 |
|
|
350 |
# 19.8.4) Static Initializers
|
|
351 |
static_initializer :
|
|
352 |
"static" block
|
|
353 |
;
|
|
354 |
|
|
355 |
# 19.8.5) Constructor Declarations
|
|
356 |
constructor_declaration :
|
|
357 |
modifiers_opt constructor_declarator throws_opt
|
|
358 |
constructor_body
|
|
359 |
;
|
|
360 |
constructor_declarator :
|
|
361 |
simple_name "(" formal_parameter_list_opt ")"
|
|
362 |
;
|
|
363 |
constructor_body :
|
|
364 |
"{" explicit_constructor_invocation
|
|
365 |
block_statements "}"
|
|
366 |
| "{" explicit_constructor_invocation "}"
|
|
367 |
| "{" block_statements "}"
|
|
368 |
| "{" "}"
|
|
369 |
;
|
|
370 |
explicit_constructor_invocation :
|
|
371 |
"this" "(" argument_list_opt ")" ";"
|
|
372 |
| "super" "(" argument_list_opt ")" ";"
|
|
373 |
| primary "." "this" "(" argument_list_opt ")" ";"
|
|
374 |
| primary "." "super" "(" argument_list_opt ")" ";"
|
|
375 |
;
|
|
376 |
|
|
377 |
# 19.9) Interfaces
|
|
378 |
|
|
379 |
# 19.9.1) Interface Declarations
|
|
380 |
interface_declaration :
|
|
381 |
modifiers_opt "interface" <IDENTIFIER> extends_interfaces_opt
|
|
382 |
interface_body
|
|
383 |
;
|
|
384 |
extends_interfaces_opt :
|
|
385 |
| extends_interfaces
|
|
386 |
;
|
|
387 |
extends_interfaces :
|
|
388 |
"extends" interface_type
|
|
389 |
| extends_interfaces "," interface_type
|
|
390 |
;
|
|
391 |
interface_body :
|
|
392 |
"{" interface_member_declarations_opt "}"
|
|
393 |
;
|
|
394 |
interface_member_declarations_opt :
|
|
395 |
| interface_member_declarations
|
|
396 |
;
|
|
397 |
interface_member_declarations :
|
|
398 |
interface_member_declaration
|
|
399 |
| interface_member_declarations interface_member_declaration
|
|
400 |
;
|
|
401 |
interface_member_declaration :
|
|
402 |
constant_declaration
|
|
403 |
| abstract_method_declaration
|
|
404 |
| class_declaration
|
|
405 |
| interface_declaration
|
|
406 |
;
|
|
407 |
constant_declaration :
|
|
408 |
field_declaration
|
|
409 |
# need to semantically check that modifiers of field declaration
|
|
410 |
# include only PUBLIC, "static", or "final". Other modifiers are
|
|
411 |
# disallowed.
|
|
412 |
;
|
|
413 |
abstract_method_declaration :
|
|
414 |
method_header ";"
|
|
415 |
;
|
|
416 |
|
|
417 |
# 19.10) Arrays
|
|
418 |
array_initializer :
|
|
419 |
"{" variable_initializers "," "}"
|
|
420 |
| "{" variable_initializers "}"
|
|
421 |
| "{" "," "}"
|
|
422 |
| "{" "}"
|
|
423 |
;
|
|
424 |
variable_initializers :
|
|
425 |
variable_initializer
|
|
426 |
| variable_initializers "," variable_initializer
|
|
427 |
;
|
|
428 |
|
|
429 |
# 19.11) Blocks and Statements
|
|
430 |
block : "{" block_statements_opt "}"
|
|
431 |
;
|
|
432 |
block_statements_opt :
|
|
433 |
| block_statements
|
|
434 |
;
|
|
435 |
block_statements :
|
|
436 |
block_statement
|
|
437 |
| block_statements block_statement
|
|
438 |
;
|
|
439 |
block_statement :
|
|
440 |
local_variable_declaration_statement
|
|
441 |
| statement
|
|
442 |
| class_declaration
|
|
443 |
| interface_declaration
|
|
444 |
;
|
|
445 |
local_variable_declaration_statement :
|
|
446 |
local_variable_declaration ";"
|
|
447 |
;
|
|
448 |
local_variable_declaration :
|
|
449 |
type variable_declarators
|
|
450 |
| "final" type variable_declarators
|
|
451 |
;
|
|
452 |
statement : statement_without_trailing_substatement
|
|
453 |
| labeled_statement
|
|
454 |
| if_then_statement
|
|
455 |
| if_then_else_statement
|
|
456 |
| while_statement
|
|
457 |
| for_statement
|
|
458 |
;
|
|
459 |
statement_no_short_if :
|
|
460 |
statement_without_trailing_substatement
|
|
461 |
| labeled_statement_no_short_if
|
|
462 |
| if_then_else_statement_no_short_if
|
|
463 |
| while_statement_no_short_if
|
|
464 |
| for_statement_no_short_if
|
|
465 |
;
|
|
466 |
statement_without_trailing_substatement :
|
|
467 |
block
|
|
468 |
| empty_statement
|
|
469 |
| expression_statement
|
|
470 |
| switch_statement
|
|
471 |
| do_statement
|
|
472 |
| break_statement
|
|
473 |
| continue_statement
|
|
474 |
| return_statement
|
|
475 |
| synchronized_statement
|
|
476 |
| throw_statement
|
|
477 |
| try_statement
|
|
478 |
;
|
|
479 |
empty_statement :
|
|
480 |
";"
|
|
481 |
;
|
|
482 |
labeled_statement :
|
|
483 |
<IDENTIFIER> ":" statement
|
|
484 |
;
|
|
485 |
labeled_statement_no_short_if :
|
|
486 |
<IDENTIFIER> ":" statement_no_short_if
|
|
487 |
;
|
|
488 |
expression_statement :
|
|
489 |
statement_expression ";"
|
|
490 |
;
|
|
491 |
statement_expression :
|
|
492 |
assignment
|
|
493 |
| preincrement_expression
|
|
494 |
| predecrement_expression
|
|
495 |
| postincrement_expression
|
|
496 |
| postdecrement_expression
|
|
497 |
| method_invocation
|
|
498 |
| class_instance_creation_expression
|
|
499 |
;
|
|
500 |
if_then_statement :
|
|
501 |
"if" "(" expression ")" statement
|
|
502 |
;
|
|
503 |
if_then_else_statement :
|
|
504 |
"if" "(" expression ")" statement_no_short_if
|
|
505 |
"else" statement
|
|
506 |
;
|
|
507 |
if_then_else_statement_no_short_if :
|
|
508 |
"if" "(" expression ")" statement_no_short_if
|
|
509 |
"else" statement_no_short_if
|
|
510 |
;
|
|
511 |
switch_statement :
|
|
512 |
"switch" "(" expression ")" switch_block
|
|
513 |
;
|
|
514 |
switch_block :
|
|
515 |
"{" switch_block_statement_groups switch_labels "}"
|
|
516 |
| "{" switch_block_statement_groups "}"
|
|
517 |
| "{" switch_labels "}"
|
|
518 |
| "{" "}"
|
|
519 |
;
|
|
520 |
switch_block_statement_groups :
|
|
521 |
switch_block_statement_group
|
|
522 |
| switch_block_statement_groups switch_block_statement_group
|
|
523 |
;
|
|
524 |
switch_block_statement_group :
|
|
525 |
switch_labels block_statements
|
|
526 |
;
|
|
527 |
switch_labels :
|
|
528 |
switch_label
|
|
529 |
| switch_labels switch_label
|
|
530 |
;
|
|
531 |
switch_label :
|
|
532 |
"case" constant_expression ":"
|
|
533 |
| "default" ":"
|
|
534 |
;
|
|
535 |
|
|
536 |
while_statement :
|
|
537 |
"while" "(" expression ")" statement
|
|
538 |
;
|
|
539 |
while_statement_no_short_if :
|
|
540 |
"while" "(" expression ")" statement_no_short_if
|
|
541 |
;
|
|
542 |
do_statement :
|
|
543 |
"do" statement "while" "(" expression ")" ";"
|
|
544 |
;
|
|
545 |
for_statement :
|
|
546 |
"for" "(" for_init_opt ";" expression_opt ";"
|
|
547 |
for_update_opt ")" statement
|
|
548 |
;
|
|
549 |
for_statement_no_short_if :
|
|
550 |
"for" "(" for_init_opt ";" expression_opt ";"
|
|
551 |
for_update_opt ")" statement_no_short_if
|
|
552 |
;
|
|
553 |
for_init_opt :
|
|
554 |
| for_init
|
|
555 |
;
|
|
556 |
for_init : statement_expression_list
|
|
557 |
| local_variable_declaration
|
|
558 |
;
|
|
559 |
for_update_opt :
|
|
560 |
| for_update
|
|
561 |
;
|
|
562 |
for_update : statement_expression_list
|
|
563 |
;
|
|
564 |
statement_expression_list :
|
|
565 |
statement_expression
|
|
566 |
| statement_expression_list "," statement_expression
|
|
567 |
;
|
|
568 |
|
|
569 |
identifier_opt :
|
|
570 |
| <IDENTIFIER>
|
|
571 |
;
|
|
572 |
|
|
573 |
break_statement :
|
|
574 |
"break" identifier_opt ";"
|
|
575 |
;
|
|
576 |
|
|
577 |
continue_statement :
|
|
578 |
"continue" identifier_opt ";"
|
|
579 |
;
|
|
580 |
return_statement :
|
|
581 |
"return" expression_opt ";"
|
|
582 |
;
|
|
583 |
throw_statement :
|
|
584 |
"throw" expression ";"
|
|
585 |
;
|
|
586 |
synchronized_statement :
|
|
587 |
"synchronized" "(" expression ")" block
|
|
588 |
;
|
|
589 |
try_statement :
|
|
590 |
"try" block catches
|
|
591 |
| "try" block catches_opt finally
|
|
592 |
;
|
|
593 |
catches_opt :
|
|
594 |
| catches
|
|
595 |
;
|
|
596 |
catches : catch_clause
|
|
597 |
| catches catch_clause
|
|
598 |
;
|
|
599 |
catch_clause :
|
|
600 |
"catch" "(" formal_parameter ")" block
|
|
601 |
;
|
|
602 |
finally : "finally" block
|
|
603 |
;
|
|
604 |
|
|
605 |
# 19.12) Expressions
|
|
606 |
primary : primary_no_new_array
|
|
607 |
| array_creation_expression
|
|
608 |
;
|
|
609 |
primary_no_new_array :
|
|
610 |
literal
|
|
611 |
| "this"
|
|
612 |
| "(" expression ")"
|
|
613 |
| class_instance_creation_expression
|
|
614 |
| field_access
|
|
615 |
| method_invocation
|
|
616 |
| array_access
|
|
617 |
| primitive_type "." "class"
|
|
618 |
| "void" "." "class"
|
|
619 |
| array_type "." "class"
|
|
620 |
| name "." "class"
|
|
621 |
| name "." "this"
|
|
622 |
;
|
|
623 |
class_instance_creation_expression :
|
|
624 |
"new" class_type "(" argument_list_opt ")"
|
|
625 |
| "new" class_type "(" argument_list_opt ")" class_body
|
|
626 |
| primary "." "new" <IDENTIFIER>
|
|
627 |
"(" argument_list_opt ")"
|
|
628 |
| primary "." "new" <IDENTIFIER>
|
|
629 |
"(" argument_list_opt ")" class_body
|
|
630 |
;
|
|
631 |
argument_list_opt :
|
|
632 |
| argument_list
|
|
633 |
;
|
|
634 |
argument_list :
|
|
635 |
expression
|
|
636 |
| argument_list "," expression
|
|
637 |
;
|
|
638 |
array_creation_expression :
|
|
639 |
"new" primitive_type dim_exprs dims_opt
|
|
640 |
| "new" class_or_interface_type dim_exprs dims_opt
|
|
641 |
| "new" primitive_type dims array_initializer
|
|
642 |
| "new" class_or_interface_type dims array_initializer
|
|
643 |
;
|
|
644 |
dim_exprs : dim_expr
|
|
645 |
| dim_exprs dim_expr
|
|
646 |
;
|
|
647 |
dim_expr : "[" expression "]"
|
|
648 |
;
|
|
649 |
dims_opt :
|
|
650 |
| dims
|
|
651 |
;
|
|
652 |
dims : "[" "]"
|
|
653 |
| dims "[" "]"
|
|
654 |
;
|
|
655 |
field_access :
|
|
656 |
primary "." <IDENTIFIER>
|
|
657 |
| "super" "." <IDENTIFIER>
|
|
658 |
| name "." "super" "." <IDENTIFIER>
|
|
659 |
;
|
|
660 |
method_invocation :
|
|
661 |
name "(" argument_list_opt ")"
|
|
662 |
| primary "." <IDENTIFIER> "(" argument_list_opt ")"
|
|
663 |
| "super" "." <IDENTIFIER> "(" argument_list_opt ")"
|
|
664 |
| name "." "super" "." <IDENTIFIER> "(" argument_list_opt ")"
|
|
665 |
;
|
|
666 |
array_access :
|
|
667 |
name "[" expression "]"
|
|
668 |
| primary_no_new_array "[" expression "]"
|
|
669 |
;
|
|
670 |
postfix_expression :
|
|
671 |
primary
|
|
672 |
| name
|
|
673 |
| postincrement_expression
|
|
674 |
| postdecrement_expression
|
|
675 |
;
|
|
676 |
postincrement_expression :
|
|
677 |
postfix_expression "++"
|
|
678 |
;
|
|
679 |
postdecrement_expression :
|
|
680 |
postfix_expression "--"
|
|
681 |
;
|
|
682 |
unary_expression :
|
|
683 |
preincrement_expression
|
|
684 |
| predecrement_expression
|
|
685 |
| "+" unary_expression
|
|
686 |
| "-" unary_expression
|
|
687 |
| unary_expression_not_plus_minus
|
|
688 |
;
|
|
689 |
preincrement_expression :
|
|
690 |
"++" unary_expression
|
|
691 |
;
|
|
692 |
predecrement_expression :
|
|
693 |
"--" unary_expression
|
|
694 |
;
|
|
695 |
unary_expression_not_plus_minus :
|
|
696 |
postfix_expression
|
|
697 |
| "~" unary_expression
|
|
698 |
| "!" unary_expression
|
|
699 |
| cast_expression
|
|
700 |
;
|
|
701 |
cast_expression :
|
|
702 |
"(" primitive_type dims_opt ")" unary_expression
|
|
703 |
| "(" expression ")" unary_expression_not_plus_minus
|
|
704 |
| "(" name dims ")" unary_expression_not_plus_minus
|
|
705 |
;
|
|
706 |
multiplicative_expression :
|
|
707 |
unary_expression
|
|
708 |
| multiplicative_expression "*" unary_expression
|
|
709 |
| multiplicative_expression "/" unary_expression
|
|
710 |
| multiplicative_expression "%" unary_expression
|
|
711 |
;
|
|
712 |
additive_expression :
|
|
713 |
multiplicative_expression
|
|
714 |
| additive_expression "+" multiplicative_expression
|
|
715 |
| additive_expression "-" multiplicative_expression
|
|
716 |
;
|
|
717 |
shift_expression :
|
|
718 |
additive_expression
|
|
719 |
| shift_expression "<<" additive_expression
|
|
720 |
| shift_expression ">>" additive_expression
|
|
721 |
| shift_expression ">>>" additive_expression
|
|
722 |
;
|
|
723 |
relational_expression :
|
|
724 |
shift_expression
|
|
725 |
| relational_expression <LT> shift_expression
|
|
726 |
| relational_expression <GT> shift_expression
|
|
727 |
| relational_expression "<=" shift_expression
|
|
728 |
| relational_expression ">=" shift_expression
|
|
729 |
| relational_expression "instanceof" reference_type
|
|
730 |
;
|
|
731 |
equality_expression :
|
|
732 |
relational_expression
|
|
733 |
| equality_expression "==" relational_expression
|
|
734 |
| equality_expression "!=" relational_expression
|
|
735 |
;
|
|
736 |
and_expression :
|
|
737 |
equality_expression
|
|
738 |
| and_expression "&" equality_expression
|
|
739 |
;
|
|
740 |
exclusive_or_expression :
|
|
741 |
and_expression
|
|
742 |
| exclusive_or_expression "^" and_expression
|
|
743 |
;
|
|
744 |
inclusive_or_expression :
|
|
745 |
exclusive_or_expression
|
|
746 |
| inclusive_or_expression "|" exclusive_or_expression
|
|
747 |
;
|
|
748 |
conditional_and_expression :
|
|
749 |
inclusive_or_expression
|
|
750 |
| conditional_and_expression "&&" inclusive_or_expression
|
|
751 |
;
|
|
752 |
conditional_or_expression :
|
|
753 |
conditional_and_expression
|
|
754 |
| conditional_or_expression "||" conditional_and_expression
|
|
755 |
;
|
|
756 |
conditional_expression :
|
|
757 |
conditional_or_expression
|
|
758 |
| conditional_or_expression "?" expression
|
|
759 |
":" conditional_expression
|
|
760 |
;
|
|
761 |
assignment_expression :
|
|
762 |
conditional_expression
|
|
763 |
| assignment
|
|
764 |
;
|
|
765 |
assignment : left_hand_side assignment_operator assignment_expression
|
|
766 |
;
|
|
767 |
left_hand_side :
|
|
768 |
name
|
|
769 |
| field_access
|
|
770 |
| array_access
|
|
771 |
;
|
|
772 |
assignment_operator :
|
|
773 |
"="
|
|
774 |
| "*="
|
|
775 |
| "/="
|
|
776 |
| "%="
|
|
777 |
| "+="
|
|
778 |
| "-="
|
|
779 |
| "<<="
|
|
780 |
| ">>="
|
|
781 |
| ">>>="
|
|
782 |
| "&="
|
|
783 |
| "^="
|
|
784 |
| "|="
|
|
785 |
;
|
|
786 |
expression_opt :
|
|
787 |
| expression
|
|
788 |
;
|
|
789 |
expression : assignment_expression
|
|
790 |
;
|
|
791 |
constant_expression :
|
|
792 |
expression
|
|
793 |
;
|