Next Higher-Order Parsing 14 

トークンのパーサToken parsers

        sub lookfor_PLUS {
          my $tokens = shift;
          my $tok = first($tokens);
          if (type($tok) eq "+") {
            return ("+", rest($tokens));
          } else {
            return;           # failure
          }
        }
        sub lookfor_NUMBER {
          my $tokens = shift;
          my $tok = first($tokens);
          if (type($tok) eq "NUMBER") {
            return (value($tok), rest($tokens));
          } else {
            return;           # failure
          }
        }

Next Copyright © 2007 M. J. Dominus