parser: accepts more optional \n
[nit.git] / src / parser / nit.sablecc3xx
1
2 /* This file is part of NIT ( http://www.nitlanguage.org ).
3  *
4  * Copyright 2008-2009 Jean Privat <jean@pryen.org>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 /* This grammar defines the NIT language. */
20 Package org.nitlanguage.gen;
21
22 /*****************************************************************************/
23 Helpers
24 /*****************************************************************************/
25
26 all = [0 .. 0xFF];
27 lowercase = ['a' .. 'z'];
28 uppercase = ['A' .. 'Z'];
29 digit = ['0' .. '9'];
30 letter = lowercase | uppercase | digit | '_';
31
32 tab = 9;
33 cr = 13;
34 lf = 10;
35 any = [all - [cr + lf]];
36 eol_helper = cr lf | cr | lf; // This takes care of different platforms
37
38 // characers inside strings and super-strings (atomaton powaa)
39 str_char
40         = [any - [['"' + '{'] + '\']] 
41         | '\' any 
42         ;
43 str_body = str_char*;
44
45 sstr_char
46         = [any - [''' + '\']]
47         | '\' any
48         ;
49
50 sstr_body = sstr_char*;
51
52 long_str_char = str_char | cr | lf;
53
54 long_str_part
55         = long_str_char
56         | '"' long_str_char
57         | '"' '"' long_str_char
58         | '{' long_str_char
59         | '{' '{' long_str_char
60         ;
61
62 long_str_body = long_str_part*;
63
64 long_sstr_char = sstr_char | cr | lf;
65 long_sstr_part
66         = long_sstr_char
67         | ''' long_sstr_char
68         | ''' ''' long_sstr_char
69         ;
70
71 long_sstr_body = long_sstr_part*;
72
73
74 extern_code_char
75         = [all - ['`' + '\']]
76         | '\' all
77         ;
78 extern_code_body = extern_code_char*;
79
80 /*****************************************************************************/
81 States
82 /*****************************************************************************/
83 initial;
84
85
86 /*****************************************************************************/
87 Tokens
88 /*****************************************************************************/
89
90 blank = (' ' | tab)+;
91
92 eol = eol_helper;
93 comment = '#' any* eol_helper?;
94
95 kwmodule = 'package'|'module';
96 kwimport = 'import';
97 kwclass = 'class';
98 kwabstract = 'abstract';
99 kwinterface = 'interface';
100 kwenum = 'universal'|'enum';
101 kwend = 'end';
102 kwmeth = 'fun';
103 kwtype = 'type';
104 kwinit = 'init';
105 kwredef = 'redef';
106 kwis = 'is';
107 kwdo = 'do';
108 kwreadable = 'readable';
109 kwwritable = 'writable';
110 kwvar = 'var';
111 kwintern = 'intern';
112 kwextern = 'extern';
113 kwprotected = 'protected';
114 kwprivate = 'private';
115 kwintrude = 'intrude';
116 kwif = 'if';
117 kwthen = 'then';
118 kwelse = 'else';
119 kwwhile = 'while';
120 kwloop = 'loop';
121 kwfor = 'for';
122 kwin = 'in';
123 kwand = 'and';
124 kwor = 'or';
125 kwnot = 'not';
126 kwreturn = 'return';
127 kwcontinue = 'continue';
128 kwbreak = 'break';
129 kwabort = 'abort';
130 kwassert = 'assert';
131 kwnew = 'new';
132 kwisa = 'isa';
133 kwonce = 'once';
134 kwsuper = 'super';
135 kwself = 'self';
136 kwtrue = 'true';
137 kwfalse = 'false';
138 kwnull = 'null';
139 kwas = 'as';
140 kwnullable = 'nullable';
141 kwisset = 'isset';
142 kwlabel = 'label';
143 kwdebug = '__debug__';
144
145 opar = '(';
146 cpar = ')';
147 obra = '[';
148 cbra = ']';
149 comma = ',';
150 column = ':';
151 quad = '::';
152 assign = '=';
153 pluseq = '+=';
154 minuseq = '-=';
155 dotdotdot = '...';
156 dotdot = '..';
157 dot = '.';
158 plus = '+';
159 minus = '-';
160 star = '*';
161 slash = '/';
162 percent = '%';
163 eq = '==';
164 ne = '!=';
165 lt = '<';
166 le = '<=';
167 ll = '<<';
168 gt = '>';
169 ge = '>=';
170 gg = '>>';
171 starship = '<=>';
172 bang='!';
173 at='@';
174
175 classid = uppercase letter*;
176 id = lowercase letter*;
177 attrid = '_' lowercase letter*;
178
179 number = digit+;
180 float = digit* '.' digit+;
181 string = '"' str_body '"' | '"' '"' '"' long_str_body '"' '"' '"' | ''' ''' ''' long_sstr_body ''' ''' ''';
182 start_string = '"' str_body '{' | '"' '"' '"' long_str_body '{' '{' '{';
183 mid_string = '}' str_body '{' | '}' '}' '}' long_str_body '{' '{' '{';
184 end_string = '}' str_body '"' | '}' '}' '}' long_str_body '"' '"' '"';
185 char = (''' [[any - '''] - '\'] ''') | (''' '\' any ''');
186 bad_string = ('"'|'}') str_body | '"' '"' '"' long_str_body | ''' ''' ''' long_sstr_body;
187 bad_char = ''' '\'? any;
188
189 extern_code_segment = '`' '{' extern_code_body '`' '}';
190
191 /*****************************************************************************/
192 Ignored Tokens
193 /*****************************************************************************/
194
195 blank;
196
197 /*****************************************************************************/
198 Productions
199 /*****************************************************************************/
200
201 /* MODULES *******************************************************************/
202 module
203         = moduledecl? [imports]:import* [extern_bodies]:extern_code_body* [classdefs]:classdef* implicit_top_class? implicit_main_class? {-> New module(moduledecl, [imports.import], [extern_bodies.extern_code_block], [classdefs.classdef,implicit_top_class.classdef,implicit_main_class.classdef])};
204
205 moduledecl
206         = [doc]:no kwmodule no module_name annotation_withend? [n2]:n1 {-> New moduledecl(doc.doc, kwmodule, module_name, annotation_withend.annotations)};
207
208 import
209         = {std} [doc]:no visibility kwimport no module_name annotation_withend? [n2]:n1 {-> New import.std(visibility, kwimport, module_name, annotation_withend.annotations)}
210         | {no} [doc]:no visibility kwimport no kwend [n2]:n1 {-> New import.no(visibility, kwimport, kwend)}
211         ;
212
213 implicit_top_class {-> classdef}
214         = propdefs_toplevel+ {-> New classdef.top([propdefs_toplevel.propdef])};
215
216 implicit_main_class {-> classdef?}
217         = implicit_main_meth {-> New classdef.main([implicit_main_meth.propdef])}
218         | {null} n {-> Null}
219         ;
220 implicit_main_meth {-> propdef}
221         = [doc]:no stmts {-> New propdef.main_meth(Null, stmts.expr)}
222         | {n} [doc]:no stmtsn {-> New propdef.main_meth(Null, stmtsn.expr)}
223         ;
224
225 /* CLASSES *******************************************************************/
226 classdef
227         = [doc]:no redef visibility classkind no classid formaldefs? line_annotations_forclass? extern_code_block? [superclasses]:superclass* propdefs* [n2]:no kwend {-> New classdef.std(doc.doc, redef.kwredef, visibility, classkind, classid, [formaldefs.formaldef], line_annotations_forclass.annotations, extern_code_block, [superclasses.superclass], [propdefs.propdef], kwend)};
228 redef {-> kwredef?}
229         = kwredef? {-> kwredef};
230 classkind
231         = {concrete} kwclass
232         | {abstract} kwabstract kwclass
233         | {interface} kwinterface
234         | {enum} kwenum
235         | {extern} kwextern kwclass?
236         ;
237
238 formaldefs {-> formaldef*}
239         = obra no formaldef formaldefs_tail* [n2]:no cbra {-> [formaldef, formaldefs_tail.formaldef]};
240 formaldefs_tail {-> formaldef}
241         = comma no formaldef {-> formaldef};
242 formaldef
243         = classid annotations? typing? {-> New formaldef(classid, typing.type, annotations)};
244
245 superclass {-> superclass}
246         = {super} no kwsuper [n2]:no type annotation_withend? {-> New superclass(kwsuper, type, annotation_withend.annotations)}
247         ;
248
249 propdefs~toplevel {-> propdef}
250         = propdef~toplevel n1 {-> propdef~toplevel.propdef}
251         ;
252 propdef~toplevel {-> propdef}
253         = {meth} [doc]:no redef visibility kwmeth methid signature annotation_noend? kwdo stmtso kwend? {-> New propdef.concrete_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature, annotation_noend.annotations, stmtso.expr)}
254         | {assign_return} [doc]:no redef visibility kwmeth methid signature_withret assign no assign_return {-> New propdef.concrete_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature_withret.signature, Null, assign_return.expr)}
255         | {nobody} [doc]:no redef visibility kwmeth methid signature annotation_withend {-> New propdef.deferred_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature, annotation_withend.annotations)}
256 !toplevel| {deferred} [doc]:no redef visibility kwmeth methid signature kwis kwabstract {-> New propdef.deferred_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature, Null)}
257 !toplevel| {intern} [doc]:no redef visibility kwmeth methid signature kwis kwintern {-> New propdef.intern_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature)}
258         | {extern} [doc]:no redef visibility kwmeth methid signature kwis kwextern string? extern_calls? extern_code_block? {-> New propdef.extern_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature, string, extern_calls, extern_code_block)}
259         | {extern_implicit} [doc]:no redef visibility kwmeth methid signature extern_calls? extern_code_block {-> New propdef.extern_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature, Null, extern_calls, extern_code_block)}
260 !toplevel| {var} [doc]:no readable? writable? redef visibility kwvar attrid typing? {-> New propdef.attr(doc.doc, readable.able, writable.able, redef.kwredef, visibility, kwvar, attrid, Null, typing.type, Null, Null)}
261 !toplevel| {var2} [doc]:no readable? writable? redef visibility kwvar attrid typing? assign [n2]:no expr {-> New propdef.attr(doc.doc, readable.able, writable.able, redef.kwredef, visibility, kwvar, attrid, Null, typing.type, Null, expr)}
262 !toplevel| {var3} [doc]:no redef visibility kwvar id typing? writable2? annotation_withend? {-> New propdef.attr(doc.doc, Null, writable2.able, redef.kwredef, visibility, kwvar, Null, id, typing.type, annotation_withend.annotations, Null)}
263 !toplevel| {var4} [doc]:no redef visibility kwvar id typing? writable2? assign [n2]:no expr_nois annotation_withend? {-> New propdef.attr(doc.doc, Null, writable2.able, redef.kwredef, visibility, kwvar, Null, id, typing.type, annotation_withend.annotations, expr_nois.expr)}
264 !toplevel| {init} [doc]:no redef visibility kwinit methid? signature annotation_noend? kwdo stmtso kwend? {-> New propdef.concrete_init(doc.doc, redef.kwredef, visibility, kwinit, methid, signature, annotation_noend.annotations, stmtso.expr)}
265 !toplevel| {type} [doc]:no redef visibility kwtype classid typing annotation_withend? {-> New propdef.type(doc.doc, redef.kwredef, visibility, kwtype, classid, typing.type, annotation_withend.annotations)}
266 !toplevel| {extern_init} [doc]:no redef visibility kwnew methid? signature kwis kwextern string? extern_calls? extern_code_block? {-> New propdef.extern_init(doc.doc, redef.kwredef, visibility, kwnew, methid, signature, string, extern_calls, extern_code_block)}
267 !toplevel| {extern_init_implicit} [doc]:no redef visibility kwnew methid? signature string? extern_calls? extern_code_block {-> New propdef.extern_init(doc.doc, redef.kwredef, visibility, kwnew, methid, signature, string, extern_calls, extern_code_block)}
268         ;
269 annotation_withend {-> annotations}
270         = {oneliner} kwis many_annotations {-> many_annotations.annotations}
271         | {more} kwis n1 line_annotations kwend {-> line_annotations.annotations}
272         ;
273 annotation_noend {-> annotations}
274         = {oneliner} kwis many_annotations {-> many_annotations.annotations}
275         | {more} kwis n1 line_annotations {-> line_annotations.annotations}
276         ;
277 readable {-> able}
278         = redef kwreadable {-> New able.read(redef.kwredef, kwreadable)}
279         ;
280 writable {-> able}
281         = redef kwwritable {-> New able.write(redef.kwredef, Null, kwwritable)}
282         ;
283 writable2 {-> able}
284         = redef visibility kwwritable {-> New able.write(redef.kwredef, visibility, kwwritable)}
285         ;
286
287 visibility
288         = {public} {-> New visibility.public()}
289         | {private} kwprivate no {-> New visibility.private(kwprivate)}
290         | {protected} kwprotected no {-> New visibility.protected(kwprotected)}
291         | {intrude} kwintrude no {-> New visibility.intrude(kwintrude)}
292         ;
293
294 methid {-> methid}
295         = {id} id {-> New methid.id(id)}
296         | {plus} plus {-> New methid.plus(plus)}
297         | {minus} minus {-> New methid.minus(minus)}
298         | {star} star {-> New methid.star(star)}
299         | {slash} slash {-> New methid.slash(slash)}
300         | {percent} percent {-> New methid.percent(percent)}
301         | {eq} eq {-> New methid.eq(eq)}
302         | {ne} ne {-> New methid.ne(ne)}
303         | {le} le {-> New methid.le(le)}
304         | {ge} ge {-> New methid.ge(ge)}
305         | {lt} lt {-> New methid.lt(lt)}
306         | {gt} gt {-> New methid.gt(gt)}
307         | {ll} ll {-> New methid.ll(ll)}
308         | {gg} gg {-> New methid.gg(gg)}
309         | {bra} obra cbra {-> New methid.bra(obra, cbra)}
310         | {starship} starship {-> New methid.starship(starship)}
311         | {assign} id assign {-> New methid.assign(id, assign)}
312         | {braassign} obra cbra assign {-> New methid.braassign(obra, cbra, assign)}
313         ;
314
315 signature~withret {-> signature}
316         = opar no params? cpar typing [no2]:no closure_decls? {-> New signature(opar, [params.param], cpar, typing.type, [closure_decls.closure_decl])}
317 !withret| {noret} opar no params? cpar [no2]:no closure_decls? {-> New signature(opar, [params.param], cpar, Null, [closure_decls.closure_decl])}
318         | {nopar} typing no closure_decls? {-> New signature(Null, [], Null, typing.type, [closure_decls.closure_decl])}
319 !withret| {noparnoret} no closure_decls? {-> New signature(Null, [], Null, Null, [closure_decls.closure_decl])}
320         ;
321
322 signature_noclosures {-> signature}
323         = opar no params? cpar typing? {-> New signature(opar, [params.param], cpar, typing.type, [])}
324         | {nopar} typing? {-> New signature(Null, [], Null, typing.type, [])}
325         ;
326
327 params {-> param*} 
328         = param params_tail* [n2]:no {-> [param, params_tail.param] }
329         ;
330 params_tail {-> param}
331         = comma no param {-> param};
332 param
333         = {untyped} id annotations? {-> New param(id, Null, Null, annotations)}
334         | id annotations? typing dotdotdot? {-> New param(id, typing.type, dotdotdot, annotations)}
335         ;
336
337 closure_decls {->closure_decl*}
338         = closure_decl+ {-> [closure_decl]};
339 closure_decl
340         = kwbreak? bang id signature_noclosures n {-> New closure_decl(kwbreak, bang, id, signature_noclosures.signature, Null)}
341         | {optionnal} kwbreak? bang id signature_noclosures kwdo stmtso n {-> New closure_decl(kwbreak, bang, id, signature_noclosures.signature, stmtso.expr)}
342         | {assign} kwbreak? bang id signature_noclosures assign no assign_continue n {-> New closure_decl(kwbreak, bang, id, signature_noclosures.signature, assign_continue.expr)}
343         ;
344
345 assign_return{-> expr}
346         = expr_final {-> New expr.return(Null, expr_final.expr)}
347         ;
348
349 extern_calls {-> extern_calls}
350         = kwimport no extern_call extern_call_tail* {-> New extern_calls( kwimport, [extern_call, extern_call_tail.extern_call] )}
351         ;
352 extern_call_tail {-> extern_call}
353         = comma no extern_call {-> extern_call};
354 extern_call {-> extern_call}
355     = {prop} extern_call_prop {-> extern_call_prop.extern_call}
356     | {cast} extern_call_cast {-> extern_call_cast.extern_call}
357         | {super} kwsuper {-> New extern_call.super( kwsuper )}
358     ;
359 extern_call_prop {-> extern_call}
360     = {local} methid {-> New extern_call.local_prop( methid )}
361         | {full} classid quad methid {-> New extern_call.full_prop( classid, quad, methid )}
362         | {init} classid {-> New extern_call.init_prop( classid )}
363         ;
364 extern_call_cast {-> extern_call}
365     = {as_cast} [from_type]:type kwas [n2]:no opar [n3]:no [to_type]:type [n4]:no cpar {-> New extern_call.cast_as(from_type, kwas, to_type)}
366         | {as_nullable} type kwas [n2]:no kwnullable {-> New extern_call.as_nullable( type, kwas, kwnullable)}
367         | {as_not_nullable} type kwas [n2]:no kwnot [n3]:no kwnullable {-> New extern_call.as_not_nullable( type, kwas, kwnot, kwnullable)}
368         ;
369
370 in_language = kwin string;
371 extern_code_block = in_language? extern_code_segment;
372 extern_code_body {-> extern_code_block} = no extern_code_block {-> extern_code_block};
373
374 /* TYPES *********************************************************************/
375 type~nobra~nopar {-> type}
376         = {simple} kwnullable? classid annotations~nopar? {-> New type(kwnullable, classid, [], annotations~nopar.annotations)}
377 !nobra  | {generic} kwnullable? classid obra no types [n2]:no cbra annotations~nopar? {-> New type(kwnullable, classid, [types.type], annotations~nopar.annotations)}
378         ;
379 types {-> type*} 
380         = type types_tail* {-> [type, types_tail.type]};
381 types_tail {-> type}
382         = comma no type {-> type};
383 typing {-> type}
384         = column no type {-> type};
385
386 /* STATMENTS *****************************************************************/
387 stmtso~withelse~withend {-> expr?}
388         = {block} n stmtsnend {-> stmtsnend.expr}
389         | {emptyblock} n kwend {-> New expr.block([], kwend)}
390         | {emptyoneline} kwend {-> New expr.block([], kwend)}
391 !withend| {oneline} stmt~withelse {-> stmt~withelse.expr}
392         ;
393 stmts {-> expr}
394         = stmt stmts_tail* {-> New expr.block([stmt.expr, stmts_tail.expr], Null)};
395 stmtsn {-> expr}
396         = stmt stmts_tail* n {-> New expr.block([stmt.expr, stmts_tail.expr], Null)};
397 stmtsnend {-> expr}
398         = stmt stmts_tail* n kwend {-> New expr.block([stmt.expr, stmts_tail.expr], kwend)};
399 stmts_tail {-> expr}
400         = n stmt {-> stmt.expr};
401 stmt~withelse~noexpr~nopar {-> expr}
402         = {vardecl} vardecl~withelse {-> vardecl~withelse.expr}
403         | {assign} assignment~withelse~nopar {-> assignment~withelse~nopar.expr}
404         | {return} kwreturn expr_final~withelse? {-> New expr.return(kwreturn, expr_final~withelse.expr)}
405         | {break} kwbreak label? expr_final~withelse? {-> New expr.break(kwbreak, label, expr_final~withelse.expr)}
406         | {abort} kwabort {-> New expr.abort(kwabort)}
407         | {continue} kwcontinue label? expr_final~withelse? {-> New expr.continue(kwcontinue, label, expr_final~withelse.expr)}
408         | {do} do~withelse {-> do~withelse.expr}
409 !noexpr | {if} if~withelse {-> if~withelse.expr}
410         | {while} while~withelse {-> while~withelse.expr}
411         | {loop} loop~withelse {-> loop~withelse.expr}
412         | {for} for~withelse {-> for~withelse.expr}
413         | {assert} assert~withelse {-> assert~withelse.expr}
414 !noexpr | {call} recv id args_nopar closure_defs~withelse? {-> New expr.call(recv.expr, id, args_nopar.exprs, [closure_defs~withelse.closure_def])}
415 !noexpr | {super} qualified? kwsuper args_nopar {-> New expr.super(qualified, kwsuper, args_nopar.exprs)}
416 !noexpr | {init} recv kwinit args_nopar {-> New expr.init(recv.expr, kwinit, args_nopar.exprs)}
417         | {debug_type_is} kwdebug kwtype type column expr_final~withelse {-> New expr.debug_type(kwdebug, kwtype, expr_final~withelse.expr, type) }
418         ;
419
420 label= kwlabel id;
421
422 closure_defs~withelse {-> closure_def*}
423         = {one} closure_def_last~withelse {-> [closure_def_last~withelse.closure_def]}
424         | closure_def closure_defs~withelse {-> [closure_def, closure_defs~withelse.closure_def]}
425         ;
426
427 closure_def_last~withelse {-> closure_def}
428         = bang [id]:closure_id idlist? kwdo stmtso_withend label {-> New closure_def(bang, id, [idlist.id], kwdo, stmtso_withend.expr, label)}
429         | {nolabel} bang [id]:closure_id idlist? kwdo stmtso~withelse {-> New closure_def(bang, id, [idlist.id], kwdo, stmtso~withelse.expr, Null)}
430         | {assign} bang [id]:closure_id idlist? assign no assign_continue~withelse {-> New closure_def(bang, id, [idlist.id], Null, assign_continue~withelse.expr, Null)}
431         ;
432
433 closure_def {-> closure_def}
434         = bang [id]:closure_id idlist? kwdo n stmtsn {-> New closure_def(bang, id, [idlist.id], kwdo, stmtsn.expr, Null)}
435         | {empty} bang [id]:closure_id idlist? kwdo n {-> New closure_def(bang, id, [idlist.id], kwdo, Null, Null)}
436         ;
437 closure_id
438         = {simple} id
439         | {break} kwbreak
440         ;
441
442 assign_continue~withelse{-> expr}
443         = expr_final~withelse {-> New expr.continue(Null, Null, expr_final~withelse.expr)}
444         ;
445
446 vardecl~withelse{-> expr}
447         = kwvar id annotations? typing? {-> New expr.vardecl(kwvar, id, typing.type, Null, Null, annotations)}
448         | {assign} kwvar id annotations? typing? assign no expr_final~withelse {-> New expr.vardecl(kwvar, id, typing.type, assign, expr_final~withelse.expr, annotations)}
449         ;
450
451 assignment~withelse~nopar {-> expr}
452         = {attr} recv~nopar attrid assign expr_final~withelse {-> New expr.attr_assign(recv~nopar.expr, attrid, assign, expr_final~withelse.expr)}
453         | {call} recv~nopar id args assign expr_final~withelse {-> New expr.call_assign(recv~nopar.expr, id, args.exprs, assign,  expr_final~withelse.expr)}
454         | {bra} expr_atom~nopar braargs assign expr_final~withelse {-> New expr.bra_assign(expr_atom~nopar.expr, braargs.exprs, assign,  expr_final~withelse.expr)}
455         | {attr_re} recv~nopar attrid assign_op expr_final~withelse {-> New expr.attr_reassign(recv~nopar.expr, attrid, assign_op,  expr_final~withelse.expr)}
456         | {call_re} recv~nopar id args assign_op expr_final~withelse {-> New expr.call_reassign(recv~nopar.expr, id, args.exprs, assign_op,  expr_final~withelse.expr)}
457         | {bra_re} expr_atom~nopar braargs assign_op expr_final~withelse {-> New expr.bra_reassign(expr_atom~nopar.expr, braargs.exprs, assign_op,  expr_final~withelse.expr)}
458         ;
459 assign_op
460         = {plus} pluseq
461         | {minus} minuseq
462         ;
463
464 do~withelse {-> expr}
465         = kwdo stmtso_withend label {-> New expr.do(kwdo, stmtso_withend.expr, label)}
466         | {nolabel} kwdo stmtso~withelse {-> New expr.do(kwdo, stmtso~withelse.expr, Null)}
467         ;
468
469 if~withelse {-> expr}
470         = {onelineelse} kwif no expr [n2]:no kwthen stmt_withelse kwelse stmtso~withelse {-> New expr.if(kwif, expr, stmt_withelse.expr, stmtso~withelse.expr)}
471 !withelse       | {oneline} kwif no expr [n2]:no kwthen stmt {-> New expr.if(kwif, expr, stmt.expr, Null)}
472 !withelse       | {block} kwif no expr [n2]:no kwthen [n3]:n stmtsn elsepartblock {-> New expr.if(kwif, expr, stmtsn.expr, elsepartblock.expr)}
473 !withelse       | {emptyblock} kwif no expr [n2]:no kwthen [n3]:n? elsepartblock {-> New expr.if(kwif, expr, Null, elsepartblock.expr)}
474         ;
475 elsepartblock {-> expr?}
476         = {else} kwelse stmtso {-> stmtso.expr}
477         | {empty} kwend {-> New expr.block([], kwend)}
478         ;
479
480 loop~withelse {-> expr}
481         = kwloop stmtso_withend label {-> New expr.loop(kwloop, stmtso_withend.expr, label)}
482         | {nolabel} kwloop stmtso~withelse {-> New expr.loop(kwloop, stmtso~withelse.expr, Null)}
483         ;
484
485 while~withelse {-> expr}
486         = kwwhile no expr [n2]:no kwdo stmtso_withend label {-> New expr.while(kwwhile, expr, kwdo, stmtso_withend.expr, label)}
487         | {nolabel} kwwhile no expr [n2]:no kwdo stmtso~withelse {-> New expr.while(kwwhile, expr, kwdo, stmtso~withelse.expr, Null)}
488         ;
489
490 for~withelse {-> expr}
491         = kwfor no [ids]:idlist [n2]:no kwin [n3]:no expr [n4]:no kwdo stmtso_withend label {-> New expr.for(kwfor, [ids.id], expr, kwdo, stmtso_withend.expr, label)}
492         | {nolabel} kwfor no [ids]:idlist [n2]:no kwin [n3]:no expr [n4]:no kwdo stmtso~withelse {-> New expr.for(kwfor, [ids.id], expr, kwdo, stmtso~withelse.expr, Null)}
493         ;
494
495 assert~withelse {-> expr}
496         = {else} kwassert assertid? expr_final_withelse kwelse stmtso~withelse {-> New expr.assert(kwassert, assertid.id, expr_final_withelse.expr, stmtso~withelse.expr)}
497 !withelse| {noelse} kwassert assertid? expr_final {-> New expr.assert(kwassert, assertid.id, expr_final.expr, Null)}
498         ;
499 assertid {-> id}
500         = id column {-> id};
501
502 /* EXPRESSIONS ***************************************************************/
503 expr_final~nopar~withelse~nobra {-> expr}
504         = expr~nopar~nobra {-> expr~nopar~nobra.expr}
505         | {closure_call} recv~nobra id args closure_defs~withelse {-> New expr.call(recv~nobra.expr, id, args.exprs, [closure_defs~withelse.closure_def])}
506 !nobra!nopar    | {closure_bra} expr_atom braargs closure_defs~withelse {-> New expr.bra(expr_atom.expr, braargs.exprs, [closure_defs~withelse.closure_def])}
507         ;
508
509 expr~nopar~nobra~nois {-> expr}
510         = expr_and~nopar~nobra~nois {-> expr_and~nopar~nobra~nois.expr}
511         | {ifexpr} kwif [n1]:no expr [n2]:no kwthen [n3]:no [then]:expr [n4]:no kwelse [n5]:no [else]:expr~nopar~nobra~nois {-> New expr.ifexpr(kwif, expr, kwthen, then, kwelse, else.expr)}
512         ;
513
514 expr_and~nopar~nobra~nois {-> expr}
515         = expr_not~nopar~nobra~nois {-> expr_not~nopar~nobra~nois.expr}
516         | {:or} expr_and~nopar~nobra~nois :kwor :no expr_not~nopar~nobra~nois
517         | {:and} expr_and~nopar~nobra~nois :kwand :no expr_not~nopar~nobra~nois
518         | {:or_else} expr_and~nopar~nobra~nois :kwor :kwelse :no expr_not~nopar~nobra~nois
519         ;
520
521 expr_not~nopar~nobra~nois {-> expr}
522         = expr_eq~nopar~nobra~nois {-> expr_eq~nopar~nobra~nois.expr}
523         | {not} kwnot no expr_not~nopar~nobra~nois {-> New expr.not(kwnot, expr_not~nopar~nobra~nois.expr)}
524         ;
525
526 expr_eq~nopar~nobra~nois {-> expr}
527         = expr_add~nopar~nobra {-> expr_add~nopar~nobra.expr}
528         | {:eq} expr_add~nopar~nobra :eq :no [expr2]:expr_add~nopar~nobra
529 !nois   | {ee} [expr]:expr_add~nopar~nobra kwis no [expr2]:expr_add~nopar~nobra {-> New expr.ee(expr.expr, expr2.expr)}
530         | {:ne} expr_add~nopar~nobra :ne :no [expr2]:expr_add~nopar~nobra
531         | {:lt} expr_add~nopar~nobra :lt :no [expr2]:expr_add~nopar~nobra
532         | {:le} expr_add~nopar~nobra :le :no [expr2]:expr_add~nopar~nobra
533         | {:ll} expr_eq~nopar~nobra~nois :ll :no [expr2]:expr_add~nopar~nobra
534         | {:gt} expr_add~nopar~nobra :gt :no [expr2]:expr_add~nopar~nobra
535         | {:ge} expr_add~nopar~nobra :ge :no [expr2]:expr_add~nopar~nobra
536         | {:gg} expr_eq~nopar~nobra~nois :gg :no [expr2]:expr_add~nopar~nobra
537         | {:starship} expr_add~nopar~nobra :starship :no [expr2]:expr_add~nopar~nobra
538         | {:isa} expr_add~nopar~nobra :kwisa :no type~nobra
539         ;
540
541 expr_add~nopar~nobra {-> expr}
542         =  expr_mul~nopar~nobra {-> expr_mul~nopar~nobra.expr}
543         | {:plus} expr_add~nopar~nobra :plus :no [expr2]:expr_mul~nopar~nobra
544         | {:minus} expr_add~nopar~nobra :minus :no [expr2]:expr_mul~nopar~nobra
545         ;
546
547 expr_mul~nopar~nobra {-> expr}
548         = expr_minus~nopar~nobra {-> expr_minus~nopar~nobra.expr}
549         | {:star} expr_mul~nopar~nobra :star :no [expr2]:expr_minus~nopar~nobra
550         | {:slash} expr_mul~nopar~nobra :slash :no [expr2]:expr_minus~nopar~nobra
551         | {:percent} expr_mul~nopar~nobra :percent :no [expr2]:expr_minus~nopar~nobra
552         ;
553
554 expr_minus~nopar~nobra {-> expr}
555         = expr_new~nopar~nobra {-> expr_new~nopar~nobra.expr}
556         | {:uminus} minus :no expr_minus~nopar~nobra
557         | {:once} kwonce :no expr_minus~nopar~nobra
558         ;
559
560 expr_new~nopar~nobra {-> expr}
561         = expr_atom~nopar~nobra {-> expr_atom~nopar~nobra.expr}
562         | {new} kwnew no type~nobra_nopar args {-> New expr.new(kwnew, type~nobra_nopar.type, Null, args.exprs)}
563         | {isset_attr} kwisset recv~nopar~nobra attrid {-> New expr.isset_attr(kwisset, recv~nopar~nobra.expr, attrid)}
564         ;
565
566 expr_atom~nopar~nobra {-> expr}
567         = {attr} recv~nopar~nobra attrid {-> New expr.attr(recv~nopar~nobra.expr, attrid)}
568         | {call} recv~nopar~nobra id args {-> New expr.call(recv~nopar~nobra.expr, id, args.exprs, [])}
569         | {super} qualified? kwsuper args {-> New expr.super(qualified, kwsuper, args.exprs)}
570         | {init} recv~nopar~nobra kwinit args {-> New expr.init(recv~nopar~nobra.expr, kwinit, args.exprs)}
571 !nobra  | {bra} expr_atom~nopar braargs {-> New expr.bra(expr_atom~nopar.expr, braargs.exprs, [])}
572         | {new} kwnew no type~nobra_nopar dot [n2]:no id args {-> New expr.new(kwnew, type~nobra_nopar.type, id, args.exprs)}
573 // !nopar to unambiguise 'foo[5].bar' between '(foo[5]).bar' and 'foo([5].bar),
574 !nobra!nopar    | {range} obra no expr [n2]:no dotdot [n3]:no [expr2]:expr_nobra [n4]:no cbra annotations? {-> New expr.crange(obra, expr, expr2.expr, cbra, annotations)}
575 !nobra!nopar    | {orange} obra no expr [n2]:no dotdot [n3]:no [expr2]:expr_nobra [n4]:no [cbra]:obra annotations? {-> New expr.orange(obra, expr, expr2.expr, cbra, annotations)}
576 !nobra!nopar    | {array} braargs annotations? {-> New expr.array(braargs.exprs, annotations)}
577         | {self} kwself annotations? {-> New expr.self(kwself, annotations)}
578         | {true} kwtrue annotations? {-> New expr.true(kwtrue, annotations)}
579         | {false} kwfalse annotations? {-> New expr.false(kwfalse, annotations)}
580         | {null} kwnull annotations? {-> New expr.null(kwnull, annotations)}
581         | {int} number annotations? {-> New expr.int(number, annotations)}
582         | {float} float annotations? {-> New expr.float(float, annotations)}
583         | {char} char annotations? {-> New expr.char(char, annotations)}
584         | {string} string annotations? {-> New expr.string(string, annotations)}
585         | {superstring} superstring  {-> superstring.expr}
586 !nopar  | {par} opar no expr [n2]:no cpar annotations? {-> New expr.par(opar, expr, cpar, annotations)}
587         | {as_cast} expr_atom~nopar~nobra dot no kwas [n2]:no opar [n3]:no type [n4]:no cpar {-> New expr.as_cast(expr_atom~nopar~nobra.expr, kwas, opar, type, cpar)}
588         | {as_notnull} expr_atom~nopar~nobra dot no kwas [n2]:no opar [n3]:no kwnot [n4]:no kwnull [n5]:no cpar {-> New expr.as_notnull(expr_atom~nopar~nobra.expr, kwas, opar, kwnot, kwnull, cpar)}
589         ;
590
591 superstring {-> expr} 
592         = superstring_start superstring_middle* superstring_end annotations? {-> New expr.superstring([superstring_start.expr, superstring_middle.expr, superstring_end.expr], annotations)};
593 superstring_start {-> expr*}
594         = start_string_p no expr [n2]:no {-> [start_string_p.expr, expr]};
595 start_string_p {-> expr}
596         = start_string {-> New expr.start_string(start_string)};
597 superstring_middle {-> expr*}
598         = mid_string_p no expr [n2]:no {-> [mid_string_p.expr, expr]};
599 mid_string_p {-> expr}
600         = mid_string {-> New expr.mid_string(mid_string)};
601 superstring_end {-> expr}
602         = end_string {-> New expr.end_string(end_string)};
603
604 /* ANNOTATIONS *******************************************************************/
605
606 annotations~nopar {-> annotations}
607         = {one} at one_annotation~nopar {-> New annotations(at, Null, [one_annotation~nopar.annotation], Null)}
608         | {many} at opar no annotation_list [n2]:no cpar {-> New annotations(at, opar, [annotation_list.annotation], cpar)}
609         ;
610
611 one_annotation~nopar {-> annotation}
612         = {alone} atid annotations~nopar? {-> New annotation(atid, Null, [], Null, annotations~nopar.annotations)}
613 // !nopar to unambiguise 'new T@foo(bar)' between 'new T@(foo(bar))' and 'new (T@foo)(bar)'
614 !nopar  | {args} atid opar no at_args [n2]:no cpar annotations~nopar? {-> New annotation(atid, opar, [at_args.at_arg], cpar, annotations~nopar.annotations)}
615         ;
616
617 many_annotations {-> annotations}
618         = {many} annotation_list {-> New annotations(Null, Null, [annotation_list.annotation], Null)}
619         ;
620
621 annotation_list {-> annotation*}
622         = {many} one_annotation annotations_tail* {-> [one_annotation.annotation, annotations_tail.annotation] }
623         ;
624
625 line_annotations~forclass {-> annotations}
626         = line_annotation~forclass+ {-> New annotations(Null, Null, [line_annotation~forclass.annotation], Null) }
627         ;
628 line_annotation~forclass {-> annotation}
629         = [doc]:no atid~forclass annotations? n1 {-> New annotation(atid~forclass.atid, Null, [], Null, annotations)}
630         | {args} [doc]:no atid~forclass opar no at_args cpar annotations? n1 {-> New annotation(atid~forclass.atid, opar, [at_args.at_arg], cpar, annotations)}
631         | {nopar} [doc]:no atid~forclass at_args_nopar n1 {-> New annotation(atid~forclass.atid, Null, [at_args_nopar.at_arg], Null, Null)}
632         ;
633
634 annotations_tail {-> annotation}
635         = comma no one_annotation {-> one_annotation.annotation}
636         ;
637
638 at_args~nopar {-> at_arg* }
639         = {many} at_arg~nopar at_args_tail* {-> [at_arg~nopar.at_arg, at_args_tail.at_arg]}
640         ;
641
642 at_args_tail {-> at_arg}
643         = comma no at_arg {-> at_arg}
644         ;
645
646 at_arg~nopar {-> at_arg}
647         = {type} type {-> New at_arg.type(type)}
648         | {expr} expr~nopar {-> New at_arg.expr(expr~nopar.expr)}
649         | {stmt} stmt_noexpr~nopar {-> New at_arg.expr(stmt_noexpr~nopar.expr)}
650 !nopar  | {at} annotations {-> New at_arg.at(annotations.annotations)}
651         ;
652
653 atid~forclass {-> atid}
654         = {id} id {-> New atid.id(id)}
655 //!forclass     | {kwextern} kwextern {-> New atid.kwextern(kwextern)}
656 //!forclass     | {kwintern} kwintern {-> New atid.kwintern(kwintern)}
657 !forclass       | {kwreadable} kwreadable {-> New atid.kwreadable(kwreadable)}
658 !forclass       | {kwwritable} kwwritable {-> New atid.kwwritable(kwwritable)}
659         | {kwimport} kwimport {-> New atid.kwimport(kwimport)}
660         ;
661
662 /* MISC **********************************************************************/
663
664 recv~nopar~nobra {-> expr}
665         = expr_atom~nopar~nobra dot no {-> expr_atom~nopar~nobra.expr}
666         | {implicit} {-> New expr.implicit_self()}
667         ;
668
669 args {-> exprs}
670         = opar no expr_list cpar {-> New exprs.par(opar, [expr_list.expr], cpar) }
671         | {emptypar} opar no cpar {-> New exprs.par(opar, [], cpar) }
672         | {empty} {-> New exprs.list([])}
673         ;
674 args_nopar {-> exprs}
675         = opar no expr_list cpar {-> New exprs.par(opar, [expr_list.expr], cpar) }
676         | {onearg} expr_nopar {-> New exprs.list([expr_nopar.expr])}
677         | {emptypar} opar no cpar {-> New exprs.par(opar, [], cpar) }
678         | {empty} {-> New exprs.list([])}
679         ;
680 braargs {-> exprs}
681         = obra no expr_list cbra {-> New exprs.bra(obra, [expr_list.expr], cbra)};
682 expr_list {-> expr*}
683         = expr [n2]:no expr_tail* {-> [expr, expr_tail.expr]};
684 expr_tail {-> expr} 
685         = comma no expr [n2]:no {-> expr};
686 idlist {-> id*}
687         = opar no idlist_nopar [n2]:no cpar {-> [idlist_nopar.id]}
688         | {nopar} idlist_nopar {-> [idlist_nopar.id]}
689         ;
690 idlist_nopar {-> id*}
691         = {single} id {-> [id]}
692         | {more} idlist_nopar no comma [n2]:no id {-> [idlist_nopar.id, id]}
693         ;
694
695 module_name {-> module_name}
696         = {mod} modquad* id {-> New module_name(Null, [modquad.id], id)}
697         | {root} quad no modquad* id {-> New module_name(quad, [modquad.id], id)}
698         ;
699
700 qualified 
701         = {cla} modquad* classquad {-> New qualified([modquad.id], classquad.classid)}
702         | {mod} modquad+ {-> New qualified([modquad.id], Null)}
703         ; 
704 modquad {-> id}
705         = id quad no {-> id};
706 classquad {-> classid} 
707         = classid quad no {-> classid};
708
709 n1      = {a} comment | {b} eol;
710 n {-> doc?}
711         = {a} n2? comment+ {-> New doc([comment])}
712         | {b} n2 {-> Null}
713         ;
714 no {-> doc?}
715         = {empty} {-> Null}
716         | n {-> n.doc}
717         ;
718
719 n2
720         = {a} n2? comment+ eol+
721         | {b} eol+
722         ;
723
724 /*****************************************************************************/
725 Abstract Syntax Tree
726 /*****************************************************************************/
727
728 module  = moduledecl? [imports]:import* [extern_code_blocks]:extern_code_block* [classdefs]:classdef*;
729
730 moduledecl
731         = doc? kwmodule [name]:module_name annotations?;
732
733 import  = {std} visibility kwimport [name]:module_name annotations?
734         | {no} visibility kwimport kwend
735         ;
736
737 visibility
738         = {public}
739         | {private} kwprivate
740         | {protected} kwprotected
741         | {intrude} kwintrude
742         ;
743
744 classdef= {std} doc? kwredef? visibility classkind [id]:classid? [formaldefs]:formaldef* annotations? extern_code_block? [superclasses]:superclass* [propdefs]:propdef* kwend
745         | {top} [propdefs]:propdef*
746         | {main} [propdefs]:propdef*
747         ;
748 classkind
749         = {concrete} kwclass
750         | {abstract} kwabstract kwclass
751         | {interface} kwinterface
752         | {enum} kwenum
753         | {extern} kwextern kwclass?
754         ;
755 formaldef = [id]:classid type? annotations?;
756 superclass = kwsuper type annotations?;
757
758
759 propdef = {attr} doc? [readable]:able? [writable]:able? kwredef? visibility kwvar [id]:attrid? [id2]:id? type? annotations? expr?
760         | {meth} doc? kwredef? visibility methid signature
761         | {deferred_meth} doc? kwredef? visibility kwmeth methid signature annotations?
762         | {intern_meth} doc? kwredef? visibility kwmeth methid signature
763         | {extern_meth} doc? kwredef? visibility kwmeth methid signature [extern]:string? extern_calls? extern_code_block?
764         | {concrete_meth} doc? kwredef? visibility kwmeth methid signature annotations? [block]:expr?
765         | {concrete_init} doc? kwredef? visibility kwinit methid? signature annotations? [block]:expr?
766         //| {concrete_new} doc? kwredef? visibility kwnew methid? signature [block]:expr?
767         | {extern_init} doc? kwredef? visibility kwnew methid? signature [extern]:string? extern_calls? extern_code_block?
768         | {main_meth} kwredef? [block]:expr?
769         | {type} doc? kwredef? visibility kwtype [id]:classid type annotations?
770         ;
771
772 able    = {read} kwredef? kwreadable
773         | {write} kwredef? visibility? kwwritable
774         ;
775
776 methid = {id} id | {plus} plus | {minus} minus | {star} star | {slash} slash | {percent} percent | {eq} eq | {ne} ne | {le} le | {ge} ge | {lt} lt | {gt} gt |  {ll} ll | {gg} gg | {bra} obra cbra | {starship} starship | {assign} id assign | {braassign} obra cbra assign;
777
778 signature = opar? [params]:param* cpar? type? [closure_decls]:closure_decl*;
779
780 param   = id type? dotdotdot? annotations?
781         ;
782
783 closure_decl = kwbreak? bang id signature expr?
784         ;
785
786 type    = kwnullable? [id]:classid [types]:type* annotations?;
787
788 label = kwlabel id;
789
790 expr    = {block} expr* kwend? 
791         | {vardecl} kwvar id type? assign? expr? annotations?
792         | {return} kwreturn? expr?
793         | {break} kwbreak label? expr?
794         | {abort} kwabort
795         | {continue} kwcontinue? label? expr?
796         | {do} kwdo [block]:expr? label?
797         | {if} kwif expr [then]:expr? [else]:expr? 
798         | {ifexpr} kwif expr kwthen [then]:expr kwelse [else]:expr
799         | {while} kwwhile expr kwdo [block]:expr? label?
800         | {loop} kwloop [block]:expr? label?
801         | {for} kwfor [ids]:id* expr kwdo [block]:expr? label?
802         | {assert} kwassert id? expr [else]:expr?
803         | {once} kwonce expr 
804         | {send} expr 
805         | {binop} expr [expr2]:expr 
806         | {or} expr [expr2]:expr 
807         | {and} expr [expr2]:expr 
808         | {or_else} expr [expr2]:expr
809         | {not} kwnot expr 
810         | {eq} expr [expr2]:expr 
811         | {ee} expr [expr2]:expr 
812         | {ne} expr [expr2]:expr 
813         | {lt} expr [expr2]:expr 
814         | {le} expr [expr2]:expr 
815         | {ll} expr [expr2]:expr
816         | {gt} expr [expr2]:expr 
817         | {ge} expr [expr2]:expr 
818         | {gg} expr [expr2]:expr
819         | {isa} expr type 
820         | {plus} expr [expr2]:expr 
821         | {minus} expr [expr2]:expr 
822         | {starship} expr [expr2]:expr 
823         | {star} expr [expr2]:expr 
824         | {slash} expr [expr2]:expr 
825         | {percent} expr [expr2]:expr 
826         | {uminus} minus expr 
827         | {new} kwnew type id? [args]:exprs
828         | {attr} expr [id]:attrid 
829         | {attr_assign} expr [id]:attrid assign [value]:expr 
830         | {attr_reassign} expr [id]:attrid assign_op [value]:expr 
831         | {call} expr id [args]:exprs [closure_defs]:closure_def*
832         | {call_assign} expr id [args]:exprs assign [value]:expr 
833         | {call_reassign} expr id [args]:exprs assign_op [value]:expr 
834         | {super} qualified? kwsuper [args]:exprs
835         | {init} expr kwinit [args]:exprs 
836         | {bra} expr [args]:exprs [closure_defs]:closure_def* 
837         | {bra_assign} expr [args]:exprs assign [value]:expr 
838         | {bra_reassign} expr [args]:exprs assign_op [value]:expr 
839         | {closure_call} id [args]:exprs [closure_defs]:closure_def*
840         | {var} id
841         | {var_assign} id assign [value]:expr 
842         | {var_reassign} id assign_op [value]:expr 
843         | {range} expr [expr2]:expr annotations?
844         | {crange} obra expr [expr2]:expr cbra annotations?
845         | {orange} obra expr [expr2]:expr [cbra]:obra annotations?
846         | {array} [exprs]:exprs annotations?
847         | {self} kwself annotations?
848         | {implicit_self} 
849         | {true} kwtrue annotations?
850         | {false} kwfalse annotations?
851         | {null} kwnull annotations?
852         | {int} number annotations?
853         | {float} float annotations?
854         | {char} char annotations?
855         | {string} string annotations?
856         | {start_string} [string]:start_string 
857         | {mid_string} [string]:mid_string 
858         | {end_string} [string]:end_string 
859         | {superstring} [exprs]:expr* annotations?
860         | {par} opar expr cpar annotations?
861         | {as_cast} expr kwas opar type cpar
862         | {as_notnull} expr kwas opar kwnot kwnull cpar
863         | {isset_attr} kwisset expr [id]:attrid
864         | {debug_type} kwdebug kwtype expr type
865         ;
866 exprs
867         = {list} [exprs]:expr*
868         | {par} opar [exprs]:expr* cpar
869         | {bra} obra [exprs]:expr* cbra
870         ;
871 assign_op
872         = {plus} pluseq
873         | {minus} minuseq
874         ;
875
876 closure_def
877         = bang [id]:closure_id [ids]:id* kwdo? expr? label?
878         ;
879 closure_id
880         = {simple} id
881         | {break} kwbreak
882         ;
883
884 module_name = quad? [path]:id* id;
885 extern_calls = kwimport [extern_calls]:extern_call*
886         ;
887 extern_call =
888         | {super} kwsuper
889         | {local_prop} methid
890         | {full_prop} classid quad? methid
891         | {init_prop} classid
892         | {cast_as} [from_type]:type kwas [to_type]:type
893         | {as_nullable} type kwas kwnullable
894         | {as_not_nullable} type kwas kwnot kwnullable
895         ;
896 in_language = kwin string;
897 extern_code_block = in_language? extern_code_segment;
898
899 qualified = id* classid? ;
900
901 doc = comment+;
902
903 annotations = at? opar? [items]:annotation* cpar?;
904
905 annotation = atid opar? [args]:at_arg* cpar? annotations?;
906
907 at_arg
908         = {type} type
909         | {expr} expr
910         | {at} annotations
911         ;
912 atid = {id} id | {kwextern} [id]:kwextern | {kwintern} [id]:kwintern | {kwreadable} [id]:kwreadable | {kwwritable} [id]:kwwritable | {kwimport} [id]:kwimport;
913
914 /*****************************************************************************/
915