Help for this page

Select Code to Download


  1. or download this
      use Stream qw/node drop list_to_stream/;
    
      my @tokens = (
    ...
      while (my $node = drop($stream)) {
        print Dumper($node, $stream);
      }
    
  2. or download this
      $node   = [ 'OP', '+' ];
      $stream = [               # AoA
        [ 'VAR', 'x' ],
    ...
    
      $node   = 'VAL';
      $stream = 3;              # scalar
    
  3. or download this
      my $parser = parser {
        my $input = shift;
        return unless defined $input;
    ...
        my $wanted_value = $value->($next, $u);
        return ($wanted_value, tail($input));
      };
    
  4. or download this
      my $parser = parser {
        my $input = shift;
        return unless defined $input;
    ...
        }
        return ($wanted_value, $tail);
      };
    
  5. 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';
    
  6. or download this
      $parser = concatenate(
        lookfor('OP'),
        lookfor('VAR'),
        lookfor('VAL'),
      );