Lisp Interpreter in C

Program constructs a grammar for a Lisp language variant and parses the input based on that grammar. On startup, a Lisp standard library is passed in, allowing for better ease of use (more shorthand syntax for declaring functions, etc.).

Syntax table:

SymbolInput typeExample inputExample output
!=Num!= 2 31
*Num* 2 510
+Num+ 7 815
-Num- 5 23
/Num/ 8 24
<Num< 10 50
<=Num<= 10 101
==Num== 2 30
>Num> 10 51
>=Num>= 2 30
Q-Exprdef {add} ( {x y} {+ x y})()
defQ-Exprdef {x} {10}()
evalQ-Expreval {head (list 1 2 3 4)}1
headQ-Exprhead {1 2 3 5}1
tailQ-Exprtail {1 2 3 5}5
if1 S-Expr, 2 Q-Exprif (== 2 1) {+ 10 5} {* 10 5}50
joinQ-Exprjoin {1 2} {7 8}{1 2 7 8}
listSym/Numlist 1 2 3{1 2 3}

Tech:

  • Language : C

  • Library : mpc parser combinator library

Info

Press the green play button to start Lisp interpreter.