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
- Host: GitHub
- URL: https://github.com/hugcis/rusp
- Owner: hugcis
- Created: 2021-10-10T11:16:49.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-21T11:51:04.000Z (over 3 years ago)
- Last Synced: 2024-12-29T07:32:55.722Z (12 months ago)
- Topics: lisp-interpreter, rust, rust-lang
- Language: Rust
- Homepage:
- Size: 50.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
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