Pugs::Compiler::Grammar - Compiler for Perl 6 Grammars
use Pugs::Compiler::Grammar; my $grammar = q{ grammar MyC; token def { <type> <?ws> <var_list> <?ws>? ';' } token type { int | float | double | char } token var_list { <ident>**{1} <?ws>? [ ',' <?ws>? <ident> ]* } grammar MyVB; token def { 'Dim' <?ws> <MyC.var_list> [ <?ws> 'As' <?ws> <MyC.type> ]? <?ws>? ';' } }; my $obj = Pugs::Compiler::Grammar->compile($grammar); my $perl5 = $obj->perl5; eval $perl5; die $@ if $@; my $match = MyC->def("float foo;"); print "type: ", $match->{type}, "\n"; print "vars: ", $match->{var_list}, "\n"; $match = MyVB->def("Dim foo, bar;"); print "vars: ", $match->{'MyC.var_list'}, "\n";
$obj = Pugs::Compile::Grammar->compile($src)
Acts as contructor. Accepts a string containing the grammar specs and returns a Pugs::Compiler::Grammar instance.
$perl5 = $obj->perl5()
Returns a string containing the Perl source for the grammars compiled.
The Pugs contributors <perl6-compiler@perl.org>.
Copyright 2007 by Agent Zhang and others.
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
compile_p6grammar.pl, Pugs::Compiler::Regex, Pugs::Grammar::Rule, Pugs::Emitter::Grammar::Perl5.
To install Pugs::Compiler::Rule, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Pugs::Compiler::Rule
CPAN shell
perl -MCPAN -e shell install Pugs::Compiler::Rule
For more information on module installation, please visit the detailed CPAN module installation guide.