A script interpreter for learning purpose (Crafting Interpreters).
See scripts
folder for example scripts.
fun makeCounter() {
var i = 0;
fun count() {
i = i + 1;
print i;
}
return count;
}
var counter = makeCounter();
counter();
counter();
counter();
var a = 1;
fun resolve() {
print a;
}
fun test() {
resolve();
var a = 2;
resolve();
}
test();
class Greeter {
init(name) {
this.name = name;
}
greet() {
print "Hello, " + this.name + "!";
}
}
class NameGreeter < Greeter {
init(firstName, lastName) {
super.init(firstName + " " + lastName);
}
}
print Greeter;
print NameGreeter;
var g = NameGreeter("Dear", "Esther");
g.greet();