| 1 | package Evo::Inference::InferenceParser; | ||
| 2 | |||
| 3 | sub new { | ||
| 4 | my ($class) = @_; | ||
| 5 | |||
| 6 | my $self = { | ||
| 7 | delimiter => Delimiter->new, | ||
| 8 | }; | ||
| 9 | |||
| 10 | $class = ref($class) || $class; | ||
| 11 | |||
| 12 | bless $self, $class; | ||
| 13 | } | ||
| 14 | |||
| 15 | sub parse { | ||
| 16 | my ($self, $cond, @condargs) = @_; | ||
| 17 | |||
| 18 | return $cond->solve(@condargs); | ||
| 19 | } | ||
| 20 | |||
| 21 | sub grep_char { | ||
| 22 | my ($self, $string, $idx) = @_; | ||
| 23 | my $fwchar = FlyweightCharacter->new; | ||
| 24 | my $s = $string[$i]; | ||
| 25 | |||
| 26 | $fwclause->set($s); | ||
| 27 | return $fwchar; | ||
| 28 | } | ||
| 29 | |||
| 30 | sub grep_clause { | ||
| 31 | my ($self, $string, $index, $delimiter) = @_; | ||
| 32 | my $fwclause = FlyweightClause->new; | ||
| 33 | my $s = ""; | ||
| 34 | |||
| 35 | $self->{delimiter} = $delimiter; | ||
| 36 | |||
| 37 | for (my $i = $index->get; $self->{delimiter} != $string[$i]; $i++) { | ||
| 38 | |||
| 39 | $s .= $string[$i]; | ||
| 40 | |||
| 41 | } | ||
| 42 | |||
| 43 | $fwclause->set($s); | ||
| 44 | return $fwclause; | ||
| 45 | } | ||
| 46 | |||
| 47 | 1; |