| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Parse::Highlife::Rule::Sequence; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 6 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 42 |  | 
| 4 | 1 |  |  | 1 |  | 6 | use base qw(Parse::Highlife::Rule); | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 633 |  | 
| 5 | 1 |  |  | 1 |  | 8 | use Parse::Highlife::Utils qw(params); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 66 |  | 
| 6 | 1 |  |  | 1 |  | 5 | use Data::Dump qw(dump); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 335 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | sub new | 
| 9 |  |  |  |  |  |  | { | 
| 10 | 0 |  |  | 0 | 0 |  | my( $class, @args ) = @_; | 
| 11 | 0 |  |  |  |  |  | my $self = bless Parse::Highlife::Rule->new( @args ), $class; | 
| 12 | 0 |  |  |  |  |  | return $self -> _init( @args ); | 
| 13 |  |  |  |  |  |  | } | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | sub _init | 
| 16 |  |  |  |  |  |  | { | 
| 17 | 0 |  |  | 0 |  |  | my( $self, $sequence ) | 
| 18 |  |  |  |  |  |  | = params( \@_, | 
| 19 |  |  |  |  |  |  | -sequence => [], | 
| 20 |  |  |  |  |  |  | ); | 
| 21 | 0 |  |  |  |  |  | $self->{'sequence'} = $sequence; | 
| 22 | 0 |  |  |  |  |  | return $self; | 
| 23 |  |  |  |  |  |  | } | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | sub parse_from_token | 
| 26 |  |  |  |  |  |  | { | 
| 27 | 0 |  |  | 0 | 0 |  | my( $self, $parser, $tokens, $t ) = @_; | 
| 28 | 0 | 0 |  |  |  |  | return (0,0,0) if $t >= scalar(@{$tokens}); | 
|  | 0 |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | # - try to parse one sub-rule after another | 
| 31 |  |  |  |  |  |  | # - abort on first failure | 
| 32 |  |  |  |  |  |  | # - on success: return result | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 0 |  |  |  |  |  | my $_t = $t; | 
| 35 | 0 |  |  |  |  |  | my @result = (); | 
| 36 | 0 |  |  |  |  |  | my ($_status, $_result); | 
| 37 | 0 |  |  |  |  |  | foreach my $subrulename (@{$self->{'sequence'}}) { | 
|  | 0 |  |  |  |  |  |  | 
| 38 | 0 |  |  |  |  |  | my $subrule = $parser->get_rule( $subrulename ); | 
| 39 | 0 |  |  |  |  |  | ($_t) = $self->_parse_ignored_tokens( $tokens, $_t ); | 
| 40 | 0 |  |  |  |  |  | ($_status, $_t, $_result)	= $subrule->wrap_parse_from_token($parser, $tokens, $_t); | 
| 41 | 0 | 0 |  |  |  |  | last unless $_status; | 
| 42 | 0 |  |  |  |  |  | push @result, $_result; | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  |  | 
| 45 | 0 | 0 |  |  |  |  | if( $_status ) { | 
| 46 |  |  |  |  |  |  | return ( | 
| 47 | 0 |  |  |  |  |  | 1, | 
| 48 |  |  |  |  |  |  | $_t, | 
| 49 |  |  |  |  |  |  | $parser->make_ast_element('group', $self->{'name'}, \@result) | 
| 50 |  |  |  |  |  |  | ); | 
| 51 |  |  |  |  |  |  | } | 
| 52 | 0 |  |  |  |  |  | return (0,0,0); | 
| 53 |  |  |  |  |  |  | } | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | 1; |