Yacc based expression calculator - lyriarte/Cm7b5 GitHub Wiki
LR grammar
- Read input from left to right
- Rightmost derivation
Bare-bones parser
git checkout simple_expression_parser
cat parser.y
Example expression:
a + b + c
Parse tree:
+
/ \
+ a
/ \
b c
Left-recursive expression calculator
git checkout interpreter
git clean -f
make
echo "(123 - 5 * 4 - 3) / 4" | ./parser
Stack automaton
git checkout yydebug
git clean -f
make
cat y.output
echo "2 * 3" | ./parser