Next Higher-Order Parsing 39 

正規表現には*という表記もある。繰り返しの意味だrepeat

        # term → factor repeat( "*" factor )
        $term = $FACTOR - repeat(L("*") - $FACTOR);
        # repeat($p) is:
     
        $p - repeat($p)  |  $nothing
        sub repeat {
          my $p = shift;
          my $repeat_p;
          my $do_repeat_p = sub { $repeat_p->(@_) };  # proxy
          $repeat_p = alt(conc($p, $do_repeat_p), $nothing);
          return $repeat_p;
        }

Next Copyright © 2007 M. J. Dominus