From c625ed1cfe7f7ea4ab2a75a8a0a6a6772f86431c Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Fri, 30 Apr 2021 14:06:58 -0400 Subject: Destroy my own code by using goto --- examp.tnsl | 172 ------------------------------------------------------------- 1 file changed, 172 deletions(-) delete mode 100644 examp.tnsl (limited to 'examp.tnsl') diff --git a/examp.tnsl b/examp.tnsl deleted file mode 100644 index 0c32f3f..0000000 --- a/examp.tnsl +++ /dev/null @@ -1,172 +0,0 @@ -#Comment like this - -/## - Or like this (blocks begin with / and end with /) - 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}} -} - -- cgit v1.2.3