X-Git-Url: http://nitlanguage.org diff --git a/src/parser/nit.sablecc3xx b/src/parser/nit.sablecc3xx index 47b9d29..9d17d23 100644 --- a/src/parser/nit.sablecc3xx +++ b/src/parser/nit.sablecc3xx @@ -57,7 +57,7 @@ blank = (' ' | tab)+; eol = eol_helper; comment = '#' any* eol_helper; -kwpackage = 'package'; +kwmodule = 'package'|'module'; kwimport = 'import'; kwclass = 'class'; kwabstract = 'abstract'; @@ -161,10 +161,10 @@ Productions /* MODULES *******************************************************************/ module - = packagedecl? [imports]:import* [classdefs]:classdef* implicit_top_class? implicit_main_class? {-> New module(packagedecl, [imports.import],[classdefs.classdef,implicit_top_class.classdef,implicit_main_class.classdef])}; + = moduledecl? [imports]:import* [classdefs]:classdef* implicit_top_class? implicit_main_class? {-> New module(moduledecl, [imports.import],[classdefs.classdef,implicit_top_class.classdef,implicit_main_class.classdef])}; -packagedecl - = [doc]:no kwpackage no id [n2]:n1 {-> New packagedecl(doc.doc, kwpackage, id)}; +moduledecl + = [doc]:no kwmodule no id [n2]:n1 {-> New moduledecl(doc.doc, kwmodule, id)}; import = {std} [doc]:no visibility kwimport no id [n2]:n1 {-> New import.std(visibility, kwimport, id)} @@ -491,7 +491,7 @@ expr_atom~nopar~nobra {-> expr} | {init} recv~nopar~nobra kwinit args {-> New expr.init(recv~nopar~nobra.expr, kwinit, [args.expr])} !nobra | {bra} expr_atom~nopar braargs {-> New expr.bra(expr_atom~nopar.expr, [braargs.expr], [])} | {new} kwnew no type~nobra dot [n2]:no id args {-> New expr.new(kwnew, type~nobra.type, id, [args.expr])} -// FIXME: Why are these 3 !nopar mandatory? +// !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 {-> New expr.crange(expr, expr2.expr)} !nobra!nopar | {orange} obra no expr [n2]:no dotdot [n3]:no [expr2]:expr_nobra [n4]:no [cbra]:obra {-> New expr.orange(expr, expr2.expr)} !nobra!nopar | {array} braargs {-> New expr.array([braargs.expr])} @@ -581,10 +581,10 @@ n2 Abstract Syntax Tree /*****************************************************************************/ -module = packagedecl? [imports]:import* [classdefs]:classdef*; +module = moduledecl? [imports]:import* [classdefs]:classdef*; -packagedecl - = doc? kwpackage id; +moduledecl + = doc? kwmodule id; import = {std} visibility kwimport id | {no} visibility kwimport kwend