All Projects → jalalmostafa → clox

jalalmostafa / clox

Licence: MIT license
A virtual machine and a tree-walk interpreter for the Lox programming language in C89 🌀

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to clox

Quickjs
The official repo is at bellard/quickjs.
Stars: ✭ 1,429 (+3660.53%)
Mutual labels:  vm, interpreter, virtual-machine
RSqueak
A Squeak/Smalltalk VM written in RPython.
Stars: ✭ 78 (+105.26%)
Mutual labels:  vm, interpreter, virtual-machine
Animach
Scheme语言实现和运行时环境 / A Scheme runtime & implementation
Stars: ✭ 45 (+18.42%)
Mutual labels:  vm, interpreter, virtual-machine
Tagha
Minimal, low-level, fast, and self-contained register-based bytecode virtual machine/runtime environment.
Stars: ✭ 101 (+165.79%)
Mutual labels:  vm, interpreter, virtual-machine
RISVM
A low overhead, embeddable bytecode virtual machine in C++
Stars: ✭ 21 (-44.74%)
Mutual labels:  vm, interpreter, virtual-machine
Box
[DEPRECATED] Official, pre-packaged Vagrant Box
Stars: ✭ 197 (+418.42%)
Mutual labels:  vm, virtual-machine
Enigma
An Erlang VM implementation in Rust
Stars: ✭ 877 (+2207.89%)
Mutual labels:  vm, virtual-machine
Dockerpi
A Virtualised Raspberry Pi inside a Docker image
Stars: ✭ 1,064 (+2700%)
Mutual labels:  vm, virtual-machine
Footloose
Container Machines - Containers that look like Virtual Machines
Stars: ✭ 1,289 (+3292.11%)
Mutual labels:  vm, virtual-machine
Redtamarin
AS3 running on the command line / server side
Stars: ✭ 105 (+176.32%)
Mutual labels:  vm, virtual-machine
Lam
🚀 a lightweight, universal actor-model vm for writing scalable and reliable applications that run natively and on WebAssembly
Stars: ✭ 176 (+363.16%)
Mutual labels:  vm, virtual-machine
Macos Virtualbox Vm
Instructions and script to help you create a VirtualBox VM running macOS.
Stars: ✭ 2,385 (+6176.32%)
Mutual labels:  vm, virtual-machine
Ethereumjs Monorepo
Monorepo for the Ethereum VM TypeScript Implementation
Stars: ✭ 813 (+2039.47%)
Mutual labels:  vm, virtual-machine
Ebcvm
EFI Byte Code Virtual Machine in userspace
Stars: ✭ 34 (-10.53%)
Mutual labels:  vm, virtual-machine
Lc3 Vm
Write your own virtual machine for the LC-3 computer!
Stars: ✭ 631 (+1560.53%)
Mutual labels:  vm, virtual-machine
Mac
bytecode interpreter in c (blog post)
Stars: ✭ 628 (+1552.63%)
Mutual labels:  vm, virtual-machine
Janet
A dynamic language and bytecode vm
Stars: ✭ 2,216 (+5731.58%)
Mutual labels:  vm, interpreter
Javo
🚀 A sandboxed VM any Java developer can afford
Stars: ✭ 144 (+278.95%)
Mutual labels:  vm, interpreter
Linux Unattended Installation
This project provides all you need to create an unattended installation of a minimal setup of Linux.
Stars: ✭ 215 (+465.79%)
Mutual labels:  vm, virtual-machine
Customasm
💻 An assembler for custom, user-defined instruction sets! https://hlorenzi.github.io/customasm/web/
Stars: ✭ 211 (+455.26%)
Mutual labels:  vm, virtual-machine

CLox

Build Status Build status

CLox is a cross-platform implementation of a tree-walk lox interpreter and a virtual machine in C89.

This implementation may be a little bit different than the original Lox implementation in the sense of data structures, project structure, and minor algorithmic changes. For example, both CLox modes use the same tokenizer that is available in include/tokenizer.h and src/tokenizer.c.

Next Chapter: Ch.25 Closures

How to Run

`lox.exe [--vm|--tree-walk] [filename]` or `lox.exe [--vm|--tree-walk]` to launch REPL interpreter.
    --tree-walk    runs clox in tree walk mode
    --vm           runs clox in bytecode mode (default)
    --help         shows this help text

Coding Conventions

clox source code follows Webkit Coding Convention. However, some rules are violated as follows:

  • Function Naming: clox uses the old ugly but practical function naming e.g. function_name()
  • Guards: clox uses guards instead of #pragma once
  • Macro Naming: clox uses capital letters with underscores to name macros

Build

In order to build and compile clox, you need to install CMake plus the toolchain of your choice, e.g. MSBuild with MSVC or make with gcc. After you setup CMake with your toolchain of choice, clone the repository and build the project as follows:

git clone https://github.com/jalalmostafa/clox.git
cd clox/
mkdir build && cd build
cmake ..
cmake --build .

In order to execute clox, check bin folder in project directory for binaries. Execute with --tree-walk in the arguments.

VS Code

You can also use VS Code to automate builds and run tests. Below is a table of the available tasks. If it is the first time running the project, then be sure to generate build files by running Rebuild task

Task Name Job Hotkey (default)
Build Compile source code and generate binaries Ctrl+Shift+B
Rebuild Run cmake to generate build files then run Build task
Run Read Test with Treewalk Run clox with examples/read_from_input.lox and --tree-walk in the arguments
Run Read Test with VM Run clox with examples/read_from_input.lox and --vm in the arguments
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].