Skip to content

Clinery1/zlox-bytecode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

This is zLox-bytecode. My implementation of Crafting Interpreter's cLox interpreter in Zig.

Compared to jLox there are fewer differences due to Zig's semantics mapping pretty well to C's semantics (can literally transpile to/from C with Zig).

Completed chapters

  • Chapter 14: Chunks of Bytecode
  • Chapter 15: A Virtual Machine
  • Chapter 16: Scanning on Demand

Major changes compared to cLox

  • Some SCREAMING_SNAKE_CASE_NAMES are now just snake_case_names namely from the OpCode enum.
  • File names. I am keeping a general adherence to them, but I am making them more in line with what I would consider good code style.
  • Dynamic arrays. I am writing my own, but using generics and a custom allocator interface.
  • The entire allocation strategy. It requires all things to go through it, but it does not implement Zig's allocator interface. This it to make it easier to intertwine the objects and collector, but does mean I have to reinvent a lot more code to go with it. That isn't a big deal though because the book reinvents the wheel a lot too.
  • Token names. They no longer have the TOKEN_ prefix
  • Tokens use Zig slices instead of a pointer and length (which is literally just a slice deconstructed).

About

cLox, but in Zig

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages