Calc with Lex and Yacc

The Grammar

line → expr eol
expr → add-expr
add-expr → mult-expr add-expr-tail
add-expr-tail → empty | (PLUS | MINUS) mult-expr add-expr-tail
mult-expr → prim-expr mult-expr-tail
mult-expr-tail → empty | (TIMES | DIV | MOD) prim-expr mult-expr-tail
prim-expr → INTEGER | LEFT-PAREN expr RIGHT-PAREN CONTENT

calc.rkt

lexer.rkt

tree.rkt

parser.rkt

eval.rkt

error.rkt