An open API service indexing awesome lists of open source software.

https://github.com/hugcis/rusp

A Lisp written in Rust
https://github.com/hugcis/rusp

lisp-interpreter rust rust-lang

Last synced: 7 days ago
JSON representation

A Lisp written in Rust

Awesome Lists containing this project

README

          

* Rusp: a lisp written in Rust

I wrote a minimal Lisp in Rust.

This is a side-project. It still needs a number of new features to be remotely
close to a working programming language.

Parsing is done with the [[https://github.com/Geal/nom][nom]] parser framework.

** REPL
The program comes with a REPL to use the language interactively:
#+begin_src bash :noeval
$ ./rusp
Rusp Version 0.0.1
Press Ctrl+c to Exit
rusp> (+ 3 3)
6
rusp>
#+end_src

** Implemented
Here is a list of implemented/planned features for rusp

*** Operations

- ☑️ Addition
#+begin_src sh :dir ./target/debug :exports both
./rusp -e "(+ 3 1)"
#+end_src

#+RESULTS:
: 4

- ☑ Substraction
#+begin_src sh :dir ./target/debug :exports both
./rusp -e "(- 3 1)"
#+end_src

#+RESULTS:
: 2

- ☑ Multiplication
#+begin_src sh :dir ./target/debug :exports both
./rusp -e "(* 3 12)"
#+end_src

#+RESULTS:
: 36

- ☑ Division
#+begin_src sh :dir ./target/debug :exports both
./rusp -e "(/ 3. 12)"
#+end_src

#+RESULTS:
: 0.25

*** Built-ins

- ☑ Define function
#+begin_src sh :dir ./target/debug :exports both
./rusp -e "(defun square (x) (* x x))"
#+end_src

#+RESULTS:
: square

- ☑ Eval function
#+begin_src sh :dir ./target/debug :exports both :results output
./rusp -e "(defun square (x) (* x x))
(square 5)"
#+end_src

#+RESULTS:
: square
: 25

- ☑ Quoted expressions
#+begin_src sh :dir ./target/debug :exports both
./rusp -e "(car '(1 2 3))"
#+end_src

#+RESULTS:
: 1

**** Functions

- ☑ Nth element of a list
#+begin_src sh :dir ./target/debug :exports both
./rusp -e "(nth 2 '((car '(4 5 6)) 2 3))"
#+end_src

#+RESULTS:
: 3

- ☑ car: first element of a list
#+begin_src sh :dir ./target/debug :exports both
./rusp -e "(car '((car '(4 5 6)) 2 3))"
#+end_src

#+RESULTS:
: (car '(4 5 6))

- ☑ eval: evaluate expression
#+begin_src sh :dir ./target/debug :exports both
./rusp -e "(eval (car '((car '(4 5 6)) 2 3)))"
#+end_src

#+RESULTS:
: 4

- ❌ range
- ❌ map