Skip to content
/ rox Public

Programming Language following the Crafting Interpreters tutorial using Rust as host language

Notifications You must be signed in to change notification settings

vmorgado/rox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROX Language

Language implementation based on the Crafting Interpreters article: https://craftinginterpreters.com/

Just a little exercise in order to learn Rust.

Build:

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.

Executing:

./rox # starts in repl mode
./rox <filename> # parses and executes the file

Examples:

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

About

Programming Language following the Crafting Interpreters tutorial using Rust as host language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages