Re: Parse::RecDescent and modperl
[email protected] (Terrence Brannon)
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <[email protected]> |
On Thursday, November 15, 2001, at 05:26 AM, Peter Sinnott wrote:
> Hi all,
> I am trying to use Mail::IMAPClient::BodyStructure
> under modperl and I am running into some problems when preloading
> the module. Since BodyStructure uses Parse::RecDescent ( v1.80)
> I was wondering if there are any problems with using RecDescent
> under modperl?
this I cannot answer
> Also is it possible to dump the parser created by
> RecDescent
> using Data::Dumper and then eval it back at a latter date?
A section of the manual entitled "Precompiling parsers" should provide
an adequate answer to this question. I include part of it below... type
perldoc Parse::RecDescent on the machine you are using Parse::RecDescent
on to read the full section
Precompiling parsers
Normally Parse::RecDescent builds a parser from a grammar
at run-time. That approach simplifies the design and
implementation of parsing code, but has the disadvantage
that it slows the parsing process down - you have to wait
for Parse::RecDescent to build the parser every time the
program runs. Long or complex grammars can be particularly
slow to build, leading to unacceptable delays at start-up.
To overcome this, the module provides a way of "pre-build-
ing" a parser object and saving it in a separate module.
That module can then be used to create clones of the orig-
inal parser.
A grammar may be precompiled using the "Precompile" class
method. For example, to precompile a grammar stored in
the scalar $grammar, and produce a class named PreGrammar
in a module file named PreGrammar.pm, you could use:
use Parse::RecDescent;
Parse::RecDescent->Precompile($grammar, "PreGrammar");
The first argument is the grammar string, the second is
the name of the class to be built. The name of the module
file is generated automatically by appending ".pm" to the
last element of the class name. Thus
Parse::RecDescent->Precompile($grammar,
"My::New::Parser");
would produce a module file named Parser.pm.