From 37fd69c79922daa00ac3617b5cc41cd6f5171e1a Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Mon, 9 Aug 2021 03:43:19 -0400 Subject: Finish appendix, ch.1 through s3 --- libtnsl/README.md | 2 +- spec/1 - language.md | 100 +++++++++++++++++++++++++++++++++++++++++++++--- spec/4 - fip.md | 8 +++- spec/Appendices.md | 22 +++++++---- tnslc/src/ast/ast.tnsl | 23 +++++------ tnslc/src/ast/node.tnsl | 23 +++++------ tnslc/src/tnslc.tnsl | 23 +++++------ 7 files changed, 148 insertions(+), 53 deletions(-) diff --git a/libtnsl/README.md b/libtnsl/README.md index 72ec72e..b8c8f1a 100644 --- a/libtnsl/README.md +++ b/libtnsl/README.md @@ -16,7 +16,7 @@ More information on these features can be found in the specification under libts ## Provided Sub-modules libtnsl provides the tnsl base module and the following sub-modules to address each feature: -* algorithm +* alg * Algorithms. Also contains the math sub-module for basic math operations. * box * Data containers (vector, map, etc.) diff --git a/spec/1 - language.md b/spec/1 - language.md index ad8b530..6b3c36a 100644 --- a/spec/1 - language.md +++ b/spec/1 - language.md @@ -89,6 +89,13 @@ Modules are to TNSL what namespaces are to c++, a way to contain a group of rela ;/ # Can access all from my_module, and my_hidden_module +*File aa.tnsl (project a)* + + /; my_function_a + # Can access all from my_module, and my_hidden_module + ;/ + # Can access all from my_module, and my_hidden_module + *File b.tnsl (project b)* /; my_function @@ -98,21 +105,104 @@ Modules are to TNSL what namespaces are to c++, a way to contain a group of rela ### Functions -TNSL functions are +TNSL functions are code blocks whose definition contains none of the following: control flow keywords, the module keyword, the method keyword. TNSL functions are called methods if they are contained within a method block. TNSL methods may only be called with relation to the user defined type they are linked to. If a TNSL function has no user defined name, it is anonymous. Anonymous funtions can be stored as void type variables or called immediately. If an anonymous function is not stored, it is interperated as inline and called immediately (this is known as a scope block). + +TNSL functions may have inputs (enclosed with `()`) and/or outputs (enclosed with `[]`). Inputs must be named; naming outputs is optional. + +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. + +Examples: + + # simple function with no inputs or outputs named "my_function" + /; my_function + + ;/ + + # function with inputs and outputs + /; my_second_function ( input1, input2 ) [ , , ... , ] + + ;/ + + # funtion calling an anonymous function + /; my_third_function + # an anonymous function (scope block) + /; + + ;/ + ;/ ### Control Flow Blocks -### Anonymous Blocks +Control flow blocks are code blocks whose definitions contain the keywords if, else, loop, match, case, or default. + +For if, else, loop, and match any inputs and/or outputs are a semicolon seperated list of statements. For case or default, only inputs are accepted in the form of a single value. Any variables defined in these inputs or outputs are scoped to the block only. Control flow blocks may not actually output any values; instead, any statements in the output are evaluated when the block ends, weather it loops or not. + +Examples: + + # simple if block + /; if ( ) + + ;/ + + # if block with else and else if + /; if ( ; ; ... ; ) + + ;; else if ( ) + + ;; else + + ;/ + + # loop block + /; loop ( ; ... ; ) + [ ] + + + ;/ + + # match block + /; match ( ; ... ; ) + + /; case + + ;; case + + # Continue here would fall through to default + ;; default + + ;/ + ;/ ## Section 3 - Statements ### TNSL Statement Notation +There are three types of tnsl statements: code, pre-processor, and comment. Code statements begin with `;` and end at the next statement. Pre-processor statements begin with `:` and end at the next statement. Comment statements (line comments) begin with `#` and end at the next new line. After a line comment ends, the previous statement resumes. + ### Variable Declaration -### Assignment +Decalring a variable is done by referencing a type and then giving a list of names for the new variables. Optionally, a list of values may be given to initialize the new variables. + +Variables may be augmented by the following keywords: `const`, `volatile`, and/or `static`. + +Declaring a variable as `const` means that it is a constant and must be imediately initialized. A constand may not be re-assigned a value. + +Declaring a variable as `volatile` means that the compiler will not attempt to optimize operations performed on it. + +Declaring a variable `static` means that the value will be kept between function calls. Static variables may create race conditions when paired with threads. + +Examples: -### Special Statements + # list with initialization + ;int a, b = 0, 1 + + # single without initialization + ;int c + + # list with partial initialization + ;int d, e = 0 # d is defined, but e is not ## Section 4 - Types @@ -140,7 +230,7 @@ TNSL functions are ### The `asm` Keyword -### Credits +## Credits Copyright 2021 Kyle Gunger diff --git a/spec/4 - fip.md b/spec/4 - fip.md index c1e9954..cc94285 100644 --- a/spec/4 - fip.md +++ b/spec/4 - fip.md @@ -1,4 +1,10 @@ -# Features in Place +# Features in Position + +## Section 1 - Bare Metal + +## Section 2 - libtnsl and Types + +## Section 3 - Cross calling C ### Credits diff --git a/spec/Appendices.md b/spec/Appendices.md index 02757f4..71a9320 100644 --- a/spec/Appendices.md +++ b/spec/Appendices.md @@ -160,22 +160,30 @@ int64 - 64-bit integer - uint8 - 8-bit integer + int - the default-width integer - uint16 - 16-bit integer + uint8 - 8-bit unsigned integer - uint32 - 32-bit integer + uint16 - 16-bit unsigned integer - uint64 - 64-bit integer + uint32 - 32-bit unsigned integer + + uint64 - 64-bit unsigned integer + + uint - the default-width unsigned integer float32 - floating point number (32-bit) float64 - floating point number (64-bit) + float - the default-width floating point number + void - void type type - meta type + vect* - libtnsl tnsl.vector.vector type + Values: @@ -194,7 +202,7 @@ extends* - extends a struct or interface - is* - checks if the variable's type is or extends another type + is* - checks if the variable's type is or extends another type (tnsl.reflect._is) method - creates a block of type-associated functions @@ -255,9 +263,9 @@ Memory control: - alloc* (and related) - allocate (or reallocate) memory from somewhere + alloc* (and related) - allocate (or reallocate) memory from somewhere (tnsl.alg._alloc) - delete* - free allocated memory + delete* - free allocated memory (tnsl.alg._delete) \* keyword requires a libtnsl implimentation diff --git a/tnslc/src/ast/ast.tnsl b/tnslc/src/ast/ast.tnsl index e086f0b..34e4f85 100644 --- a/tnslc/src/ast/ast.tnsl +++ b/tnslc/src/ast/ast.tnsl @@ -1,20 +1,17 @@ /## - Copyright 2020-2021 Kyle Gunger + Copyright 2021 Kyle Gunger - Licensed under the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE - (CDDL) Version 1.0 (the "License"). You may not use this file - except in compliance with the License. You may obtain a copy of - the License at + This file is licenced under the CDDL 1.0 (the Licence) + and may only be used in accordance with the Licence. + You should have recieved a copy of the Licence with this + software/source code. If you did not, a copy can be found + at the following URL: - https://opensource.org/licenses/CDDL-1.0 + https://opensource.org/licenses/CDDL-1.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied. - - See the License for the specific language governing permissions - and limitations under the License. + THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO + WARRENTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE + EXPRESS OR IMPLIED #/ /; export module ast diff --git a/tnslc/src/ast/node.tnsl b/tnslc/src/ast/node.tnsl index 26d192c..cddfe5d 100644 --- a/tnslc/src/ast/node.tnsl +++ b/tnslc/src/ast/node.tnsl @@ -1,20 +1,17 @@ /## - Copyright 2020-2021 Kyle Gunger + Copyright 2021 Kyle Gunger - Licensed under the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE - (CDDL) Version 1.0 (the "License"). You may not use this file - except in compliance with the License. You may obtain a copy of - the License at + This file is licenced under the CDDL 1.0 (the Licence) + and may only be used in accordance with the Licence. + You should have recieved a copy of the Licence with this + software/source code. If you did not, a copy can be found + at the following URL: - https://opensource.org/licenses/CDDL-1.0 + https://opensource.org/licenses/CDDL-1.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied. - - See the License for the specific language governing permissions - and limitations under the License. + THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO + WARRENTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE + EXPRESS OR IMPLIED #/ # AST node (non-block) diff --git a/tnslc/src/tnslc.tnsl b/tnslc/src/tnslc.tnsl index 9f3d53a..ea4f2ce 100644 --- a/tnslc/src/tnslc.tnsl +++ b/tnslc/src/tnslc.tnsl @@ -1,20 +1,17 @@ /## - Copyright 2020-2021 Kyle Gunger + Copyright 2021 Kyle Gunger - Licensed under the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE - (CDDL) Version 1.0 (the "License"). You may not use this file - except in compliance with the License. You may obtain a copy of - the License at + This file is licenced under the CDDL 1.0 (the Licence) + and may only be used in accordance with the Licence. + You should have recieved a copy of the Licence with this + software/source code. If you did not, a copy can be found + at the following URL: - https://opensource.org/licenses/CDDL-1.0 + https://opensource.org/licenses/CDDL-1.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied. - - See the License for the specific language governing permissions - and limitations under the License. + THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO + WARRENTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE + EXPRESS OR IMPLIED #/ /; export module tnslc -- cgit v1.2.3