yarn global add jlox
or
npm install -g jlox
jlox --path=<FILE.EXT>
var a = 123;
var b;
b = 223;
var c = "hello world";
print "hello world";
print 3 * 4;
var name = "John"; // username
print name;
(5 + 6) * 10 - 12 / 3;
var a = 5;
print a * 5;
print "John" + " " + "Doe";
// 25
// John Doe
var a = 3;
if (a < 4)
print 111;
else
print 222;
// 111
print "hi" or 2; // "hi".
print nil or "yes"; // "yes".
var a = 3;
if (a > 2 and a == 3)
print("if statement");
else
print("else statement");
// if statement
var a = 0;
var temp;
for (var b = 1; a < 10000; b = temp + b) {
print a;
temp = a;
a = b;
}
var a = 1;
while (a < 10) {
print a;
a = a + 1;
}
fun sayHi(first, last) {
return "Hi, " + first + " " + last + "!";
}
print sayHi("Dear", "Reader"); // Hi, Dear Reader!
class Breakfast {
cook(something) {
print "cook " + something + ".";
}
}
Breakfast().cook("egg");
class Doughnut {
cook() {
print "Fry until golden brown.";
}
}
class BostonCream < Doughnut {
cook() {
super.cook();
print "Pipe full of custard and coat with chocolate.";
}
}
BostonCream().cook();