Skip to content

KMJ-007/RustyScheme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rusty_scheme

A Lisp interpreter in Rust.

Features

  • 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.

Motivation

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."

Challenges and Learnings

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, but println 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
  • 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)]
  • 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

features pending:

  • supporting float values
  • divide by zero and similar errors

Reddit Discussion:

Built a Lisp Interpreter in Rust – Roast my Code!

About

lisp interpreter in rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages