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