all = [0 .. 0xFF];
lowercase = ['a' .. 'z'];
uppercase = ['A' .. 'Z'];
+
digit = ['0' .. '9'];
+hexdigit = ['0'..'9'] | ['a'..'f'] | ['A'..'F'] | '_';
+bindigit = '0' | '1' | '_';
+octdigit = ['0' .. '7'] | '_';
+number = digit (digit | '_')*;
+hex_number = ('0x' | '0X') hexdigit+;
+bin_number = ('0b' | '0B') bindigit+;
+oct_number = ('0o' | '0O') octdigit+;
+prec = '8' | '16' | '32';
+
letter = lowercase | uppercase | digit | '_';
tab = 9;
// characers inside strings and super-strings (atomaton powaa)
str_char
- = [any - [['"' + '{'] + '\']]
- | '\' any
+ = [any - [['"' + '{'] + '\']]
+ | '\' any
;
str_body = str_char*;
long_str_char = str_char | cr | lf;
+// because no substraction in sablecc3, complex long strings are difficult to express
+ls1 = '"' '"'? ;
+ls2 = '{' '{'? ;
+ls12 = ls1? (ls2 ls1)* ls2?;
+
long_str_part
- = long_str_char
- | '"' long_str_char
- | '"' '"' long_str_char
- | '{' long_str_char
- | '{' '{' long_str_char
+ = ls12 long_str_char
;
long_str_body = long_str_part*;
+lsend1 = ls2? (ls1 ls2)* '"""' '"'*;
+lsend2 = ls1? (ls2 ls1)* '{{{' '{'*;
long_sstr_char = sstr_char | cr | lf;
long_sstr_part
extern_code_char
= [all - ['`' + '\']]
| '\' all
+ | '`' [all - '}']
;
extern_code_body = extern_code_char*;
+id = lowercase letter*;
+
/*****************************************************************************/
States
/*****************************************************************************/
eol = eol_helper;
comment = '#' any* eol_helper?;
-kwmodule = 'package'|'module';
+kwpackage = 'package';
+kwmodule = 'module';
kwimport = 'import';
kwclass = 'class';
kwabstract = 'abstract';
kwredef = 'redef';
kwis = 'is';
kwdo = 'do';
-kwreadable = 'readable';
-kwwritable = 'writable';
kwvar = 'var';
-kwintern = 'intern';
kwextern = 'extern';
+kwpublic = 'public';
kwprotected = 'protected';
kwprivate = 'private';
kwintrude = 'intrude';
kwand = 'and';
kwor = 'or';
kwnot = 'not';
+kwimplies = 'implies';
kwreturn = 'return';
kwcontinue = 'continue';
kwbreak = 'break';
kwnullable = 'nullable';
kwisset = 'isset';
kwlabel = 'label';
+kwwith = 'with';
kwdebug = '__debug__';
+kwyield = 'yield';
+kwcatch = 'catch';
opar = '(';
cpar = ')';
assign = '=';
pluseq = '+=';
minuseq = '-=';
+stareq = '*=';
+slasheq = '/=';
+percenteq = '%=';
+starstareq = '**=';
+pipeeq = '|=';
+careteq = '^=';
+ampeq = '&=';
+lleq = '<<=';
+ggeq = '>>=';
dotdotdot = '...';
dotdot = '..';
dot = '.';
plus = '+';
minus = '-';
star = '*';
+starstar = '**';
slash = '/';
percent = '%';
+pipe = '|';
+caret = '^';
+amp = '&';
+tilde = '~';
eq = '==';
ne = '!=';
lt = '<';
starship = '<=>';
bang='!';
at='@';
+semi=';';
classid = uppercase letter*;
-id = lowercase letter*;
+id = id;
attrid = '_' lowercase letter*;
-number = digit+;
-float = digit* '.' digit+;
-string = '"' str_body '"' | '"' '"' '"' long_str_body '"' '"' '"' | ''' ''' ''' long_sstr_body ''' ''' ''';
-start_string = '"' str_body '{' | '"' '"' '"' long_str_body '{' '{' '{';
-mid_string = '}' str_body '{' | '}' '}' '}' long_str_body '{' '{' '{';
-end_string = '}' str_body '"' | '}' '}' '}' long_str_body '"' '"' '"';
-char = (''' [[any - '''] - '\'] ''') | (''' '\' any ''');
+integer = (number | hex_number | bin_number | oct_number) (('u' prec) | ('i' prec) |);
+float = digit* '.' digit+ | (digit+ | digit* '.' digit+) ('E'|'e') ('+'|'-'|) digit+;
+string = id? '"' str_body '"' id? | id? '"' '"' '"' long_str_body lsend1 | id? ''' ''' ''' long_sstr_body ''' ''' ''' id?;
+start_string = id? '"' str_body '{' | id? '"' '"' '"' long_str_body lsend2;
+mid_string = '}' str_body '{' | '}' '}' '}' long_str_body lsend2;
+end_string = '}' str_body '"' id? | '}' '}' '}' long_str_body lsend1 id? ;
+char = id? ((''' [[any - '''] - '\'] ''') | (''' '\' any ''')) id?;
bad_string = ('"'|'}') str_body | '"' '"' '"' long_str_body | ''' ''' ''' long_sstr_body;
bad_char = ''' '\'? any;
/* MODULES *******************************************************************/
module
- = 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])};
+ = moduledecl? [imports]:import* [extern_bodies]:extern_code_body* [classdefs]:topdef* implicit_main_class {-> New module(moduledecl, [imports.import], [extern_bodies.extern_code_block], [classdefs.classdef,implicit_main_class.classdef])};
moduledecl
- = [doc]:no kwmodule no module_name annotation_withend? [n2]:n1 {-> New moduledecl(doc.doc, kwmodule, module_name, annotation_withend.annotations)};
+ = [doc]:nd redef visibility kwmodule no module_name annotation_withend [n2]:n1 {-> New moduledecl(doc.doc, redef.kwredef, visibility, kwmodule, module_name, annotation_withend.annotations)};
import
- = {std} [doc]:no visibility kwimport no module_name annotation_withend? [n2]:n1 {-> New import.std(visibility, kwimport, module_name, annotation_withend.annotations)}
- | {no} [doc]:no visibility kwimport no kwend [n2]:n1 {-> New import.no(visibility, kwimport, kwend)}
+ = {std} [doc]:nd redef visibility kwimport no module_name annotation_withend [n2]:n1 {-> New import.std(visibility, kwimport, module_name, annotation_withend.annotations)}
+ | {no} [doc]:nd redef visibility kwimport no kwend [n2]:n1 {-> New import.no(visibility, kwimport, kwend)}
;
-implicit_top_class {-> classdef}
- = propdefs_toplevel+ {-> New classdef.top([propdefs_toplevel.propdef])};
+topdef {-> classdef}
+ = {classdef} classdef {-> classdef}
+ | propdef_toplevel n1 {-> New classdef.top([propdef_toplevel.propdef])}
+ ;
implicit_main_class {-> classdef?}
= implicit_main_meth {-> New classdef.main([implicit_main_meth.propdef])}
- | {null} n {-> Null}
+ | {null} n? {-> Null}
;
implicit_main_meth {-> propdef}
- = [doc]:no stmts {-> New propdef.main_meth(Null, stmts.expr)}
- | {n} [doc]:no stmtsn {-> New propdef.main_meth(Null, stmtsn.expr)}
+ = [doc]:nd stmts {-> New propdef.main_meth(Null, stmts.expr)}
+ | {n} [doc]:nd stmtsn {-> New propdef.main_meth(Null, stmtsn.expr)}
;
/* CLASSES *******************************************************************/
classdef
- = [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)};
+ = [doc]:nd redef visibility classkind no qclassid extern_code_block? propdefs kwend {-> New classdef.std(doc.doc, redef.kwredef, visibility, classkind, qclassid, Null, [], Null, extern_code_block, [propdefs.propdef], kwend)}
+ | {for} [doc]:nd redef visibility classkind no qclassid obra [n2]:no formaldefs cbra extern_code_block? propdefs kwend {-> New classdef.std(doc.doc, redef.kwredef, visibility, classkind, qclassid, obra, [formaldefs.formaldef], cbra, extern_code_block, [propdefs.propdef], kwend)}
+ ;
+
redef {-> kwredef?}
= kwredef? {-> kwredef};
classkind
| {abstract} kwabstract kwclass
| {interface} kwinterface
| {enum} kwenum
- | {extern} kwextern kwclass?
+ | {extern} kwextern kwclass
;
formaldefs {-> formaldef*}
- = obra no formaldef formaldefs_tail* [n2]:no cbra {-> [formaldef, formaldefs_tail.formaldef]};
+ = formaldef formaldefs_tail* {-> [formaldef, formaldefs_tail.formaldef]}
+ | {empty} {->[]}
+ ;
formaldefs_tail {-> formaldef}
= comma no formaldef {-> formaldef};
formaldef
- = classid annotations? typing? {-> New formaldef(classid, typing.type, annotations)};
+ = classid annotations? typing_o no {-> New formaldef(classid, typing_o.type, annotations)};
-superclass {-> superclass}
- = {super} no kwsuper [n2]:no type annotation_withend? {-> New superclass(kwsuper, type, annotation_withend.annotations)}
+superclass {-> propdef}
+ = {super} [doc]:nd redef visibility kwsuper [n2]:no type annotation_withend {-> New propdef.super(doc.doc, redef.kwredef, visibility, kwsuper, type, annotation_withend.annotations)}
;
-propdefs~toplevel {-> propdef}
- = propdef~toplevel n1 {-> propdef~toplevel.propdef}
+propdefs {-> propdef*}
+ = propdefn+ no {-> [propdefn.propdef]}
+ | {super} superclass {-> [superclass.propdef]}
+ | {empty} nd {-> []}
+ ;
+propdefn {-> propdef}
+ = propdef n1 {-> propdef.propdef}
;
propdef~toplevel {-> propdef}
- = {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)}
- | {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)}
- | {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)}
-!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)}
-!toplevel| {intern} [doc]:no redef visibility kwmeth methid signature kwis kwintern {-> New propdef.intern_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature)}
- | {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)}
- | {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)}
-!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)}
-!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)}
-!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)}
-!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)}
-!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)}
-!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)}
-!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)}
-!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)}
- ;
-annotation_withend {-> annotations}
- = {oneliner} kwis many_annotations {-> many_annotations.annotations}
- | {more} kwis n1 line_annotations kwend {-> line_annotations.annotations}
+ = {meth} [doc]:nd redef visibility kwmeth qmethid signature annotation_noend? kwdo stmtso kwend_o {-> New propdef.meth(doc.doc, redef.kwredef, visibility, kwmeth, Null, Null, qmethid.methid, signature, annotation_noend.annotations, Null, Null, kwdo, stmtso.expr, kwend_o.kwend)}
+ | {nobody} [doc]:nd redef visibility kwmeth qmethid signature annotation_withend_nonull {-> New propdef.meth(doc.doc, redef.kwredef, visibility, kwmeth, Null, Null, qmethid.methid, signature.signature, annotation_withend_nonull.annotations, Null, Null, Null, Null, Null)}
+!toplevel| {intern_new} [doc]:nd redef visibility kwnew qmethid? signature annotation_withend_nonull {-> New propdef.meth(doc.doc, redef.kwredef, visibility, Null, Null, kwnew, qmethid.methid, signature, annotation_withend_nonull.annotations, Null, Null, Null, Null, Null)}
+!toplevel| {new} [doc]:nd redef visibility kwnew qmethid? signature annotation_noend? kwdo stmtso kwend_o {-> New propdef.meth(doc.doc, redef.kwredef, visibility, Null, Null, kwnew, qmethid.methid, signature, annotation_noend.annotations, Null, Null, kwdo, stmtso.expr, kwend_o.kwend)}
+ | {extern_implicit} [doc]:nd redef visibility kwmeth qmethid signature annotation_noend? extern_calls extern_code_block {-> New propdef.meth(doc.doc, redef.kwredef, visibility, kwmeth, Null, Null, qmethid.methid, signature.signature, annotation_noend.annotations, extern_calls, extern_code_block, Null, Null, Null)}
+!toplevel| {var3} [doc]:nd redef visibility kwvar id typing_o annotation_withend {-> New propdef.attr(doc.doc, redef.kwredef, visibility, kwvar, id, typing_o.type, Null, Null, annotation_withend.annotations, Null, Null, Null)}
+!toplevel| {var4} [doc]:nd redef visibility kwvar id typing_o assign [n2]:no expr annotation_withend {-> New propdef.attr(doc.doc, redef.kwredef, visibility, kwvar, id, typing_o.type, assign, expr.expr, annotation_withend.annotations, Null, Null, Null)}
+!toplevel| {var5} [doc]:nd redef visibility kwvar id typing_o annotation_noend? kwdo stmtso kwend? {-> New propdef.attr(doc.doc, redef.kwredef, visibility, kwvar, id, typing_o.type, Null, Null, annotation_noend.annotations, kwdo, stmtso.expr, kwend)}
+!toplevel| {init} [doc]:nd redef visibility kwinit qmethid? signature annotation_noend? kwdo stmtso kwend_o {-> New propdef.meth(doc.doc, redef.kwredef, visibility, Null, kwinit, Null, qmethid.methid, signature, annotation_noend.annotations, Null, Null, kwdo, stmtso.expr, kwend_o.kwend)}
+!toplevel| {type} [doc]:nd redef visibility kwtype qclassid typing annotation_withend {-> New propdef.type(doc.doc, redef.kwredef, visibility, kwtype, qclassid, typing.type, annotation_withend.annotations)}
+!toplevel| {extern_init_implicit} [doc]:nd redef visibility kwnew qmethid? signature annotation_noend? extern_calls extern_code_block {-> New propdef.meth(doc.doc, redef.kwredef, visibility, Null, Null, kwnew, qmethid.methid, signature, annotation_noend.annotations, extern_calls, extern_code_block, Null, Null, Null)}
+!toplevel| {annot} line_annotation_forclass {-> line_annotation_forclass.propdef}
+!toplevel| {super} superclass {-> superclass.propdef}
+ ;
+annotation_withend~nonull {-> annotations?}
+ = {oneliner} kwis annotation_list {-> New annotations(kwis, Null, Null, [annotation_list.annotation], Null, Null)}
+ | {more} kwis n1 line_annotation+ kwend {-> New annotations(kwis, Null, Null, [line_annotation.annotation], Null, kwend) }
+!nonull | {null} {-> Null}
;
annotation_noend {-> annotations}
- = {oneliner} kwis many_annotations {-> many_annotations.annotations}
- | {more} kwis n1 line_annotations {-> line_annotations.annotations}
- ;
-readable {-> able}
- = redef kwreadable {-> New able.read(redef.kwredef, kwreadable)}
- ;
-writable {-> able}
- = redef kwwritable {-> New able.write(redef.kwredef, Null, kwwritable)}
- ;
-writable2 {-> able}
- = redef visibility kwwritable {-> New able.write(redef.kwredef, visibility, kwwritable)}
+ = {oneliner} kwis annotation_list {-> New annotations(kwis, Null, Null, [annotation_list.annotation], Null, Null)}
+ | {more} kwis n1 line_annotation+ {-> New annotations(kwis, Null, Null, [line_annotation.annotation], Null, Null) }
;
visibility
- = {public} {-> New visibility.public()}
+ = {public} {-> New visibility.public(Null)}
+ | {public2} kwpublic no {-> New visibility.public(kwpublic)}
| {private} kwprivate no {-> New visibility.private(kwprivate)}
| {protected} kwprotected no {-> New visibility.protected(kwprotected)}
| {intrude} kwintrude no {-> New visibility.intrude(kwintrude)}
;
-methid {-> methid}
- = {id} id {-> New methid.id(id)}
- | {plus} plus {-> New methid.plus(plus)}
+methid~noid {-> methid}
+ = {plus} plus {-> New methid.plus(plus)}
| {minus} minus {-> New methid.minus(minus)}
| {star} star {-> New methid.star(star)}
+ | {starstar} starstar {-> New methid.starstar(starstar)}
| {slash} slash {-> New methid.slash(slash)}
| {percent} percent {-> New methid.percent(percent)}
+ | {pipe} pipe {-> New methid.pipe(pipe)}
+ | {caret} caret {-> New methid.caret(caret)}
+ | {amp} amp {-> New methid.amp(amp)}
+ | {tilde} tilde {-> New methid.tilde(tilde)}
| {eq} eq {-> New methid.eq(eq)}
| {ne} ne {-> New methid.ne(ne)}
| {le} le {-> New methid.le(le)}
| {starship} starship {-> New methid.starship(starship)}
| {assign} id assign {-> New methid.assign(id, assign)}
| {braassign} obra cbra assign {-> New methid.braassign(obra, cbra, assign)}
+!noid | {id} id {-> New methid.id(id)}
;
-signature~withret {-> signature}
- = opar no params? cpar typing [no2]:no closure_decls? {-> New signature(opar, [params.param], cpar, typing.type, [closure_decls.closure_decl])}
-!withret| {noret} opar no params? cpar [no2]:no closure_decls? {-> New signature(opar, [params.param], cpar, Null, [closure_decls.closure_decl])}
- | {nopar} typing no closure_decls? {-> New signature(Null, [], Null, typing.type, [closure_decls.closure_decl])}
-!withret| {noparnoret} no closure_decls? {-> New signature(Null, [], Null, Null, [closure_decls.closure_decl])}
- ;
-
-signature_noclosures {-> signature}
- = opar no params? cpar typing? {-> New signature(opar, [params.param], cpar, typing.type, [])}
- | {nopar} typing? {-> New signature(Null, [], Null, typing.type, [])}
+signature {-> signature}
+ = opar no params cpar typing [no2]:no {-> New signature(opar, [params.param], cpar, typing.type)}
+ | {noret} opar no params cpar [no2]:no {-> New signature(opar, [params.param], cpar, Null)}
+ | {nopar} typing no {-> New signature(Null, [], Null, typing.type)}
+ | {noparnoret} no {-> New signature(Null, [], Null, Null)}
;
-params {-> param*}
+params {-> param*}
= param params_tail* [n2]:no {-> [param, params_tail.param] }
+ | {null} {-> []}
;
params_tail {-> param}
= comma no param {-> param};
param
- = {untyped} id annotations? {-> New param(id, Null, Null, annotations)}
+ = {untyped} id annotations_o {-> New param(id, Null, Null, annotations_o.annotations)}
| id annotations? typing dotdotdot? {-> New param(id, typing.type, dotdotdot, annotations)}
;
-closure_decls {->closure_decl*}
- = closure_decl+ {-> [closure_decl]};
-closure_decl
- = kwbreak? bang id signature_noclosures n {-> New closure_decl(kwbreak, bang, id, signature_noclosures.signature, Null)}
- | {optionnal} kwbreak? bang id signature_noclosures kwdo stmtso n {-> New closure_decl(kwbreak, bang, id, signature_noclosures.signature, stmtso.expr)}
- | {assign} kwbreak? bang id signature_noclosures assign no assign_continue n {-> New closure_decl(kwbreak, bang, id, signature_noclosures.signature, assign_continue.expr)}
- ;
-
-assign_return{-> expr}
- = expr_final {-> New expr.return(Null, expr_final.expr)}
- ;
-
-extern_calls {-> extern_calls}
+extern_calls {-> extern_calls?}
= kwimport no extern_call extern_call_tail* {-> New extern_calls( kwimport, [extern_call, extern_call_tail.extern_call] )}
+ | {null} {-> Null}
;
extern_call_tail {-> extern_call}
= comma no extern_call {-> extern_call};
extern_call {-> extern_call}
- = {prop} extern_call_prop {-> extern_call_prop.extern_call}
- | {cast} extern_call_cast {-> extern_call_cast.extern_call}
+ = {prop} extern_call_prop {-> extern_call_prop.extern_call}
+ | {cast} extern_call_cast {-> extern_call_cast.extern_call}
| {super} kwsuper {-> New extern_call.super( kwsuper )}
- ;
+ ;
extern_call_prop {-> extern_call}
- = {local} methid {-> New extern_call.local_prop( methid )}
- | {full} classid quad methid {-> New extern_call.full_prop( classid, quad, methid )}
- | {init} classid {-> New extern_call.init_prop( classid )}
+ = {local} qmethid {-> New extern_call.local_prop( qmethid.methid )}
+ | {full} type dot qmethid {-> New extern_call.full_prop( type, dot, qmethid.methid )}
+ | {init} type {-> New extern_call.init_prop( type )}
;
extern_call_cast {-> extern_call}
- = {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)}
- | {as_nullable} type kwas [n2]:no kwnullable {-> New extern_call.as_nullable( type, kwas, kwnullable)}
- | {as_not_nullable} type kwas [n2]:no kwnot [n3]:no kwnullable {-> New extern_call.as_not_nullable( type, kwas, kwnot, kwnullable)}
+ = {as_cast} [from_type]:type dot kwas [n2]:no opar [n3]:no [to_type]:type [n4]:no cpar {-> New extern_call.cast_as(from_type, dot, kwas, to_type)}
+ | {as_cast2}[from_type]:type dot kwas [n2]:no [to_type]:type {-> New extern_call.cast_as(from_type, dot, kwas, to_type)}
+ | {as_nullable} type dot kwas [n2]:no opar [n3]:no kwnullable [n4]:no cpar {-> New extern_call.as_nullable( type, kwas, kwnullable)}
+ | {as_nullable2}type dot kwas [n2]:no kwnullable {-> New extern_call.as_nullable( type, kwas, kwnullable)}
+ | {as_not_nullable} type dot kwas [n2]:no opar [n3]:no kwnot [n4]:no kwnullable [n5]:no cpar {-> New extern_call.as_not_nullable( type, kwas, kwnot, kwnullable)}
+ | {as_not_nullable2}type dot kwas [n2]:no kwnot [n3]:no kwnullable {-> New extern_call.as_not_nullable( type, kwas, kwnot, kwnullable)}
;
-in_language = kwin string;
+string_o {->string?} = string? {-> string};
+
+in_language = kwin no string [n1]:no {-> New in_language(kwin, string)};
extern_code_block = in_language? extern_code_segment;
+extern_code_block_o {-> extern_code_block?}
+ = extern_code_block {-> extern_code_block}
+ | {null} {-> Null}
+ ;
extern_code_body {-> extern_code_block} = no extern_code_block {-> extern_code_block};
/* TYPES *********************************************************************/
type~nobra~nopar {-> type}
- = {simple} kwnullable? classid annotations~nopar? {-> New type(kwnullable, classid, [], annotations~nopar.annotations)}
-!nobra | {generic} kwnullable? classid obra no types [n2]:no cbra annotations~nopar? {-> New type(kwnullable, classid, [types.type], annotations~nopar.annotations)}
+ = {simple} kwnullable? qclassid annotations_o~nopar {-> New type(kwnullable, qclassid, Null, [], Null, annotations_o~nopar.annotations)}
+!nobra | {generic} kwnullable? qclassid obra no types [n2]:no cbra annotations_o~nopar {-> New type(kwnullable, qclassid, obra, [types.type], cbra, annotations_o~nopar.annotations)}
;
-types {-> type*}
+types {-> type*}
= type types_tail* {-> [type, types_tail.type]};
types_tail {-> type}
= comma no type {-> type};
typing {-> type}
= column no type {-> type};
+typing_o {-> type?}
+ = column no type {-> type}
+ | {null} {-> Null}
+ ;
/* STATMENTS *****************************************************************/
stmtso~withelse~withend {-> expr?}
stmts_tail {-> expr}
= n stmt {-> stmt.expr};
stmt~withelse~noexpr~nopar {-> expr}
- = {vardecl} vardecl~withelse {-> vardecl~withelse.expr}
- | {assign} assignment~withelse~nopar {-> assignment~withelse~nopar.expr}
- | {return} kwreturn expr_final~withelse? {-> New expr.return(kwreturn, expr_final~withelse.expr)}
- | {break} kwbreak label? expr_final~withelse? {-> New expr.break(kwbreak, label, expr_final~withelse.expr)}
+ = {vardecl} vardecl {-> vardecl.expr}
+ | {assign} assignment~nopar {-> assignment~nopar.expr}
+ | {return} kwreturn expr? {-> New expr.return(kwreturn, expr)}
+ | {yield} kwyield expr {-> New expr.yield(kwyield, expr)}
+ | {break} kwbreak label? {-> New expr.break(kwbreak, label)}
| {abort} kwabort {-> New expr.abort(kwabort)}
- | {continue} kwcontinue label? expr_final~withelse? {-> New expr.continue(kwcontinue, label, expr_final~withelse.expr)}
+ | {continue} kwcontinue label? {-> New expr.continue(kwcontinue, label)}
| {do} do~withelse {-> do~withelse.expr}
!noexpr | {if} if~withelse {-> if~withelse.expr}
| {while} while~withelse {-> while~withelse.expr}
| {loop} loop~withelse {-> loop~withelse.expr}
| {for} for~withelse {-> for~withelse.expr}
+ | {with} with~withelse {-> with~withelse.expr}
| {assert} assert~withelse {-> assert~withelse.expr}
-!noexpr | {call} recv id args_nopar closure_defs~withelse? {-> New expr.call(recv.expr, id, args_nopar.exprs, [closure_defs~withelse.closure_def])}
-!noexpr | {super} qualified? kwsuper args_nopar {-> New expr.super(qualified, kwsuper, args_nopar.exprs)}
-!noexpr | {init} recv kwinit args_nopar {-> New expr.init(recv.expr, kwinit, args_nopar.exprs)}
- | {debug_type_is} kwdebug kwtype type column expr_final~withelse {-> New expr.debug_type(kwdebug, kwtype, expr_final~withelse.expr, type) }
+!noexpr | {call} recv qid args_nopar {-> New expr.call(recv.expr, qid, args_nopar.exprs)}
+!noexpr | {super} qualified_o kwsuper args_nopar {-> New expr.super(qualified_o.qualified, kwsuper, args_nopar.exprs)}
+!noexpr | {init} recv qualified? kwinit args_nopar {-> New expr.init(recv.expr, kwinit, args_nopar.exprs)}
+ | {debug_type_is} kwdebug kwtype type column expr {-> New expr.debug_type(kwdebug, kwtype, expr.expr, type) }
;
-label= kwlabel id;
+label= kwlabel id?;
-closure_defs~withelse {-> closure_def*}
- = {one} closure_def_last~withelse {-> [closure_def_last~withelse.closure_def]}
- | closure_def closure_defs~withelse {-> [closure_def, closure_defs~withelse.closure_def]}
+vardecl{-> expr}
+ = kwvar id annotations? typing_o {-> New expr.vardecl(kwvar, id, typing_o.type, Null, Null, annotations)}
+ | {assign} kwvar id annotations? typing_o assign no expr {-> New expr.vardecl(kwvar, id, typing_o.type, assign, expr.expr, annotations)}
;
-closure_def_last~withelse {-> closure_def}
- = bang [id]:closure_id idlist? kwdo stmtso_withend label {-> New closure_def(bang, id, [idlist.id], kwdo, stmtso_withend.expr, label)}
- | {nolabel} bang [id]:closure_id idlist? kwdo stmtso~withelse {-> New closure_def(bang, id, [idlist.id], kwdo, stmtso~withelse.expr, Null)}
- | {assign} bang [id]:closure_id idlist? assign no assign_continue~withelse {-> New closure_def(bang, id, [idlist.id], Null, assign_continue~withelse.expr, Null)}
- ;
-
-closure_def {-> closure_def}
- = bang [id]:closure_id idlist? kwdo n stmtsn {-> New closure_def(bang, id, [idlist.id], kwdo, stmtsn.expr, Null)}
- | {empty} bang [id]:closure_id idlist? kwdo n {-> New closure_def(bang, id, [idlist.id], kwdo, Null, Null)}
- ;
-closure_id
- = {simple} id
- | {break} kwbreak
- ;
-
-assign_continue~withelse{-> expr}
- = expr_final~withelse {-> New expr.continue(Null, Null, expr_final~withelse.expr)}
- ;
-
-vardecl~withelse{-> expr}
- = kwvar id annotations? typing? {-> New expr.vardecl(kwvar, id, typing.type, Null, Null, annotations)}
- | {assign} kwvar id annotations? typing? assign no expr_final~withelse {-> New expr.vardecl(kwvar, id, typing.type, assign, expr_final~withelse.expr, annotations)}
- ;
-
-assignment~withelse~nopar {-> expr}
- = {attr} recv~nopar attrid assign expr_final~withelse {-> New expr.attr_assign(recv~nopar.expr, attrid, assign, expr_final~withelse.expr)}
- | {call} recv~nopar id args assign expr_final~withelse {-> New expr.call_assign(recv~nopar.expr, id, args.exprs, assign, expr_final~withelse.expr)}
- | {bra} expr_atom~nopar braargs assign expr_final~withelse {-> New expr.bra_assign(expr_atom~nopar.expr, braargs.exprs, assign, expr_final~withelse.expr)}
- | {attr_re} recv~nopar attrid assign_op expr_final~withelse {-> New expr.attr_reassign(recv~nopar.expr, attrid, assign_op, expr_final~withelse.expr)}
- | {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)}
- | {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)}
+assignment~nopar {-> expr}
+ = {attr} recv~nopar qualified_o attrid assign expr {-> New expr.attr_assign(recv~nopar.expr, attrid, assign, expr)}
+ | {call} recv~nopar qid args assign expr {-> New expr.call_assign(recv~nopar.expr, qid, args.exprs, assign, expr)}
+ | {bra} expr_atom~nopar braargs assign expr {-> New expr.bra_assign(expr_atom~nopar.expr, braargs.exprs, assign, expr)}
+ | {attr_re} recv~nopar qualified_o attrid assign_op expr {-> New expr.attr_reassign(recv~nopar.expr, attrid, assign_op, expr)}
+ | {call_re} recv~nopar qid args assign_op expr {-> New expr.call_reassign(recv~nopar.expr, qid, args.exprs, assign_op, expr)}
+ | {bra_re} expr_atom~nopar braargs assign_op expr {-> New expr.bra_reassign(expr_atom~nopar.expr, braargs.exprs, assign_op, expr)}
;
assign_op
= {plus} pluseq
| {minus} minuseq
+ | {star} stareq
+ | {slash} slasheq
+ | {percent} percenteq
+ | {starstar} starstareq
+ | {pipe} pipeeq
+ | {caret} careteq
+ | {amp} ampeq
+ | {ll} lleq
+ | {gg} ggeq
;
do~withelse {-> expr}
- = kwdo stmtso_withend label {-> New expr.do(kwdo, stmtso_withend.expr, label)}
- | {nolabel} kwdo stmtso~withelse {-> New expr.do(kwdo, stmtso~withelse.expr, Null)}
+ = kwdo stmtso_withend label {-> New expr.do(kwdo, stmtso_withend.expr, Null, Null, label)}
+ | {nolabel} kwdo stmtso~withelse {-> New expr.do(kwdo, stmtso~withelse.expr, Null, Null, Null)}
+ | {with_catch} kwdo n stmtsn kwcatch stmtso_withend {-> New expr.do(kwdo, stmtsn.expr, kwcatch, stmtso_withend.expr, Null)}
;
if~withelse {-> expr}
- = {onelineelse} kwif no expr [n2]:no kwthen stmt_withelse kwelse stmtso~withelse {-> New expr.if(kwif, expr, stmt_withelse.expr, stmtso~withelse.expr)}
-!withelse | {oneline} kwif no expr [n2]:no kwthen stmt {-> New expr.if(kwif, expr, stmt.expr, Null)}
-!withelse | {block} kwif no expr [n2]:no kwthen [n3]:n stmtsn elsepartblock {-> New expr.if(kwif, expr, stmtsn.expr, elsepartblock.expr)}
-!withelse | {emptyblock} kwif no expr [n2]:no kwthen [n3]:n? elsepartblock {-> New expr.if(kwif, expr, Null, elsepartblock.expr)}
+ = {onelineelse} kwif no expr [n2]:no kwthen stmt_withelse kwelse stmtso~withelse {-> New expr.if(kwif, expr, kwthen, stmt_withelse.expr, kwelse, stmtso~withelse.expr)}
+!withelse | {oneline} kwif no expr [n2]:no kwthen stmt {-> New expr.if(kwif, expr, kwthen, stmt.expr, Null, Null)}
+!withelse | {block} kwif no expr [n2]:no kwthen [n3]:n stmtsn kwelse stmtso {-> New expr.if(kwif, expr, kwthen, stmtsn.expr, kwelse, stmtso.expr)}
+!withelse | {emptyblock} kwif no expr [n2]:no kwthen [n3]:n? kwelse stmtso {-> New expr.if(kwif, expr, kwthen, Null, kwelse, stmtso.expr)}
+!withelse | {blocknoelse} kwif no expr [n2]:no kwthen [n3]:n stmtsn endblock {-> New expr.if(kwif, expr, kwthen, stmtsn.expr, Null, endblock.expr)}
+!withelse | {emptyblocknoelse} kwif no expr [n2]:no kwthen [n3]:n? endblock {-> New expr.if(kwif, expr, kwthen, Null, Null, endblock.expr)}
;
-elsepartblock {-> expr?}
- = {else} kwelse stmtso {-> stmtso.expr}
- | {empty} kwend {-> New expr.block([], kwend)}
+endblock {-> expr}
+ = {empty} kwend {-> New expr.block([], kwend)}
;
loop~withelse {-> expr}
;
for~withelse {-> expr}
- = 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)}
- | {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)}
+ = kwfor no for_groups [n4]:no kwdo stmtso_withend label {-> New expr.for(kwfor, [for_groups.for_group], kwdo, stmtso_withend.expr, label)}
+ | {nolabel} kwfor no for_groups [n4]:no kwdo stmtso~withelse {-> New expr.for(kwfor, [for_groups.for_group], kwdo, stmtso~withelse.expr, Null)}
+ ;
+
+for_groups {-> for_group*}
+ = {one} for_group {-> [for_group]}
+ | {many} for_groups no comma [n2]:no for_group {-> [for_groups.for_group, for_group] }
+ ;
+for_group
+ = [ids]:idlist [n2]:no kwin [n3]:no expr {-> New for_group([ids.id], kwin, expr)}
+ ;
+
+with~withelse {-> expr}
+ = kwwith no withexpr [n4]:no kwdo stmtso_withend label {-> New expr.with(kwwith, withexpr.expr, kwdo, stmtso_withend.expr, label)}
+ | {nolabel} kwwith no withexpr [n4]:no kwdo stmtso~withelse {-> New expr.with(kwwith, withexpr.expr, kwdo, stmtso~withelse.expr, Null)}
+ ;
+
+withexpr {-> expr}
+ = {assign} id annotations? typing_o assign no expr {-> New expr.vardecl(Null, id, typing_o.type, assign, expr.expr, annotations)}
+ | expr {-> expr}
;
assert~withelse {-> expr}
- = {else} kwassert assertid? expr_final_withelse kwelse stmtso~withelse {-> New expr.assert(kwassert, assertid.id, expr_final_withelse.expr, stmtso~withelse.expr)}
-!withelse| {noelse} kwassert assertid? expr_final {-> New expr.assert(kwassert, assertid.id, expr_final.expr, Null)}
+ = {else} kwassert assertid? expr kwelse stmtso~withelse {-> New expr.assert(kwassert, assertid.id, expr, kwelse, stmtso~withelse.expr)}
+!withelse| {noelse} kwassert assertid? expr {-> New expr.assert(kwassert, assertid.id, expr, Null, Null)}
;
assertid {-> id}
= id column {-> id};
/* EXPRESSIONS ***************************************************************/
-expr_final~nopar~withelse~nobra {-> expr}
- = expr~nopar~nobra {-> expr~nopar~nobra.expr}
- | {closure_call} recv~nobra id args closure_defs~withelse {-> New expr.call(recv~nobra.expr, id, args.exprs, [closure_defs~withelse.closure_def])}
-!nobra!nopar | {closure_bra} expr_atom braargs closure_defs~withelse {-> New expr.bra(expr_atom.expr, braargs.exprs, [closure_defs~withelse.closure_def])}
+expr~nopar~nobra {-> expr}
+ = expr_and~nopar~nobra {-> expr_and~nopar~nobra.expr}
+ | {ifexpr} kwif [n1]:no expr [n2]:no kwthen [n3]:no [then]:expr [n4]:no kwelse [n5]:no [else]:expr~nopar~nobra {-> New expr.ifexpr(kwif, expr, kwthen, then, kwelse, else.expr)}
+ ;
+
+expr_and~nopar~nobra {-> expr}
+ = expr_not~nopar~nobra {-> expr_not~nopar~nobra.expr}
+ | {:or} expr_and~nopar~nobra kwor :no expr_not~nopar~nobra
+ | {:and} expr_and~nopar~nobra kwand :no expr_not~nopar~nobra
+ | {:or_else} expr_and~nopar~nobra kwor kwelse :no expr_not~nopar~nobra
+ | {:implies} expr_and~nopar~nobra kwimplies :no expr_not~nopar~nobra
;
-expr~nopar~nobra~nois {-> expr}
- = expr_and~nopar~nobra~nois {-> expr_and~nopar~nobra~nois.expr}
- | {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)}
+expr_not~nopar~nobra {-> expr}
+ = expr_eq~nopar~nobra {-> expr_eq~nopar~nobra.expr}
+ | {not} kwnot no expr_not~nopar~nobra {-> New expr.not(kwnot, expr_not~nopar~nobra.expr)}
;
-expr_and~nopar~nobra~nois {-> expr}
- = expr_not~nopar~nobra~nois {-> expr_not~nopar~nobra~nois.expr}
- | {:or} expr_and~nopar~nobra~nois :kwor :no expr_not~nopar~nobra~nois
- | {:and} expr_and~nopar~nobra~nois :kwand :no expr_not~nopar~nobra~nois
- | {:or_else} expr_and~nopar~nobra~nois :kwor :kwelse :no expr_not~nopar~nobra~nois
+expr_eq~nopar~nobra {-> expr}
+ = expr_bitor~nopar~nobra {-> expr_bitor~nopar~nobra.expr}
+ | {:eq} expr_bitor~nopar~nobra eq :no [expr2]:expr_bitor~nopar~nobra
+ | {:ne} expr_bitor~nopar~nobra ne :no [expr2]:expr_bitor~nopar~nobra
+ | {:lt} expr_bitor~nopar~nobra lt :no [expr2]:expr_bitor~nopar~nobra
+ | {:le} expr_bitor~nopar~nobra le :no [expr2]:expr_bitor~nopar~nobra
+ | {:gt} expr_bitor~nopar~nobra gt :no [expr2]:expr_bitor~nopar~nobra
+ | {:ge} expr_bitor~nopar~nobra ge :no [expr2]:expr_bitor~nopar~nobra
+ | {:starship} expr_bitor~nopar~nobra starship :no [expr2]:expr_bitor~nopar~nobra
+ | {:isa} expr_bitor~nopar~nobra kwisa :no type~nobra
;
-expr_not~nopar~nobra~nois {-> expr}
- = expr_eq~nopar~nobra~nois {-> expr_eq~nopar~nobra~nois.expr}
- | {not} kwnot no expr_not~nopar~nobra~nois {-> New expr.not(kwnot, expr_not~nopar~nobra~nois.expr)}
+expr_bitor~nopar~nobra {-> expr}
+ = [expr]:expr_bitxor~nopar~nobra {-> expr.expr}
+ | {:pipe} expr_bitor~nopar~nobra pipe :no [expr2]:expr_bitxor~nopar~nobra
;
-expr_eq~nopar~nobra~nois {-> expr}
- = expr_add~nopar~nobra {-> expr_add~nopar~nobra.expr}
- | {:eq} expr_add~nopar~nobra :eq :no [expr2]:expr_add~nopar~nobra
-!nois | {ee} [expr]:expr_add~nopar~nobra kwis no [expr2]:expr_add~nopar~nobra {-> New expr.ee(expr.expr, expr2.expr)}
- | {:ne} expr_add~nopar~nobra :ne :no [expr2]:expr_add~nopar~nobra
- | {:lt} expr_add~nopar~nobra :lt :no [expr2]:expr_add~nopar~nobra
- | {:le} expr_add~nopar~nobra :le :no [expr2]:expr_add~nopar~nobra
- | {:ll} expr_eq~nopar~nobra~nois :ll :no [expr2]:expr_add~nopar~nobra
- | {:gt} expr_add~nopar~nobra :gt :no [expr2]:expr_add~nopar~nobra
- | {:ge} expr_add~nopar~nobra :ge :no [expr2]:expr_add~nopar~nobra
- | {:gg} expr_eq~nopar~nobra~nois :gg :no [expr2]:expr_add~nopar~nobra
- | {:starship} expr_add~nopar~nobra :starship :no [expr2]:expr_add~nopar~nobra
- | {:isa} expr_add~nopar~nobra :kwisa :no type~nobra
+expr_bitxor~nopar~nobra {-> expr}
+ = [expr]:expr_bitand~nopar~nobra {-> expr.expr}
+ | {:caret} expr_bitxor~nopar~nobra caret :no [expr2]:expr_bitand~nopar~nobra
+ ;
+
+expr_bitand~nopar~nobra {-> expr}
+ = [expr]:expr_shift~nopar~nobra {-> expr.expr}
+ | {:amp} expr_bitand~nopar~nobra amp :no [expr2]:expr_shift~nopar~nobra
+ ;
+
+expr_shift~nopar~nobra {-> expr}
+ = [expr]:expr_add~nopar~nobra {-> expr.expr}
+ | {:ll} expr_shift~nopar~nobra ll :no [expr2]:expr_add~nopar~nobra
+ | {:gg} expr_shift~nopar~nobra gg :no [expr2]:expr_add~nopar~nobra
;
expr_add~nopar~nobra {-> expr}
= expr_mul~nopar~nobra {-> expr_mul~nopar~nobra.expr}
- | {:plus} expr_add~nopar~nobra :plus :no [expr2]:expr_mul~nopar~nobra
- | {:minus} expr_add~nopar~nobra :minus :no [expr2]:expr_mul~nopar~nobra
+ | {:plus} expr_add~nopar~nobra plus :no [expr2]:expr_mul~nopar~nobra
+ | {:minus} expr_add~nopar~nobra minus :no [expr2]:expr_mul~nopar~nobra
;
expr_mul~nopar~nobra {-> expr}
+ = expr_pow~nopar~nobra {-> expr_pow~nopar~nobra.expr}
+ | {:star} expr_mul~nopar~nobra star :no [expr2]:expr_pow~nopar~nobra
+ | {:slash} expr_mul~nopar~nobra slash :no [expr2]:expr_pow~nopar~nobra
+ | {:percent} expr_mul~nopar~nobra percent :no [expr2]:expr_pow~nopar~nobra
+ ;
+
+expr_pow~nopar~nobra {-> expr}
= expr_minus~nopar~nobra {-> expr_minus~nopar~nobra.expr}
- | {:star} expr_mul~nopar~nobra :star :no [expr2]:expr_minus~nopar~nobra
- | {:slash} expr_mul~nopar~nobra :slash :no [expr2]:expr_minus~nopar~nobra
- | {:percent} expr_mul~nopar~nobra :percent :no [expr2]:expr_minus~nopar~nobra
+ | {:starstar} expr_minus~nopar~nobra starstar :no [expr2]:expr_pow~nopar~nobra
;
expr_minus~nopar~nobra {-> expr}
= expr_new~nopar~nobra {-> expr_new~nopar~nobra.expr}
- | {:uminus} minus :no expr_minus~nopar~nobra
- | {:once} kwonce :no expr_minus~nopar~nobra
+ | {:uminus} minus expr_minus~nobra
+ | {:uplus} plus expr_minus~nobra
+ | {:utilde} tilde expr_minus~nobra
+ | {:once} kwonce :no expr_minus~nobra
;
expr_new~nopar~nobra {-> expr}
= expr_atom~nopar~nobra {-> expr_atom~nopar~nobra.expr}
| {new} kwnew no type~nobra_nopar args {-> New expr.new(kwnew, type~nobra_nopar.type, Null, args.exprs)}
- | {isset_attr} kwisset recv~nopar~nobra attrid {-> New expr.isset_attr(kwisset, recv~nopar~nobra.expr, attrid)}
+ | {isset_attr} kwisset recv~nopar~nobra qualified_o attrid {-> New expr.isset_attr(kwisset, recv~nopar~nobra.expr, attrid)}
;
expr_atom~nopar~nobra {-> expr}
- = {attr} recv~nopar~nobra attrid {-> New expr.attr(recv~nopar~nobra.expr, attrid)}
- | {call} recv~nopar~nobra id args {-> New expr.call(recv~nopar~nobra.expr, id, args.exprs, [])}
- | {super} qualified? kwsuper args {-> New expr.super(qualified, kwsuper, args.exprs)}
+ = expr_single~nopar~nobra {-> expr_single~nopar~nobra.expr}
+ | {attr} recv~nopar~nobra qualified_o attrid {-> New expr.attr(recv~nopar~nobra.expr, attrid)}
+ | {call} recv~nopar~nobra qid args {-> New expr.call(recv~nopar~nobra.expr, qid, args.exprs)}
+ | {super} qualified_o kwsuper args {-> New expr.super(qualified_o.qualified, kwsuper, args.exprs)}
| {init} recv~nopar~nobra kwinit args {-> New expr.init(recv~nopar~nobra.expr, kwinit, args.exprs)}
-!nobra | {bra} expr_atom~nopar braargs {-> New expr.bra(expr_atom~nopar.expr, braargs.exprs, [])}
- | {new} kwnew no type~nobra_nopar dot [n2]:no id args {-> New expr.new(kwnew, type~nobra_nopar.type, id, args.exprs)}
-// !nopar to unambiguise 'foo[5].bar' between '(foo[5]).bar' and 'foo([5].bar),
-!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)}
-!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)}
-!nobra!nopar | {array} braargs annotations? {-> New expr.array(braargs.exprs, annotations)}
- | {self} kwself annotations? {-> New expr.self(kwself, annotations)}
- | {true} kwtrue annotations? {-> New expr.true(kwtrue, annotations)}
- | {false} kwfalse annotations? {-> New expr.false(kwfalse, annotations)}
- | {null} kwnull annotations? {-> New expr.null(kwnull, annotations)}
- | {int} number annotations? {-> New expr.int(number, annotations)}
- | {float} float annotations? {-> New expr.float(float, annotations)}
- | {char} char annotations? {-> New expr.char(char, annotations)}
- | {string} string annotations? {-> New expr.string(string, annotations)}
- | {superstring} superstring {-> superstring.expr}
-!nopar | {par} opar expr cpar annotations? {-> New expr.par(opar, expr, cpar, annotations)}
+!nobra | {bra} expr_atom~nopar braargs {-> New expr.bra(expr_atom~nopar.expr, braargs.exprs)}
+ | {new} kwnew no type~nobra_nopar dot [n2]:no qid args {-> New expr.new(kwnew, type~nobra_nopar.type, qid, args.exprs)}
| {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)}
| {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)}
+ | {as_notnull2}expr_atom~nopar~nobra dot no kwas [n2]:no kwnot [n4]:no kwnull {-> New expr.as_notnull(expr_atom~nopar~nobra.expr, kwas, Null, kwnot, kwnull, Null)}
+ ;
+
+arg~nopar~nobra {-> expr}
+ = [expr]:expr~nopar~nobra {-> expr.expr}
+ | {vararg} [expr]:expr~nopar~nobra dotdotdot {-> New expr.vararg(expr.expr, dotdotdot)}
+ | {namedarg} id assign [expr]:expr~nopar~nobra {-> New expr.namedarg(id, assign, expr.expr) }
+ ;
+
+expr_single~nopar~nobra {-> expr}
+ = {self} kwself annotations_o {-> New expr.self(kwself, annotations_o.annotations)}
+ | {true} kwtrue annotations_o {-> New expr.true(kwtrue, annotations_o.annotations)}
+ | {false} kwfalse annotations_o {-> New expr.false(kwfalse, annotations_o.annotations)}
+ | {null} kwnull annotations_o {-> New expr.null(kwnull, annotations_o.annotations)}
+ | {integer} integer annotations_o {-> New expr.integer(integer, annotations_o.annotations)}
+ | {float} float annotations_o {-> New expr.float(float, annotations_o.annotations)}
+ | {char} char annotations_o {-> New expr.char(char, annotations_o.annotations)}
+ | {string} string annotations_o {-> New expr.string(string, annotations_o.annotations)}
+ | {superstring} superstring {-> superstring.expr}
+!nopar | {par} expr_par {-> expr_par.expr}
+// !nopar to unambiguise 'foo[5].bar' between '(foo[5]).bar' and 'foo([5].bar),
+!nobra!nopar | {range} obra no expr [n2]:no dotdot [n3]:no [expr2]:expr_nobra [n4]:no cbra annotations_o {-> New expr.crange(obra, expr, dotdot, expr2.expr, cbra, annotations_o.annotations)}
+!nobra!nopar | {orange} obra no expr [n2]:no dotdot [n3]:no [expr2]:expr_nobra [n4]:no [cbra]:obra annotations_o {-> New expr.orange(obra, expr, dotdot, expr2.expr, cbra, annotations_o.annotations)}
+!nobra!nopar | {array} obra no array_items typing_o cbra annotations_o {-> New expr.array(obra, [array_items.expr], typing_o.type, cbra, annotations_o.annotations)}
+ ;
+
+expr_par {-> expr}
+ = {par} opar no any_expr [n2]:no cpar annotations_o {-> New expr.par(opar, any_expr.expr, cpar, annotations_o.annotations)}
+ | {tuple} opar no many_expr [n2]:no cpar annotations_o {-> New expr.par(opar, many_expr.expr, cpar, annotations_o.annotations)}
;
-superstring {-> expr}
- = superstring_start superstring_middle* superstring_end annotations? {-> New expr.superstring([superstring_start.expr, superstring_middle.expr, superstring_end.expr], annotations)};
+many_expr {->expr}
+ = any_expr many_expr_tail+ {-> New expr.many([any_expr.expr, many_expr_tail.expr])}
+ ;
+
+many_expr_tail {->expr}
+ = comma no any_expr {-> any_expr.expr}
+ ;
+
+array_items {-> expr*}
+ = array_item array_items_tail* {-> [array_item.expr, array_items_tail.expr]}
+ ;
+array_items_tail {-> expr}
+ = comma no array_item {-> array_item.expr}
+ ;
+array_item {-> expr}
+ = expr no {-> expr}
+ | {for} kwfor no for_groups [n4]:no kwdo [block]:array_item {-> New expr.for(kwfor, [for_groups.for_group], kwdo, block.expr, Null)}
+ | {if} kwif [n1]:no expr [n2]:no kwthen [n3]:no [then]:array_item {-> New expr.if(kwif, expr, kwthen, then.expr, Null, Null)}
+ ;
+
+superstring {-> expr}
+ = superstring_start superstring_middle* superstring_end annotations_o {-> New expr.superstring([superstring_start.expr, superstring_middle.expr, superstring_end.expr], annotations_o.annotations)};
superstring_start {-> expr*}
- = start_string_p no expr [n2]:no {-> [start_string_p.expr, expr]};
+ = start_string_p no expr [n2]:no {-> [start_string_p.expr, expr]}
+ | {noexpr} start_string_p no {-> [start_string_p.expr]}
+ ;
start_string_p {-> expr}
= start_string {-> New expr.start_string(start_string)};
superstring_middle {-> expr*}
- = mid_string_p no expr [n2]:no {-> [mid_string_p.expr, expr]};
+ = mid_string_p no expr [n2]:no {-> [mid_string_p.expr, expr]}
+ | {noexpr} mid_string_p no {-> [mid_string_p.expr]}
+ ;
mid_string_p {-> expr}
= mid_string {-> New expr.mid_string(mid_string)};
superstring_end {-> expr}
/* ANNOTATIONS *******************************************************************/
annotations~nopar {-> annotations}
- = {one} at one_annotation~nopar {-> New annotations(at, Null, [one_annotation~nopar.annotation], Null)}
- | {many} at opar annotation_list cpar {-> New annotations(at, opar, [annotation_list.annotation], cpar)}
+ = {one} at one_annotation~nopar {-> New annotations(Null, at, Null, [one_annotation~nopar.annotation], Null, Null)}
+ | {many} at opar no annotation_list [n2]:no cpar {-> New annotations(Null, at, opar, [annotation_list.annotation], cpar, Null)}
+ ;
+annotations_o~nopar {-> annotations?}
+ = annotations~nopar {-> annotations~nopar.annotations}
+ | {null} {-> Null}
;
one_annotation~nopar {-> annotation}
- = {alone} atid annotations~nopar? {-> New annotation(atid, Null, [], Null, annotations~nopar.annotations)}
+ = {alone} redef visibility atid annotations_o~nopar {-> New annotation(Null, redef.kwredef, visibility, atid, Null, [], Null, annotations_o~nopar.annotations)}
// !nopar to unambiguise 'new T@foo(bar)' between 'new T@(foo(bar))' and 'new (T@foo)(bar)'
-!nopar | {args} atid opar at_args cpar annotations~nopar? {-> New annotation(atid, opar, [at_args.at_arg], cpar, annotations~nopar.annotations)}
- ;
-
-many_annotations {-> annotations}
- = {many} annotation_list {-> New annotations(Null, Null, [annotation_list.annotation], Null)}
+!nopar | {args} redef visibility atid opar no at_args [n2]:no cpar annotations_o~nopar {-> New annotation(Null, redef.kwredef, visibility, atid, opar, [at_args.expr], cpar, annotations_o~nopar.annotations)}
;
annotation_list {-> annotation*}
- = {many} one_annotation annotations_tail* {-> [one_annotation.annotation, annotations_tail.annotation] }
+ = {many} one_annotation_list annotations_tail* {-> [one_annotation_list.annotation, annotations_tail.annotation] }
;
-line_annotations~forclass {-> annotations}
- = line_annotation~forclass+ {-> New annotations(Null, Null, [line_annotation~forclass.annotation], Null) }
+one_annotation_list~nopar {-> annotation}
+ = {alone} redef visibility atid annotations_o~nopar {-> New annotation(Null, redef.kwredef, visibility, atid, Null, [], Null, annotations_o~nopar.annotations)}
+// !nopar to unambiguise 'new T@foo(bar)' between 'new T@(foo(bar))' and 'new (T@foo)(bar)'
+!nopar | {args} redef visibility atid opar no at_args [n2]:no cpar annotations_o~nopar {-> New annotation(Null, redef.kwredef, visibility, atid, opar, [at_args.expr], cpar, annotations_o~nopar.annotations)}
+!nopar | {nopar} redef visibility atid at_arg_single {-> New annotation(Null, redef.kwredef, visibility, atid, Null, [at_arg_single.expr], Null, Null)}
;
-line_annotation~forclass {-> annotation}
- = [doc]:no atid~forclass annotations? n1 {-> New annotation(atid~forclass.atid, Null, [], Null, annotations)}
- | {args} [doc]:no atid~forclass opar at_args cpar annotations? n1 {-> New annotation(atid~forclass.atid, opar, [at_args.at_arg], cpar, annotations)}
- | {nopar} [doc]:no atid~forclass at_args_nopar n1 {-> New annotation(atid~forclass.atid, Null, [at_args_nopar.at_arg], Null, Null)}
+at_arg_single {-> expr}
+// FIXME: why expr_single but not expr_atom is not clear :(
+ = {expr} [expr]:expr_single_nopar {-> expr.expr}
;
annotations_tail {-> annotation}
- = comma no one_annotation {-> one_annotation.annotation}
+ = comma no one_annotation_list {-> one_annotation_list.annotation}
;
-at_args~nopar {-> at_arg* }
- = {many} at_arg~nopar at_args_tail* {-> [at_arg~nopar.at_arg, at_args_tail.at_arg]}
+line_annotation {-> annotation}
+ = [doc]:nd redef visibility atid annotations? n1 {-> New annotation(doc.doc, redef.kwredef, visibility, atid.atid, Null, [], Null, annotations)}
+ | {args} [doc]:nd redef visibility atid opar no at_args cpar annotations? n1 {-> New annotation(doc.doc, redef.kwredef, visibility, atid.atid, opar, [at_args.expr], cpar, annotations)}
+ | {nopar} [doc]:nd redef visibility atid at_args_nopar n1 {-> New annotation(doc.doc, redef.kwredef, visibility, atid.atid, Null, [at_args_nopar.expr], Null, Null)}
+ ;
+line_annotation_forclass {-> propdef}
+ = [doc]:nd atid_forclass annotations? {-> New propdef.annot(doc.doc, Null, Null, atid_forclass.atid, Null, [], Null, annotations)}
+ | {args} [doc]:nd atid_forclass opar no at_args cpar annotations? {-> New propdef.annot(doc.doc, Null, Null, atid_forclass.atid, opar, [at_args.expr], cpar, annotations)}
+ | {nopar} [doc]:nd atid_forclass at_args_nopar {-> New propdef.annot(doc.doc, Null, Null, atid_forclass.atid, Null, [at_args_nopar.expr], Null, Null)}
+ ;
+
+at_args~nopar {-> expr* }
+ = {many} any_expr~nopar at_args_tail* {-> [any_expr~nopar.expr, at_args_tail.expr]}
;
-at_args_tail {-> at_arg}
- = comma no at_arg {-> at_arg}
+at_args_tail {-> expr}
+ = comma no any_expr {-> any_expr.expr}
;
-at_arg~nopar {-> at_arg}
- = {type} type {-> New at_arg.type(type)}
- | {expr} expr~nopar {-> New at_arg.expr(expr~nopar.expr)}
- | {stmt} stmt_noexpr~nopar {-> New at_arg.expr(stmt_noexpr~nopar.expr)}
-!nopar | {at} annotations {-> New at_arg.at(annotations.annotations)}
+any_expr~nopar {-> expr}
+ = {type} type {-> New expr.type(type)}
+ | {expr} expr~nopar {-> expr~nopar.expr}
+ | {stmt} stmt_noexpr~nopar {-> stmt_noexpr~nopar.expr}
+ | {methid} recv~nopar qmethid_noid {-> New expr.methid(recv~nopar.expr, qmethid_noid.methid)}
+!nopar | {at} annotations {-> New expr.at(annotations.annotations)}
;
atid~forclass {-> atid}
- = {id} id {-> New atid.id(id)}
-//!forclass | {kwextern} kwextern {-> New atid.kwextern(kwextern)}
-//!forclass | {kwintern} kwintern {-> New atid.kwintern(kwintern)}
-!forclass | {kwreadable} kwreadable {-> New atid.kwreadable(kwreadable)}
-!forclass | {kwwritable} kwwritable {-> New atid.kwwritable(kwwritable)}
- | {kwimport} kwimport {-> New atid.kwimport(kwimport)}
+ = {id} id {-> New atid.id(id)}
+!forclass | {kwextern} kwextern {-> New atid.kwextern(kwextern)}
+// | {kwimport} kwimport {-> New atid.kwimport(kwimport)}
+ | {kwabstract} kwabstract {-> New atid.kwabstract(kwabstract)}
;
/* MISC **********************************************************************/
;
args {-> exprs}
+ = args_n {-> args_n.exprs}
+ | {empty} {-> New exprs.list([])}
+ ;
+args_n {-> exprs}
= opar no expr_list cpar {-> New exprs.par(opar, [expr_list.expr], cpar) }
| {emptypar} opar no cpar {-> New exprs.par(opar, [], cpar) }
- | {empty} {-> New exprs.list([])}
;
args_nopar {-> exprs}
= opar no expr_list cpar {-> New exprs.par(opar, [expr_list.expr], cpar) }
braargs {-> exprs}
= obra no expr_list cbra {-> New exprs.bra(obra, [expr_list.expr], cbra)};
expr_list {-> expr*}
- = expr [n2]:no expr_tail* {-> [expr, expr_tail.expr]};
-expr_tail {-> expr}
- = comma no expr [n2]:no {-> expr};
+ = arg [n2]:no expr_tail* {-> [arg.expr, expr_tail.expr]};
+expr_tail {-> expr}
+ = comma no arg [n2]:no {-> arg.expr};
idlist {-> id*}
- = opar idlist_nopar cpar {-> [idlist_nopar.id]}
+ = opar no idlist_nopar [n2]:no cpar {-> [idlist_nopar.id]}
| {nopar} idlist_nopar {-> [idlist_nopar.id]}
;
idlist_nopar {-> id*}
= {single} id {-> [id]}
- | {more} idlist_nopar no comma [n2]:no id {-> [idlist_nopar.id, id]}
+ | {more} idlist_nopar comma [n2]:no id {-> [idlist_nopar.id, id]}
;
module_name {-> module_name}
| {root} quad no modquad* id {-> New module_name(quad, [modquad.id], id)}
;
-qualified
+qualified
= {cla} modquad* classquad {-> New qualified([modquad.id], classquad.classid)}
| {mod} modquad+ {-> New qualified([modquad.id], Null)}
- ;
+ ;
+qualified_o {-> qualified?}
+ = qualified {-> qualified}
+ | {null} {-> Null}
+ ;
+qid
+ = qualified? id
+ ;
+qclassid
+ = qualified? classid
+ ;
+qmethid~noid {-> methid}
+ = qualified? methid~noid {-> methid~noid.methid}
+ ;
modquad {-> id}
= id quad no {-> id};
-classquad {-> classid}
+classquad {-> classid}
= classid quad no {-> classid};
-n1 = {a} comment | {b} eol;
-n {-> doc?}
- = {a} n2? comment+ {-> New doc([comment])}
- | {b} n2 {-> Null}
+kwend_o {-> kwend?}
+ = kwend? {-> kwend}
;
-no {-> doc?}
+
+/* A single hard break */
+n1 = {a} comment | {b} eol | {c} semi;
+
+/* A mandatory hard break, returns the last comment */
+n~nosemi {-> doc?}
+ = {a} n2* comment+ {-> New doc([comment])}
+ | {b} n2+ {-> Null}
+!nosemi | {c} n2* comment* semi n? {-> n.doc }
+ ;
+
+/* An optional hard break, returns the last comment.
+ * Used mainly to introduce optional documentation */
+nd {-> doc?}
= {empty} {-> Null}
| n {-> n.doc}
;
+/* An optional soft break.
+ * Used when a unambiguous line break or comment could be inserted/ */
+no
+ = {empty}
+ | n_nosemi
+ ;
+
n2
- = {a} n2? comment+ eol+
- | {b} eol+
+ = {a} comment* eol
;
/*****************************************************************************/
module = moduledecl? [imports]:import* [extern_code_blocks]:extern_code_block* [classdefs]:classdef*;
moduledecl
- = doc? kwmodule [name]:module_name annotations?;
+ = doc? kwredef? visibility kwmodule [name]:module_name annotations?;
import = {std} visibility kwimport [name]:module_name annotations?
| {no} visibility kwimport kwend
;
visibility
- = {public}
+ = {public} kwpublic?
| {private} kwprivate
| {protected} kwprotected
| {intrude} kwintrude
;
-classdef= {std} doc? kwredef? visibility classkind [id]:classid? [formaldefs]:formaldef* annotations? extern_code_block? [superclasses]:superclass* [propdefs]:propdef* kwend
+classdef= {std} doc? kwredef? visibility classkind [qid]:qclassid? obra? [formaldefs]:formaldef* cbra? extern_code_block? [propdefs]:propdef* kwend
| {top} [propdefs]:propdef*
| {main} [propdefs]:propdef*
;
| {extern} kwextern kwclass?
;
formaldef = [id]:classid type? annotations?;
-superclass = kwsuper type annotations?;
-
-
-propdef = {attr} doc? [readable]:able? [writable]:able? kwredef? visibility kwvar [id]:attrid? [id2]:id? type? annotations? expr?
- | {meth} doc? kwredef? visibility methid signature
- | {deferred_meth} doc? kwredef? visibility kwmeth methid signature annotations?
- | {intern_meth} doc? kwredef? visibility kwmeth methid signature
- | {extern_meth} doc? kwredef? visibility kwmeth methid signature [extern]:string? extern_calls? extern_code_block?
- | {concrete_meth} doc? kwredef? visibility kwmeth methid signature annotations? [block]:expr?
- | {concrete_init} doc? kwredef? visibility kwinit methid? signature annotations? [block]:expr?
- //| {concrete_new} doc? kwredef? visibility kwnew methid? signature [block]:expr?
- | {extern_init} doc? kwredef? visibility kwnew methid? signature [extern]:string? extern_calls? extern_code_block?
- | {main_meth} kwredef? [block]:expr?
- | {type} doc? kwredef? visibility kwtype [id]:classid type annotations?
- ;
-able = {read} kwredef? kwreadable
- | {write} kwredef? visibility? kwwritable
- ;
-
-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;
-signature = opar? [params]:param* cpar? type? [closure_decls]:closure_decl*;
+propdef = {attr} doc? kwredef? visibility kwvar [id2]:id type? assign? expr? annotations? kwdo? [block]:expr? kwend?
+ | {main_meth} kwredef? [block]:expr?
+ | {type} doc? kwredef? visibility kwtype [qid]:qclassid type annotations?
+ | {meth} doc? kwredef? visibility kwmeth? kwinit? kwnew? methid? signature annotations? extern_calls? extern_code_block? kwdo? [block]:expr? kwend?
+ | {super} doc? kwredef? visibility kwsuper type annotations?
+ | {annot} doc? kwredef? visibility? atid opar? [args]:expr* cpar? annotations?
+ ;
+
+methid
+ = {id} id
+ | {plus} [op]:plus
+ | {minus} [op]:minus
+ | {star} [op]:star
+ | {starstar} [op]:starstar
+ | {slash} [op]:slash
+ | {percent} [op]:percent
+ | {eq} [op]:eq
+ | {ne} [op]:ne
+ | {le} [op]:le
+ | {ge} [op]:ge
+ | {lt} [op]:lt
+ | {gt} [op]:gt
+ | {ll} [op]:ll
+ | {gg} [op]:gg
+ | {starship} [op]:starship
+ | {pipe} [op]:pipe
+ | {caret} [op]:caret
+ | {amp} [op]:amp
+ | {tilde} [op]:tilde
+ | {bra} obra cbra
+ | {assign} id assign
+ | {braassign} obra cbra assign
+ ;
+
+qid
+ = qualified? id
+ ;
+
+qclassid
+ = qualified? [id]:classid
+ ;
+
+signature = opar? [params]:param* cpar? type?;
param = id type? dotdotdot? annotations?
;
-closure_decl = kwbreak? bang id signature expr?
- ;
+type = kwnullable? [qid]:qclassid obra? [types]:type* cbra? annotations?;
-type = kwnullable? [id]:classid [types]:type* annotations?;
+label = kwlabel id?;
-label = kwlabel id;
-
-expr = {block} expr* kwend?
- | {vardecl} kwvar id type? assign? expr? annotations?
+expr = {block} expr* kwend?
+ | {vardecl} kwvar? id type? assign? expr? annotations?
| {return} kwreturn? expr?
- | {break} kwbreak label? expr?
+ | {yield} kwyield expr
+ | {break} kwbreak label?
| {abort} kwabort
- | {continue} kwcontinue? label? expr?
- | {do} kwdo [block]:expr? label?
- | {if} kwif expr [then]:expr? [else]:expr?
+ | {continue} kwcontinue? label?
+ | {do} kwdo [block]:expr? kwcatch? [catch]:expr? label?
+ | {if} kwif expr kwthen [then]:expr? kwelse? [else]:expr?
| {ifexpr} kwif expr kwthen [then]:expr kwelse [else]:expr
| {while} kwwhile expr kwdo [block]:expr? label?
| {loop} kwloop [block]:expr? label?
- | {for} kwfor [ids]:id* expr kwdo [block]:expr? label?
- | {assert} kwassert id? expr [else]:expr?
- | {once} kwonce expr
- | {send} expr
- | {binop} expr [expr2]:expr
- | {or} expr [expr2]:expr
- | {and} expr [expr2]:expr
- | {or_else} expr [expr2]:expr
- | {not} kwnot expr
- | {eq} expr [expr2]:expr
- | {ee} expr [expr2]:expr
- | {ne} expr [expr2]:expr
- | {lt} expr [expr2]:expr
- | {le} expr [expr2]:expr
- | {ll} expr [expr2]:expr
- | {gt} expr [expr2]:expr
- | {ge} expr [expr2]:expr
- | {gg} expr [expr2]:expr
- | {isa} expr type
- | {plus} expr [expr2]:expr
- | {minus} expr [expr2]:expr
- | {starship} expr [expr2]:expr
- | {star} expr [expr2]:expr
- | {slash} expr [expr2]:expr
- | {percent} expr [expr2]:expr
- | {uminus} minus expr
- | {new} kwnew type id? [args]:exprs
- | {attr} expr [id]:attrid
- | {attr_assign} expr [id]:attrid assign [value]:expr
- | {attr_reassign} expr [id]:attrid assign_op [value]:expr
- | {call} expr id [args]:exprs [closure_defs]:closure_def*
- | {call_assign} expr id [args]:exprs assign [value]:expr
- | {call_reassign} expr id [args]:exprs assign_op [value]:expr
+ | {for} kwfor [groups]:for_group* kwdo [block]:expr? label?
+ | {with} kwwith expr kwdo [block]:expr? label?
+ | {assert} kwassert id? expr kwelse? [else]:expr?
+ | {once} kwonce expr
+ | {send} expr
+ | {binop} expr [expr2]:expr
+ | {or} expr [op]:kwor [expr2]:expr
+ | {and} expr [op]:kwand [expr2]:expr
+ | {or_else} expr [op]:kwor kwelse [expr2]:expr
+ | {implies} expr [op]:kwimplies [expr2]:expr
+ | {not} kwnot expr
+ | {eq} expr [op]:eq [expr2]:expr
+ | {ne} expr [op]:ne [expr2]:expr
+ | {lt} expr [op]:lt [expr2]:expr
+ | {le} expr [op]:le [expr2]:expr
+ | {ll} expr [op]:ll [expr2]:expr
+ | {gt} expr [op]:gt [expr2]:expr
+ | {ge} expr [op]:ge [expr2]:expr
+ | {gg} expr [op]:gg [expr2]:expr
+ | {isa} expr kwisa type
+ | {plus} expr [op]:plus [expr2]:expr
+ | {minus} expr [op]:minus [expr2]:expr
+ | {starship} expr [op]:starship [expr2]:expr
+ | {star} expr [op]:star [expr2]:expr
+ | {starstar} expr [op]:starstar [expr2]:expr
+ | {slash} expr [op]:slash [expr2]:expr
+ | {percent} expr [op]:percent [expr2]:expr
+ | {pipe} expr [op]:pipe [expr2]:expr
+ | {caret} expr [op]:caret [expr2]:expr
+ | {amp} expr [op]:amp [expr2]:expr
+ | {uminus} [op]:minus expr
+ | {uplus} [op]:plus expr
+ | {utilde} [op]:tilde expr
+ | {new} kwnew type qid? [args]:exprs
+ | {attr} expr [id]:attrid
+ | {attr_assign} expr [id]:attrid assign [value]:expr
+ | {attr_reassign} expr [id]:attrid assign_op [value]:expr
+ | {call} expr qid [args]:exprs
+ | {call_assign} expr qid [args]:exprs assign [value]:expr
+ | {call_reassign} expr qid [args]:exprs assign_op [value]:expr
| {super} qualified? kwsuper [args]:exprs
- | {init} expr kwinit [args]:exprs
- | {bra} expr [args]:exprs [closure_defs]:closure_def*
- | {bra_assign} expr [args]:exprs assign [value]:expr
- | {bra_reassign} expr [args]:exprs assign_op [value]:expr
- | {closure_call} id [args]:exprs [closure_defs]:closure_def*
+ | {init} expr kwinit [args]:exprs
+ | {bra} expr [args]:exprs
+ | {bra_assign} expr [args]:exprs assign [value]:expr
+ | {bra_reassign} expr [args]:exprs assign_op [value]:expr
| {var} id
- | {var_assign} id assign [value]:expr
- | {var_reassign} id assign_op [value]:expr
+ | {var_assign} id assign [value]:expr
+ | {var_reassign} id assign_op [value]:expr
| {range} expr [expr2]:expr annotations?
- | {crange} obra expr [expr2]:expr cbra annotations?
- | {orange} obra expr [expr2]:expr [cbra]:obra annotations?
- | {array} [exprs]:exprs annotations?
+ | {crange} obra expr dotdot [expr2]:expr cbra annotations?
+ | {orange} obra expr dotdot [expr2]:expr [cbra]:obra annotations?
+ | {array} obra [exprs]:expr* type? cbra annotations?
| {self} kwself annotations?
- | {implicit_self}
+ | {implicit_self}
| {true} kwtrue annotations?
| {false} kwfalse annotations?
| {null} kwnull annotations?
- | {int} number annotations?
+ | {integer} integer annotations?
| {float} float annotations?
| {char} char annotations?
| {string} string annotations?
- | {start_string} [string]:start_string
- | {mid_string} [string]:mid_string
- | {end_string} [string]:end_string
+ | {start_string} [string]:start_string
+ | {mid_string} [string]:mid_string
+ | {end_string} [string]:end_string
| {superstring} [exprs]:expr* annotations?
| {par} opar expr cpar annotations?
- | {as_cast} expr kwas opar type cpar
- | {as_notnull} expr kwas opar kwnot kwnull cpar
+ | {as_cast} expr kwas opar? type cpar?
+ | {as_notnull} expr kwas opar? kwnot kwnull cpar?
| {isset_attr} kwisset expr [id]:attrid
| {debug_type} kwdebug kwtype expr type
+ | {vararg} expr dotdotdot
+ | {namedarg} id assign expr
+ | {type} type
+ | {methid} expr [id]:methid
+ | {at} annotations
+ | {many} [exprs]:expr*
;
exprs
= {list} [exprs]:expr*
| {bra} obra [exprs]:expr* cbra
;
assign_op
- = {plus} pluseq
- | {minus} minuseq
- ;
-
-closure_def
- = bang [id]:closure_id [ids]:id* kwdo? expr? label?
- ;
-closure_id
- = {simple} id
- | {break} kwbreak
+ = {plus} [op]:pluseq
+ | {minus}[op]:minuseq
+ | {star} [op]:stareq
+ | {slash} [op]:slasheq
+ | {percent} [op]:percenteq
+ | {starstar} [op]:starstareq
+ | {pipe} [op]:pipeeq
+ | {caret} [op]:careteq
+ | {amp} [op]:ampeq
+ | {ll} [op]:lleq
+ | {gg} [op]:ggeq
+ ;
+for_group
+ = [ids]:id* kwin expr
;
module_name = quad? [path]:id* id;
extern_call =
| {super} kwsuper
| {local_prop} methid
- | {full_prop} classid quad? methid
- | {init_prop} classid
- | {cast_as} [from_type]:type kwas [to_type]:type
+ | {full_prop} type dot? methid
+ | {init_prop} type
+ | {cast_as} [from_type]:type dot? kwas [to_type]:type
| {as_nullable} type kwas kwnullable
| {as_not_nullable} type kwas kwnot kwnullable
;
doc = comment+;
-annotations = at? opar? [items]:annotation* cpar?;
+annotations = kwis? at? opar? [items]:annotation* cpar? kwend?;
-annotation = atid opar? [args]:at_arg* cpar? annotations?;
+annotation = doc? kwredef? visibility? atid opar? [args]:expr* cpar? annotations?;
-at_arg
- = {type} type
- | {expr} expr
- | {at} annotations
- ;
-atid = {id} id | {kwextern} [id]:kwextern | {kwintern} [id]:kwintern | {kwreadable} [id]:kwreadable | {kwwritable} [id]:kwwritable | {kwimport} [id]:kwimport;
+atid = {id} id | {kwextern} [id]:kwextern | {kwabstract} [id]:kwabstract | {kwimport} [id]:kwimport;
/*****************************************************************************/