| 1 | package Gherkin::ParserBase; | ||||||||||||||||||||||||||||||||||||||
| 2 | 1 | $Gherkin::ParserBase::VERSION = '42.0.1'; | |||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Class::XSAccessor accessors => | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | 1 | [ qw/ast_builder token_matcher stop_at_first_error max_errors/, ]; | |||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Gherkin::ParserContext; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Gherkin::Exceptions; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Gherkin::AstBuilder; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Gherkin::TokenMatcher; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Gherkin::TokenScanner; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 17 | 3 | my ( $class, $ast_builder, $token_matcher ) = @_; | |||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | bless { | ||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$ast_builder || 'Gherkin::AstBuilder'->new
$token_matcher || 'Gherkin::TokenMatcher'->new
MC/DC0%0/2
$ast_builder || 'Gherkin::AstBuilder'->new
$ast_builder
'Gherkin::AstBuilder'->new
MC/DC0%0/2
$token_matcher || 'Gherkin::TokenMatcher'->new
$token_matcher
'Gherkin::TokenMatcher'->new
Truth table33%1/3
A || B
A= $ast_builderB= 'Gherkin::AstBuilder'->new
Truth table33%1/3
A || B
A= $token_matcherB= 'Gherkin::TokenMatcher'->new
| |||||||||||||||||||||||||||||||||||||||
| 19 | ast_builder => $ast_builder || Gherkin::AstBuilder->new(), | ||||||||||||||||||||||||||||||||||||||
| 20 | token_matcher => $token_matcher || Gherkin::TokenMatcher->new(), | ||||||||||||||||||||||||||||||||||||||
| 21 | stop_at_first_error => 0, | ||||||||||||||||||||||||||||||||||||||
| 22 | max_errors => 10, | ||||||||||||||||||||||||||||||||||||||
| 23 | }, | ||||||||||||||||||||||||||||||||||||||
| 24 | $class; | ||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||
| 27 | 3 | ▶ | sub get_result { return $_[0]->ast_builder->get_result } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
get_result: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub add_error { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
add_error: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my ( $self, $context, $error ) = @_; | |||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | die $error if not ref $error; # rethrow if unstructured; not ours | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | die $error if $self->stop_at_first_error; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if ( ref $error eq 'Gherkin::Exceptions::CompositeParser' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $context->add_errors( @{ $error->errors } ); | |||||||||||||||||||||||||||||||||||||
| 36 | } else { | ||||||||||||||||||||||||||||||||||||||
| 37 | 0 | $context->add_errors( $error ); | |||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my @errors = $context->errors; | |||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | Gherkin::Exceptions::CompositeParser->throw(@errors) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 42 | if @errors > $self->max_errors; | ||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||
| 45 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||||||
| 46 | # Private subs (subs prefixed with an underscore) are used as "friend methods" here, | ||||||||||||||||||||||||||||||||||||||
| 47 | # to be used by the actual parser class which is based on this one. | ||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||
| 49 | 33 | ▶ | sub _start_rule { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_start_rule: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||
| 50 | 33 | my ( $self, $context, $ruleType ) = @_; | |||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||
| 52 | 33 | ▶ | if (not eval { $self->ast_builder->start_rule( $ruleType ); 1 }) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $self->add_error( $context, $@ ); | |||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | 33 | ▶ | sub _end_rule { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_end_rule: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||
| 58 | 33 | my ( $self, $context, $ruleType ) = @_; | |||||||||||||||||||||||||||||||||||||
| 59 | 33 | ▶ | if (not eval { $self->ast_builder->end_rule( $ruleType ); 1 }) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $self->add_error( $context, $@ ); | |||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||
| 64 | 36 | ▶ | sub _build { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_build: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||
| 65 | 36 | my ( $self, $context, $token ) = @_; | |||||||||||||||||||||||||||||||||||||
| 66 | 36 | ▶ | if (not eval { $self->ast_builder->build( $token ); 1 }) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $self->add_error( $context, $@ ); | |||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||
| 71 | 1 | 1; | |||||||||||||||||||||||||||||||||||||