A tree-walk interpreter for Bob Nystrom's Lox Language from Crafting Interpreters , written in JavaScript.
node bin/main.js
launches a REPL. prints the values of expressions (and null for statements)
node bin/main.js file
loads, parses, and interprets the file then exits.
>print "Hello" + ", " + "world!";
Hello, world!
>print 19 + 2 < 20;
false
There are some test files in t/. Some of them follow Nystrom's convention of // expect:...
comments. Nystrom has a test suite in the book's repo.
node bin/main.js t/testPrint1.lox
For quickie command line tests:
$ printf "var a = 19;\nprint a;\n" | npm run r
npm run r
=== node bin/main.js
2019-10-11 chapter 13 done, except for challenges
2019-10-10 chapter 12 done, except for challenges
2019-10-07 chapter 11 done, except for challenges
2019-10-02 chapter 10 done, except for anonymous functions challenge