| 1 | 15 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 2 | 15 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | #use Smart::Comments; | ||||||||||||
| 4 | |||||||||||||
| 5 | package Pugs::Compiler::Grammar; | ||||||||||||
| 6 | |||||||||||||
| 7 | 15 | our $VERSION = '0.28'; | |||||||||||
| 8 | |||||||||||||
| 9 | 15 | ▶ | use Pugs::Grammar::Rule; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 15 | ▶ | use Pugs::Emitter::Grammar::Perl5; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 15 | ▶ | use Carp qw(carp croak); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | |||||||||||||
| 13 | 15 | ▶ | sub compile { | ||||||||||
|
Subroutine
compile: called CC=4 SCAR=23.1
Pod
documented
| |||||||||||||
| 14 | 15 | my ($class, $src, $opts) = @_; | |||||||||||
| 15 | 15 | ▶ | $opts ||= {}; | ||||||||||
|
Condition100%2/2
$opts ||= {}
MC/DC100%1/1
$opts ||= {}
$opts
Truth table100%2/2
A
A= $opts
| |||||||||||||
| 16 | 15 | my $match = Pugs::Grammar::Rule->spec($src); | |||||||||||
| 17 | 0 | ▶ | if ($match->bool) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 18 | ## $match | ||||||||||||
| 19 | 0 | my $capture = $match->(); | |||||||||||
| 20 | 0 | my $leading_block = $capture->{block}; | |||||||||||
| 21 | ### leading block: $leading_block | ||||||||||||
| 22 | 0 | my $ast = $capture->{grammar}; | |||||||||||
| 23 | ## $ast | ||||||||||||
| 24 | 0 | my $perl5; | |||||||||||
| 25 | 0 | for my $g (@$ast) { | |||||||||||
| 26 | ### Grammar found... | ||||||||||||
| 27 | 0 | $g = $g->(); | |||||||||||
| 28 | 0 | my ($name) = keys %$g; | |||||||||||
| 29 | ### Grammar: $name | ||||||||||||
| 30 | 0 | $perl5 .= Pugs::Emitter::Grammar::Perl5::emit($g, $opts); | |||||||||||
| 31 | } | ||||||||||||
| 32 | bless { | ||||||||||||
| 33 | 0 | source => $src, | |||||||||||
| 34 | ast => $ast, | ||||||||||||
| 35 | perl5 => $perl5, | ||||||||||||
| 36 | }, $class; | ||||||||||||
| 37 | } else { | ||||||||||||
| 38 | 0 | carp "Failed to compile the grammar source"; | |||||||||||
| 39 | } | ||||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | 0 | ▶ | sub perl5 { | ||||||||||
|
Subroutine
perl5: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 43 | 0 | $_[0]->{perl5}; | |||||||||||
| 44 | } | ||||||||||||
| 45 | |||||||||||||
| 46 | 15 | 1; | |||||||||||
| 47 | __END__ | ||||||||||||