interpreter in Java as part of the book Crafting Interpreters
run make bin/lox/Lox.class
(without Make: javac src/lox/Lox.java -d bin -sourcepath src
)
run make bin/lox.jar
run make run
(without Make: java -cp bin lox.Lox
)
run make run ARGS=<FILENAME>
the AST is generated from a string definition and must be regenerated whenever this string is updated.
- add new definition under
Main
, insrc/lox/GenerateAst.java
- run
make run-GenerateAst
- fill in new visitor methods for
Interpreter
insrc/lox/Interpreter.java
- increment (PLUSPLUS) unary operator
- parser: add newline token for better error handling, unwinding and synchronizing
- interpreter: cast double to boolean for things like
1 ? a : b;
- interpreter: cast boolean to double for things like
(a == b) * 4
- fully implement ternary expressions (
cond ? branch1 : branch2
) - parser with global "level" state, or match error production for extra closing bracket (ex.:
{}}
)
- throw some kind of EndOfExpression exception during parsing so we can skip the upward chain of redundant checks when we know the next token (EOF) won't match anything
- allow identifiers to start with a number - current valid identifier is
/[a-zA-Z][a-zA-Z0-9]*/
(cursed)