This is My version of JLox from the book craftinginterpreters.
It is mostly the same as presented in the book, but I have made a few changes:
- Integers:
- int values are supported alongside doubles.
- when doing math, if both operands are ints, then integer math is used, otherwise both operands are treated as doubles.
- String concatenation:
- concat is done using the
..
operator and not the+
operator. - concat operator converts all operands to a String representation.
- concat is done using the
- some keywords have been changed:
- var -> stash
- class -> designation
- func -> functi
- print -> say
- this -> self
- internal changes:
- code has been organized along a more java enterprise style of coding. perhaps to an excessive extent.
- I used java 13 and 14 features such as enhanced switch and instanceof operators when applicable.
- I used streams rather than loops where applicable.
- reorganized some code to be in a separate method/class. reorganized some switch cases. did a few other small miscellaneous code changes.
- overall, my code doesn't match 100% what is in the book,but the end result when running the interpreter is the same.
- Implements anonymous functions:
- this is an optional challenge in the book, a basic Lox implementation might not implement this feature.
- Inheritance
- the operator for declaring a superclass is
:
- for example, to declare that mySubCLass is a subclass of mySuperClass :
designation mySubClass : mySuperClass {}
- for example, to declare that mySubCLass is a subclass of mySuperClass :
- the operator for declaring a superclass is