MarusDod / lisp-interpreter

My own common lisp interpreter in C (work in progress)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lisp Interpreter

A lisp interpreter in C. Still work in progress.

Build project:

    git clone https://github.com/MarusDod/lisp-interpreter
    #cd into directory
    mkdir build
    cd build
    cmake ..
    make

Install:

    sudo make install

Uninstall:

    sudo xargs rm < install_manifest.txt

Run source file:

    lisp file.lisp

Run repl:

    lisp

Safely exit the repl:

    abort

Parser:

-Supports quotes, symbols, strings, integers, list and arryas
-Single line comments with semi-colon.

Eval:

-Pretty much same syntax as common lisp
-No need for funcall

Memory management:

-None (as of yet)

Features:

- Vectors
- Higher order functions
- Closures
- Lists
- Strings
- Positive integers
- C FFI

Examples:

      (cons 1 '(2 3)) ; (1 2 3)
  
      (setf b (+ 2 3)) ; b
  
      (* 3 (+ 6 b)) ; 33
    (defun double (x) (* x 2)) ; double
  
    (double b) ; 10
    (if (numberp b) 5 10) ; 5
    (length '((1 2 3) w (3 f))) ; 3

     (print "haha") ; "haha" "haha"
     (null nil) ; T
    (defun factorial (x) (if (< x 2) 1 (* x (factorial (- x 1))))
      (print (factorial 10)) ; 3628800

    (defun make-adder (x) (lambda (y) (+ x y)))

    (setf adder (make-adder 5))

    (print (adder 10)) ; 15
    (setf handle (dll-open "./libtest.so"))

    (setf foo (dll-load handle "foo"))
    (defun b (x y) (dll-apply foo x y))
    (print (b 1 2))

    (dll-close handle)

Features to implement:

- Macros
- Optional Arguments
- String manipulation
- Garbage collection
- Just in Time Compilation

About

My own common lisp interpreter in C (work in progress)


Languages

Language:Makefile 61.5%Language:C 32.5%Language:CMake 4.5%Language:Common Lisp 1.3%Language:TypeScript 0.2%Language:NewLisp 0.1%