From: Jean Privat Date: Thu, 26 Jun 2014 09:37:49 +0000 (-0400) Subject: grammar: accept redef and visibility on module declaration X-Git-Tag: v0.6.7~52^2~5 X-Git-Url: http://nitlanguage.org grammar: accept redef and visibility on module declaration The visibility on modules will hide thing inter-projects The redef is accepted only for convenience, and could be rejected on a latter analysis. Signed-off-by: Jean Privat --- diff --git a/src/parser/nit.sablecc3xx b/src/parser/nit.sablecc3xx index b27c073..41de805 100644 --- a/src/parser/nit.sablecc3xx +++ b/src/parser/nit.sablecc3xx @@ -211,7 +211,7 @@ module = moduledecl? [imports]:import* [extern_bodies]:extern_code_body* [classdefs]:topdef* implicit_main_class {-> New module(moduledecl, [imports.import], [extern_bodies.extern_code_block], [classdefs.classdef,implicit_main_class.classdef])}; moduledecl - = [doc]:no kwmodule no module_name annotation_withend [n2]:n1 {-> New moduledecl(doc.doc, kwmodule, module_name, annotation_withend.annotations)}; + = [doc]:no redef visibility kwmodule no module_name annotation_withend [n2]:n1 {-> New moduledecl(doc.doc, redef.kwredef, visibility, kwmodule, module_name, annotation_withend.annotations)}; import = {std} [doc]:no redef visibility kwimport no module_name annotation_withend [n2]:n1 {-> New import.std(visibility, kwimport, module_name, annotation_withend.annotations)} @@ -736,7 +736,7 @@ Abstract Syntax Tree module = moduledecl? [imports]:import* [extern_code_blocks]:extern_code_block* [classdefs]:classdef*; moduledecl - = doc? kwmodule [name]:module_name annotations?; + = doc? kwredef? visibility kwmodule [name]:module_name annotations?; import = {std} visibility kwimport [name]:module_name annotations? | {no} visibility kwimport kwend diff --git a/src/parser/parser_nodes.nit b/src/parser/parser_nodes.nit index 99fb9c6..435a809 100644 --- a/src/parser/parser_nodes.nit +++ b/src/parser/parser_nodes.nit @@ -706,6 +706,12 @@ class AModuledecl var _n_doc: nullable ADoc = null fun n_doc: nullable ADoc do return _n_doc fun n_doc=(n_doc: nullable ADoc) do _n_doc = n_doc + var _n_kwredef: nullable TKwredef = null + fun n_kwredef: nullable TKwredef do return _n_kwredef + fun n_kwredef=(n_kwredef: nullable TKwredef) do _n_kwredef = n_kwredef + var _n_visibility: AVisibility + fun n_visibility: AVisibility do return _n_visibility + fun n_visibility=(n_visibility: AVisibility) do _n_visibility = n_visibility var _n_kwmodule: TKwmodule fun n_kwmodule: TKwmodule do return _n_kwmodule fun n_kwmodule=(n_kwmodule: TKwmodule) do _n_kwmodule = n_kwmodule