summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2022-12-05 11:21:47 -0500
committerKyle Gunger <kgunger12@gmail.com>2022-12-05 11:21:47 -0500
commit569783c5fb37a017934c2071e0c4e5036ec424a3 (patch)
tree71171adb615b5ee90e166597b005423ac29b53f0
parent42832cdbd6f04f6ce44c130f54e4a4aa89f2f03d (diff)
Play around with syntax a bit
-rw-r--r--tnslc/syntax-playground.tnsl69
1 files changed, 69 insertions, 0 deletions
diff --git a/tnslc/syntax-playground.tnsl b/tnslc/syntax-playground.tnsl
new file mode 100644
index 0000000..12aa895
--- /dev/null
+++ b/tnslc/syntax-playground.tnsl
@@ -0,0 +1,69 @@
+# This file is for playing with syntax and seeing what works and what does not.
+
+
+## TEST 1 - newlines seperate statements, not ;
+## newlines can be escaped with \
+
+/; test1
+ int main = 0
+
+ /; loop (int i = 0, i < 5) [i++]
+ tnsl.io.println("Hi!")
+ ;/
+
+ String str = {}
+
+ /; loop (char j = ' ', j != 'k') \
+ [j++]
+
+ str.append(j)
+ ;/
+
+ tnsl.io.println(str)
+
+ return main
+;/
+
+## END TEST 1
+
+## TEST 2 - get '.' augment auto de-references pointers
+
+struct a {
+ int i, j
+}
+
+struct b {
+ String str,
+ ~a ints
+}
+
+/; ptr_test1
+ b str_b = {"Hello", {0, 1}}
+
+ ~b ptr_b = ~str_b
+
+ tnsl.io.println(ptr_b.str)
+ # vs
+ tnsl.io.println(ptr_b`.str)
+ # both work
+
+ ptr_b.ints.i = 12
+ ptr_b.ints.j = ptr_b.ints.i / 4
+ # vs
+ ptr_b`.ints`.i = 12
+ ptr_b`.ints`.j = ptr_b`.ints`.i / 4
+ # Again, the second one is more descriptive, but is it better?
+
+ ptr_call(ptr_b)
+ ref_call(ptr_b)
+;/
+
+/; ptr_call (~b ptr)
+ ptr.ints.i = 8
+;/
+
+/; ref_call (b` ref)
+ ref.ints.j = 9
+;/
+
+## END TEST 2 \ No newline at end of file