From 22e923c9b9519a309d51f6f1029bd542800dad4c Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Mon, 9 Aug 2021 07:38:09 -0400 Subject: 5, 6, much of 4 + Finish much of ch 1 + Fix spelling in copyright notices --- README.md | 2 +- libtnsl/README.md | 36 +++--- libtnsl/src/alg/alg.tnsl | 4 +- libtnsl/src/alg/math/math.tnsl | 4 +- libtnsl/src/bootstrap.tnsl | 2 +- libtnsl/src/box/box.tnsl | 4 +- libtnsl/src/box/iterator.tnsl | 4 +- libtnsl/src/box/map.tnsl | 4 +- libtnsl/src/box/string.tnsl | 4 +- libtnsl/src/box/tree.tnsl | 4 +- libtnsl/src/box/vector.tnsl | 4 +- libtnsl/src/io/block.tnsl | 4 +- libtnsl/src/io/file.tnsl | 4 +- libtnsl/src/io/io.tnsl | 4 +- libtnsl/src/io/std.tnsl | 4 +- libtnsl/src/io/stream.tnsl | 4 +- libtnsl/src/libtnsl.tnsl | 2 +- libtnsl/src/reflect/dynamic.tnsl | 4 +- libtnsl/src/reflect/method.tnsl | 4 +- libtnsl/src/reflect/reflect.tnsl | 4 +- libtnsl/src/reflect/resolver.tnsl | 4 +- libtnsl/src/reflect/static.tnsl | 4 +- libtnsl/src/reflect/type.tnsl | 4 +- libtnsl/src/time/alg.tnsl | 4 +- libtnsl/src/time/conv.tnsl | 4 +- libtnsl/src/time/parse.tnsl | 4 +- libtnsl/src/time/time.tnsl | 2 +- spec/1 - language.md | 213 ++++++++++++++++++++++++++++++++- spec/2 - features.md | 2 +- spec/3 - abi.md | 2 +- spec/4 - fip.md | 2 +- spec/Appendices.md | 36 +++++- spec/README.md | 2 +- tnslc/README.md | 2 +- tnslc/src/ast/ast.tnsl | 2 +- tnslc/src/ast/node.tnsl | 2 +- tnslc/src/compile/arch/arch.tnsl | 2 +- tnslc/src/compile/arch/common.tnsl | 2 +- tnslc/src/compile/arch/isa_arm.tnsl | 2 +- tnslc/src/compile/arch/isa_risc_v.tnsl | 2 +- tnslc/src/compile/arch/isa_x86.tnsl | 2 +- tnslc/src/compile/compile.tnsl | 2 +- tnslc/src/flags/flags.tnsl | 2 +- tnslc/src/parse/parse.tnsl | 2 +- tnslc/src/parse/token.tnsl | 2 +- tnslc/src/tnslc.tnsl | 2 +- 46 files changed, 326 insertions(+), 89 deletions(-) diff --git a/README.md b/README.md index 564cb52..b349dea 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ The standard TNSL compiler suite. Contains a universal front end for producing This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/libtnsl/README.md b/libtnsl/README.md index b8c8f1a..7fb8922 100644 --- a/libtnsl/README.md +++ b/libtnsl/README.md @@ -30,21 +30,21 @@ libtnsl provides the tnsl base module and the following sub-modules to address e Each sub-module should have its own README to address features --- - Copyright 2021 Kyle Gunger - - Dual licenced under the CDDL 1.0 and BSD 3-Clause licences. - - This file may only be used in accordance with one of the two - licences. You should have recieved a copy of each licence with - the source code. In the event that you did not recieve a copy - of the licences, they may be found at the following URLs: - - CDDL 1.0: - https://opensource.org/licenses/CDDL-1.0 - - BSD 3-Clause: - https://opensource.org/licenses/BSD-3-Clause - - THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO - WARRENTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE - EXPRESS OR IMPLIED + Copyright 2021 Kyle Gunger + + Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. + + This file may only be used in accordance with one of the two + licenses. You should have received a copy of each license with + the source code. In the event that you did not recieve a copy + of the licenses, they may be found at the following URLs: + + CDDL 1.0: + https://opensource.org/licenses/CDDL-1.0 + + BSD 3-Clause: + https://opensource.org/licenses/BSD-3-Clause + + THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO + WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE + EXPRESS OR IMPLIED diff --git a/libtnsl/src/alg/alg.tnsl b/libtnsl/src/alg/alg.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/alg/alg.tnsl +++ b/libtnsl/src/alg/alg.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/alg/math/math.tnsl b/libtnsl/src/alg/math/math.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/alg/math/math.tnsl +++ b/libtnsl/src/alg/math/math.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/bootstrap.tnsl b/libtnsl/src/bootstrap.tnsl index 5f407fa..aa36956 100644 --- a/libtnsl/src/bootstrap.tnsl +++ b/libtnsl/src/bootstrap.tnsl @@ -4,7 +4,7 @@ Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/box/box.tnsl b/libtnsl/src/box/box.tnsl index 6048d85..2f270b6 100644 --- a/libtnsl/src/box/box.tnsl +++ b/libtnsl/src/box/box.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/box/iterator.tnsl b/libtnsl/src/box/iterator.tnsl index 9c59bd2..13b9ef9 100644 --- a/libtnsl/src/box/iterator.tnsl +++ b/libtnsl/src/box/iterator.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/box/map.tnsl b/libtnsl/src/box/map.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/box/map.tnsl +++ b/libtnsl/src/box/map.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/box/string.tnsl b/libtnsl/src/box/string.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/box/string.tnsl +++ b/libtnsl/src/box/string.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/box/tree.tnsl b/libtnsl/src/box/tree.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/box/tree.tnsl +++ b/libtnsl/src/box/tree.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/box/vector.tnsl b/libtnsl/src/box/vector.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/box/vector.tnsl +++ b/libtnsl/src/box/vector.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/io/block.tnsl b/libtnsl/src/io/block.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/io/block.tnsl +++ b/libtnsl/src/io/block.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/io/file.tnsl b/libtnsl/src/io/file.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/io/file.tnsl +++ b/libtnsl/src/io/file.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/io/io.tnsl b/libtnsl/src/io/io.tnsl index 5c6d217..68e2fc0 100644 --- a/libtnsl/src/io/io.tnsl +++ b/libtnsl/src/io/io.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/io/std.tnsl b/libtnsl/src/io/std.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/io/std.tnsl +++ b/libtnsl/src/io/std.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/io/stream.tnsl b/libtnsl/src/io/stream.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/io/stream.tnsl +++ b/libtnsl/src/io/stream.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/libtnsl.tnsl b/libtnsl/src/libtnsl.tnsl index 98a2e7c..266c1fa 100644 --- a/libtnsl/src/libtnsl.tnsl +++ b/libtnsl/src/libtnsl.tnsl @@ -4,7 +4,7 @@ Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/reflect/dynamic.tnsl b/libtnsl/src/reflect/dynamic.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/reflect/dynamic.tnsl +++ b/libtnsl/src/reflect/dynamic.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/reflect/method.tnsl b/libtnsl/src/reflect/method.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/reflect/method.tnsl +++ b/libtnsl/src/reflect/method.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/reflect/reflect.tnsl b/libtnsl/src/reflect/reflect.tnsl index 3308eda..3c1d583 100644 --- a/libtnsl/src/reflect/reflect.tnsl +++ b/libtnsl/src/reflect/reflect.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/reflect/resolver.tnsl b/libtnsl/src/reflect/resolver.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/reflect/resolver.tnsl +++ b/libtnsl/src/reflect/resolver.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/reflect/static.tnsl b/libtnsl/src/reflect/static.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/reflect/static.tnsl +++ b/libtnsl/src/reflect/static.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/reflect/type.tnsl b/libtnsl/src/reflect/type.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/reflect/type.tnsl +++ b/libtnsl/src/reflect/type.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/time/alg.tnsl b/libtnsl/src/time/alg.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/time/alg.tnsl +++ b/libtnsl/src/time/alg.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/time/conv.tnsl b/libtnsl/src/time/conv.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/time/conv.tnsl +++ b/libtnsl/src/time/conv.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/time/parse.tnsl b/libtnsl/src/time/parse.tnsl index 8029197..d346464 100644 --- a/libtnsl/src/time/parse.tnsl +++ b/libtnsl/src/time/parse.tnsl @@ -1,10 +1,10 @@ -/# +/## Copyright 2021 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/libtnsl/src/time/time.tnsl b/libtnsl/src/time/time.tnsl index b993f45..dc24369 100644 --- a/libtnsl/src/time/time.tnsl +++ b/libtnsl/src/time/time.tnsl @@ -4,7 +4,7 @@ Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two - licenses. You should have recieved a copy of each license with + licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: diff --git a/spec/1 - language.md b/spec/1 - language.md index 73ebfb4..345eb1a 100644 --- a/spec/1 - language.md +++ b/spec/1 - language.md @@ -111,7 +111,7 @@ TNSL functions may have inputs (enclosed with `()`) and/or outputs (enclosed wit TNSL functions may have their call stack modified by the `raw` and/or `inline` keywords. If the `inline` keyword is placed around the function declaration, the function will still be exported (if it is being exported), but any time it is used in the project's code, it will be optimized as if in-line. -The use of the `raw` keyword has several effects: the function will have no generated assembly preamble, the function will not be optimized, and the function will allow `asm` statements. Any function may be labeled `raw`, even `main` and anonymous functions. +The use of the `raw` keyword has several effects: the function will have no generated assembly preamble, the function will allow `raw return` statements, the function will not be optimized, and the function will allow `asm` statements. Any function may be labeled `raw`, even `main` and anonymous functions. Examples: @@ -206,37 +206,244 @@ Examples: ## Section 4 - Types -### Built-in Types +An exhaustive list of built-in types can be found in Appendix B. ### The `void` Type +The `void` type represents one of two things: an unknown data type, or a function. When the void type is paired with input and output parameters `void( )[ ]` it represents a function. When it is not paired with these things it represents an unknown data type. + +Pure `void` types can not be created. Function types are *always* references to the function, more like pointers than data holders. Otherwise, void types must be created as pure pointers. In this case, they are in a sense "un-typed" pointers which do not know the length of the object they are pointing at, only the address. + +Examples: + + # simple function + /; func_1 + ;/ + + # void example func + /; func_2 + + # create a void type and assign it func_1's value + ;void()[] func_ref = func_1 + + # call func_1 using func_ref + ;func_ref() + ;/ + +More examples of pointer voids are available in the pointers section of this document. + ### Arrays +In memory, arrays store their length as a uint, then immediately follow with the contents of the array. This way, all arrays can be checked for length with the `len` operator. + +Arrays are created by prefixing a type with `{ <# of elements> }` or simply `{}` so long as the array is immediately initialized. One can similarly access an element of an array by suffixing the variable name with `{ }`. + +When initializing or assigning a new value to an entire array, use `{}` to encase a list of values. + +The length of the array can be gotten by `len ` + +Examples: + + # create an array of five integers + ;{5}int i + + # assign values to the array + ;i{0} = 0 + ;i{1} = 2 + ;i{2} = 0 + ;i{3} = 2 + ;i{4} = 1 + + # store the length of the array + ;uint array_length = len i + + # create an initialized array with length five + ;{}int j = {1, 2, 3, 4, 5} + + # loop through the array and add them. + /; loop (int k = 0; k < array_length) [k++] + + ;i{k} += j{k} + ;/ + + ### Pointers +Pointer types are created using the `~` (pointer to) operator. This operator serves as both part of the type, and as a way to get a pointer from a type. To de-reference a pointer into it's base type, use the `` ` `` (de-reference) operator. + +Passing by reference can be done by prefixing the type with the de-reference operator. This type is only available in function parameter declaration. To call a function with this type, a pointer to the desired variable must be given. + +Examples: + + # define int + ;int i + + # pointer to i + ;~int p = ~i + + # set i using p + ;`p = 1 + + # a function taking a pass by reference + /; add_two (`int i) + i += 2 + ;/ + + # calling add_two in two different ways + ;add_two(p) + ;add_two(~i) + + # i is now 5 + +### Casting Types + +Casting between types uses the standard input and output enclosing `()` and `[]` in conjunction. Place a value in the input enclosing characters and a type to output in the output enclosing characters to cast one type to another (`( )[ ]`). + +Examples: + + # define an int and a float + ;int i = 10 + ;float f = 11.5 + + # define a void pointer and set it to reference i + ;~void v = ~i + + # define an int pointer and cast the void pointer to initialize it + ;~int p = (v)[~int] + + # cast the float to an int and set the value of i + ;`p = (f)[int] + ### Defining Types + + ### Interfaces ### Type Levels ## Section 5 - Operators +An exhaustive list of operators can be found in Appendix A + ### Operator Precedence +Operator precedence is as follows (from greatest to least): + + Pointer operators (p0): + + ~ - address of + + ` - de-reference + + + Access operator (p1): + + . - get/access + + + Increment/de-increment (p2): + + ++ - increment + + -- - de-increment + + + Multiplication/division (p3): + + * - multiply + + / - divide + + + Addition and subtraction (p4): + + + - addition + + - - subtraction + + + Modulus (p5): + + % - modulus + + + Bitwise operators (p6): + + & - and + + | - nor + + ^ - xor + + << - shift left + + >> - shift right + + !& - nand + + !| - nor + + !^ - xand + + ! - not (bitwise or boolean) + + + Boolean operators (p7): + + && - boolean and + + || - boolean or + + == - boolean eq + + > - greater than + + < - less than + + !&& - boolean nand + + !|| - boolean nor + + !== - boolean neq + + !> - boolean not greater than + + !< - boolean not less than + + >== - boolean greater than or equal to + + <== - boolean less than or equal to + ## Section 6 - `raw` and `asm` ### The `raw` Keyword +The `raw` keyword can be used in three different scenarios, and each has a different meaning. + +1. The `raw` keyword can be used in function definitions. These effects were discussed in section 2.2. + +2. The `raw` keyword may be used in conjunction with the `return` keyword, but only inside of raw functions. This causes an instant return regardless of stack or register state. It is recommended to clean up function and provide return types before using this. + +3. The `raw` keyword may be used with the `struct` keyword to create a raw struct. Raw structs can not contain user defined types or generics. Raw types encode no type information and may not be extended. Raw structs, unlike static or dynamic structs, are only as wide their members. + - Static and dynamic structs contain a small amount of information pertaining to their actual type and generics so may be larger than only their members. + - In addition, since static and dynamic structs may be extended, they may not be the initially defined type and may be larger, further complicating matters. + ### The `asm` Keyword +The `asm` keyword may be used in `raw` functions or blocks to produce raw asm code for the assembler. Any valid assembly code may be used, and certain extensions are available such as variable pointer references. + +Syntax: + + ;asm "" + ## Credits Copyright 2021 Kyle Gunger This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/spec/2 - features.md b/spec/2 - features.md index 4687f29..5d8d952 100644 --- a/spec/2 - features.md +++ b/spec/2 - features.md @@ -6,7 +6,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/spec/3 - abi.md b/spec/3 - abi.md index a83600a..5ea5c15 100644 --- a/spec/3 - abi.md +++ b/spec/3 - abi.md @@ -6,7 +6,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/spec/4 - fip.md b/spec/4 - fip.md index fc2e86b..db70987 100644 --- a/spec/4 - fip.md +++ b/spec/4 - fip.md @@ -14,7 +14,7 @@ To use higher level features in TNSL, an implimentation of libtnsl must be in pl This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/spec/Appendices.md b/spec/Appendices.md index 87f5f15..5049ad9 100644 --- a/spec/Appendices.md +++ b/spec/Appendices.md @@ -43,7 +43,7 @@ | - bitwise or - ^ - bitwise not + ^ - bitwise xor > - greater than @@ -144,13 +144,19 @@ <== - less than or equal to + ++ - increment + + -- - de-increment + ## Appendix B - Reserved words and their uses Built-in Types: bool - boolean - char - ascii + char - ascii/extended ascii 8-bit value + + charp - unicode 8-bit character part (using either UTF-8 or UN7+1) int8 - 8-bit integer @@ -191,6 +197,10 @@ false - boolean false value + size - size (in bytes) of a variable or type + + len - size (in elements) of an array + User defined types: @@ -277,21 +287,41 @@ In TNSL there exist three different levels of complexity structs can take on. I Raw structs are the simplist structs with the fastest lookup times. Raw structs can not be extended, though they may themselves extend interfaces (but not other structs). All members of raw structs must be built-in types, other raw structs, or pointers. Raw structs are always fixed-width and all methods are linked directly, thus there is no lookup time for calling one (they are essentially as fast as calling a regular function as long as you are referencing the struct directly and not by one of it's extended interfaces). +NOTE: Raw structs do not allow generics + ### Static structs Static structs are similar to raw structs except they may be extended. This creates a small delay for calling functions on static structs as there is a lookup time to find the method the call is actually referencing (as it may be calling the function on an extension of the type). All members of static structs must be built-in types, other raw structs, or pointers. Static structs can only extend static structs. +NOTE: Static structs *can* allow generics so long as they do not store said generics and only store pointers to them. + ### Dynamic structs Variable width structs (dynamic structs) can accomodate generics and variable width members. Dynamic structs may extend static structs or other dynamic structs. By extending a dynamic struct, even if one makes no use of the dynamic members, their struct is automatically a dynamic struct. These structs offer the least control over memory, and slightly slower call times, but offer the most flexability to the programmer. + +## Appendix D - UN7+1 + +Unicode Non-standard 7+1 bit (UN7+1) encoding is a non-standard way to represent any unicode character using a series of 8-bit values. The first bit in the 8-bit sequence represents if the next 8-bit sequence is included in the character code, the other seven bits are part of the character code. + +Examples: + + ASCII characters: + 0xxxxxxx (U+00 - U+7F) + + Unicode characters: + 1xxxxxxx 0xxxxxxx (U+0080 - U+3FFF) + 1xxxxxxx 1xxxxxxx 0xxxxxxx (U+004000 - U+1FFFFF) + 1xxxxxxx 1xxxxxxx 1xxxxxxx 0xxxxxxx (U+0200000 - U+FFFFFFF) + etc. + ## Credits Copyright 2021 Kyle Gunger This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/spec/README.md b/spec/README.md index 83a6375..1dc82aa 100644 --- a/spec/README.md +++ b/spec/README.md @@ -50,7 +50,7 @@ Right now, TNSL isn't a language. But it *could* be. And, really, I think it's This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/tnslc/README.md b/tnslc/README.md index b242a4c..d09edc9 100644 --- a/tnslc/README.md +++ b/tnslc/README.md @@ -8,7 +8,7 @@ The reference compiler for the TNSL programming language. The compiler is writt This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/tnslc/src/ast/ast.tnsl b/tnslc/src/ast/ast.tnsl index 33d1f93..405a94a 100644 --- a/tnslc/src/ast/ast.tnsl +++ b/tnslc/src/ast/ast.tnsl @@ -3,7 +3,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/tnslc/src/ast/node.tnsl b/tnslc/src/ast/node.tnsl index 0e6e9d0..5eeac91 100644 --- a/tnslc/src/ast/node.tnsl +++ b/tnslc/src/ast/node.tnsl @@ -3,7 +3,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/tnslc/src/compile/arch/arch.tnsl b/tnslc/src/compile/arch/arch.tnsl index 5fc7860..bcabbfa 100644 --- a/tnslc/src/compile/arch/arch.tnsl +++ b/tnslc/src/compile/arch/arch.tnsl @@ -3,7 +3,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/tnslc/src/compile/arch/common.tnsl b/tnslc/src/compile/arch/common.tnsl index bb6edf1..cba0d9f 100644 --- a/tnslc/src/compile/arch/common.tnsl +++ b/tnslc/src/compile/arch/common.tnsl @@ -3,7 +3,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/tnslc/src/compile/arch/isa_arm.tnsl b/tnslc/src/compile/arch/isa_arm.tnsl index 61d8996..0dc3468 100644 --- a/tnslc/src/compile/arch/isa_arm.tnsl +++ b/tnslc/src/compile/arch/isa_arm.tnsl @@ -3,7 +3,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/tnslc/src/compile/arch/isa_risc_v.tnsl b/tnslc/src/compile/arch/isa_risc_v.tnsl index 61d8996..0dc3468 100644 --- a/tnslc/src/compile/arch/isa_risc_v.tnsl +++ b/tnslc/src/compile/arch/isa_risc_v.tnsl @@ -3,7 +3,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/tnslc/src/compile/arch/isa_x86.tnsl b/tnslc/src/compile/arch/isa_x86.tnsl index 61d8996..0dc3468 100644 --- a/tnslc/src/compile/arch/isa_x86.tnsl +++ b/tnslc/src/compile/arch/isa_x86.tnsl @@ -3,7 +3,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/tnslc/src/compile/compile.tnsl b/tnslc/src/compile/compile.tnsl index 5a58029..b3f4c5d 100644 --- a/tnslc/src/compile/compile.tnsl +++ b/tnslc/src/compile/compile.tnsl @@ -3,7 +3,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/tnslc/src/flags/flags.tnsl b/tnslc/src/flags/flags.tnsl index 4feff0f..bc5d43f 100644 --- a/tnslc/src/flags/flags.tnsl +++ b/tnslc/src/flags/flags.tnsl @@ -3,7 +3,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/tnslc/src/parse/parse.tnsl b/tnslc/src/parse/parse.tnsl index 3ca8d40..dc6b9a2 100644 --- a/tnslc/src/parse/parse.tnsl +++ b/tnslc/src/parse/parse.tnsl @@ -3,7 +3,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/tnslc/src/parse/token.tnsl b/tnslc/src/parse/token.tnsl index f845daf..92b2ca4 100644 --- a/tnslc/src/parse/token.tnsl +++ b/tnslc/src/parse/token.tnsl @@ -3,7 +3,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: diff --git a/tnslc/src/tnslc.tnsl b/tnslc/src/tnslc.tnsl index 627541f..617e9e7 100644 --- a/tnslc/src/tnslc.tnsl +++ b/tnslc/src/tnslc.tnsl @@ -3,7 +3,7 @@ This file is licensed under the CDDL 1.0 (the License) and may only be used in accordance with the License. - You should have recieved a copy of the License with this + You should have received a copy of the License with this software/source code. If you did not, a copy can be found at the following URL: -- cgit v1.2.3