ast: remove classes AAtArg and make them simple AExpr
[nit.git] / src / parser / nit.sablecc3xx
index fa6d955..ad3ad66 100644 (file)
@@ -395,9 +395,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)}
@@ -410,23 +410,23 @@ stmt~withelse~noexpr~nopar {-> 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
@@ -465,17 +465,13 @@ for~withelse {-> 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)}
@@ -528,8 +524,8 @@ expr_pow~nopar~nobra {-> expr}
 
 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 :no expr_minus~nobra
+       | {:once} kwonce :no expr_minus~nobra
        ;
 
 expr_new~nopar~nobra {-> expr}
@@ -563,7 +559,7 @@ 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} opar no any_expr [n2]:no cpar annotations_o {-> New expr.par(opar, any_expr.expr, cpar, annotations_o.annotations)}
 // !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)}
@@ -601,7 +597,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}
@@ -615,12 +611,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}
@@ -632,31 +628,31 @@ 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)}
+       | {args} [doc]:no atid_forclass opar no at_args cpar annotations? n1 {-> New annotation(doc.doc, Null, Null, atid_forclass.atid, opar, [at_args.expr], cpar, annotations)}
+       | {nopar} [doc]:no atid_forclass at_args_nopar n1 {-> New annotation(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}
+!nopar | {at} annotations {-> New expr.at(annotations.annotations)}
        ;
 
 atid~forclass {-> atid}
@@ -698,7 +694,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}
@@ -873,6 +869,8 @@ expr        = {block} expr* kwend?
        | {isset_attr} kwisset expr [id]:attrid
        | {debug_type} kwdebug kwtype expr type
        | {vararg} expr dotdotdot
+       | {type} type
+       | {at} annotations
        ;
 exprs
        = {list} [exprs]:expr*
@@ -905,13 +903,8 @@ 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 | {kwabstract} [id]:kwabstract | {kwimport} [id]:kwimport;
 
 /*****************************************************************************/