crlox
Version, currently main branch1 version
- main branchlatestJun 29, 2021
github.com/Raelr/crlox
An implementation of the `lox` interpreter in `crystal`.
Installation
# Add this to your shard.yml
dependencies:
crlox:
github: Raelr/crlox
branch: mainmain is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
This shard.yml declares only a name and a version: no Crystal constraint, no dependencies, no targets and no executables. It is a plain library with nothing to build.
Dependencies
This version declares no dependencies.
README
crlox
An implementation of the lox interpreter in crystal.
Summary
crlox is an attempt to re-implement jlox, a programming language designed and implemented by Robert Nystrom. This repository follows Nystrom's amazing book: crafting compilers, and re-interprets their java compiler into crystal. This repository is entirely experimental is expected to be a means to learn the basics of compilers and interpreters.
Setup
Setting the project up is quite simple.
- Make sure you have
crystalinstalled. If not, follow the steps on the official crystal website!. - Clone the repository:
$ git clone https://github.com/Raelr/crlox.git
- In the project's root folder, run the following:
$ shards init
$ shards install
- Once complete, run the compiler using the following:
$ crystal run src/crlox.cr -- "assets/test.lox"
You can also write you own Lox code and pass in the file's location. We just provided a sample file for your convenience.
The project can also be tested using:
$ crystal spec
Generating AST Tree Files
An AST file definition can be generated by running the following command:
$ crystal run src/tool/generate_ast.cr
This will generate a file called expr.cr which contains all relevant Expression classes. You can specify a location for the file to be generated by providing a path after the command:
$ crystal run src/tool/generate_ast.cr -- "your/desired/path"
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
main- Seen
- Jun 29, 2021
- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/Raelr/crlox
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 1