[erlang-patches] Absolute module references in Yecc parsers (was: New yecc:file/2 option: parserpackage)
Alceste Scalas
alceste@REDACTED
Thu Feb 14 17:19:04 CET 2008
Il giorno gio, 14/02/2008 alle 14.43 +0100, Alceste Scalas ha scritto:
> This option allows to generate parsers within Erlang packages: for
> example, given the file src/foo/bar/parser.yrl, a call like
>
> yecc:file(parser, [{parserpackage, 'foo.bar'}])
>
> will generate parser.erl with module 'foo.bar.parser' (instead of
> 'parser' alone).
The following patch may help, too: it makes the generated parsers always
use absolute module references, by adding a leading dot to some function
calls (both in yecc.erl and yeccpre.hrl).
I chose this solution over two other approaches:
1. adding -import(lists) and -import(io_lib) to yeccpre.hrl;
2. asking the Yecc users to explicitly add -import(lists) and
-import(io_lib) to the "Erlang code" section of their grammars,
when they want to generate parsers inside a package hierarchy.
IMHO the patch is clearer (no packaging issues at all) and cleaner (it
does not interfere with "Erlang code" sections by adding unexpected
imports).
Regards,
alceste
--
Alceste Scalas <alceste@REDACTED>
CRS4 - http://www.crs4.it/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: yecc-absmodules.diff
Type: text/x-patch
Size: 2568 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20080214/1ac68566/attachment.bin>
More information about the erlang-patches
mailing list