parser: new class AOperatorMethid to factorize operator methods
[nit.git] / src / parser / nit.sablecc3xx
index 2dc8600..a3f4e6f 100644 (file)
@@ -78,6 +78,7 @@ long_sstr_body = long_sstr_part*;
 extern_code_char
        = [all - ['`' + '\']]
        | '\' all
+       | '`' [all - '}']
        ;
 extern_code_body = extern_code_char*;
 
@@ -110,10 +111,7 @@ kwinit = 'init';
 kwredef = 'redef';
 kwis = 'is';
 kwdo = 'do';
-kwreadable = 'readable';
-kwwritable = 'writable';
 kwvar = 'var';
-kwintern = 'intern';
 kwextern = 'extern';
 kwpublic = 'public';
 kwprotected = 'protected';
@@ -147,6 +145,7 @@ kwas = 'as';
 kwnullable = 'nullable';
 kwisset = 'isset';
 kwlabel = 'label';
+kwwith = 'with';
 kwdebug = '__debug__';
 
 opar = '(';
@@ -159,12 +158,19 @@ quad = '::';
 assign = '=';
 pluseq = '+=';
 minuseq = '-=';
+stareq = '*=';
+slasheq = '/=';
+percenteq = '%=';
+starstareq = '**=';
+lleq = '<<=';
+ggeq = '>>=';
 dotdotdot = '...';
 dotdot = '..';
 dot = '.';
 plus = '+';
 minus = '-';
 star = '*';
+starstar = '**';
 slash = '/';
 percent = '%';
 eq = '==';
@@ -220,7 +226,7 @@ import
 
 topdef {-> classdef}
        = {classdef} classdef {-> classdef}
-       | propdefs_toplevel {-> New classdef.top([propdefs_toplevel.propdef])}
+       | propdef_toplevel n1 {-> New classdef.top([propdef_toplevel.propdef])}
        ;
 
 implicit_main_class {-> classdef?}
@@ -234,7 +240,7 @@ implicit_main_meth {-> propdef}
 
 /* CLASSES *******************************************************************/
 classdef
-       = [doc]:no redef visibility classkind no qclassid formaldefs line_annotations_forclass? extern_code_block? [superclasses]:superclass* propdefs* [n2]:no kwend {-> New classdef.std(doc.doc, redef.kwredef, visibility, classkind, qclassid.classid, [formaldefs.formaldef], line_annotations_forclass.annotations, extern_code_block, [superclasses.superclass], [propdefs.propdef], kwend)};
+       = [doc]:no redef visibility classkind no qclassid formaldefs extern_code_block? propdefs kwend {-> New classdef.std(doc.doc, redef.kwredef, visibility, classkind, qclassid.classid, [formaldefs.formaldef], extern_code_block, [propdefs.propdef], kwend)};
 redef {-> kwredef?}
        = kwredef? {-> kwredef};
 classkind
@@ -254,29 +260,32 @@ formaldefs_tail {-> formaldef}
 formaldef
        = classid annotations? typing_o {-> 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]:no 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} no {-> []}
+       ;
+propdefn {-> propdef}
+       = propdef n1 {-> propdef.propdef}
        ;
 propdef~toplevel {-> propdef}
-       = {meth} [doc]:no redef visibility kwmeth methid signature annotation_noend? kwdo stmtso kwend_o {-> New propdef.concrete_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature, annotation_noend.annotations, stmtso.expr)}
-       | {nobody} [doc]:no redef visibility kwmeth methid signature annotation_withend_nonull {-> New propdef.deferred_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature, annotation_withend_nonull.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)}
-       | {intern} [doc]:no redef visibility kwmeth methid signature kwis kwintern {-> New propdef.intern_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature)}
-!toplevel| {intern_new} [doc]:no redef visibility kwnew methid? signature kwis kwintern {-> New propdef.intern_new(doc.doc, redef.kwredef, visibility, kwnew, methid, signature)}
-       | {extern} [doc]:no redef visibility kwmeth methid signature kwis kwextern string_o extern_calls extern_code_block_o {-> New propdef.extern_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature, Null, string_o.string, extern_calls, extern_code_block_o.extern_code_block)}
-       | {extern_implicit} [doc]:no redef visibility kwmeth methid signature annotation_noend? extern_calls extern_code_block {-> New propdef.extern_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature, annotation_noend.annotations, Null, extern_calls, extern_code_block)}
-!toplevel| {var} [doc]:no readable? writable? redef visibility kwvar attrid typing_o {-> New propdef.attr(doc.doc, readable.able, writable.able, redef.kwredef, visibility, kwvar, attrid, Null, typing_o.type, Null, Null)}
-!toplevel| {var2} [doc]:no readable? writable? redef visibility kwvar attrid typing_o assign [n2]:no expr {-> New propdef.attr(doc.doc, readable.able, writable.able, redef.kwredef, visibility, kwvar, attrid, Null, typing_o.type, Null, expr)}
-!toplevel| {var3} [doc]:no redef visibility kwvar id typing_o writable? annotation_withend {-> New propdef.attr(doc.doc, Null, writable.able, redef.kwredef, visibility, kwvar, Null, id, typing_o.type, annotation_withend.annotations, Null)}
-!toplevel| {var4} [doc]:no redef visibility kwvar id typing_o writable? assign [n2]:no expr annotation_withend {-> New propdef.attr(doc.doc, Null, writable.able, redef.kwredef, visibility, kwvar, Null, id, typing_o.type, annotation_withend.annotations, expr.expr)}
-!toplevel| {init} [doc]:no redef visibility kwinit methid? signature annotation_noend? kwdo stmtso kwend_o {-> New propdef.concrete_init(doc.doc, redef.kwredef, visibility, kwinit, methid, signature, annotation_noend.annotations, stmtso.expr)}
+       = {meth} [doc]:no 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, stmtso.expr)}
+       | {nobody} [doc]:no 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)}
+!toplevel| {intern_new} [doc]:no 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)}
+!toplevel| {new} [doc]:no 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, stmtso.expr)}
+       | {extern_implicit} [doc]:no 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)}
+!toplevel| {var3} [doc]:no redef visibility kwvar id typing_o annotation_withend {-> New propdef.attr(doc.doc, redef.kwredef, visibility, kwvar, id, typing_o.type, Null, annotation_withend.annotations, Null)}
+!toplevel| {var4} [doc]:no 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, expr.expr, annotation_withend.annotations, Null)}
+!toplevel| {var5} [doc]:no 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, annotation_noend.annotations, stmtso.expr)}
+!toplevel| {init} [doc]:no 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, 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_o extern_calls extern_code_block_o {-> New propdef.extern_init(doc.doc, redef.kwredef, visibility, kwnew, methid, signature, Null, string_o.string, extern_calls, extern_code_block_o.extern_code_block)}
-!toplevel| {extern_init_implicit} [doc]:no redef visibility kwnew methid? signature annotation_noend? extern_calls extern_code_block {-> New propdef.extern_init(doc.doc, redef.kwredef, visibility, kwnew, methid, signature, annotation_noend.annotations, Null, extern_calls, extern_code_block)}
+!toplevel| {extern_init_implicit} [doc]:no 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)}
+!toplevel| {annot} line_annotation_forclass {-> line_annotation_forclass.propdef}
+!toplevel| {super} superclass {-> superclass.propdef}
        ;
 annotation_withend~nonull {-> annotations?}
        = {oneliner} kwis many_annotations {-> many_annotations.annotations}
@@ -287,12 +296,6 @@ annotation_noend {-> annotations}
        = {oneliner} kwis many_annotations {-> many_annotations.annotations}
        | {more} kwis n1 line_annotations {-> line_annotations.annotations}
        ;
-readable {-> able}
-       = redef visibility kwreadable {-> New able.read(redef.kwredef, kwreadable)}
-       ;
-writable {-> able}
-       = redef visibility kwwritable {-> New able.write(redef.kwredef, visibility, kwwritable)}
-       ;
 
 visibility
        = {public} {-> New visibility.public(Null)}
@@ -302,11 +305,11 @@ visibility
        | {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)}
        | {eq} eq {-> New methid.eq(eq)}
@@ -321,6 +324,7 @@ methid {-> methid}
        | {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 {-> signature}
@@ -353,8 +357,8 @@ extern_call {-> extern_call}
        | {super} kwsuper {-> New extern_call.super( kwsuper )}
        ;
 extern_call_prop {-> extern_call}
-       = {local} methid {-> New extern_call.local_prop( methid )}
-       | {full} type dot methid {-> New extern_call.full_prop( type, dot, methid )}
+       = {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}
@@ -408,9 +412,9 @@ stmtsnend {-> 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)}
+       = {vardecl} vardecl {-> vardecl.expr}
+       | {assign} assignment~nopar {-> assignment~nopar.expr}
+       | {return} kwreturn expr? {-> New expr.return(kwreturn, expr)}
        | {break} kwbreak label? {-> New expr.break(kwbreak, label)}
        | {abort} kwabort {-> New expr.abort(kwabort)}
        | {continue} kwcontinue label? {-> New expr.continue(kwcontinue, label)}
@@ -419,31 +423,38 @@ stmt~withelse~noexpr~nopar {-> 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 qid args_nopar {-> New expr.call(recv.expr, qid.id, 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_final~withelse {-> New expr.debug_type(kwdebug, kwtype, expr_final~withelse.expr, type) }
+       | {debug_type_is} kwdebug kwtype type column expr {-> New expr.debug_type(kwdebug, kwtype, expr.expr, type) }
        ;
 
 label= kwlabel id?;
 
-vardecl~withelse{-> expr}
+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_final~withelse {-> New expr.vardecl(kwvar, id, typing_o.type, assign, expr_final~withelse.expr, annotations)}
+       | {assign} kwvar id annotations? typing_o assign no expr {-> New expr.vardecl(kwvar, id, typing_o.type, assign, expr.expr, annotations)}
        ;
 
-assignment~withelse~nopar {-> expr}
-       = {attr} recv~nopar qualified_o attrid assign expr_final~withelse {-> New expr.attr_assign(recv~nopar.expr, attrid, assign, expr_final~withelse.expr)}
-       | {call} recv~nopar qid args assign expr_final~withelse {-> New expr.call_assign(recv~nopar.expr, qid.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 qualified_o attrid assign_op expr_final~withelse {-> New expr.attr_reassign(recv~nopar.expr, attrid, assign_op,  expr_final~withelse.expr)}
-       | {call_re} recv~nopar qid args assign_op expr_final~withelse {-> New expr.call_reassign(recv~nopar.expr, qid.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.id, 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.id, 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
+       | {ll} lleq
+       | {gg} ggeq
        ;
 
 do~withelse {-> expr}
@@ -477,18 +488,24 @@ for~withelse {-> expr}
        | {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)}
        ;
 
+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, stmtso~withelse.expr)}
+!withelse| {noelse} kwassert assertid? expr {-> New expr.assert(kwassert, assertid.id, expr, Null)}
        ;
 assertid {-> id}
        = id column {-> id};
 
 /* EXPRESSIONS ***************************************************************/
-expr_final~nopar~withelse~nobra {-> expr}
-       = expr~nopar~nobra {-> expr~nopar~nobra.expr}
-       ;
-
 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)}
@@ -496,10 +513,10 @@ expr~nopar~nobra {-> 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
+       | {: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_not~nopar~nobra {-> expr}
@@ -509,35 +526,41 @@ expr_not~nopar~nobra {-> expr}
 
 expr_eq~nopar~nobra {-> expr}
        = expr_add~nopar~nobra {-> expr_add~nopar~nobra.expr}
-       | {:eq} expr_add~nopar~nobra :eq :no [expr2]:expr_add~nopar~nobra
-       | {: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 :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 :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
+       | {:eq} expr_add~nopar~nobra eq :no [expr2]:expr_add~nopar~nobra
+       | {: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 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 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_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
+       | {:once} kwonce :no expr_minus~nobra
        ;
 
 expr_new~nopar~nobra {-> expr}
@@ -571,11 +594,36 @@ expr_single~nopar~nobra {-> expr}
        | {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} opar no expr [n2]:no cpar annotations_o {-> New expr.par(opar, expr, cpar, annotations_o.annotations)}
+!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, 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, expr2.expr, cbra, annotations_o.annotations)}
-!nobra!nopar   | {array} braargs annotations_o {-> New expr.array(braargs.exprs, 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)}
+       ;
+
+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 [ids]:idlist [n2]:no kwin [n3]:no expr [n4]:no kwdo [block]:array_item {-> New expr.for(kwfor, [ids.id], expr, kwdo, block.expr, Null)}
+       | {if} kwif [n1]:no expr [n2]:no kwthen [n3]:no [then]:array_item {-> New expr.if(kwif, expr, then.expr, Null)}
        ;
 
 superstring {-> expr} 
@@ -609,7 +657,7 @@ annotations_o~nopar {-> annotations?}
 one_annotation~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.at_arg], cpar, annotations_o~nopar.annotations)}
+!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)}
        ;
 
 many_annotations {-> annotations}
@@ -623,12 +671,12 @@ annotation_list {-> annotation*}
 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.at_arg], cpar, annotations_o~nopar.annotations)}
-!nopar | {nopar} redef visibility atid at_arg_single {-> New annotation(Null, redef.kwredef, visibility, atid, Null, [at_arg_single.at_arg], Null, 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)}
+!nopar | {nopar} redef visibility atid at_arg_single {-> New annotation(Null, redef.kwredef, visibility, atid, Null, [at_arg_single.expr], Null, Null)}
        ;
-at_arg_single {-> at_arg}
+at_arg_single {-> expr}
 // FIXME: why expr_single but not expr_atom is not clear :(
-       = {expr} [expr]:expr_single_nopar {-> New at_arg.expr(expr.expr)}
+       = {expr} [expr]:expr_single_nopar {-> expr.expr}
        ;
 
 annotations_tail {-> annotation}
@@ -640,40 +688,36 @@ line_annotations {-> annotations}
        ;
 line_annotation {-> annotation}
        = [doc]:no redef visibility atid annotations? n1 {-> New annotation(doc.doc, redef.kwredef, visibility, atid.atid, Null, [], Null, annotations)}
-       | {args} [doc]:no redef visibility atid opar no at_args cpar annotations? n1 {-> New annotation(doc.doc, redef.kwredef, visibility, atid.atid, opar, [at_args.at_arg], cpar, annotations)}
-       | {nopar} [doc]:no redef visibility atid at_args_nopar n1 {-> New annotation(doc.doc, redef.kwredef, visibility, atid.atid, Null, [at_args_nopar.at_arg], Null, Null)}
+       | {args} [doc]:no 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]:no redef visibility atid at_args_nopar n1 {-> New annotation(doc.doc, redef.kwredef, visibility, atid.atid, Null, [at_args_nopar.expr], Null, Null)}
        ;
-line_annotations_forclass {-> annotations}
-       = line_annotation_forclass+ {-> New annotations(Null, Null, [line_annotation_forclass.annotation], Null) }
-       ;
-line_annotation_forclass {-> annotation}
-       = [doc]:no atid_forclass annotations? n1 {-> New annotation(doc.doc, Null, Null, atid_forclass.atid, Null, [], Null, annotations)}
-       | {args} [doc]:no atid_forclass opar no at_args cpar annotations? n1 {-> New annotation(doc.doc, Null, Null, atid_forclass.atid, opar, [at_args.at_arg], cpar, annotations)}
-       | {nopar} [doc]:no atid_forclass at_args_nopar n1 {-> New annotation(doc.doc, Null, Null, atid_forclass.atid, Null, [at_args_nopar.at_arg], Null, Null)}
+line_annotation_forclass {-> propdef}
+       = [doc]:no atid_forclass annotations? {-> New propdef.annot(doc.doc, Null, Null, atid_forclass.atid, Null, [], Null, annotations)}
+       | {args} [doc]:no 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]:no 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 {-> at_arg* }
-       = {many} at_arg~nopar at_args_tail* {-> [at_arg~nopar.at_arg, at_args_tail.at_arg]}
+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)}
+!forclass      | {kwextern} kwextern {-> New atid.kwextern(kwextern)}
 //     | {kwimport} kwimport {-> New atid.kwimport(kwimport)}
+       | {kwabstract} kwabstract {-> New atid.kwabstract(kwabstract)}
        ;
 
 /* MISC **********************************************************************/
@@ -684,9 +728,12 @@ recv~nopar~nobra {-> expr}
        ;
 
 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) }
@@ -696,6 +743,8 @@ args_nopar {-> exprs}
        ;
 braargs        {-> exprs}
        = obra no expr_list cbra {-> New exprs.bra(obra, [expr_list.expr], cbra)};
+args_list {-> exprs}
+       = expr_list {-> New exprs.list([expr_list.expr])};
 expr_list {-> expr*}
        = expr [n2]:no expr_tail* {-> [expr, expr_tail.expr]};
 expr_tail {-> expr} 
@@ -706,7 +755,7 @@ idlist {-> 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}
@@ -728,6 +777,9 @@ qid {-> id}
 qclassid {-> classid}
        = qualified? classid {-> classid}
        ;
+qmethid~noid {-> methid}
+       = qualified? methid~noid {-> methid~noid.methid}
+       ;
 modquad {-> id}
        = id quad no {-> id};
 classquad {-> classid} 
@@ -772,7 +824,7 @@ visibility
        | {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 [id]:classid? [formaldefs]:formaldef* extern_code_block? [propdefs]:propdef* kwend
        | {top} [propdefs]:propdef*
        | {main} [propdefs]:propdef*
        ;
@@ -784,29 +836,38 @@ classkind
        | {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
-       | {intern_new} doc? kwredef? visibility kwnew methid? signature
-       | {extern_meth} doc? kwredef? visibility kwmeth methid signature annotations? [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 annotations? [extern]:string? extern_calls? extern_code_block?
+
+
+propdef = {attr} doc? kwredef? visibility kwvar [id2]:id type? expr? annotations? [block]:expr?
        | {main_meth} kwredef? [block]:expr?
        | {type} doc? kwredef? visibility kwtype [id]:classid type annotations?
+       | {meth} doc? kwredef? visibility kwmeth? kwinit? kwnew? methid? signature annotations? extern_calls? extern_code_block? [block]:expr?
+       | {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
+       | {bra} obra cbra
+       | {assign} id assign
+       | {braassign} obra cbra assign
        ;
 
-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?;
 
 param  = id type? dotdotdot? annotations?
@@ -817,7 +878,7 @@ type        = kwnullable? [id]:classid [types]:type* annotations?;
 label = kwlabel id?;
 
 expr   = {block} expr* kwend? 
-       | {vardecl} kwvar id type? assign? expr? annotations?
+       | {vardecl} kwvar? id type? assign? expr? annotations?
        | {return} kwreturn? expr?
        | {break} kwbreak label?
        | {abort} kwabort
@@ -828,37 +889,40 @@ expr      = {block} expr* kwend?
        | {while} kwwhile expr kwdo [block]:expr? label?
        | {loop} kwloop [block]:expr? label?
        | {for} kwfor [ids]:id* expr kwdo [block]:expr? label?
+       | {with} kwwith 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
-       | {implies} expr [expr2]:expr
-       | {not} kwnot expr 
-       | {eq} 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 
+       | {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
        | {uminus} minus expr 
+       | {uplus} plus 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
-       | {call_assign} expr id [args]:exprs assign [value]:expr 
+       | {call_assign} expr id [args]:exprs assign [value]:expr
        | {call_reassign} expr id [args]:exprs assign_op [value]:expr 
        | {super} qualified? kwsuper [args]:exprs
        | {init} expr kwinit [args]:exprs 
@@ -871,7 +935,7 @@ expr        = {block} expr* kwend?
        | {range} expr [expr2]:expr annotations?
        | {crange} obra expr [expr2]:expr cbra annotations?
        | {orange} obra expr [expr2]:expr [cbra]:obra annotations?
-       | {array} [exprs]:exprs annotations?
+       | {array} obra [exprs]:expr* type? cbra annotations?
        | {self} kwself annotations?
        | {implicit_self} 
        | {true} kwtrue annotations?
@@ -892,6 +956,10 @@ expr       = {block} expr* kwend?
        | {isset_attr} kwisset expr [id]:attrid
        | {debug_type} kwdebug kwtype expr type
        | {vararg} expr dotdotdot
+       | {type} type
+       | {methid} expr [id]:methid
+       | {at} annotations
+       | {many} [exprs]:expr*
        ;
 exprs
        = {list} [exprs]:expr*
@@ -899,8 +967,14 @@ exprs
        | {bra} obra [exprs]:expr* cbra
        ;
 assign_op
-       = {plus} pluseq
-       | {minus} minuseq
+       = {plus} [op]:pluseq
+       | {minus}[op]:minuseq
+       | {star} [op]:stareq
+       | {slash} [op]:slasheq
+       | {percent} [op]:percenteq
+       | {starstar} [op]:starstareq
+       | {ll} [op]:lleq
+       | {gg} [op]:ggeq
        ;
 
 module_name = quad? [path]:id* id;
@@ -924,14 +998,9 @@ doc = comment+;
 
 annotations = at? opar? [items]:annotation* cpar?;
 
-annotation = doc? kwredef? visibility? 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;
 
 /*****************************************************************************/