Skip to content

YuriRDev/another-lisp-interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YALI - Yet Another Lisp Interpreter

Wowww, omggg, another Lisp Interpreter!! That's so original!! I bet you learned a lot from doing this, didn't u?...

Usage

cargo run <file_path> # Interpret the file
cargo run  # REPL mode

Technical Decisions

  • Heterogenous ASTs: Because homogenous sucks. There are just a few nodes that really need children. Using a homogenous type would force us to waste memory (a lot).
  • Parse don't just parse: For now! For enhancing static types and ""optimizations"", we are moving this to another tree walk.
  • Monolithic scopes: We only have one scope... And for the future (lambda ...) implementations we are going to change a few things. For lambda functions we hack our way into making a aux stack to preserve the previous scope.

WIP

  • Lambda
  • REPL (Read-Eval-Print Loop).
  • Read file instead of just hardcoding it... Obviously.
  • Better error messages. (Current one it's terrible)
  • Should use graphemes. unicode-segmentation
  • Use static lifetimes instead of just .clone() everything. lol
  • TokenType FunCall can be extinct. That's gonna change the grammar into a CSG... We are going to use the symbol table at the parser probably... Looking at another approach.
  • Allow recursive functions.
  • Allow multiple s_expr as a new s_expr. Like a list of expressions that must be evaluated. The return of this list will be the first or last evaluation (Probably two different lists for this?) if (<condition>) (print ("true")) (list (print("it's false")) (define x (+ x 1)) (define y (+ y x)))

Examples

(
    (+ 1 2)         ;  3
    (+ 1 (+ 2 3))       ;  6
    (* 4 2 ) ; 8
)

Defining Variables

(define <ID> (<s_expr>))
(define (x) ) | (define x ("asd")) | (define x (true)) | (define x (false))
(define a (x)) | (define x (+ 1 2)) | ...

Comparison

Lol, we only have three comparisons

(< 1 2) ;; < number number
(> 2 1) ;; > number number
(= 1 2) ;; = number number | string string | boolean boolean 

Arithmetic

(+ 1 2 3 4 5...)
(- 1 2 3 4 5...)

Conditionals

(if (<s_expr>) (<s_expr>) (<s_expr>))

(if (> x 2) (
            define g 2
            ) (
                if (= x 4) (define g 4) (define g 1)
            ))

About

Yep, just another lisp intepreter made in rust. A language created just to learn some new techniques

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages