#!/usr/bin/env perl use lib 'lib'; use File::Slurp 'slurp'; use Getopt::Std; use Pugs::Compiler::Grammar; use Pugs::Runtime::Tracer; my %opts; getopts("TDs:", \%opts) or help(); my $safe_mode = 0; if ($opts{T}) { $safe_mode = 1; } if (defined $opts{s}) { $::PCR_SEED = $opts{s}; } my $infile = shift or help(); my $grammar = slurp($infile); my $compiler = Pugs::Compiler::Grammar->compile( $grammar, { safe_mode => $safe_mode } ) or die; if ($compiler) { my $perl5 = $compiler->perl5; my $localtime = localtime; print < Foo.pm Options: -D Specify the safe mode in which no action blocks are allowed in the grammar spec. -T Specify the tracing mode in which the parser generated will emit tracing info to stdout. _EOC_ } __END__ =head1 NAME compile_p6grammar.pl - Compile Perl 6 Grammars to Perl 5 Modules =head1 SYNOPSIS $ util/compile_p6grammar.pl examples/adder.grammar > Adder.pm $ perl -MAdder -e 'print Adder->add("3 + 23")->(), "\n"' $ cat examples/adder.grammar grammar Adder; token add { (\d+) ? '+' ? (\d+) { return $/[0] + $/[1] } } $ =head1 OPTIONS -D Specify the safe mode in which no action blocks are allowed in the grammar spec. -T Specify the tracing mode in which the parser generated will emit tracing info to stdout. =head1 DESCRIPTION Used to convert grammars in Perl 6 syntax into Perl 5 modules. =head1 AUTHORS The Pugs Team Eperl6-compiler@perl.orgE. =head1 SEE ALSO The Perl 6 Rules Spec: L =head1 COPYRIGHT Copyright 2006, 2007 by Nathan Gray and Agent Zhang (Eagentzh@yahoo.cnE). This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =head1 SEE ALSO "A graphical tracer for Perl 6 regexes based on PCR" L. L, L, L, L. =cut