Next Higher-Order Parsing 15 

トークンのパーサToken parsers

        sub lookfor {
          my $target = shift;
          my $parser = 
            sub {
              my $tokens = shift;
              my $tok = first($tokens);
              if (type($tok) eq $target) {
                return (value($tok), rest($tokens));
              } else {
               return;           # failure
              }
            };
          return $parser;
        }

Next Copyright © 2007 M. J. Dominus