https://github.com/ananthvk/cpp-lox
C++ implementation of Lox programming language using a bytecode VM
https://github.com/ananthvk/cpp-lox
bytecode-compiler cpp20 crafting-interpreters craftinginterpreters lox lox-interpreter lox-language vm
Last synced: 6 months ago
JSON representation
C++ implementation of Lox programming language using a bytecode VM
- Host: GitHub
- URL: https://github.com/ananthvk/cpp-lox
- Owner: ananthvk
- License: mit
- Created: 2025-05-11T13:04:54.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2025-06-08T20:53:25.000Z (7 months ago)
- Last Synced: 2025-06-08T21:31:20.440Z (7 months ago)
- Topics: bytecode-compiler, cpp20, crafting-interpreters, craftinginterpreters, lox, lox-interpreter, lox-language, vm
- Language: C++
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cpp-lox
My implementation of second part of Lox programming language from [Crafting interpreters](https://www.craftinginterpreters.com/contents.html) in C++. This implementation uses a bytecode VM to execute the programs.
## How to run?
Install `meson`, `ninja` and a C++ 20 capable compiler
```
$ meson setup builddir
$ cd builddir
$ ninja -j8
```
If you are on linux, run
```
$ ./src/cpplox
```
On windows, run
```
.\src\cpplox.exe
```
## To run tests
To run tests, you need to have `Python 3`
First install `pytest`, a test automation library used to test programs.
Create a virtual environment
```
$ python -m venv .venv
```
Install dependencies
```
$ pip install -r requirements.txt
```
Run tests
```
$ meson setup builddir -Denable-tests=true
$ cd builddir
$ ninja -j8
$ meson test -v
```
## Development build
Have `Clang` installed along with `asan`. You also need to follow the steps in the above section, `pytest` must be installed and available on the `PATH`
Then run the following command,
```
$ ./development.sh
```
## TODO
- [ ] Fix division by zero error