|
NAMEPegex::Compiler - Pegex CompilerSYNOPSISuse Pegex::Compiler; my $grammar_text = '... grammar text ...'; my $pegex_compiler = Pegex::Compiler->new(); my $grammar_tree = $pegex_compiler->compile($grammar_text)->tree; or: perl -Ilib -MYourGrammarModule=compile DESCRIPTIONThe Pegex::Compiler transforms a Pegex grammar string (or file) into a compiled form. The compiled form is known as a grammar tree, which is simply a nested data structure.The grammar tree can be serialized to YAML, JSON, Perl, or any other programming language. This makes it extremely portable. Pegex::Grammar has methods for serializing to all these forms. NOTE: Unless you are developing Pegex based modules, you can safely ignore this module. Even if you are you probably won't use it directly. See [In Place Compilation] below. METHODSThe following public methods are available:
IN PLACE COMPILATIONWhen you write a Pegex based module you will want to precompile your grammar into Perl so that it has no load penalty. Pegex::Grammar provides a special mechanism for this. Say you have a class like this:package MyThing::Grammar; use Pegex::Base; extends 'Pegex::Grammar'; use constant file => '../mything-grammar-repo/mything.pgx'; sub make_tree { } Simply use this command: perl -Ilib -MMyThing::Grammar=compile and Pegex::Grammar will call Pegex::Compile to put your compiled grammar inside your "make_tree" subroutine. It will actually write the text into your module. This makes it trivial to update your grammar module after making changes to the grammar file. See Pegex::JSON for an example. AUTHORIngy döt Net <ingy@cpan.org>COPYRIGHT AND LICENSECopyright 2010-2020. Ingy döt Net.This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See <http://www.perl.com/perl/misc/Artistic.html>
Visit the GSP FreeBSD Man Page Interface. |