First Syntax Tree
📦 Release 0.5.0 — First Syntax Tree
✨ Features
First version of rslox capable of generating syntax trees!
rslox is a Rust implementation of the Lox language, based on the book Crafting Interpreters. This release completes the Parsing Expressions section, allowing the language to convert a sequence of tokens into a correctly structured AST (Abstract Syntax Tree).
✅ Highlights:
- 📖 Implemented the Parsing Expressions section from Crafting Interpreters.
- 📝 Support for arithmetic expressions with correct operator precedence and associativity.
- 🛠️ The
runcommand now prints the generated AST for each entered expression. - 🎨 Significant CLI improvements, including:
- New parameters and commands
- Colored output for better readability
- Improved command-line feedback and structure
📚 Example:
Expression:
1 + 2 * (3 - 4) / 5
AST:
(+ 1 (/ (* 2 (group (- 3 4))) 5))
⚠️ Warnings
rsloxcurrently does not support keywords.- If a keyword (such as
print,fun,if,return…) is found during interpretation, the program will raise an error and exit immediately with exit code1. - Because of this, the
examplefile located in theplaygroundwill fail to run, as it contains unsupported keywords.
🛠️ Usage
Run an expression and print its AST:
cargo run -- runThen enter expressions like:
(1 + 2) * 3
🚀 Next Steps (0.5.1)
- Add a
debugcommand with the--astoption to optionally print the AST, moving this functionality out of theruncommand.
✍️ Based on: Crafting Interpreters by Bob Nystrom