Skip to content

VrugteVlieg/dlox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dlox

An implementation of the Lox programming language in Dart.

This implementation used Crafting Interpreters as a guide.

It includes a couple of features from the end of chapter challenges:

  1. Ternary operator (?) print ? true "true" : "false;
  2. Read builtin
// Declare variable and read into it
var a;
read a;

// Or declare and assign in one step
read var a;
  1. Lambda functions
fun thrice(fn) {
 for (var i = 1; i <= 3; i = i + 1) {
   fn(i);
 }
}

thrice(fun (a) {
 print a;
});
// "1".
// "2".
// "3".

Usage

To enter a REPL simply run

dart run                                                                     
Building package executable... 
Built dlox:dlox.
> 
print "Hello World";
Hello World
>                                                           

Execute a file

dart run bin/dlox.dart run test/test_cases/hello_world.dlox
Hello World

Format a file and print to stdout

dart run bin/dlox.dart format test/test_cases/hello_world.dlox
print "Hello World";

Powers the Dlotter project

About

An implementation of the Lox programming language in Dart

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages