- or download this
use Stream qw/node drop list_to_stream/;
my @tokens = (
...
while (my $node = drop($stream)) {
print Dumper($node, $stream);
}
- or download this
$node = [ 'OP', '+' ];
$stream = [ # AoA
[ 'VAR', 'x' ],
...
$node = 'VAL';
$stream = 3; # scalar
- or download this
my $parser = parser {
my $input = shift;
return unless defined $input;
...
my $wanted_value = $value->($next, $u);
return ($wanted_value, tail($input));
};
- or download this
my $parser = parser {
my $input = shift;
return unless defined $input;
...
}
return ($wanted_value, $tail);
};
- or download this
my $parser = concatenate(
lookfor('OP'),
lookfor('VAR'),
...
'concatenate should return the parsed values';
is_deeply $remainder, [[ VAL => 3 ]], # AoA, not just an aref
'... and the rest of the stream';
- or download this
$parser = concatenate(
lookfor('OP'),
lookfor('VAR'),
lookfor('VAL'),
);