Skip to content

Latest commit

 

History

57 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages