Skip to content

A bytecode compiler and virtual machine for the Lox language, in C#. Includes a C# / Lox object interface generator and bytecode serialization.

License

Notifications You must be signed in to change notification settings

ZaneDubya/LoxScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LoxScript

LoxScript is a bytecode compiler and virtual machine ("Gears") for Bob Nystrom's Lox language, both written in C#.

The LoxScript bytecode virtual machine is called Gears. Gears executes bytecode created by the LoxScript compiler. The output of Gears matches the reference "clox" virtual machine described in Chapters 14-30 of Bob's book Crafting Interpreters. However, the internal implementation of the virtual machine is different, and the bytecode generated by the Gears compiler will not run on clox.

Improvements over Lox/clox:

  • Compiler can write bytecode to a binary file and load/run this at runtime.
  • Native interfaces allow Lox files to interact with native C# functions and objects.
  • Support for switch statement! This only took hours, and the code is horrifying.

Performance:

  • Gears runs the reference 'fibonnaci' benchmark roughly 69x slower than native c# code.

About

A bytecode compiler and virtual machine for the Lox language, in C#. Includes a C# / Lox object interface generator and bytecode serialization.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages