Lisp infix
2006-11-07 15:38:13
For no real reason I'm collecting implementations of infix calculators in lisp.
I have six so far:
This one is based off of the Crenshaw tutorials. It doesn't emit any code it just evaluates the expression as we walk the tree.
Here is another one that is based off of the Crenshaw tutorials. It creates intermediate lisp code that works with a single register, dx, and a stack.
This one is based off of the infix calculator in "Compiler Construction by Niklaus Wirth".
All of the calculators use a recursive decent parser besides this one which uses cl-yacc. It was lifted straight form the cl-yacc tutorial.
Here I use a funky algorithm that requires an explicit stack to convert the infix notation into prefix before evaluating it.
The last one uses an implicit stack to convert from infix to prefix before evaluating the expression. It's my favorite one so far since I can see it being extended to convert other languages into lisp.
A few of these programs use closure-reader.lisp to work with the input stream.