Skip to content
/ rlox Public

A tree-walk lox interpreter written in Rust.

Notifications You must be signed in to change notification settings

fampiyush/rlox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A tree walk lox interpreter written in Rust.
Lox is a dynamically typed, interpreted scripting language designed by Bob Nystom for his book "Crafting Interpreters".

How to run

  • Clone the repository.
  • Make sure rust is installed in your system.
  • In the directory run cargo run example.lox

Lox Features

  • Arithmetic operators (+, -, *, /)
  • Comparison operators (<, >, <=, >=, ==)
  • Logical operators (and, or, !)
  • Variables
  • Functions
  • Conditional statements (if, if-else)
  • Loops (for, while)
  • Classes
  • Inheritance

Example

class Doughnut {
  cook() {
    print "Fry until golden brown.";
  }
}

class BostonCream < Doughnut {
  cook() {
    super.cook();
    print "Pipe full of custard and coat with chocolate.";
  }
}

fun cooking(num) {
    var dish = BostonCream();
    print num;
    dish.cook();
}

for(var i=0; i<5; i=i+1) {
    cooking(i);
}

Releases

No releases published

Packages

No packages published

Languages