@@ -35,63 +35,61 @@ abstract syntax description language (ASDL) as follows:
3535
3636module Java
3737{
38- mod = CompilationUnit(Package? package, Import* imports, declaration* types )
39- | ModularUnit(Import* imports, Module types )
38+ mod = CompilationUnit(Package? package, Import* imports, declaration* body )
39+ | ModularUnit(Import* imports, Module body )
4040
4141 declaration = EmptyDecl()
4242 | Package(Annotation* annotations, qname name)
43- | Import(Annotation* annotations, bool static, qname name, bool on_demand)
44- | Module(bool open, qname name, directive* directives)
45- | Field(modifier* modifiers, jtype type, declarator* declarators)
46- | Method(modifier* modifiers, typeparams? type_params, Annotation* annotations, jtype return_type,
47- identifier id, params parameters, dim* dims, qname* throws, Block? body)
48- | Constructor(modifier* modifiers, typeparams? type_params, identifier id, params? parameters, Block? body)
43+ | Import(bool? static, qname name, bool? on_demand)
44+ | Module(bool? open, qname name, directive* directives)
45+ | Field(modifier* modifiers, jtype type, declarator+ declarators)
46+ | Method(modifier* modifiers, typeparams? type_params, Annotation* annotations,
47+ jtype return_type, identifier id, params? parameters, dim* dims,
48+ qname* throws, Block? body)
49+ | Constructor(modifier* modifiers, typeparams? type_params, identifier id,
50+ params? parameters, Block body)
4951 | AnnotationMethod(modifier* modifiers, jtype type, identifier id,
5052 (elementarrayinit | Annotation | expr)? default_value)
51- | Initializer(bool static, Block body )
52- | Class(modifier* modifiers, identifier id, typeparams? type_params, jtype? extends, jtype* implements,
53- jtype* permits, declaration* body)
54- | Enum(modifier* modifiers, identifier id, jtype* implements, enumconstant* constants,
55- declaration* body)
56- | Interface(modifier* modifiers, identifier id, typeparams? type_params, jtype* extends, jtype* permits,
57- declaration* body)
58- | AnnotationDecl(modifier* modifiers, identifier id, jtype* extends, jtype* permits, declaration* body)
59- | Record(modifier* modifiers, identifier id, typeparams? type_params, recordcomponent* components,
60- jtype* implements , jtype* permits , declaration* body)
53+ | Initializer(Block body, bool? static )
54+ | Class(modifier* modifiers, identifier id, typeparams? type_params,
55+ jtype? extends, jtype* implements, jtype * permits, declaration* body)
56+ | Enum(modifier* modifiers, identifier id, jtype* implements,
57+ enumconstant* constants, declaration* body)
58+ | Interface(modifier* modifiers, identifier id, typeparams? type_params,
59+ jtype? extends, jtype* implements, declaration* body)
60+ | AnnotationDecl(modifier* modifiers, identifier id, declaration* body)
61+ | Record(modifier* modifiers, identifier id, typeparams? type_params,
62+ recordcomponent* components , jtype* implements , declaration* body)
6163 attributes (int lineno, int col_offset, int end_lineno, int end_col_offset)
6264
6365 directive = Requires(modifier* modifiers, qname name)
64- | Exports(modifier* modifiers, qname name, qname to)
65- | Opens(modifier* modifiers, qname name, qname to)
66- | Uses(modifier* modifiers, qname name)
67- | Provides(modifier* modifiers, qname name, qname with_)
66+ | Exports(qname name, qname to)
67+ | Opens(qname name, qname to)
68+ | Uses(qname name)
69+ | Provides(qname name, qname with_)
6870 attributes (int lineno, int col_offset, int end_lineno, int end_col_offset)
6971
7072 stmt = Empty()
7173 | Block(stmt* body)
7274 | Compound(stmt* body)
7375
74- | LocalClass(Class decl)
75- | LocalInterface(Interface decl)
76- | LocalRecord(Record decl)
77- | LocalVariable(modifier* modifiers, jtype type, declarator* variables)
76+ | LocalType((Class | Interface | Record) decl)
77+ | LocalVariable(modifier* modifiers, jtype type, declarator+ variables)
7878
7979 | Labeled(identifier label, stmt body)
8080
8181 | If(expr test, stmt body, stmt? orelse)
8282 | Switch(expr value, switchblock body)
8383 | While(expr test, stmt body)
8484 | DoWhile(stmt body, expr test)
85- | For((expr* | LocalVariable)? init, expr? test, expr* update, stmt body)
86- | ForEach(modifier* modifiers, jtype type, identifier id, expr iter, stmt body)
85+ | For((expr* | LocalVariable?) init, expr? test, expr* update, stmt body)
86+ | ForEach(modifier* modifiers, jtype type,
87+ identifier id, expr iter, stmt body)
8788 | Try(Block body, catch* catches, Block? final)
88- | TryWithResources(Block body,
89- (resource | qname)* resources,
90- catch* catches,
91- Block? final)
92-
89+ | TryWithResources((resource | qname)+ resources,
90+ Block body, catch* catches, Block? final)
9391 | Assert(expr test, expr? msg)
94- | Throw(expr value )
92+ | Throw(expr exc )
9593 | Expression(expr value)
9694 | Return(expr? value)
9795 | Yield(expr value)
@@ -112,82 +110,87 @@ module Java
112110 | NewArray(jtype type, expr* expr_dims, dim* dims, arrayinit? initializer)
113111 | SwitchExp(expr value, switchexprule* rules)
114112 | This()
115- | Super(typeargs? type_args. identifier? id)
113+ | Super(typeargs? type_args, identifier? id)
116114 | Constant(literal value)
117115 | Name(identifier id)
118116 | ClassExpr(jtype type)
119117 | ExplicitGenericInvocation(typeargs? type_args, expr value)
120118 | Subscript(expr value, expr index)
121119 | Member(expr value, expr member)
122120 | Call(expr func, expr* args)
123- | Reference((expr | jtype )type, typeargs? type_args, identifier id, bool new)
121+ | Reference((expr | jtype ) type, typeargs? type_args, identifier? id, bool? new)
124122 | Match(jtype type, identifier id)
125123 attributes (int lineno, int col_offset, int end_lineno, int end_col_offset)
126124
127- operator = Or() | And() | BitOr() | BitXor() | BitAnd() | Eq() | NotEq() | Lt() | LtE() | Gt() | GtE()
128- | LShift() | RShift() | URShift() | Add() | Sub() | Mult() | Div() | Mod()
125+ operator = Or() | And() | BitOr() | BitXor() | BitAnd() | Eq() | NotEq()
126+ | Lt() | LtE() | Gt() | GtE() | LShift() | RShift() | URShift()
127+ | Add() | Sub() | Mult() | Div() | Mod()
129128
130129 unaryop = PreInc() | PreDec() | UAdd() | USub() | Invert() | Not()
131130
132131 postop = PostInc() | PostDec()
133132
134- enumconstant = (Annotation* annotations, identifier id, expr* arguments, Block? body)
133+ enumconstant = (Annotation* annotations, identifier id, expr* args, declaration* body)
135134
136135 recordcomponent = (jtype type, identifier id)
137136
138- switchlabel = Case(expr value ) | DefaultCase()
139- switchgroup = (switchlabel* labels, stmt* statements )
137+ switchlabel = Case(expr guard ) | DefaultCase()
138+ switchgroup = (switchlabel* labels, stmt* body )
140139 switchblock = (switchgroup* groups, switchlabel* labels)
141140
142- catch = (modifier* modifiers, qname* excs, identifier id, Block body)
141+ catch = (modifier* modifiers, qname+ excs, identifier id, Block body)
143142
144143 resource = (modifier* modifiers, jtype type, declarator variable)
145144
146145 switchexplabel = ExpCase() | ExpDefault()
147- switchexprule = (switchexplabel label, (expr | guardedpattern)* cases, bool arrow, stmt* body)
146+ switchexprule = (switchexplabel label, (expr | guardedpattern)* cases,
147+ bool arrow, stmt* body)
148148
149149 arrayinit = ((expr | arrayinit)* values)
150150
151151 receiver = (jtype type, identifier* identifiers)
152152 param = (modifier* modifiers, jtype type, variabledeclaratorid id)
153153 arity = (modifier* modifiers, jtype type, Annotation* annotations, variabledeclaratorid id)
154- params = (receiver receiver_param, (param | arity)* parameters)
154+ params = (receiver? receiver_param, (param | arity)* parameters)
155155
156- literal = IntLiteral(int value, bool long) | FloatLiteral(float value, bool double) | BoolLiteral(bool value)
157- | CharLiteral(char value) | StringLiteral(string value) | TextBlock(string value) | NullLiteral()
156+ literal = IntLiteral(int value, bool? long) | FloatLiteral(float value, bool? double)
157+ | BoolLiteral(bool value) | CharLiteral(char value) | StringLiteral(string value)
158+ | TextBlock(string* value) | NullLiteral()
158159
159- modifier = Abstract() | Default() | Final() | Native() | NonSealed() | Private() | Protected()
160- | Public() | Sealed() | Static() | Strictfp() | Synchronized() | Transient() | Transitive() | Volatile()
160+ modifier = Abstract() | Default() | Final() | Native() | NonSealed() | Private()
161+ | Protected() | Public() | Sealed() | Static() | Strictfp() | Synchronized()
162+ | Transient() | Transitive() | Volatile()
161163 | Annotation(qname name, (elementvaluepair | elementarrayinit | Annotation | expr)* elements)
162164
163165
164166 elementvaluepair = (identifier id, (elementarrayinit | Annotation | expr) value)
165167 elementarrayinit = ((elementarrayinit | Annotation | expr)* values)
166168
167- jtype = Void() | Var() | Boolean() | Byte() | Short() | Int() | Long() | Char() | Float() | Double()
169+ jtype = Void() | Var() | Boolean() | Byte() | Short()
170+ | Int() | Long() | Char() | Float() | Double()
168171 | Wildcard(Annotation* annotations, wildcardbound? bound)
169172 | Coit(Annotation* annotations, identifier id, typeargs? type_args)
170173 | ClassType(Annotation* annotations, Coit+ coits)
171174 | ArrayType(Annotation* annotations, jtype type, dim* dims)
172175
173176
174- wildcardbound = (jtype type, bool extends, bool super_)
177+ wildcardbound = (jtype type, bool? extends, bool? super_)
175178
176- typeargs = (jtype* types)
179+ typeargs = (jtype+ types)
177180
178181 dim = (Annotation* annotations)
179182
180183 variabledeclaratorid = (identifier id, dim* dims)
181- declarator = (variabledeclaratorid id, expr? value )
184+ declarator = (variabledeclaratorid id, expr? init )
182185
183- typebound = (Annotation* annotations, jtype* types)
186+ typebound = (Annotation* annotations, jtype+ types)
184187 typeparam = (Annotation* annotations, identifier id, typebound? bound)
185- typeparams = (typeparam* params )
188+ typeparams = (typeparam* parameters )
186189
187190 pattern = (modifier* modifiers, jtype type, Annotation* annotations, identifier id)
188- guardedpattern = (pattern pattern , expr* conditions)
191+ guardedpattern = (pattern value , expr* conditions)
189192
190- qname = (identifier* identifiers)
193+ qname = (identifier+ identifiers)
191194}
192195```
193196
0 commit comments