Next Higher-Order Parsing 21 

選択Alternation

        sub alt {
          my @p = @_;
          my $parser = sub {
            my $in = shift;
            for my $p (@p) {
              if (my ($result, $out) = $p->($in)) {
                return ($result, $out);
              }
            }
            return;   # failure
          };
          return $parser;
        }

Next Copyright © 2007 M. J. Dominus