Dear sisters and brothers,
I'm using Parse::Lex to generate lexers for a lexer/parser for Erlang source that I'm writing.
Fortunately or unfortunately, when you bootstrap a Lex object, it creates symbol table entries in the calling package for the tokens you've defined for the lexer. The code doing that is Parse/Token.pm, saying:
sub exportTo { my $self = shift; my $inpkg = $self->inpkg; unless (defined $inpkg) { $inpkg = caller; # (caller(0))[0]; $self->inpkg($inpkg); } my $name = $self->name; no strict 'refs'; if ($^W and defined ${"$inpkg" . "::" . "$name"}) { require Carp; Carp::carp "the '${inpkg}::$name' token is already defined"; } ${"$inpkg" . "::" . "$name"} = $self; $self; }
I'm trying to make my generated lexers at least vaguely re-entrant, so the lexer symbol table is being recreated each time you make a new lexer, meaning I'm getting these lovely "the 'XYZ::ABC' token is already defined" errors. It looks like there's no such thing as an anonymous package, so I can't enter one of those before generating the symbols.
Is there other way (possibly involving black magic) to get these tokens to go elsewhere, or otherwise stop this happening? (preferably without having to mess up Parse::Lex)
Yours in deep respect,
Anneli
In reply to Stopping a package from infesting my namespace by anneli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |