Skip to content

kevinjoseph1995/lox-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A byte-code virtual machine lox interpreter written in C++

This is a C++ implementation of the Lox programming language as I work through Robert Nystrom's wonderful book Crafting Interpreters.

The implementation does lean on some C++23 language/library features and so will require gcc-13 or clang-16. You can find docker development environments here clang and gcc.

Work in progress

  • Global variables
  • Lexical Scopes and scoped local variables
  • Conditionals
  • Loops
  • Functions
  • Closures
  • Garbage Collection
  • Classes and Instances (Partial WIP)
  • Methods and Initializers
  • Superclasses
var sum = 0;
{
     for(var i = 1; i <= 3; i = i + 1){
         sum = sum + i;
     }
     print sum;
 }
print sum;
sum = 1;
print sum;
fun Fib(n) {
    if( n<= 1) {
        return n;
    }
    return Fib(n-2) + Fib(n-1);
}
print Fib(10);
var globalOne;
var globalTwo;

fun main() {
  {
    var a = "one";
    fun one() {
      print a;
    }
    globalOne = one;
  }

  {
    var a = "two";
    fun two() {
      print a;
    }
    globalTwo = two;
  }
}

main();
globalOne();
globalTwo();
class Outer {
  method() {
    class Inner {
      method() {
        print this;
      }
    }
    return Inner;
  }
}
var class_internal = Outer().method();
var internal_instance = class_internal();
internal_instance.method();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published