summaryrefslogtreecommitdiff
path: root/small-tests
diff options
context:
space:
mode:
Diffstat (limited to 'small-tests')
-rw-r--r--small-tests/base.tnsl5
-rw-r--r--small-tests/examp.tnsl172
-rw-r--r--small-tests/out.tnt1
-rw-r--r--small-tests/test.tnsl13
4 files changed, 191 insertions, 0 deletions
diff --git a/small-tests/base.tnsl b/small-tests/base.tnsl
new file mode 100644
index 0000000..f291cf3
--- /dev/null
+++ b/small-tests/base.tnsl
@@ -0,0 +1,5 @@
+# This
+;a.pl()
+
+# Same
+; a . pl () \ No newline at end of file
diff --git a/small-tests/examp.tnsl b/small-tests/examp.tnsl
new file mode 100644
index 0000000..0c32f3f
--- /dev/null
+++ b/small-tests/examp.tnsl
@@ -0,0 +1,172 @@
+#Comment like this
+
+/##
+ Or like this (blocks begin with /<symbol> and end with <symbol>/)
+ Block Comment
+#/
+/##
+ Doc Comment
+#/
+
+# Preprocessor directives are like this
+# Import from library using '
+:import 'what/what.tnsl' a
+# Import from local file using "
+:import "what/what.tnsl"
+
+# Code lines start with ;
+
+# pass a variable
+;int s = 3
+
+;byte bitbyte = .2
+
+
+# generic scope block
+
+# d does not exist
+
+/; # Scope
+
+ ;int d = 1
+ # d exists
+ ;s = d
+
+;/ # Scope end
+
+# d does not exist
+
+
+# Function def:
+# Any non-reserved word
+# Sig: [output1, output2] (input1, input2)
+# Main may have
+/;main ({}string str) [int] # Doesn't matter what order the sig is in
+ # Main may also omit either for void sig
+
+
+ # {} represents a tnsl style array
+ # ~ before var represents address var
+ # ~ after a address var represents the data the address points at
+
+ ;int i = 1
+ ;~int j ~= i # address of int j = address of i
+ j~ = 2 # i = 2 # data of j = 2
+
+ # /;loop represents the only loop in tnsl
+ # loop is followed by (init statements) [multi statements]
+ # where the first statement in multi is the test, and the once statements are only run once at the beginning of the loop
+ /;loop [i!==1]
+ # Do something
+ ; i = 1
+ ;/
+
+;/ # End main
+
+
+
+# The struct keyword is followed by [name] {values}
+;struct [s1] {string Name, string Message = "Default message (c-style strings)"}
+
+# Most people should declare as such:
+;struct [s1] {
+ string Name,
+ string Message = "Default message (c-style strings)"
+}
+
+# When defining a new struct, use {}
+;s1 a = {}
+# Same as
+;s1 a{}
+;a.Name = "Kyle Gunger"
+
+;~s1 b = ~a
+;b~.Name # "Kyle Gunger"
+
+# Quick initialization
+;s1 c = {"", ""}
+# These come in the same order that they do in the struct, so {Name, Message} in this case.
+
+# You can also specify
+;s1 d{
+ Message = "Message",
+ Name = "Name"
+}
+
+
+
+
+# This is how arrays are defined as well.
+;{}int a = {
+ 1, 2, 3, 4
+}
+
+# Same as
+;{}int a{
+ 1, 2, 3, 4
+}
+
+
+# You may also define an initializer like such:
+/;s1 [s1]
+ # Initializer must be named same as struct, and must return one of the structs as its only output
+ return new s1{"Kyle", "TNSL Creator"}
+;/
+
+/; if (i == 3)
+
+# Quick define new block
+;;else
+
+;/
+
+/; switch (i)
+ # You can do stuff here as well
+ ;int t = 0
+
+ # Case block
+ /;case 1
+ ;i = 0
+ ;t = 2
+ ;break
+
+ ;;case 2
+ ;i = 1
+ ;t = 2
+ ;break
+
+ ;;default
+ ;i = 3
+ ;break
+ ;/
+
+ # You can do stuff here too
+ /; if [t == 2]
+ ;i = t - i
+
+ ;;else if [t==3]
+ ;i = t+i
+ ;/
+
+ # Second case block
+ /;case 1
+ ;i = 4
+ ;/
+;/
+
+
+# Dumb generic type struct
+; struct [gen] (type T) {
+ T i
+}
+
+# This seems dumb
+;gen(int) j{2}
+
+# But this seems dumber
+;{}gen(gen(int)) j{
+ {{1}},
+ {{2}},
+ {{3}}
+}
+
diff --git a/small-tests/out.tnt b/small-tests/out.tnt
new file mode 100644
index 0000000..9f77b4b
--- /dev/null
+++ b/small-tests/out.tnt
@@ -0,0 +1 @@
+{{9 test.tnsl 0 0} [{{10 block 0 0} [{{10 block 0 0} [{{11 ; 0 0} []} {{11 ; 0 0} []}]} {{10 block 0 0} [{{11 ; 0 0} []} {{11 ; 0 0} []}]} {{11 ; 0 0} []} {{11 ; 0 0} []}]} {{11 ; 0 0} []}]}
diff --git a/small-tests/test.tnsl b/small-tests/test.tnsl
new file mode 100644
index 0000000..f7c030c
--- /dev/null
+++ b/small-tests/test.tnsl
@@ -0,0 +1,13 @@
+/;
+ /;
+ ;
+ ;
+ ;;
+ ;
+ ;
+ ;/
+ ;
+ ;
+;/
+
+; thing \ No newline at end of file