Next Higher-Order Parsing 23 

パーサ$expressionはこうParsers

     # expression → "(" expression ")" 
     #             | term ("+" expression | nothing)
     
     $expression = alt(conc(lookfor("(")),
                            $EXPRESSION,
                            lookfor(")"),
     
                       conc($TERM,
                            alt(conc(lookfor("+"), $EXPRESSION),
                                \&nothing));
      $expression = L("(") - $EXPRESSION - L(")")
                  | $TERM - (L("+") - $EXPRESSION | $nothing);

Next Copyright © 2007 M. J. Dominus