| 1 | package Parse::Highlife::Rule::Regex; | ||
| 2 | |||
| 3 | # not needed anymore | ||
| 4 | |||
| 5 | # use strict; | ||
| 6 | # use base qw(Highlife::Rule); | ||
| 7 | # use Highlife::Utils qw(params); | ||
| 8 | # | ||
| 9 | # sub new | ||
| 10 | # { | ||
| 11 | # my( $class, @args ) = @_; | ||
| 12 | # my $self = bless Highlife::Rule->new( @args ), $class; | ||
| 13 | # return $self -> _init( @args ); | ||
| 14 | # } | ||
| 15 | # | ||
| 16 | # sub _init | ||
| 17 | # { | ||
| 18 | # my( $self, $regex ) | ||
| 19 | # = params( \@_, | ||
| 20 | # -regex => '', | ||
| 21 | # ); | ||
| 22 | # $self->{'regex'} = $regex; | ||
| 23 | # return $self; | ||
| 24 | # } | ||
| 25 | # | ||
| 26 | # sub parse_from_token | ||
| 27 | # { | ||
| 28 | # my( $self, $parser, $tokens, $t ) = @_; | ||
| 29 | # return (0,0,0) if $t >= scalar(@{$tokens}); | ||
| 30 | # | ||
| 31 | # # - try to match regex with next token | ||
| 32 | # # - on match: return result, else return failure | ||
| 33 | # | ||
| 34 | # my $_t = $t; | ||
| 35 | # ($_t) = $self->_parse_ignored_tokens( $tokens, $_t ); | ||
| 36 | # | ||
| 37 | # my $token = $tokens->[$_t]; | ||
| 38 | # my $value = $token->{'matched-substring'}; | ||
| 39 | # my $regex = $self->{'regex'}; | ||
| 40 | # | ||
| 41 | # if( $value =~ /^$regex$/ ) { | ||
| 42 | # return (1, $_t + 1, {'type' => $self->{'name'}, 'ast' => $value}); | ||
| 43 | # } | ||
| 44 | # return (0,0,0); | ||
| 45 | # } | ||
| 46 | |||
| 47 | 1; |