blob: bef79194a9290834aed1567cac524f11bd046603 [file] [log] [blame]
Stephan Herrmann7b7062f2010-04-01 19:56:59 +00001--main options
2%options ACTION, AN=JavaAction.java, GP=java,
3%options FILE-PREFIX=java, ESCAPE=$, PREFIX=TokenName, OUTPUT-SIZE=125 ,
4%options NOGOTO-DEFAULT, SINGLE-PRODUCTIONS, LALR=1 , TABLE,
5
6--error recovering options.....
7%options ERROR_MAPS
8
9--grammar understanding options
10%options first follow
11%options TRACE=FULL ,
12%options VERBOSE
13
14%options DEFERRED
15%options NAMES=MAX
16%options SCOPES
17
18--Usefull macros helping reading/writing semantic actions
19$Define
20$putCase
21/. case $rule_number : // System.out.println("$rule_text"); //$NON-NLS-1$
22 ./
23
24$break
25/.
26 break ;
27./
28
29$readableName
30/.$rule_number=./
31
32-- here it starts really ------------------------------------------
33$Terminals
34
35 Identifier
36
37 abstract assert boolean break byte case catch char class
38 continue default do double else extends false final finally float
39 for if implements import instanceof int
40 interface long native new null package private
41 protected public return short static strictfp super switch
42 synchronized this throw throws transient true try void
43 volatile while
44
45 IntegerLiteral
46 LongLiteral
47 FloatingPointLiteral
48 DoubleLiteral
49 CharacterLiteral
50 StringLiteral
51
52 PLUS_PLUS
53 MINUS_MINUS
54 EQUAL_EQUAL
55 LESS_EQUAL
56 GREATER_EQUAL
57 NOT_EQUAL
58 LEFT_SHIFT
59 RIGHT_SHIFT
60 UNSIGNED_RIGHT_SHIFT
61 PLUS_EQUAL
62 MINUS_EQUAL
63 MULTIPLY_EQUAL
64 DIVIDE_EQUAL
65 AND_EQUAL
66 OR_EQUAL
67 XOR_EQUAL
68 REMAINDER_EQUAL
69 LEFT_SHIFT_EQUAL
70 RIGHT_SHIFT_EQUAL
71 UNSIGNED_RIGHT_SHIFT_EQUAL
72 OR_OR
73 AND_AND
74 PLUS
75 MINUS
76 NOT
77 REMAINDER
78 XOR
79 AND
80 MULTIPLY
81 OR
82 TWIDDLE
83 DIVIDE
84 GREATER
85 LESS
86 LPAREN
87 RPAREN
88 LBRACE
89 RBRACE
90 LBRACKET
91 RBRACKET
92 SEMICOLON
93 QUESTION
94 COLON
95 COMMA
96 DOT
97 EQUAL
98
99-- BodyMarker
100
101$Alias
102
103 '++' ::= PLUS_PLUS
104 '--' ::= MINUS_MINUS
105 '==' ::= EQUAL_EQUAL
106 '<=' ::= LESS_EQUAL
107 '>=' ::= GREATER_EQUAL
108 '!=' ::= NOT_EQUAL
109 '<<' ::= LEFT_SHIFT
110 '>>' ::= RIGHT_SHIFT
111 '>>>' ::= UNSIGNED_RIGHT_SHIFT
112 '+=' ::= PLUS_EQUAL
113 '-=' ::= MINUS_EQUAL
114 '*=' ::= MULTIPLY_EQUAL
115 '/=' ::= DIVIDE_EQUAL
116 '&=' ::= AND_EQUAL
117 '|=' ::= OR_EQUAL
118 '^=' ::= XOR_EQUAL
119 '%=' ::= REMAINDER_EQUAL
120 '<<=' ::= LEFT_SHIFT_EQUAL
121 '>>=' ::= RIGHT_SHIFT_EQUAL
122 '>>>=' ::= UNSIGNED_RIGHT_SHIFT_EQUAL
123 '||' ::= OR_OR
124 '&&' ::= AND_AND
125
126 '+' ::= PLUS
127 '-' ::= MINUS
128 '!' ::= NOT
129 '%' ::= REMAINDER
130 '^' ::= XOR
131 '&' ::= AND
132 '*' ::= MULTIPLY
133 '|' ::= OR
134 '~' ::= TWIDDLE
135 '/' ::= DIVIDE
136 '>' ::= GREATER
137 '<' ::= LESS
138 '(' ::= LPAREN
139 ')' ::= RPAREN
140 '{' ::= LBRACE
141 '}' ::= RBRACE
142 '[' ::= LBRACKET
143 ']' ::= RBRACKET
144 ';' ::= SEMICOLON
145 '?' ::= QUESTION
146 ':' ::= COLON
147 ',' ::= COMMA
148 '.' ::= DOT
149 '=' ::= EQUAL
150
151$Start
152 Goal
153
154$Rules
155
156/. // This method is part of an automatic generation : do NOT edit-modify
157protected void consumeRule(int act) {
158 switch ( act ) {
159./
160
161
162
163Goal ::= '++' CompilationUnit
164Goal ::= '--' MethodBody
165-- Initializer
166Goal ::= '>>' StaticInitializer
167Goal ::= '>>' Initializer
168-- error recovery
169Goal ::= '>>>' Headers
170Goal ::= '*' BlockStatements
171Goal ::= '*' CatchHeader
172-- JDOM
173Goal ::= '&&' FieldDeclaration
174Goal ::= '||' ImportDeclaration
175Goal ::= '?' PackageDeclaration
176Goal ::= '+' TypeDeclaration
177Goal ::= '/' GenericMethodDeclaration
178Goal ::= '&' ClassBodyDeclarations
179-- code snippet
180Goal ::= '%' Expression
181-- completion parser
182Goal ::= '~' BlockStatementsopt
183/:$readableName Goal:/
184
185Literal -> IntegerLiteral
186Literal -> LongLiteral
187Literal -> FloatingPointLiteral
188Literal -> DoubleLiteral
189Literal -> CharacterLiteral
190Literal -> StringLiteral
191Literal -> null
192Literal -> BooleanLiteral
193/:$readableName Literal:/
194BooleanLiteral -> true
195BooleanLiteral -> false
196/:$readableName BooleanLiteral:/
197
198-------------------------------------------------------------
199-------------------------------------------------------------
200--a Type results in both a push of its dimension(s) and its name(s).
201
202Type ::= PrimitiveType
203 /.$putCase consumePrimitiveType(); $break ./
204Type -> ReferenceType
205/:$readableName Type:/
206
207PrimitiveType -> NumericType
208/:$readableName PrimitiveType:/
209NumericType -> IntegralType
210NumericType -> FloatingPointType
211/:$readableName NumericType:/
212
213PrimitiveType -> 'boolean'
214PrimitiveType -> 'void'
215IntegralType -> 'byte'
216IntegralType -> 'short'
217IntegralType -> 'int'
218IntegralType -> 'long'
219IntegralType -> 'char'
220/:$readableName IntegralType:/
221FloatingPointType -> 'float'
222FloatingPointType -> 'double'
223/:$readableName FloatingPointType:/
224
225ReferenceType ::= ClassOrInterfaceType
226/.$putCase consumeReferenceType(); $break ./
227ReferenceType -> ArrayType -- here a push of dimensions is done, that explains the two previous push 0
228/:$readableName ReferenceType:/
229ClassOrInterfaceType -> Name
230/:$readableName Type:/
231
232--
233-- These rules have been rewritten to avoid some conflicts introduced
234-- by adding the 1.1 features
235--
236-- ArrayType ::= PrimitiveType '[' ']'
237-- ArrayType ::= Name '[' ']'
238-- ArrayType ::= ArrayType '[' ']'
239--
240
241ArrayType ::= PrimitiveType Dims
242ArrayType ::= Name Dims
243/:$readableName ArrayType:/
244
245ClassType -> ClassOrInterfaceType
246/:$readableName ClassType:/
247
248--------------------------------------------------------------
249--------------------------------------------------------------
250
251Name -> SimpleName
252Name -> QualifiedName
253/:$readableName Name:/
254
255SimpleName -> 'Identifier'
256/:$readableName SimpleName:/
257
258QualifiedName ::= Name '.' SimpleName
259/.$putCase consumeQualifiedName(); $break ./
260/:$readableName QualifiedName:/
261
262CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt TypeDeclarationsopt
263/.$putCase consumeCompilationUnit(); $break ./
264/:$readableName CompilationUnit:/
265
266EnterCompilationUnit ::= $empty
267/.$putCase consumeEnterCompilationUnit(); $break ./
268/:$readableName EnterCompilationUnit:/
269
270Headers -> Header
271Headers ::= Headers Header
272/:$readableName Headers:/
273
274Header -> ImportDeclaration
275Header -> PackageDeclaration
276Header -> ClassHeader
277Header -> InterfaceHeader
278Header -> StaticInitializer
279Header -> MethodHeader
280Header -> ConstructorHeader
281Header -> FieldDeclaration
282Header -> AllocationHeader
283Header -> ArrayCreationHeader
284/:$readableName Header:/
285
286CatchHeader ::= 'catch' '(' FormalParameter ')' '{'
287/.$putCase consumeCatchHeader(); $break ./
288/:$readableName CatchHeader:/
289
290ImportDeclarations -> ImportDeclaration
291ImportDeclarations ::= ImportDeclarations ImportDeclaration
292/.$putCase consumeImportDeclarations(); $break ./
293/:$readableName ImportDeclarations:/
294
295TypeDeclarations -> TypeDeclaration
296TypeDeclarations ::= TypeDeclarations TypeDeclaration
297/.$putCase consumeTypeDeclarations(); $break ./
298/:$readableName TypeDeclarations:/
299
300PackageDeclaration ::= PackageDeclarationName ';'
301/.$putCase consumePackageDeclaration(); $break ./
302/:$readableName PackageDeclaration:/
303
304PackageDeclarationName ::= 'package' Name
305/.$putCase consumePackageDeclarationName(); $break ./
306/:$readableName PackageDeclarationName:/
307
308ImportDeclaration -> SingleTypeImportDeclaration
309ImportDeclaration -> TypeImportOnDemandDeclaration
310/:$readableName ImportDeclaration:/
311
312SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';'
313/.$putCase consumeSingleTypeImportDeclaration(); $break ./
314/:$readableName SingleTypeImportDeclaration:/
315
316SingleTypeImportDeclarationName ::= 'import' Name
317/.$putCase consumeSingleTypeImportDeclarationName(); $break ./
318/:$readableName SingleTypeImportDeclarationName:/
319
320TypeImportOnDemandDeclaration ::= TypeImportOnDemandDeclarationName ';'
321/.$putCase consumeTypeImportOnDemandDeclaration(); $break ./
322/:$readableName TypeImportOnDemandDeclaration:/
323
324TypeImportOnDemandDeclarationName ::= 'import' Name '.' '*'
325/.$putCase consumeTypeImportOnDemandDeclarationName(); $break ./
326/:$readableName TypeImportOnDemandDeclarationName:/
327
328TypeDeclaration -> ClassDeclaration
329TypeDeclaration -> InterfaceDeclaration
330-- this declaration in part of a list od declaration and we will
331-- use and optimized list length calculation process
332-- thus we decrement the number while it will be incremend.....
333TypeDeclaration ::= ';'
334/. $putCase consumeEmptyTypeDeclaration(); $break ./
335/:$readableName TypeDeclaration:/
336
337--18.7 Only in the LALR(1) Grammar
338
339Modifiers ::= Modifier
340Modifiers ::= Modifiers Modifier
341/:$readableName Modifiers:/
342
343Modifier -> 'public'
344Modifier -> 'protected'
345Modifier -> 'private'
346Modifier -> 'static'
347Modifier -> 'abstract'
348Modifier -> 'final'
349Modifier -> 'native'
350Modifier -> 'synchronized'
351Modifier -> 'transient'
352Modifier -> 'volatile'
353Modifier -> 'strictfp'
354/:$readableName Modifier:/
355
356--18.8 Productions from 8: Class Declarations
357--ClassModifier ::=
358-- 'abstract'
359-- | 'final'
360-- | 'public'
361--18.8.1 Productions from 8.1: Class Declarations
362
363ClassDeclaration ::= ClassHeader ClassBody
364/.$putCase consumeClassDeclaration(); $break ./
365/:$readableName ClassDeclaration:/
366
367ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt
368/.$putCase consumeClassHeader(); $break ./
369/:$readableName ClassHeader:/
370
371ClassHeaderName ::= Modifiersopt 'class' 'Identifier'
372/.$putCase consumeClassHeaderName(); $break ./
373/:$readableName ClassHeaderName:/
374
375ClassHeaderExtends ::= 'extends' ClassType
376/.$putCase consumeClassHeaderExtends(); $break ./
377/:$readableName ClassHeaderExtends:/
378
379ClassHeaderImplements ::= 'implements' InterfaceTypeList
380/.$putCase consumeClassHeaderImplements(); $break ./
381/:$readableName ClassHeaderImplements:/
382
383InterfaceTypeList -> InterfaceType
384InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType
385/.$putCase consumeInterfaceTypeList(); $break ./
386/:$readableName InterfaceTypeList:/
387
388InterfaceType ::= ClassOrInterfaceType
389/.$putCase consumeInterfaceType(); $break ./
390/:$readableName InterfaceType:/
391
392ClassBody ::= '{' ClassBodyDeclarationsopt '}'
393/:$readableName ClassBody:/
394
395ClassBodyDeclarations ::= ClassBodyDeclaration
396ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration
397/.$putCase consumeClassBodyDeclarations(); $break ./
398/:$readableName ClassBodyDeclarations:/
399
400ClassBodyDeclaration -> ClassMemberDeclaration
401ClassBodyDeclaration -> StaticInitializer
402ClassBodyDeclaration -> ConstructorDeclaration
403--1.1 feature
404ClassBodyDeclaration ::= Diet NestedMethod Block
405/.$putCase consumeClassBodyDeclaration(); $break ./
406/:$readableName ClassBodyDeclaration:/
407Diet ::= $empty
408/.$putCase consumeDiet(); $break./
409/:$readableName Diet:/
410
411Initializer ::= Diet NestedMethod Block
412/.$putCase consumeClassBodyDeclaration(); $break ./
413/:$readableName Initializer:/
414
415ClassMemberDeclaration -> FieldDeclaration
416ClassMemberDeclaration -> MethodDeclaration
417--1.1 feature
418ClassMemberDeclaration -> ClassDeclaration
419--1.1 feature
420ClassMemberDeclaration -> InterfaceDeclaration
421/:$readableName ClassMemberDeclaration:/
422
423-- Empty declarations are not valid Java ClassMemberDeclarations.
424-- However, since the current (2/14/97) Java compiler accepts them
425-- (in fact, some of the official tests contain this erroneous
426-- syntax)
427
428GenericMethodDeclaration -> MethodDeclaration
429GenericMethodDeclaration -> ConstructorDeclaration
430/:$readableName GenericMethodDeclaration:/
431
432ClassMemberDeclaration ::= ';'
433/.$putCase consumeEmptyClassMemberDeclaration(); $break./
434
435--18.8.2 Productions from 8.3: Field Declarations
436--VariableModifier ::=
437-- 'public'
438-- | 'protected'
439-- | 'private'
440-- | 'static'
441-- | 'final'
442-- | 'transient'
443-- | 'volatile'
444
445FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';'
446/.$putCase consumeFieldDeclaration(); $break ./
447/:$readableName FieldDeclaration:/
448
449VariableDeclarators -> VariableDeclarator
450VariableDeclarators ::= VariableDeclarators ',' VariableDeclarator
451/.$putCase consumeVariableDeclarators(); $break ./
452/:$readableName VariableDeclarators:/
453
454VariableDeclarator ::= VariableDeclaratorId EnterVariable ExitVariableWithoutInitialization
455
456VariableDeclarator ::= VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization
457/:$readableName VariableDeclarator:/
458
459EnterVariable ::= $empty
460/.$putCase consumeEnterVariable(); $break ./
461/:$readableName EnterVariable:/
462
463ExitVariableWithInitialization ::= $empty
464/.$putCase consumeExitVariableWithInitialization(); $break ./
465/:$readableName ExitVariableWithInitialization:/
466
467ExitVariableWithoutInitialization ::= $empty
468/.$putCase consumeExitVariableWithoutInitialization(); $break ./
469/:$readableName ExitVariableWithoutInitialization:/
470
471ForceNoDiet ::= $empty
472/.$putCase consumeForceNoDiet(); $break ./
473/:$readableName ForceNoDiet:/
474RestoreDiet ::= $empty
475/.$putCase consumeRestoreDiet(); $break ./
476/:$readableName RestoreDiet:/
477
478VariableDeclaratorId ::= 'Identifier' Dimsopt
479/:$readableName VariableDeclaratorId:/
480
481VariableInitializer -> Expression
482VariableInitializer -> ArrayInitializer
483/:$readableName VariableInitializer:/
484
485--18.8.3 Productions from 8.4: Method Declarations
486--MethodModifier ::=
487-- 'public'
488-- | 'protected'
489-- | 'private'
490-- | 'static'
491-- | 'abstract'
492-- | 'final'
493-- | 'native'
494-- | 'synchronized'
495--
496
497MethodDeclaration -> AbstractMethodDeclaration
498MethodDeclaration ::= MethodHeader MethodBody
499/.$putCase // set to true to consume a method with a body
500 consumeMethodDeclaration(true); $break ./
501/:$readableName MethodDeclaration:/
502
503AbstractMethodDeclaration ::= MethodHeader ';'
504/.$putCase // set to false to consume a method without body
505 consumeMethodDeclaration(false); $break ./
506/:$readableName AbstractMethodDeclaration:/
507
508MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims MethodHeaderThrowsClauseopt
509/.$putCase consumeMethodHeader(); $break ./
510/:$readableName MethodHeader:/
511
512MethodHeaderName ::= Modifiersopt Type 'Identifier' '('
513/.$putCase consumeMethodHeaderName(); $break ./
514/:$readableName MethodHeaderName:/
515
516MethodHeaderParameters ::= FormalParameterListopt ')'
517/.$putCase consumeMethodHeaderParameters(); $break ./
518/:$readableName MethodHeaderParameters:/
519
520MethodHeaderExtendedDims ::= Dimsopt
521/.$putCase consumeMethodHeaderExtendedDims(); $break ./
522/:$readableName MethodHeaderExtendedDims:/
523
524MethodHeaderThrowsClause ::= 'throws' ClassTypeList
525/.$putCase consumeMethodHeaderThrowsClause(); $break ./
526/:$readableName MethodHeaderThrowsClause:/
527
528ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters MethodHeaderThrowsClauseopt
529/.$putCase consumeConstructorHeader(); $break ./
530/:$readableName ConstructorHeader:/
531
532ConstructorHeaderName ::= Modifiersopt 'Identifier' '('
533/.$putCase consumeConstructorHeaderName(); $break ./
534/:$readableName ConstructorHeaderName:/
535
536FormalParameterList -> FormalParameter
537FormalParameterList ::= FormalParameterList ',' FormalParameter
538/.$putCase consumeFormalParameterList(); $break ./
539/:$readableName FormalParameterList:/
540
541--1.1 feature
542FormalParameter ::= Modifiersopt Type VariableDeclaratorId
543/.$putCase // the boolean is used to know if the modifiers should be reset
544 consumeFormalParameter(); $break ./
545/:$readableName FormalParameter:/
546
547ClassTypeList -> ClassTypeElt
548ClassTypeList ::= ClassTypeList ',' ClassTypeElt
549/.$putCase consumeClassTypeList(); $break ./
550/:$readableName ClassTypeList:/
551
552ClassTypeElt ::= ClassType
553/.$putCase consumeClassTypeElt(); $break ./
554/:$readableName ClassType:/
555
556MethodBody ::= NestedMethod '{' BlockStatementsopt '}'
557/.$putCase consumeMethodBody(); $break ./
558/:$readableName MethodBody:/
559
560NestedMethod ::= $empty
561/.$putCase consumeNestedMethod(); $break ./
562/:$readableName NestedMethod:/
563
564--18.8.4 Productions from 8.5: Static Initializers
565
566StaticInitializer ::= StaticOnly Block
567/.$putCase consumeStaticInitializer(); $break./
568/:$readableName StaticInitializer:/
569
570StaticOnly ::= 'static'
571/.$putCase consumeStaticOnly(); $break ./
572/:$readableName StaticOnly:/
573
574--18.8.5 Productions from 8.6: Constructor Declarations
575--ConstructorModifier ::=
576-- 'public'
577-- | 'protected'
578-- | 'private'
579--
580--
581ConstructorDeclaration ::= ConstructorHeader MethodBody
582/.$putCase consumeConstructorDeclaration() ; $break ./
583
584-- These rules are added to be able to parse constructors with no body
585ConstructorDeclaration ::= ConstructorHeader ';'
586/.$putCase consumeInvalidConstructorDeclaration() ; $break ./
587/:$readableName ConstructorDeclaration:/
588
589-- the rules ExplicitConstructorInvocationopt has been expanded
590-- in the rule below in order to make the grammar lalr(1).
591
592ExplicitConstructorInvocation ::= 'this' '(' ArgumentListopt ')' ';'
593/.$putCase consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.This); $break ./
594
595ExplicitConstructorInvocation ::= 'super' '(' ArgumentListopt ')' ';'
596/.$putCase consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.Super); $break ./
597
598--1.1 feature
599ExplicitConstructorInvocation ::= Primary '.' 'super' '(' ArgumentListopt ')' ';'
600/.$putCase consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.Super); $break ./
601
602--1.1 feature
603ExplicitConstructorInvocation ::= Name '.' 'super' '(' ArgumentListopt ')' ';'
604/.$putCase consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.Super); $break ./
605
606--1.1 feature
607ExplicitConstructorInvocation ::= Primary '.' 'this' '(' ArgumentListopt ')' ';'
608/.$putCase consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.This); $break ./
609
610--1.1 feature
611ExplicitConstructorInvocation ::= Name '.' 'this' '(' ArgumentListopt ')' ';'
612/.$putCase consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.This); $break ./
613/:$readableName ExplicitConstructorInvocation:/
614
615--18.9 Productions from 9: Interface Declarations
616
617--18.9.1 Productions from 9.1: Interface Declarations
618--InterfaceModifier ::=
619-- 'public'
620-- | 'abstract'
621--
622InterfaceDeclaration ::= InterfaceHeader InterfaceBody
623/.$putCase consumeInterfaceDeclaration(); $break ./
624/:$readableName InterfaceDeclaration:/
625
626InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt
627/.$putCase consumeInterfaceHeader(); $break ./
628/:$readableName InterfaceHeader:/
629
630InterfaceHeaderName ::= Modifiersopt 'interface' 'Identifier'
631/.$putCase consumeInterfaceHeaderName(); $break ./
632/:$readableName InterfaceHeaderName:/
633
634-- This rule will be used to accept inner local interface and then report a relevant error message
635InvalidInterfaceDeclaration -> InterfaceHeader InterfaceBody
636/:$readableName InvalidInterfaceDeclaration:/
637
638InterfaceHeaderExtends ::= 'extends' InterfaceTypeList
639/.$putCase consumeInterfaceHeaderExtends(); $break ./
640/:$readableName InterfaceHeaderExtends:/
641
642InterfaceBody ::= '{' InterfaceMemberDeclarationsopt '}'
643/:$readableName InterfaceBody:/
644
645InterfaceMemberDeclarations -> InterfaceMemberDeclaration
646InterfaceMemberDeclarations ::= InterfaceMemberDeclarations InterfaceMemberDeclaration
647/.$putCase consumeInterfaceMemberDeclarations(); $break ./
648/:$readableName InterfaceMemberDeclarations:/
649
650--same as for class members
651InterfaceMemberDeclaration ::= ';'
652/.$putCase consumeEmptyInterfaceMemberDeclaration(); $break ./
653/:$readableName InterfaceMemberDeclaration:/
654
655-- This rule is added to be able to parse non abstract method inside interface and then report a relevent error message
656InvalidMethodDeclaration -> MethodHeader MethodBody
657/:$readableName InvalidMethodDeclaration:/
658
659InterfaceMemberDeclaration -> ConstantDeclaration
660InterfaceMemberDeclaration ::= InvalidMethodDeclaration
661/.$putCase ignoreMethodBody(); $break ./
662/:$readableName InterfaceMemberDeclaration:/
663
664-- These rules are added to be able to parse constructors inside interface and then report a relevent error message
665InvalidConstructorDeclaration ::= ConstructorHeader MethodBody
666/.$putCase ignoreInvalidConstructorDeclaration(true); $break ./
667
668InvalidConstructorDeclaration ::= ConstructorHeader ';'
669/.$putCase ignoreInvalidConstructorDeclaration(false); $break ./
670/:$readableName InvalidConstructorDeclaration:/
671
672InterfaceMemberDeclaration -> AbstractMethodDeclaration
673InterfaceMemberDeclaration -> InvalidConstructorDeclaration
674/:$readableName InterfaceMemberDeclaration:/
675
676--1.1 feature
677InterfaceMemberDeclaration -> ClassDeclaration
678--1.1 feature
679InterfaceMemberDeclaration -> InterfaceDeclaration
680/:$readableName InterfaceMemberDeclaration:/
681
682ConstantDeclaration -> FieldDeclaration
683/:$readableName ConstantDeclaration:/
684
685ArrayInitializer ::= '{' ,opt '}'
686/.$putCase consumeEmptyArrayInitializer(); $break ./
687ArrayInitializer ::= '{' VariableInitializers '}'
688/.$putCase consumeArrayInitializer(); $break ./
689ArrayInitializer ::= '{' VariableInitializers , '}'
690/.$putCase consumeArrayInitializer(); $break ./
691/:$readableName ArrayInitializer:/
692
693VariableInitializers ::= VariableInitializer
694VariableInitializers ::= VariableInitializers ',' VariableInitializer
695/.$putCase consumeVariableInitializers(); $break ./
696/:$readableName VariableInitializers:/
697
698Block ::= OpenBlock '{' BlockStatementsopt '}'
699/.$putCase consumeBlock(); $break ./
700/:$readableName Block:/
701
702OpenBlock ::= $empty
703/.$putCase consumeOpenBlock() ; $break ./
704/:$readableName OpenBlock:/
705
706BlockStatements -> BlockStatement
707BlockStatements ::= BlockStatements BlockStatement
708/.$putCase consumeBlockStatements() ; $break ./
709/:$readableName BlockStatements:/
710
711BlockStatement -> LocalVariableDeclarationStatement
712BlockStatement -> Statement
713--1.1 feature
714BlockStatement -> ClassDeclaration
715BlockStatement ::= InvalidInterfaceDeclaration
716/.$putCase ignoreInterfaceDeclaration(); $break ./
717/:$readableName BlockStatement:/
718
719LocalVariableDeclarationStatement ::= LocalVariableDeclaration ';'
720/.$putCase consumeLocalVariableDeclarationStatement(); $break ./
721/:$readableName LocalVariableDeclarationStatement:/
722
723LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators
724/.$putCase consumeLocalVariableDeclaration(); $break ./
725
726-- 1.1 feature
727-- The modifiers part of this rule makes the grammar more permissive.
728-- The only modifier here is final. We put Modifiers to allow multiple modifiers
729-- This will require to check the validity of the modifier
730
731LocalVariableDeclaration ::= Modifiers Type PushModifiers VariableDeclarators
732/.$putCase consumeLocalVariableDeclaration(); $break ./
733/:$readableName LocalVariableDeclaration:/
734
735PushModifiers ::= $empty
736/.$putCase consumePushModifiers(); $break ./
737/:$readableName PushModifiers:/
738
739Statement -> StatementWithoutTrailingSubstatement
740Statement -> LabeledStatement
741Statement -> IfThenStatement
742Statement -> IfThenElseStatement
743Statement -> WhileStatement
744Statement -> ForStatement
745/:$readableName Statement:/
746
747StatementNoShortIf -> StatementWithoutTrailingSubstatement
748StatementNoShortIf -> LabeledStatementNoShortIf
749StatementNoShortIf -> IfThenElseStatementNoShortIf
750StatementNoShortIf -> WhileStatementNoShortIf
751StatementNoShortIf -> ForStatementNoShortIf
752/:$readableName Statement:/
753
754StatementWithoutTrailingSubstatement -> AssertStatement
755StatementWithoutTrailingSubstatement -> Block
756StatementWithoutTrailingSubstatement -> EmptyStatement
757StatementWithoutTrailingSubstatement -> ExpressionStatement
758StatementWithoutTrailingSubstatement -> SwitchStatement
759StatementWithoutTrailingSubstatement -> DoStatement
760StatementWithoutTrailingSubstatement -> BreakStatement
761StatementWithoutTrailingSubstatement -> ContinueStatement
762StatementWithoutTrailingSubstatement -> ReturnStatement
763StatementWithoutTrailingSubstatement -> SynchronizedStatement
764StatementWithoutTrailingSubstatement -> ThrowStatement
765StatementWithoutTrailingSubstatement -> TryStatement
766/:$readableName Statement:/
767
768EmptyStatement ::= ';'
769/.$putCase consumeEmptyStatement(); $break ./
770/:$readableName EmptyStatement:/
771
772LabeledStatement ::= 'Identifier' ':' Statement
773/.$putCase consumeStatementLabel() ; $break ./
774/:$readableName LabeledStatement:/
775
776LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf
777/.$putCase consumeStatementLabel() ; $break ./
778/:$readableName LabeledStatement:/
779
780ExpressionStatement ::= StatementExpression ';'
781/. $putCase consumeExpressionStatement(); $break ./
782ExpressionStatement ::= ExplicitConstructorInvocation
783/:$readableName Statement:/
784
785StatementExpression ::= Assignment
786StatementExpression ::= PreIncrementExpression
787StatementExpression ::= PreDecrementExpression
788StatementExpression ::= PostIncrementExpression
789StatementExpression ::= PostDecrementExpression
790StatementExpression ::= MethodInvocation
791StatementExpression ::= ClassInstanceCreationExpression
792/:$readableName Expression:/
793
794IfThenStatement ::= 'if' '(' Expression ')' Statement
795/.$putCase consumeStatementIfNoElse(); $break ./
796/:$readableName IfStatement:/
797
798IfThenElseStatement ::= 'if' '(' Expression ')' StatementNoShortIf 'else' Statement
799/.$putCase consumeStatementIfWithElse(); $break ./
800/:$readableName IfStatement:/
801
802IfThenElseStatementNoShortIf ::= 'if' '(' Expression ')' StatementNoShortIf 'else' StatementNoShortIf
803/.$putCase consumeStatementIfWithElse(); $break ./
804/:$readableName IfStatement:/
805
806SwitchStatement ::= 'switch' '(' Expression ')' OpenBlock SwitchBlock
807/.$putCase consumeStatementSwitch() ; $break ./
808/:$readableName SwitchStatement:/
809
810SwitchBlock ::= '{' '}'
811/.$putCase consumeEmptySwitchBlock() ; $break ./
812
813SwitchBlock ::= '{' SwitchBlockStatements '}'
814SwitchBlock ::= '{' SwitchLabels '}'
815SwitchBlock ::= '{' SwitchBlockStatements SwitchLabels '}'
816/.$putCase consumeSwitchBlock() ; $break ./
817/:$readableName SwitchBlock:/
818
819SwitchBlockStatements -> SwitchBlockStatement
820SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement
821/.$putCase consumeSwitchBlockStatements() ; $break ./
822/:$readableName SwitchBlockStatements:/
823
824SwitchBlockStatement ::= SwitchLabels BlockStatements
825/.$putCase consumeSwitchBlockStatement() ; $break ./
826/:$readableName SwitchBlockStatement:/
827
828
829SwitchLabels -> SwitchLabel
830SwitchLabels ::= SwitchLabels SwitchLabel
831/.$putCase consumeSwitchLabels() ; $break ./
832/:$readableName SwitchLabels:/
833
834SwitchLabel ::= 'case' ConstantExpression ':'
835/. $putCase consumeCaseLabel(); $break ./
836
837SwitchLabel ::= 'default' ':'
838/. $putCase consumeDefaultLabel(); $break ./
839/:$readableName SwitchLabel:/
840
841WhileStatement ::= 'while' '(' Expression ')' Statement
842/.$putCase consumeStatementWhile() ; $break ./
843/:$readableName WhileStatement:/
844
845WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf
846/.$putCase consumeStatementWhile() ; $break ./
847/:$readableName WhileStatement:/
848
849DoStatement ::= 'do' Statement 'while' '(' Expression ')' ';'
850/.$putCase consumeStatementDo() ; $break ./
851/:$readableName DoStatement:/
852
853ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' Statement
854/.$putCase consumeStatementFor() ; $break ./
855/:$readableName ForStatement:/
856
857ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf
858/.$putCase consumeStatementFor() ; $break ./
859/:$readableName ForStatement:/
860
861--the minus one allows to avoid a stack-to-stack transfer
862ForInit ::= StatementExpressionList
863/.$putCase consumeForInit() ; $break ./
864ForInit -> LocalVariableDeclaration
865/:$readableName ForInit:/
866
867ForUpdate -> StatementExpressionList
868/:$readableName ForUpdate:/
869
870StatementExpressionList -> StatementExpression
871StatementExpressionList ::= StatementExpressionList ',' StatementExpression
872/.$putCase consumeStatementExpressionList() ; $break ./
873/:$readableName StatementExpressionList:/
874
875-- 1.4 feature
876AssertStatement ::= 'assert' Expression ';'
877/.$putCase consumeSimpleAssertStatement() ; $break ./
878
879AssertStatement ::= 'assert' Expression ':' Expression ';'
880/.$putCase consumeAssertStatement() ; $break ./
881/:$readableName AssertStatement:/
882
883BreakStatement ::= 'break' ';'
884/.$putCase consumeStatementBreak() ; $break ./
885
886BreakStatement ::= 'break' Identifier ';'
887/.$putCase consumeStatementBreakWithLabel() ; $break ./
888/:$readableName BreakStatement:/
889
890ContinueStatement ::= 'continue' ';'
891/.$putCase consumeStatementContinue() ; $break ./
892
893ContinueStatement ::= 'continue' Identifier ';'
894/.$putCase consumeStatementContinueWithLabel() ; $break ./
895/:$readableName ContinueStatement:/
896
897ReturnStatement ::= 'return' Expressionopt ';'
898/.$putCase consumeStatementReturn() ; $break ./
899/:$readableName ReturnStatement:/
900
901ThrowStatement ::= 'throw' Expression ';'
902/.$putCase consumeStatementThrow();
903$break ./
904/:$readableName ThrowStatement:/
905
906SynchronizedStatement ::= OnlySynchronized '(' Expression ')' Block
907/.$putCase consumeStatementSynchronized(); $break ./
908/:$readableName SynchronizedStatement:/
909
910OnlySynchronized ::= 'synchronized'
911/.$putCase consumeOnlySynchronized(); $break ./
912/:$readableName OnlySynchronized:/
913
914TryStatement ::= 'try' TryBlock Catches
915/.$putCase consumeStatementTry(false); $break ./
916TryStatement ::= 'try' TryBlock Catchesopt Finally
917/.$putCase consumeStatementTry(true); $break ./
918/:$readableName TryStatement:/
919
920TryBlock ::= Block ExitTryBlock
921/:$readableName Block:/
922
923ExitTryBlock ::= $empty
924/.$putCase consumeExitTryBlock(); $break ./
925/:$readableName ExitTryBlock:/
926
927Catches -> CatchClause
928Catches ::= Catches CatchClause
929/.$putCase consumeCatches(); $break ./
930/:$readableName Catches:/
931
932CatchClause ::= 'catch' '(' FormalParameter ')' Block
933/.$putCase consumeStatementCatch() ; $break ./
934/:$readableName CatchClause:/
935
936Finally ::= 'finally' Block
937/:$readableName Finally:/
938
939--18.12 Productions from 14: Expressions
940
941--for source positionning purpose
942PushLPAREN ::= '('
943/.$putCase consumeLeftParen(); $break ./
944/:$readableName (:/
945PushRPAREN ::= ')'
946/.$putCase consumeRightParen(); $break ./
947/:$readableName ):/
948
949Primary -> PrimaryNoNewArray
950Primary -> ArrayCreationWithArrayInitializer
951Primary -> ArrayCreationWithoutArrayInitializer
952/:$readableName Expression:/
953
954PrimaryNoNewArray -> Literal
955PrimaryNoNewArray ::= 'this'
956/.$putCase consumePrimaryNoNewArrayThis(); $break ./
957
958PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN
959/.$putCase consumePrimaryNoNewArray(); $break ./
960
961PrimaryNoNewArray -> ClassInstanceCreationExpression
962PrimaryNoNewArray -> FieldAccess
963--1.1 feature
964PrimaryNoNewArray ::= Name '.' 'this'
965/.$putCase consumePrimaryNoNewArrayNameThis(); $break ./
966PrimaryNoNewArray ::= Name '.' 'super'
967/.$putCase consumePrimaryNoNewArrayNameSuper(); $break ./
968
969--1.1 feature
970--PrimaryNoNewArray ::= Type '.' 'class'
971--inline Type in the previous rule in order to make the grammar LL1 instead
972-- of LL2. The result is the 3 next rules.
973PrimaryNoNewArray ::= Name '.' 'class'
974/.$putCase consumePrimaryNoNewArrayName(); $break ./
975
976PrimaryNoNewArray ::= ArrayType '.' 'class'
977/.$putCase consumePrimaryNoNewArrayArrayType(); $break ./
978
979PrimaryNoNewArray ::= PrimitiveType '.' 'class'
980/.$putCase consumePrimaryNoNewArrayPrimitiveType(); $break ./
981
982PrimaryNoNewArray -> MethodInvocation
983PrimaryNoNewArray -> ArrayAccess
984/:$readableName Expression:/
985--1.1 feature
986--
987-- In Java 1.0 a ClassBody could not appear at all in a
988-- ClassInstanceCreationExpression.
989--
990
991AllocationHeader ::= 'new' ClassType '(' ArgumentListopt ')'
992/.$putCase consumeAllocationHeader(); $break ./
993/:$readableName AllocationHeader:/
994
995ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
996/.$putCase consumeClassInstanceCreationExpression(); $break ./
997--1.1 feature
998
999ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
1000/.$putCase consumeClassInstanceCreationExpressionQualified() ; $break ./
1001
1002--1.1 feature
1003ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
1004/.$putCase consumeClassInstanceCreationExpressionQualified() ; $break ./
1005/:$readableName ClassInstanceCreationExpression:/
1006
1007ClassInstanceCreationExpressionName ::= Name '.'
1008/.$putCase consumeClassInstanceCreationExpressionName() ; $break ./
1009/:$readableName ClassInstanceCreationExpressionName:/
1010
1011ClassBodyopt ::= $empty --test made using null as contents
1012/.$putCase consumeClassBodyopt(); $break ./
1013ClassBodyopt ::= EnterAnonymousClassBody ClassBody
1014/:$readableName ClassBody:/
1015
1016EnterAnonymousClassBody ::= $empty
1017/.$putCase consumeEnterAnonymousClassBody(); $break ./
1018/:$readableName EnterAnonymousClassBody:/
1019
1020ArgumentList ::= Expression
1021ArgumentList ::= ArgumentList ',' Expression
1022/.$putCase consumeArgumentList(); $break ./
1023/:$readableName ArgumentList:/
1024
1025ArrayCreationHeader ::= 'new' PrimitiveType DimWithOrWithOutExprs
1026/.$putCase consumeArrayCreationHeader(); $break ./
1027
1028ArrayCreationHeader ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs
1029/.$putCase consumeArrayCreationHeader(); $break ./
1030/:$readableName ArrayCreationHeader:/
1031
1032ArrayCreationWithoutArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs
1033/.$putCase consumeArrayCreationExpressionWithoutInitializer(); $break ./
1034/:$readableName ArrayCreationWithoutArrayInitializer:/
1035
1036ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
1037/.$putCase consumeArrayCreationExpressionWithInitializer(); $break ./
1038/:$readableName ArrayCreationWithArrayInitializer:/
1039
1040ArrayCreationWithoutArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs
1041/.$putCase consumeArrayCreationExpressionWithoutInitializer(); $break ./
1042
1043ArrayCreationWithArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializer
1044/.$putCase consumeArrayCreationExpressionWithInitializer(); $break ./
1045
1046DimWithOrWithOutExprs ::= DimWithOrWithOutExpr
1047DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr
1048/.$putCase consumeDimWithOrWithOutExprs(); $break ./
1049/:$readableName Dimensions:/
1050
1051DimWithOrWithOutExpr ::= '[' Expression ']'
1052DimWithOrWithOutExpr ::= '[' ']'
1053/. $putCase consumeDimWithOrWithOutExpr(); $break ./
1054/:$readableName Dimension:/
1055-- -----------------------------------------------
1056
1057Dims ::= DimsLoop
1058/. $putCase consumeDims(); $break ./
1059/:$readableName Dimensions:/
1060DimsLoop -> OneDimLoop
1061DimsLoop ::= DimsLoop OneDimLoop
1062/:$readableName Dimensions:/
1063OneDimLoop ::= '[' ']'
1064/. $putCase consumeOneDimLoop(); $break ./
1065/:$readableName Dimension:/
1066
1067FieldAccess ::= Primary '.' 'Identifier'
1068/.$putCase consumeFieldAccess(false); $break ./
1069
1070FieldAccess ::= 'super' '.' 'Identifier'
1071/.$putCase consumeFieldAccess(true); $break ./
1072/:$readableName FieldAccess:/
1073
1074MethodInvocation ::= Name '(' ArgumentListopt ')'
1075/.$putCase consumeMethodInvocationName(); $break ./
1076
1077MethodInvocation ::= Primary '.' 'Identifier' '(' ArgumentListopt ')'
1078/.$putCase consumeMethodInvocationPrimary(); $break ./
1079
1080MethodInvocation ::= 'super' '.' 'Identifier' '(' ArgumentListopt ')'
1081/.$putCase consumeMethodInvocationSuper(); $break ./
1082/:$readableName MethodInvocation:/
1083
1084ArrayAccess ::= Name '[' Expression ']'
1085/.$putCase consumeArrayAccess(true); $break ./
1086ArrayAccess ::= PrimaryNoNewArray '[' Expression ']'
1087/.$putCase consumeArrayAccess(false); $break ./
1088ArrayAccess ::= ArrayCreationWithArrayInitializer '[' Expression ']'
1089/.$putCase consumeArrayAccess(false); $break ./
1090/:$readableName ArrayAccess:/
1091
1092PostfixExpression -> Primary
1093PostfixExpression ::= Name
1094/.$putCase consumePostfixExpression(); $break ./
1095PostfixExpression -> PostIncrementExpression
1096PostfixExpression -> PostDecrementExpression
1097/:$readableName Expression:/
1098
1099PostIncrementExpression ::= PostfixExpression '++'
1100/.$putCase consumeUnaryExpression(OperatorIds.PLUS,true); $break ./
1101/:$readableName PostIncrementExpression:/
1102
1103PostDecrementExpression ::= PostfixExpression '--'
1104/.$putCase consumeUnaryExpression(OperatorIds.MINUS,true); $break ./
1105/:$readableName PostDecrementExpression:/
1106
1107--for source managment purpose
1108PushPosition ::= $empty
1109 /.$putCase consumePushPosition(); $break ./
1110/:$readableName PushPosition:/
1111
1112UnaryExpression -> PreIncrementExpression
1113UnaryExpression -> PreDecrementExpression
1114UnaryExpression ::= '+' PushPosition UnaryExpression
1115/.$putCase consumeUnaryExpression(OperatorIds.PLUS); $break ./
1116UnaryExpression ::= '-' PushPosition UnaryExpression
1117/.$putCase consumeUnaryExpression(OperatorIds.MINUS); $break ./
1118UnaryExpression -> UnaryExpressionNotPlusMinus
1119/:$readableName Expression:/
1120
1121PreIncrementExpression ::= '++' PushPosition UnaryExpression
1122/.$putCase consumeUnaryExpression(OperatorIds.PLUS,false); $break ./
1123/:$readableName PreIncrementExpression:/
1124
1125PreDecrementExpression ::= '--' PushPosition UnaryExpression
1126/.$putCase consumeUnaryExpression(OperatorIds.MINUS,false); $break ./
1127/:$readableName PreDecrementExpression:/
1128
1129UnaryExpressionNotPlusMinus -> PostfixExpression
1130UnaryExpressionNotPlusMinus ::= '~' PushPosition UnaryExpression
1131/.$putCase consumeUnaryExpression(OperatorIds.TWIDDLE); $break ./
1132UnaryExpressionNotPlusMinus ::= '!' PushPosition UnaryExpression
1133/.$putCase consumeUnaryExpression(OperatorIds.NOT); $break ./
1134UnaryExpressionNotPlusMinus -> CastExpression
1135/:$readableName Expression:/
1136
1137CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN InsideCastExpression UnaryExpression
1138/.$putCase consumeCastExpression(); $break ./
1139 CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
1140/.$putCase consumeCastExpression(); $break ./
1141-- Expression is here only in order to make the grammar LL1
1142CastExpression ::= PushLPAREN Expression PushRPAREN InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
1143/.$putCase consumeCastExpressionLL1(); $break ./
1144/:$readableName CastExpression:/
1145
1146InsideCastExpression ::= $empty
1147/.$putCase consumeInsideCastExpression(); $break ./
1148/:$readableName InsideCastExpression:/
1149InsideCastExpressionLL1 ::= $empty
1150/.$putCase consumeInsideCastExpressionLL1(); $break ./
1151/:$readableName InsideCastExpression:/
1152
1153MultiplicativeExpression -> UnaryExpression
1154MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression
1155/.$putCase consumeBinaryExpression(OperatorIds.MULTIPLY); $break ./
1156MultiplicativeExpression ::= MultiplicativeExpression '/' UnaryExpression
1157/.$putCase consumeBinaryExpression(OperatorIds.DIVIDE); $break ./
1158MultiplicativeExpression ::= MultiplicativeExpression '%' UnaryExpression
1159/.$putCase consumeBinaryExpression(OperatorIds.REMAINDER); $break ./
1160/:$readableName Expression:/
1161
1162AdditiveExpression -> MultiplicativeExpression
1163AdditiveExpression ::= AdditiveExpression '+' MultiplicativeExpression
1164/.$putCase consumeBinaryExpression(OperatorIds.PLUS); $break ./
1165AdditiveExpression ::= AdditiveExpression '-' MultiplicativeExpression
1166/.$putCase consumeBinaryExpression(OperatorIds.MINUS); $break ./
1167/:$readableName Expression:/
1168
1169ShiftExpression -> AdditiveExpression
1170ShiftExpression ::= ShiftExpression '<<' AdditiveExpression
1171/.$putCase consumeBinaryExpression(OperatorIds.LEFT_SHIFT); $break ./
1172ShiftExpression ::= ShiftExpression '>>' AdditiveExpression
1173/.$putCase consumeBinaryExpression(OperatorIds.RIGHT_SHIFT); $break ./
1174ShiftExpression ::= ShiftExpression '>>>' AdditiveExpression
1175/.$putCase consumeBinaryExpression(OperatorIds.UNSIGNED_RIGHT_SHIFT); $break ./
1176/:$readableName Expression:/
1177
1178RelationalExpression -> ShiftExpression
1179RelationalExpression ::= RelationalExpression '<' ShiftExpression
1180/.$putCase consumeBinaryExpression(OperatorIds.LESS); $break ./
1181RelationalExpression ::= RelationalExpression '>' ShiftExpression
1182/.$putCase consumeBinaryExpression(OperatorIds.GREATER); $break ./
1183RelationalExpression ::= RelationalExpression '<=' ShiftExpression
1184/.$putCase consumeBinaryExpression(OperatorIds.LESS_EQUAL); $break ./
1185RelationalExpression ::= RelationalExpression '>=' ShiftExpression
1186/.$putCase consumeBinaryExpression(OperatorIds.GREATER_EQUAL); $break ./
1187RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType
1188/.$putCase consumeInstanceOfExpression(OperatorIds.INSTANCEOF); $break ./
1189/:$readableName Expression:/
1190
1191EqualityExpression -> RelationalExpression
1192EqualityExpression ::= EqualityExpression '==' RelationalExpression
1193/.$putCase consumeEqualityExpression(OperatorIds.EQUAL_EQUAL); $break ./
1194EqualityExpression ::= EqualityExpression '!=' RelationalExpression
1195/.$putCase consumeEqualityExpression(OperatorIds.NOT_EQUAL); $break ./
1196/:$readableName Expression:/
1197
1198AndExpression -> EqualityExpression
1199AndExpression ::= AndExpression '&' EqualityExpression
1200/.$putCase consumeBinaryExpression(OperatorIds.AND); $break ./
1201/:$readableName Expression:/
1202
1203ExclusiveOrExpression -> AndExpression
1204ExclusiveOrExpression ::= ExclusiveOrExpression '^' AndExpression
1205/.$putCase consumeBinaryExpression(OperatorIds.XOR); $break ./
1206/:$readableName Expression:/
1207
1208InclusiveOrExpression -> ExclusiveOrExpression
1209InclusiveOrExpression ::= InclusiveOrExpression '|' ExclusiveOrExpression
1210/.$putCase consumeBinaryExpression(OperatorIds.OR); $break ./
1211/:$readableName Expression:/
1212
1213ConditionalAndExpression -> InclusiveOrExpression
1214ConditionalAndExpression ::= ConditionalAndExpression '&&' InclusiveOrExpression
1215/.$putCase consumeBinaryExpression(OperatorIds.AND_AND); $break ./
1216/:$readableName Expression:/
1217
1218ConditionalOrExpression -> ConditionalAndExpression
1219ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpression
1220/.$putCase consumeBinaryExpression(OperatorIds.OR_OR); $break ./
1221/:$readableName Expression:/
1222
1223ConditionalExpression -> ConditionalOrExpression
1224ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression
1225/.$putCase consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ; $break ./
1226/:$readableName Expression:/
1227
1228AssignmentExpression -> ConditionalExpression
1229AssignmentExpression -> Assignment
1230/:$readableName Expression:/
1231
1232Assignment ::= PostfixExpression AssignmentOperator AssignmentExpression
1233/.$putCase consumeAssignment(); $break ./
1234/:$readableName Assignment:/
1235
1236-- this rule is added to parse an array initializer in a assigment and then report a syntax error knowing the exact senario
1237InvalidArrayInitializerAssignement ::= PostfixExpression AssignmentOperator ArrayInitializer
1238/:$readableName ArrayInitializerAssignement:/
1239Assignment ::= InvalidArrayInitializerAssignement
1240/.$putcase ignoreExpressionAssignment();$break ./
1241
1242AssignmentOperator ::= '='
1243/.$putCase consumeAssignmentOperator(EQUAL); $break ./
1244AssignmentOperator ::= '*='
1245/.$putCase consumeAssignmentOperator(MULTIPLY); $break ./
1246AssignmentOperator ::= '/='
1247/.$putCase consumeAssignmentOperator(DIVIDE); $break ./
1248AssignmentOperator ::= '%='
1249/.$putCase consumeAssignmentOperator(REMAINDER); $break ./
1250AssignmentOperator ::= '+='
1251/.$putCase consumeAssignmentOperator(PLUS); $break ./
1252AssignmentOperator ::= '-='
1253/.$putCase consumeAssignmentOperator(MINUS); $break ./
1254AssignmentOperator ::= '<<='
1255/.$putCase consumeAssignmentOperator(LEFT_SHIFT); $break ./
1256AssignmentOperator ::= '>>='
1257/.$putCase consumeAssignmentOperator(RIGHT_SHIFT); $break ./
1258AssignmentOperator ::= '>>>='
1259/.$putCase consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT); $break ./
1260AssignmentOperator ::= '&='
1261/.$putCase consumeAssignmentOperator(AND); $break ./
1262AssignmentOperator ::= '^='
1263/.$putCase consumeAssignmentOperator(XOR); $break ./
1264AssignmentOperator ::= '|='
1265/.$putCase consumeAssignmentOperator(OR); $break ./
1266/:$readableName AssignmentOperator:/
1267
1268Expression -> AssignmentExpression
1269/:$readableName Expression:/
1270
1271ConstantExpression -> Expression
1272/:$readableName ConstantExpression:/
1273
1274-- The following rules are for optional nonterminals.
1275--
1276
1277PackageDeclarationopt -> $empty
1278PackageDeclarationopt -> PackageDeclaration
1279/:$readableName PackageDeclaration:/
1280
1281ClassHeaderExtendsopt ::= $empty
1282ClassHeaderExtendsopt -> ClassHeaderExtends
1283/:$readableName ClassHeaderExtends:/
1284
1285Expressionopt ::= $empty
1286/.$putCase consumeEmptyExpression(); $break ./
1287Expressionopt -> Expression
1288/:$readableName Expression:/
1289
1290
1291---------------------------------------------------------------------------------------
1292--
1293-- The rules below are for optional terminal symbols. An optional comma,
1294-- is only used in the context of an array initializer - It is a
1295-- "syntactic sugar" that otherwise serves no other purpose. By contrast,
1296-- an optional identifier is used in the definition of a break and
1297-- continue statement. When the identifier does not appear, a NULL
1298-- is produced. When the identifier is present, the user should use the
1299-- corresponding TOKEN(i) method. See break statement as an example.
1300--
1301---------------------------------------------------------------------------------------
1302
1303,opt -> $empty
1304,opt -> ,
1305/:$readableName ,:/
1306
1307ImportDeclarationsopt ::= $empty
1308/.$putCase consumeEmptyImportDeclarationsopt(); $break ./
1309ImportDeclarationsopt ::= ImportDeclarations
1310/.$putCase consumeImportDeclarationsopt(); $break ./
1311/:$readableName ImportDeclarations:/
1312
1313TypeDeclarationsopt ::= $empty
1314/.$putCase consumeEmptyTypeDeclarationsopt(); $break ./
1315TypeDeclarationsopt ::= TypeDeclarations
1316/.$putCase consumeTypeDeclarationsopt(); $break ./
1317/:$readableName TypeDeclarations:/
1318
1319ClassBodyDeclarationsopt ::= $empty
1320/.$putCase consumeEmptyClassBodyDeclarationsopt(); $break ./
1321ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations
1322/.$putCase consumeClassBodyDeclarationsopt(); $break ./
1323/:$readableName ClassBodyDeclarations:/
1324
1325Modifiersopt ::= $empty
1326/. $putCase consumeDefaultModifiers(); $break ./
1327Modifiersopt ::= Modifiers
1328/.$putCase consumeModifiers(); $break ./
1329/:$readableName Modifiers:/
1330
1331BlockStatementsopt ::= $empty
1332/.$putCase consumeEmptyBlockStatementsopt(); $break ./
1333BlockStatementsopt -> BlockStatements
1334/:$readableName BlockStatements:/
1335
1336Dimsopt ::= $empty
1337/. $putCase consumeEmptyDimsopt(); $break ./
1338Dimsopt -> Dims
1339/:$readableName Dimensions:/
1340
1341ArgumentListopt ::= $empty
1342/. $putCase consumeEmptyArgumentListopt(); $break ./
1343ArgumentListopt -> ArgumentList
1344/:$readableName ArgumentList:/
1345
1346MethodHeaderThrowsClauseopt ::= $empty
1347MethodHeaderThrowsClauseopt -> MethodHeaderThrowsClause
1348/:$readableName MethodHeaderThrowsClause:/
1349
1350FormalParameterListopt ::= $empty
1351/.$putcase consumeFormalParameterListopt(); $break ./
1352FormalParameterListopt -> FormalParameterList
1353/:$readableName FormalParameterList:/
1354
1355ClassHeaderImplementsopt ::= $empty
1356ClassHeaderImplementsopt -> ClassHeaderImplements
1357/:$readableName ClassHeaderImplements:/
1358
1359InterfaceMemberDeclarationsopt ::= $empty
1360/. $putCase consumeEmptyInterfaceMemberDeclarationsopt(); $break ./
1361InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations
1362/. $putCase consumeInterfaceMemberDeclarationsopt(); $break ./
1363/:$readableName InterfaceMemberDeclarations:/
1364
1365NestedType ::= $empty
1366/.$putCase consumeNestedType(); $break./
1367/:$readableName NestedType:/
1368
1369ForInitopt ::= $empty
1370/. $putCase consumeEmptyForInitopt(); $break ./
1371ForInitopt -> ForInit
1372/:$readableName ForInit:/
1373
1374ForUpdateopt ::= $empty
1375/. $putCase consumeEmptyForUpdateopt(); $break ./
1376ForUpdateopt -> ForUpdate
1377/:$readableName ForUpdate:/
1378
1379InterfaceHeaderExtendsopt ::= $empty
1380InterfaceHeaderExtendsopt -> InterfaceHeaderExtends
1381/:$readableName InterfaceHeaderExtends:/
1382
1383Catchesopt ::= $empty
1384/. $putCase consumeEmptyCatchesopt(); $break ./
1385Catchesopt -> Catches
1386/:$readableName Catches:/
1387
1388/. }
1389} ./
1390
1391---------------------------------------------------------------------------------------
1392
1393$names
1394
1395-- BodyMarker ::= '"class Identifier { ... MethodHeader "'
1396
1397-- void ::= 'void'
1398
1399PLUS_PLUS ::= '++'
1400MINUS_MINUS ::= '--'
1401EQUAL_EQUAL ::= '=='
1402LESS_EQUAL ::= '<='
1403GREATER_EQUAL ::= '>='
1404NOT_EQUAL ::= '!='
1405LEFT_SHIFT ::= '<<'
1406RIGHT_SHIFT ::= '>>'
1407UNSIGNED_RIGHT_SHIFT ::= '>>>'
1408PLUS_EQUAL ::= '+='
1409MINUS_EQUAL ::= '-='
1410MULTIPLY_EQUAL ::= '*='
1411DIVIDE_EQUAL ::= '/='
1412AND_EQUAL ::= '&='
1413OR_EQUAL ::= '|='
1414XOR_EQUAL ::= '^='
1415REMAINDER_EQUAL ::= '%='
1416LEFT_SHIFT_EQUAL ::= '<<='
1417RIGHT_SHIFT_EQUAL ::= '>>='
1418UNSIGNED_RIGHT_SHIFT_EQUAL ::= '>>>='
1419OR_OR ::= '||'
1420AND_AND ::= '&&'
1421
1422PLUS ::= '+'
1423MINUS ::= '-'
1424NOT ::= '!'
1425REMAINDER ::= '%'
1426XOR ::= '^'
1427AND ::= '&'
1428MULTIPLY ::= '*'
1429OR ::= '|'
1430TWIDDLE ::= '~'
1431DIVIDE ::= '/'
1432GREATER ::= '>'
1433LESS ::= '<'
1434LPAREN ::= '('
1435RPAREN ::= ')'
1436LBRACE ::= '{'
1437RBRACE ::= '}'
1438LBRACKET ::= '['
1439RBRACKET ::= ']'
1440SEMICOLON ::= ';'
1441QUESTION ::= '?'
1442COLON ::= ':'
1443COMMA ::= ','
1444DOT ::= '.'
1445EQUAL ::= '='
1446
1447$end
1448-- need a carriage return after the $end