49 lines
1.1 KiB
Plaintext
49 lines
1.1 KiB
Plaintext
# File showing examples of Kabel syntax
|
|
# This should lex and parse OK, but it will not run.
|
|
|
|
# Function/procedure definition
|
|
# General structure:
|
|
# to <identifier> [with <argument list, comma separated>]:
|
|
# An argument list may accept 'and' after
|
|
|
|
|
|
|
|
to doSomething using r, x, and p:
|
|
if r == 6: # Contemplate simply using =
|
|
return 7;
|
|
else:
|
|
|
|
|
|
# Hoisting and declaration is implicit
|
|
_7 = 6;
|
|
n = 5;
|
|
_kt_hr = "string literal!";
|
|
tab = {n: 7, mod: p};
|
|
|
|
# Here's every type.
|
|
my_str = "string lit"; # Str
|
|
my_num = 128; # Num
|
|
my_list = [1, 2, 3, 4, "I", "Declare", "a Thumb", "War"]; # List
|
|
my_table = {
|
|
x = 4,
|
|
q = 6,
|
|
t = "mystr",
|
|
n_ar = [5, 6, 7, 8, "Try to", "Keep your", "Thumb", "Straight"],
|
|
k_pr = tab, # references abstracted away. just bodge it behind the scenes
|
|
# Trailing comma optional
|
|
}
|
|
|
|
# OOP-ish-ly:
|
|
# g = 7 + t.x.find(n, k, g+5, p) + 6;
|
|
g = (t's x: find using n, k, g + 5, p) + 6;
|
|
|
|
# OOP-ish-ly: for module in p:
|
|
foreach module in p:
|
|
# This should be valid.
|
|
n=n+(_7+1);
|
|
|
|
while k's angle > 50:
|
|
# 'decrease x by y' and 'increase x by y' are simply aliases for
|
|
# 'x = x - y' and 'x = x + y'
|
|
decrease k's angle by 5;
|