;
extern_code_body = extern_code_char*;
+id = lowercase letter*;
+
/*****************************************************************************/
States
/*****************************************************************************/
semi=';';
classid = uppercase letter*;
-id = lowercase letter*;
+id = id;
attrid = '_' lowercase letter*;
integer = (number | hex_number | bin_number | oct_number) (('u' prec) | ('i' prec) |);
float = digit* '.' digit+ | (digit+ | digit* '.' digit+) ('E'|'e') ('+'|'-'|) digit+;
-string = '"' str_body '"' | '"' '"' '"' long_str_body lsend1 | ''' ''' ''' long_sstr_body ''' ''' ''';
-start_string = '"' str_body '{' | '"' '"' '"' long_str_body lsend2;
+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 '"' | '}' '}' '}' long_str_body lsend1;
-char = (''' [[any - '''] - '\'] ''') | (''' '\' any ''');
+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;
/* CLASSES *******************************************************************/
classdef
- = [doc]:nd redef visibility classkind no qclassid extern_code_block? propdefs kwend {-> New classdef.std(doc.doc, redef.kwredef, visibility, classkind, qclassid.classid, 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.classid, obra, [formaldefs.formaldef], cbra, extern_code_block, [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?}
!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 classid typing annotation_withend {-> New propdef.type(doc.doc, redef.kwredef, visibility, kwtype, classid, typing.type, annotation_withend.annotations)}
+!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}
/* TYPES *********************************************************************/
type~nobra~nopar {-> type}
- = {simple} kwnullable? classid annotations_o~nopar {-> New type(kwnullable, classid, Null, [], Null, annotations_o~nopar.annotations)}
-!nobra | {generic} kwnullable? classid obra no types [n2]:no cbra annotations_o~nopar {-> New type(kwnullable, classid, obra, [types.type], cbra, annotations_o~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*}
= type types_tail* {-> [type, types_tail.type]};
;
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], kwin, 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], kwin, 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}
;
array_item {-> expr}
= expr no {-> expr}
- | {for} kwfor no [ids]:idlist [n2]:no kwin [n3]:no expr [n4]:no kwdo [block]:array_item {-> New expr.for(kwfor, [ids.id], kwin, expr, kwdo, block.expr, Null)}
+ | {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)}
;
qid
= qualified? id
;
-qclassid {-> classid}
- = qualified? classid {-> classid}
+qclassid
+ = qualified? classid
;
qmethid~noid {-> methid}
= qualified? methid~noid {-> methid~noid.methid}
| {intrude} kwintrude
;
-classdef= {std} doc? kwredef? visibility classkind [id]:classid? obra? [formaldefs]:formaldef* cbra? extern_code_block? [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*
;
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 [id]:classid type annotations?
+ | {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?
= qualified? id
;
+qclassid
+ = qualified? [id]:classid
+ ;
+
signature = opar? [params]:param* cpar? type?;
param = id type? dotdotdot? annotations?
;
-type = kwnullable? [id]:classid obra? [types]:type* cbra? annotations?;
+type = kwnullable? [qid]:qclassid obra? [types]:type* cbra? annotations?;
label = kwlabel id?;
| {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* kwin expr kwdo [block]:expr? label?
+ | {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
| {ll} [op]:lleq
| {gg} [op]:ggeq
;
+for_group
+ = [ids]:id* kwin expr
+ ;
module_name = quad? [path]:id* id;
extern_calls = kwimport [extern_calls]:extern_call*