diff options
Added bison calculator as a demo
1 files changed, 208 insertions, 0 deletions
| -rw-r--r-- | demo/bison/calc/parser.output | 208 |
diff --git a/demo/bison/calc/parser.output b/demo/bison/calc/parser.output new file mode 100644 index 0000000..6cc9074 --- /dev/null +++ b/demo/bison/calc/parser.output @@ -0,0 +1,208 @@ +Grammar + + 0 $accept: input $end + + 1 input: %empty + 2 | expr + + 3 expr: NUMBER + 4 | '(' expr ')' + 5 | expr PLUS expr + 6 | expr MINUS expr + 7 | expr MULT expr + 8 | expr DIV expr + + +Terminals, with rules where they appear + +$end (0) 0 +'(' (40) 4 +')' (41) 4 +error (256) +NUMBER (258) 3 +PLUS (259) 5 +MINUS (260) 6 +MULT (261) 7 +DIV (262) 8 + + +Nonterminals, with rules where they appear + +$accept (10) + on left: 0 +input (11) + on left: 1 2, on right: 0 +expr (12) + on left: 3 4 5 6 7 8, on right: 2 4 5 6 7 8 + + +State 0 + + 0 $accept: . input $end + + NUMBER shift, and go to state 1 + '(' shift, and go to state 2 + + $default reduce using rule 1 (input) + + input go to state 3 + expr go to state 4 + + +State 1 + + 3 expr: NUMBER . + + $default reduce using rule 3 (expr) + + +State 2 + + 4 expr: '(' . expr ')' + + NUMBER shift, and go to state 1 + '(' shift, and go to state 2 + + expr go to state 5 + + +State 3 + + 0 $accept: input . $end + + $end shift, and go to state 6 + + +State 4 + + 2 input: expr . + 5 expr: expr . PLUS expr + 6 | expr . MINUS expr + 7 | expr . MULT expr + 8 | expr . DIV expr + + PLUS shift, and go to state 7 + MINUS shift, and go to state 8 + MULT shift, and go to state 9 + DIV shift, and go to state 10 + + $default reduce using rule 2 (input) + + +State 5 + + 4 expr: '(' expr . ')' + 5 | expr . PLUS expr + 6 | expr . MINUS expr + 7 | expr . MULT expr + 8 | expr . DIV expr + + PLUS shift, and go to state 7 + MINUS shift, and go to state 8 + MULT shift, and go to state 9 + DIV shift, and go to state 10 + ')' shift, and go to state 11 + + +State 6 + + 0 $accept: input $end . + + $default accept + + +State 7 + + 5 expr: expr PLUS . expr + + NUMBER shift, and go to state 1 + '(' shift, and go to state 2 + + expr go to state 12 + + +State 8 + + 6 expr: expr MINUS . expr + + NUMBER shift, and go to state 1 + '(' shift, and go to state 2 + + expr go to state 13 + + +State 9 + + 7 expr: expr MULT . expr + + NUMBER shift, and go to state 1 + '(' shift, and go to state 2 + + expr go to state 14 + + +State 10 + + 8 expr: expr DIV . expr + + NUMBER shift, and go to state 1 + '(' shift, and go to state 2 + + expr go to state 15 + + +State 11 + + 4 expr: '(' expr ')' . + + $default reduce using rule 4 (expr) + + +State 12 + + 5 expr: expr . PLUS expr + 5 | expr PLUS expr . + 6 | expr . MINUS expr + 7 | expr . MULT expr + 8 | expr . DIV expr + + MULT shift, and go to state 9 + DIV shift, and go to state 10 + + $default reduce using rule 5 (expr) + + +State 13 + + 5 expr: expr . PLUS expr + 6 | expr . MINUS expr + 6 | expr MINUS expr . + 7 | expr . MULT expr + 8 | expr . DIV expr + + MULT shift, and go to state 9 + DIV shift, and go to state 10 + + $default reduce using rule 6 (expr) + + +State 14 + + 5 expr: expr . PLUS expr + 6 | expr . MINUS expr + 7 | expr . MULT expr + 7 | expr MULT expr . + 8 | expr . DIV expr + + $default reduce using rule 7 (expr) + + +State 15 + + 5 expr: expr . PLUS expr + 6 | expr . MINUS expr + 7 | expr . MULT expr + 8 | expr . DIV expr + 8 | expr DIV expr . + + $default reduce using rule 8 (expr) |
