diff -r e009bce29782 lib/parsetools/src/yecc.erl --- a/lib/parsetools/src/yecc.erl +++ b/lib/parsetools/src/yecc.erl @@ -282,6 +282,7 @@ options(Options0) when is_list(Options0) (T) -> [T] end, Options0), options(Options, [file_attributes, includefile, parserfile, + parserpackage, report_errors, report_warnings, return_errors, return_warnings, time, verbose], []) catch error: _ -> badarg @@ -310,6 +311,15 @@ options(Options0, [Key | Keys], L) when Filename -> {ok, [{Key, Filename}]} end; + {value, {Key, Pkg}} when Key =:= parserpackage -> + if + is_atom(Pkg) orelse (Pkg =:= "") -> + {ok, [{Key, Pkg}]}; + is_list(Pkg) -> + {ok, [{Key, list_to_atom(Pkg)}]}; + true -> + badarg + end; {value, {Key, Bool}} when Bool =:= true; Bool =:= false -> {ok, [{Key, Bool}]}; {value, {Key, _}} -> @@ -335,6 +345,7 @@ default_option(file_attributes) -> true; default_option(file_attributes) -> true; default_option(includefile) -> []; default_option(parserfile) -> []; +default_option(parserpackage) -> []; default_option(report_errors) -> true; default_option(report_warnings) -> true; default_option(return_errors) -> false; @@ -371,6 +382,7 @@ start(Infilex, Options) -> start(Infilex, Options) -> Infile = assure_extension(Infilex, ".yrl"), {value, {_, Outfilex0}} = keysearch(parserfile, 1, Options), + {value, {_, Package}} = keysearch(parserpackage, 1, Options), {value, {_, Includefilex}} = keysearch(includefile, 1, Options), Outfilex = case Outfilex0 of [] -> filename:rootname(Infilex, ".yrl"); @@ -381,7 +393,11 @@ start(Infilex, Options) -> _ -> assure_extension(Includefilex,".hrl") end, Outfile = assure_extension(Outfilex, ".erl"), - Module = list_to_atom(filename:basename(Outfile, ".erl")), + Module0 = filename:rootname(filename:basename(Outfile), ".erl"), + Module = case Package of + [] -> list_to_atom(Module0); + _ -> list_to_atom(atom_to_list(Package) ++ "." ++ Module0) + end, #yecc{infile = Infile, outfile = Outfile, includefile = Includefile,