/chef

clox programming language written in Rust

Primary LanguageRustMIT LicenseMIT

chef

Chef is a stack-based language designed to read like a recipe


The language was created following completion of Part III of the book Crafting Interpreters, porting the C bytecode interpreter into Rust (the implementation of Lox, with classes, closures etc. can be found on the lox branch)

In creating a grammar for a recipe-oriented language, I gained deeper insights into Pratt-parsing and stack-based compilation than the first pass through the book. I have written about the interesting challenges and alterations here (TODO)

Fibonacci Recipe Recipe for the nth fibonacci number

Features

  • Function support and basic control flow including if-statements and while-loops (grammar here) (TODO incomplete)
  • Syntax highlighting is provided by the VSCode extension chef-colouring (source here) (TODO finish and publish)

Usage

To build local, clone this repository and build with

git clone git@github.com:D-J-Harris/chef.git
cargo build --release

Run either with zero arguments as a REPL, or compile source code at the .chef or .recipe extensions

chef
chef <.chef | .recipe file>

Features Flags

  • --debug_code - print out each disassembled chunk at the end of compile time
  • --debug_trace - print out each disassembled operation during runtime

Test

cargo test

License

Codebases and references all MIT licensed, including this repository

Icon by tulpahn, on Freepik