A small, extendable interpreter for a minimalist scripting language implemented in Kotlin using the better-parse library.
- Variables:
var name = expression - Data Types: Integer, String, Boolean
- Expressions:
- Arithmetic:
+,-,*,/ - Comparison:
==,!=,<,>,<=,>= - Logical:
&&,||, unary!, unary+, unary-
- Arithmetic:
- Control Flow:
if (condition) { ... } else { ... }while (condition) { ... }
- Function Calls: built-in
submit()andshowAlert(message)for side effects - AST-based: clear separation between parsing and evaluation
- JDK 8+ or later
- Gradle or Maven
Using Gradle:
./gradlew buildUsing Maven:
mvn clean packageYou can run it from your IDE or via a main launcher, for example:
# If you have an application plugin set up in Gradle:
./gradlew runThis minimal interpreter can be extended with:
- Loops:
for,do-while - Functions: user-defined functions, parameters,
return - Scope Management: local vs. global variables
- Data Structures: Lists, Maps, Arrays
- Error Handling: richer error messages, exception handling (
throw/catch) - Standard Library:
print(),toString(), math utilities
To add new grammar rules, update Parser.kt and extend Interpreter.evaluateExpression or executeStatement accordingly.
Feel free to open issues or submit pull requests to add features or fix bugs. Please follow the existing code style and add tests for new functionality.
This project is released under the GPL3 License.