util/compile_p6grammar.pl

filter: Statementstmt 72.7% 24 / 33 Branchbran 35.7% 5 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod n/a totaltotal 64.1% 34 / 53 CC 1 SCAR 1.5
CC
1
Cov
62%
help
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« blib/lib/Pugs/Grammar/RulePure.pm ↑ Summary blib/lib/Pugs/Runtime/Rule.pm »
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
BranchTrueFalseTotal
&getopts("TDs:", \%opts) or help() 14 0 14
11 14 my $safe_mode = 0;
12 14 ▶if ($opts{T}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"T"}) 2 12 14
13 2 $safe_mode = 1;
14 }
15 14 ▶if (defined $opts{s}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"s"}) 0 14 14
16 0 $::PCR_SEED = $opts{s};
17 }
18  
19 14 ▶my $infile = shift or help();
Branch: 1 branch
BranchTrueFalseTotal
my $infile = shift @ARGV or help() 14 0 14
20 14 my $grammar = slurp($infile);
21 14 ▶my $compiler = Pugs::Compiler::Grammar->compile(
Branch: 1 branch
BranchTrueFalseTotal
my $compiler = "Pugs::Compiler::Grammar"->compile($grammar, {"safe_mode", $safe_mode}) or die 0 0 0
22 $grammar,
23 { safe_mode => $safe_mode }
24 ) or die;
25 0 ▶if ($compiler) {
Branch: 1 branch
BranchTrueFalseTotal
if ($compiler) 0 0 0
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
BranchTrueFalseTotal
if ($opts{"D"}) 0 0 0
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__
« blib/lib/Pugs/Grammar/RulePure.pm ↑ Summary blib/lib/Pugs/Runtime/Rule.pm »