Language implementation based on the Crafting Interpreters article: https://craftinginterpreters.com/
Just a little exercise in order to learn Rust.
Run this commands in order to build the project:
rm rox
cargo build
ln -s target/debug/rox rox
sudo chmod +x ./rox
This should create a symlink to the executable rox in the root directory of the project.
./rox # starts in repl mode
./rox <filename> # parses and executes the file
Print “Hello World” into stdout:
./rox examples/hello.rox
# > Hello World
Prints the sum of two numbers:
./rox examples/sum_example.rox
# > Sum of two numbers 2 + 2:
# > 4
# > Casting String to Sum 2 + 3
# > 5
Evaluation:
./rox examples/evaluation.rox
# > Is 3 bigger than 5
# > false
# > Is true really true?
# > true
# > Is false not true?
# > true
Grouping:
./rox examples/grouping.rox
# > Binary not true
# > false
# > Negative
# > -3
# > What's the result for 3 + 5 * ( 2 - 3 ) + 5 / ( 2 + 3 )
# > -1
Declaration:
./rox examples/declaration.rox
# > printing a:
# > 10
# > printing b:
# > 20
# > printing a * b
# > 200
Assignemnt:
./rox examples/assignment.rox
# > 10
# > false
Variable Scopes and Code Blocks:
./rox examples/scopes.rox
# > inner a
# > outer b
# > global c
# > outer a
# > outer b
# > global c
# > global a
# > global b
# > global c
Conditions and Flow:
./rox examples/condition.rox
# > Yes