Skip to content

kore-signet/lax

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lax - A Lox interpreter

Examples

// Operations
print(1 + 2);
print(2 - 1);
print(2 * 2);
print(2 / 2);

// Comparison
print(2 == 2);
print(2 != 1);
print(2 > 1);
print(1 < 2);
print(2 >= 2);
print(2 =< 2);

// Strings
print("Hiya!");
print("Hello, " + "world!");

// Booleans
print(true or false);
print(true and false);

// Null values
nil

// Variables
var a = 0;
print(a);
a = a + 1;
print(a);

// Conditionals
if (2 > 1) {
  print("The universe still works!");
} else {
  print("oh what")
}
// Looping
var i = 0;
while (i < 100) {
  print(i);
  i = i + 1;
}

for(var i = 0; i < 100; i = i + 1;) {
  print(i);
}

// Functions
fun plus_one(i) {
  return i + 1;
}

print(plus_one(1));

// Note: Functions are like variables, witch means you can pass them to other functions. You cant do this though: function(fun (i) { return i + 1; })

About

a lox interpreter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages