Next Higher-Order Parsing 29 

演算子Operators

     $expression = 
        expression_parser(
            ATOM => $ATOM,
     
            OPS => [[lookfor(['^']), sub { $_[0] ** $_[1] }, "right-assoc"],
     
                    [lookfor(['*']), sub { $_[0] * $_[1] },
                     lookfor(['/']), sub { $_[0] / $_[1] }],
     
                    [lookfor(['+']), sub { $_[0] + $_[1] },
                     lookfor(['-']), sub { $_[0] - $_[1] }],
                   ],
                   
         );

Next Copyright © 2007 M. J. Dominus