![]() |
![]()
| ![]() |
![]()
NAMEPugs::Compiler::Grammar - Compiler for Perl 6 Grammars SYNOSPISuse 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"; METHODS
AUTHORThe Pugs contributors <perl6-compiler@perl.org>. COPYRIGHTCopyright 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> SEE ALSOcompile_p6grammar.pl, Pugs::Compiler::Regex, Pugs::Grammar::Rule, Pugs::Emitter::Grammar::Perl5.
|