Help for this page

Select Code to Download


  1. or download this
    expr      := number
               | expr ws unary_operator 
               | expr ws expr ws binary_operator
    
  2. or download this
    RULE1 = RULE2 | RULE3
    RULE2 = A B
    ...
    RULE1x = A ( RULE2x | RULE3x )
    RULE2x = B
    RULE3x = C
    
  3. or download this
    Parse "1 2 +" as an expr
     Try 'number'
    ...
        Parse 'end', PANIC!
       Try 'expr unary'
       ...
    
  4. or download this
    Parse "1 2 +" as an expr
     Try 'number'
    ...
      Parse 'number', left with "+"
      Parse 'binary', left with ""
      Parse 'end', done!
    
  5. or download this
    my %ops = (
        '+' => sub { $_[0] + $_[1] },
    ...
    #sx;
    
    (reverse $line) =~ $RPN3;