An interpretted language I'm working on with the help of my language tools. Still very much a work in progress, but most fundamental structures have been implemented:
Currently, the only literal values support are integers.
let a = 1;
let b = a;
let c = 2;
a = 5;
b = 15;
c = b - 5;
All the basic mathematic operators are supported, including parenthesis for controlling precedence. Exponents (**
) are recognized by the lexer, but not in the parser / evaluator yet. Since the only supported type is an integer, division is integer division.
let a = 1 + 2;
let b = a - 5;
let c = a * 2 + 4;
let d = a * (2 + 4);
let e = a / 5;
func add(a,b) {
return a + b;
}
add(1,1);
func outer(a, b) {
let c = 1;
func inner(a,b) {
return a + b + c;
}
return add(a, b);
}
outer(1,1);
if (a) {
print(a);
} elif (b) {
print(b);
} else {
print(c);
}
let i = 0;
while (i < 10) {
print(i)
i = i + 1;
}
for (let i = 0; i < 10; i = i + 1) {
print(i)
}
func print0_9() {
for (let i = 0; i < 10; i = i + 1) {
if (i > 5) {
break;
}
print(i);
}
for (let j = i; j < 10; j = j + 1) {
print(j);
}
}
print0_9();
func print_only_one(a,b) {
print(1);
return;
print(2);
print(3);
}
print_only_one();
print(1 + 1);
- Arrays
- More types
- First class functions
- Clone the repo
- Symlink
lara
to somewhere on your PATH - Make executable
chmod +x lara
- Execute programs like
lara test.lr
(Note this assumes python3 is default python version on your machine) - If python3 is not default, run the script explicitly
python3 lara test.lr