line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gherkin::ParserBase; |
2
|
|
|
|
|
|
|
$Gherkin::ParserBase::VERSION = '27.0.0'; |
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
|
|
6
|
use Class::XSAccessor accessors => |
7
|
1
|
|
|
1
|
|
463
|
[ qw/ast_builder token_matcher stop_at_first_error max_errors/, ]; |
|
1
|
|
|
|
|
2361
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
764
|
use Gherkin::ParserContext; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
10
|
1
|
|
|
1
|
|
398
|
use Gherkin::Exceptions; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
11
|
1
|
|
|
1
|
|
459
|
use Gherkin::AstBuilder; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
460
|
use Gherkin::TokenMatcher; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
14
|
1
|
|
|
1
|
|
448
|
use Gherkin::TokenScanner; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
374
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
3
|
|
|
3
|
0
|
6683
|
my ( $class, $ast_builder, $token_matcher ) = @_; |
18
|
3
|
|
33
|
|
|
22
|
bless { |
|
|
|
33
|
|
|
|
|
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
|
|
|
3
|
0
|
13
|
sub get_result { return $_[0]->ast_builder->get_result } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub add_error { |
30
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $context, $error ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
0
|
die $error if not ref $error; # rethrow if unstructured; not ours |
33
|
0
|
0
|
|
|
|
0
|
die $error if $self->stop_at_first_error; |
34
|
0
|
0
|
|
|
|
0
|
if ( ref $error eq 'Gherkin::Exceptions::CompositeParser' ) { |
35
|
0
|
|
|
|
|
0
|
$context->add_errors( @{ $error->errors } ); |
|
0
|
|
|
|
|
0
|
|
36
|
|
|
|
|
|
|
} else { |
37
|
0
|
|
|
|
|
0
|
$context->add_errors( $error ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
my @errors = $context->errors; |
41
|
0
|
0
|
|
|
|
0
|
Gherkin::Exceptions::CompositeParser->throw(@errors) |
42
|
|
|
|
|
|
|
if @errors > $self->max_errors; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _start_rule { |
46
|
33
|
|
|
33
|
|
75
|
my ( $self, $context, $ruleType ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
33
|
50
|
|
|
|
47
|
if (not eval { $self->ast_builder->start_rule( $ruleType ); 1 }) { |
|
33
|
|
|
|
|
124
|
|
|
33
|
|
|
|
|
94
|
|
49
|
0
|
|
|
|
|
0
|
$self->add_error( $context, $@ ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _end_rule { |
54
|
33
|
|
|
33
|
|
69
|
my ( $self, $context, $ruleType ) = @_; |
55
|
33
|
50
|
|
|
|
46
|
if (not eval { $self->ast_builder->end_rule( $ruleType ); 1 }) { |
|
33
|
|
|
|
|
113
|
|
|
33
|
|
|
|
|
111
|
|
56
|
0
|
|
|
|
|
0
|
$self->add_error( $context, $@ ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _build { |
61
|
36
|
|
|
36
|
|
68
|
my ( $self, $context, $token ) = @_; |
62
|
36
|
50
|
|
|
|
46
|
if (not eval { $self->ast_builder->build( $token ); 1 }) { |
|
36
|
|
|
|
|
111
|
|
|
36
|
|
|
|
|
97
|
|
63
|
0
|
|
|
|
|
|
$self->add_error( $context, $@ ); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |