Wednesday, March 5, 2025

Programming Language from Scratch

I made my own programming language clox from scratch Lox in C. It is a compiled and interpreted language.

It has dynamic typing. It has expressions and scopes, global variables and local variables.


This gets compiled to bytecode and looks like this:


Then it gets executed by the virtual machine which is a stack based machine, you can see the stack grow (variables in brackets) when constants are pushed into the stack by operation OP_CONSTANT:


Locals are stored in the stack directly and globals are stored in a hash table.

If you want to look at the code:

No comments:

Post a Comment