Skip to content

tushyagupta81/interpreter-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interpreter-zig

Continuation from the interpreter-rust
The rust borrow checker made the way of making the interpreter feel like hell

I will still be following Crafting Interpreters hopeful on my own this time

Working model

Check out the working model at https://tushyagupta81.github.io/interpreter-zig
The backend might take 1-2 min to turn back on

Current progress

  • How to read a file
  • Using the gpa allocator
  • REPL mode working
  • Tokens
  • Scanner
    • Challenge
      • Multiline comments
  • Parser
    • Temp hack - Using arena allocator to help memory release
    • Challenge
      • Implement Comma operator from C and C++
      • Ternary operator
      • Detect a Binary operation with a missing left hand operator
  • Interpreter
    • Challenge
      • compare numbers and string(Don't know what it should really do?)
      • and numbers to string
      • divide by 0 check
  • Statements
    • Parts
      • Exprs
      • print
      • variables(without scope)
      • variables(with scope)
      • conditionals
      • and or operators
      • loops
    • Challenge
      • REPL to auto detect a expr vs a statement and execute them accordingly
      • Give runtime error for variable that are declared but not initialized
      • branching statements?
      • break statement
  • Functions
    • Return
    • Local functions(can't really figure it out moved all environments to the heap)
    • Challenge
      • Checking number of args at runtime hits preformance
      • Anonymous functions
  • Resolver
    • Coping the env at the time of creation of the function
    • For the one from the book to work need to make it so that I can HashMap Expr itself and not there pointers
      • Got the tedious HashMap defination from tusharhero
      • Also needed a globals list(pointed the init env 2 times)
    • Resolve time errors
    • Challenge
      • Extend resolver to detect unused local variables
      • Look up variable using a index array instead of a hashmap
        • By sending the index and distance from the resolver
  • ...

Pitfalls to fix

  1. interpreter.zig
    • evaluvate_binary -> string concat size limit of 4096
  2. token.zig
    • LiteralValue
      • to_string methods size limit of 4096
  3. enironment.zig
    • get -> string concat size limit of 4096

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published