| 1 | #!/usr/bin/env perl | ||||||||||
| 2 | |||||||||||
| 3 | 14 | ▶ | use lib 'lib'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 14 | ▶ | use File::Slurp 'slurp'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 14 | ▶ | use Getopt::Std; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 14 | ▶ | use Pugs::Compiler::Grammar; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 14 | ▶ | use Pugs::Runtime::Tracer; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 14 | my %opts; | |||||||||
| 10 | 14 | ▶ | getopts("TDs:", \%opts) or help(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 11 | 14 | my $safe_mode = 0; | |||||||||
| 12 | 14 | ▶ | if ($opts{T}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | 2 | $safe_mode = 1; | |||||||||
| 14 | } | ||||||||||
| 15 | 14 | ▶ | if (defined $opts{s}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 0 | $::PCR_SEED = $opts{s}; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 14 | ▶ | my $infile = shift or help(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 14 | my $grammar = slurp($infile); | |||||||||
| 21 | 14 | ▶ | my $compiler = Pugs::Compiler::Grammar->compile( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | $grammar, | ||||||||||
| 23 | { safe_mode => $safe_mode } | ||||||||||
| 24 | ) or die; | ||||||||||
| 25 | 0 | ▶ | if ($compiler) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | my $perl5 = $compiler->perl5; | |||||||||
| 27 | 0 | my $localtime = localtime; | |||||||||
| 28 | 0 | print <<EOC; | |||||||||
| 29 | # !!! DO NOT EDIT !!! | ||||||||||
| 30 | # This file was generated by Pugs::Compiler::Rule's compile_p6grammar.pl | ||||||||||
| 31 | # script from $infile at $localtime | ||||||||||
| 32 | |||||||||||
| 33 | use strict; | ||||||||||
| 34 | use warnings; | ||||||||||
| 35 | |||||||||||
| 36 | EOC | ||||||||||
| 37 | 0 | ▶ | if ($opts{D}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | #print "use Pugs::Runtime::Tracer;\n"; | ||||||||||
| 39 | 0 | $perl5 = expand_tracing_code($perl5); | |||||||||
| 40 | } | ||||||||||
| 41 | 0 | print $perl5; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | sub help { | ||||||||
|
Subroutine
help: not called CC=1 SCAR=6.9
| |||||||||||
| 45 | 0 | die <<"_EOC_"; | |||||||||
| 46 | Usage: $0 [-s seed] [-D] [-T] foo.grammar > Foo.pm | ||||||||||
| 47 | Options: | ||||||||||
| 48 | -D Specify the safe mode in which no action blocks are allowed | ||||||||||
| 49 | in the grammar spec. | ||||||||||
| 50 | -T Specify the tracing mode in which the parser generated will | ||||||||||
| 51 | emit tracing info to stdout. | ||||||||||
| 52 | _EOC_ | ||||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | __END__ | ||||||||||