chip away at everything.kab
This commit is contained in:
parent
a3e222237a
commit
e1d004d986
|
@ -1,22 +1,48 @@
|
||||||
# File showing examples of Kabel syntax
|
# File showing examples of Kabel syntax
|
||||||
|
# This should lex and parse OK, but it will not run.
|
||||||
|
|
||||||
# Function/procedure definition
|
# Function/procedure definition
|
||||||
# 'using', 'and', and the commas should be lexed out because they don't mean
|
# General structure:
|
||||||
# anything However, they should be required nonetheless for the sake of
|
# to <identifier> [with <argument list, comma separated>]:
|
||||||
# clarity and consistency.
|
# An argument list may accept 'and' after
|
||||||
# ^^ perhaps? leave in if it's useful at parser
|
|
||||||
|
|
||||||
to myFunction using r, x, and p:
|
|
||||||
|
|
||||||
|
to doSomething using r, x, and p:
|
||||||
|
if r == 6: # Contemplate simply using =
|
||||||
|
return 7;
|
||||||
|
else:
|
||||||
|
|
||||||
|
|
||||||
# Hoisting and declaration is implicit
|
# Hoisting and declaration is implicit
|
||||||
n = 5;
|
|
||||||
_7 = 6;
|
_7 = 6;
|
||||||
|
n = 5;
|
||||||
_kt_hr = "string literal!";
|
_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:
|
# OOP-ish-ly:
|
||||||
# g = 7 + t.x.find(n, k, g+5, p) + 6;
|
# g = 7 + t.x.find(n, k, g+5, p) + 6;
|
||||||
g = (t's x: find using n, k, g + 5, p) + 6;
|
g = (t's x: find using n, k, g + 5, p) + 6;
|
||||||
|
|
||||||
|
|
||||||
for module in p:
|
# 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;
|
||||||
|
|
Loading…
Reference in New Issue