Interpreter for a custom scripting language, similar to JS
You can peek into the supported functionality in this short REPL session.
This is a CMake based project, so you can install CMake and do the following steps.
- Create a
build
folder in the repo root - Change directory into this
build
- Open a terminal and type
cmake .. -G"Your generator"
. There are many types of generators. For windows, if you have Visual studio installed, you can use a windows generator which will generate a VS solution. - Compile the actual program and run.
- For windows, if you are working under VS, you can use the IDE to run the project.
- For linux, after the
cmake
command, you have to runmake
and run the binary executable.
- Main
- Scanner
- Parser
- Interpreter
- When the process is terminated with Ctrl + C, the program crashes. When adding Windows.h to handle the Ctrl+C, the project goes wild.
- It would be good to warn users if they input a floating point number which overflows the supported precision in our language. For this, we have to introduce a BigDecimal type of object.
- The primary grammar rule is trying and failing to parse a semicolon at the end of expression. It should not try to parse it, it should stop.
- LoxValue is copied a lot while storing and retrieving from Environment storage. Let's improve that.
- Never ignore the warnings from the compiler. Really odd linking errors could happen and some compilers are more strict than others.
- In visual studio compiler, when you have reference to an object fields in classes, you must import the header files of these classes. Forward declarations won't work for fields.