From e1d004d9868fed87f7e2e2ead024dfa538f964b9 Mon Sep 17 00:00:00 2001 From: TerraMaster85 Date: Fri, 19 Jan 2024 19:47:56 -0500 Subject: [PATCH] chip away at everything.kab --- examples/everything.kab | 44 ++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/examples/everything.kab b/examples/everything.kab index b4ee9a6..96fce4d 100644 --- a/examples/everything.kab +++ b/examples/everything.kab @@ -1,22 +1,48 @@ # File showing examples of Kabel syntax +# This should lex and parse OK, but it will not run. # Function/procedure definition -# 'using', 'and', and the commas should be lexed out because they don't mean -# anything However, they should be required nonetheless for the sake of -# clarity and consistency. -# ^^ perhaps? leave in if it's useful at parser +# General structure: +# to [with ]: +# An argument list may accept 'and' after -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 -n = 5; _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; - -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;