A Lisp interpreter in Rust.
- Lexing: Converting the Lisp program text into a stream of tokens.
- Parsing: Converting the stream of tokens into an in-memory recursive list data structure.
- Evaluation: Walking the in-memory recursive list and producing the final result.
I completed half of the Rust book and 50% of rustlings, but I wasn't feeling confident. Although I started to get familiar with the syntax, I wanted to build something. So, I made this project.
This project would not have been possible without this guide.
why lisp ?
- i read hackers and painters and want to understand it more
- and this quote from Rich Programmer Food
"If you don't know how compilers work, then you don't know how computers work."
This was my first time writing interpreter, during the development, I used ChatGPT and did a lot of Googling, redditing(is is real term?):
- I wanted to use the
println
macro for debugging tests, but for some reason, it wasn't working. The tests were passing, butprintln
was not displaying anything.- Solution: By default, in tests, outputs are captured to keep the test output clean and focused only on what matters. To display the outputs during tests, you can run them like this:
cargo test -- --nocapture
- Solution: By default, in tests, outputs are captured to keep the test output clean and focused only on what matters. To display the outputs during tests, you can run them like this:
- your code may seem like exact to the solution or online forums, but if rust compiler is still saying no, then there is high chance that you forgot to implement trait, this will take some time to get used to it, you can add them in attributes array
- want to debug or allow clone ? add
#[derive(Debug, Clone)]
- want to debug or allow clone ? add
- asked about this None and is_empty question, people on reddit are really nice, they replied and taught me new things
- spend half hour debugging because i put semi colon after Ok at the end 😭
- learn about reference pointers this was lot of confusing, and i still think i only understand somewhat, still i haven't got intuitive understanding, but i managed to implement it
- got more used to rust syntax, and this was good then just watching and reading about rust on the internet
- supporting float values
- divide by zero and similar errors