parser: closure syntax use '!' instead of 'with'
[nit.git] / src / parser / nit.sablecc3xx
index d61ddba..1a123d3 100644 (file)
@@ -65,9 +65,8 @@ kwinterface = 'interface';
 kwuniversal = 'universal';
 kwspecial = 'special';
 kwend = 'end';
-kwmeth = 'meth' | 'fun'; //FIXME: Remove the 'meth' alternative once the transition is done
+kwmeth = 'fun';
 kwtype = 'type';
-kwattr = 'attr'; //FIXME: remove kwattr once the transition is done
 kwinit = 'init';
 kwredef = 'redef';
 kwis = 'is';
@@ -103,7 +102,6 @@ kwtrue = 'true';
 kwfalse = 'false';
 kwnull = 'null';
 kwas = 'as';
-kwwith = 'with';
 kwnullable = 'nullable';
 kwisset = 'isset';
 kwlabel = 'label';
@@ -133,6 +131,7 @@ le = '<=';
 gt = '>';
 ge = '>=';
 starship = '<=>';
+bang='!';
 
 classid = uppercase letter*;
 id = lowercase letter*;
@@ -212,11 +211,8 @@ propdef~toplevel {-> propdef}
 !toplevel| {deferred} [doc]:no redef visibility kwmeth methid signature kwis kwabstract {-> New propdef.deferred_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature)}
 !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? {-> New propdef.extern_meth(doc.doc, redef.kwredef, visibility, kwmeth, methid, signature.signature, string)}
-//FIXME: Remove attr alternative once the transition is done
-!toplevel| {attr} [doc]:no readable writable redef visibility kwattr attrid typing? {-> New propdef.attr(doc.doc, readable.able, writable.able, redef.kwredef, visibility, kwattr, Null, attrid, typing.type, Null)}
-!toplevel| {attr2} [doc]:no readable writable redef visibility kwattr attrid typing? assign [n2]:no expr {-> New propdef.attr(doc.doc, readable.able, writable.able, redef.kwredef, visibility, kwattr, Null, attrid, typing.type, expr)}
-!toplevel| {var} [doc]:no readable writable redef visibility kwvar attrid typing? {-> New propdef.attr(doc.doc, readable.able, writable.able, redef.kwredef, visibility, Null, kwvar, attrid, typing.type, 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, Null, kwvar, attrid, typing.type, expr)}
+!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, typing.type, 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, typing.type, expr)}
 !toplevel| {init} [doc]:no redef visibility kwinit methid? signature kwdo stmtso kwend? {-> New propdef.concrete_init(doc.doc, redef.kwredef, visibility, kwinit, methid, signature, stmtso.expr)}
 !toplevel| {type} [doc]:no redef visibility kwtype classid typing {-> New propdef.type(doc.doc, redef.kwredef, visibility, kwtype, classid, typing.type)}
        ;
@@ -277,8 +273,8 @@ param
 closure_decls {->closure_decl*}
        = no closure_decl+ {-> [closure_decl]};
 closure_decl
-       = kwwith kwbreak? [no2]:no id signature_noclosures n {-> New closure_decl(kwwith, kwbreak, id, signature_noclosures.signature, Null)}
-       | {optionnal} kwwith kwbreak? [no2]:no id signature_noclosures kwdo stmtso n {-> New closure_decl(kwwith, kwbreak, id, signature_noclosures.signature, stmtso.expr)}
+       = 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)}
        ;
 
 /* TYPES *********************************************************************/
@@ -329,13 +325,17 @@ closure_defs~withelse {-> closure_def*}
        ;
 
 closure_def_last~withelse {-> closure_def}
-       = kwwith idlist? kwdo stmtso~withelse_withend label? {-> New closure_def(kwwith, [idlist.id], kwdo, stmtso~withelse_withend.expr, label)}
-       | {noend} kwwith idlist? kwdo stmt~withelse {-> New closure_def(kwwith, [idlist.id], kwdo, stmt~withelse.expr, Null)}
+       = bang [id]:closure_id idlist? kwdo stmtso~withelse_withend label? {-> New closure_def(bang, id, [idlist.id], kwdo, stmtso~withelse_withend.expr, label)}
+       | {noend} bang [id]:closure_id idlist? kwdo stmt~withelse {-> New closure_def(bang, id, [idlist.id], kwdo, stmt~withelse.expr, Null)}
        ;
 
 closure_def {-> closure_def}
-       = kwwith idlist? kwdo n stmts [n2]:n {-> New closure_def(kwwith, [idlist.id], kwdo, stmts.expr, Null)}
-       | {empty} kwwith idlist? kwdo n {-> New closure_def(kwwith, [idlist.id], kwdo, Null, Null)}
+       = bang [id]:closure_id idlist? kwdo n stmts [n2]:n {-> New closure_def(bang, id, [idlist.id], kwdo, stmts.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
        ;
 
 vardecl~withelse{-> expr}
@@ -508,8 +508,12 @@ braargs    {-> expr*}
 args_tail {-> expr} 
        = comma no expr [n2]:no {-> expr};
 idlist {-> id*}
+       = opar idlist_nopar cpar {-> [idlist_nopar.id]}
+       | {nopar} idlist_nopar {-> [idlist_nopar.id]}
+       ;
+idlist_nopar {-> id*}
        = {single} id {-> [id]}
-       | {more} idlist no comma [n2]:no id {-> [idlist.id, id]}
+       | {more} idlist_nopar no comma [n2]:no id {-> [idlist_nopar.id, id]}
        ;
 
 qualified 
@@ -570,7 +574,7 @@ formaldef = [id]:classid type?;
 superclass = kwspecial type;
 
 
-propdef = {attr} doc? [readable]:able? [writable]:able? kwredef? visibility kwattr? kwvar? [id]:attrid type? expr? // Remove the kwattr? once the transition is done
+propdef = {attr} doc? [readable]:able? [writable]:able? kwredef? visibility kwvar [id]:attrid type? expr?
        | {meth} doc? kwredef? visibility methid signature 
        | {deferred_meth} doc? kwredef? visibility kwmeth methid signature 
        | {intern_meth} doc? kwredef? visibility kwmeth methid signature 
@@ -592,7 +596,7 @@ signature = [params]:param* type? [closure_decls]:closure_decl*;
 param  = id type? dotdotdot? 
        ;
 
-closure_decl = kwwith kwbreak? id signature expr?
+closure_decl = kwbreak? bang id signature expr?
        ;
 
 type   = kwnullable? [id]:classid [types]:type*;
@@ -676,7 +680,11 @@ assign_op
        ;
 
 closure_def
-       = kwwith id* kwdo expr? label?
+       = bang [id]:closure_id [ids]:id* kwdo expr? label?
+       ;
+closure_id
+       = {simple} id
+       | {break} kwbreak
        ;
 
 qualified = id* classid? ;