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:

Symbol Input type Example input Example output
!= Num != 2 3 1
* Num * 2 5 10
+ Num + 7 8 15
- Num - 5 2 3
/ Num / 8 2 4
< Num < 10 5 0
<= Num <= 10 10 1
== Num == 2 3 0
> Num > 10 5 1
>= Num >= 2 3 0
Q-Expr def {add} ( {x y} {+ x y}) ()
def Q-Expr def {x} {10} ()
eval Q-Expr eval {head (list 1 2 3 4)} {1}
head Q-Expr head {1 2 3 5} {1}
tail Q-Expr tail {1 2 3 5} {5}
if 1 S-Expr, 2 Q-Expr if (== 2 1) {+ 10 5} {* 10 5} 50
join Q-Expr join {1 2} {7 8} {1 2 7 8}
list Sym/Num list 1 2 3 {1 2 3}

Tech:

  • Language : C

  • Library : mpc parser combinator library

Info

Press the green run button to start
Follow instructions in the terminal