From 5eeec21759dc49252ebbcdb5e0d9336f68d0a51e Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Tue, 23 Nov 2021 13:05:49 -0500 Subject: Some changes, plus a logo. --- README.md | 6 +- libtnsl/src/algo/algo.tnsl | 3 + libtnsl/src/algo/alloc.tnsl | 20 +++++ libtnsl/src/algo/dealloc.tnsl | 20 +++++ libtnsl/src/asm/asm.tnsl | 29 +++++++ libtnsl/src/bootstrap.tnsl | 38 --------- libtnsl/src/libtnsl.tnsl | 2 + libtnsl/src/reflect/dispatch.tnsl | 20 +++++ libtnsl/src/reflect/dynamic.tnsl | 20 ----- libtnsl/src/reflect/lib.tnsl | 26 ------- libtnsl/src/reflect/method.tnsl | 20 ----- libtnsl/src/reflect/reflect.tnsl | 6 ++ libtnsl/src/reflect/static.tnsl | 20 ----- libtnsl/src/reflect/type.tnsl | 74 ++++++------------ libtnsl/src/reflect/virtual.tnsl | 144 +++++++++++++++++++++++++++++++++++ logo/tnsl-logo.png | Bin 0 -> 15175 bytes logo/tnsl-logo.svg | 47 ++++++++++++ spec/4 - fip.md | 14 ++-- spec/Appendices.md | 2 + tnslc/src/compile/arch/arch.tnsl | 8 +- tnslc/src/compile/compile.tnsl | 9 +-- tnslc/src/compile/format/format.tnsl | 20 +++++ tnslc/src/parse/token.tnsl | 18 ++--- tnslc/src/tnslc.tnsl | 35 ++++----- 24 files changed, 382 insertions(+), 219 deletions(-) create mode 100644 libtnsl/src/algo/alloc.tnsl create mode 100644 libtnsl/src/algo/dealloc.tnsl create mode 100644 libtnsl/src/asm/asm.tnsl delete mode 100644 libtnsl/src/bootstrap.tnsl create mode 100644 libtnsl/src/reflect/dispatch.tnsl delete mode 100644 libtnsl/src/reflect/dynamic.tnsl delete mode 100644 libtnsl/src/reflect/lib.tnsl delete mode 100644 libtnsl/src/reflect/method.tnsl delete mode 100644 libtnsl/src/reflect/static.tnsl create mode 100644 libtnsl/src/reflect/virtual.tnsl create mode 100644 logo/tnsl-logo.png create mode 100644 logo/tnsl-logo.svg diff --git a/README.md b/README.md index b349dea..bf6b363 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,11 @@ The standard TNSL compiler suite. Contains a universal front end for producing - arm64 - risc-v -### Status +## notice + +Until the go based interpereter is done, some code may not be correct TNSL code to account for inconsistancies in the bootstrap interpereter. However, the code shouldn't be too far from normal TNSL, the only real difference should be import statements, which will be fixed after the compiler can compile itself. + +## Status Specification: incomplete libtnsl: incomplete diff --git a/libtnsl/src/algo/algo.tnsl b/libtnsl/src/algo/algo.tnsl index 7ddd677..7df9198 100644 --- a/libtnsl/src/algo/algo.tnsl +++ b/libtnsl/src/algo/algo.tnsl @@ -21,6 +21,9 @@ /; export module algo /: include + "alloc.tnsl" + "dealloc.tnsl" + "math" :/ ;/ \ No newline at end of file diff --git a/libtnsl/src/algo/alloc.tnsl b/libtnsl/src/algo/alloc.tnsl new file mode 100644 index 0000000..d346464 --- /dev/null +++ b/libtnsl/src/algo/alloc.tnsl @@ -0,0 +1,20 @@ +/## + 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 +#/ \ No newline at end of file diff --git a/libtnsl/src/algo/dealloc.tnsl b/libtnsl/src/algo/dealloc.tnsl new file mode 100644 index 0000000..d346464 --- /dev/null +++ b/libtnsl/src/algo/dealloc.tnsl @@ -0,0 +1,20 @@ +/## + 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 +#/ \ No newline at end of file diff --git a/libtnsl/src/asm/asm.tnsl b/libtnsl/src/asm/asm.tnsl new file mode 100644 index 0000000..d0da9a6 --- /dev/null +++ b/libtnsl/src/asm/asm.tnsl @@ -0,0 +1,29 @@ +/## + 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 +#/ + +/## tnsl.asm + + Unexported module for internal library use. Bridges + the gaps between the main language and assembly for + the selected ISA/OS combo. + +#; module asm +;/ \ No newline at end of file diff --git a/libtnsl/src/bootstrap.tnsl b/libtnsl/src/bootstrap.tnsl deleted file mode 100644 index aa36956..0000000 --- a/libtnsl/src/bootstrap.tnsl +++ /dev/null @@ -1,38 +0,0 @@ -/## - 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 -#/ - -/# - This file provides a nonstandard entry point for a bootstrap implementation of TNSL. - - The reference implementation of the TNSL compiler (written in GOLANG for now), does - not contain feature complete functionality in the form of pre-compiler directives, which the - full libts uses for compilation on different operating systems. This version is provided - so that the reference compiler can produce a functional enough libts to compile the - full tnslc compiler (written in TNSL). - - As such, this entry point must be modified manually to use windows, mac, or linux - code files, and then will provide a barebones file, stream, and error handeling library - with nothing else to act as a bootstrap for the compiler. The bootstrap compiler should - be able to compile the full libts and, in turn, the full compiler. -#/ - -/;export module ts -;/ \ No newline at end of file diff --git a/libtnsl/src/libtnsl.tnsl b/libtnsl/src/libtnsl.tnsl index 434e7a4..070bfd2 100644 --- a/libtnsl/src/libtnsl.tnsl +++ b/libtnsl/src/libtnsl.tnsl @@ -20,6 +20,8 @@ #/ /;export module tnsl + ; const ~void _null = 0x0 + /: import "algo" "box" diff --git a/libtnsl/src/reflect/dispatch.tnsl b/libtnsl/src/reflect/dispatch.tnsl new file mode 100644 index 0000000..d346464 --- /dev/null +++ b/libtnsl/src/reflect/dispatch.tnsl @@ -0,0 +1,20 @@ +/## + 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 +#/ \ No newline at end of file diff --git a/libtnsl/src/reflect/dynamic.tnsl b/libtnsl/src/reflect/dynamic.tnsl deleted file mode 100644 index d346464..0000000 --- a/libtnsl/src/reflect/dynamic.tnsl +++ /dev/null @@ -1,20 +0,0 @@ -/## - 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 -#/ \ No newline at end of file diff --git a/libtnsl/src/reflect/lib.tnsl b/libtnsl/src/reflect/lib.tnsl deleted file mode 100644 index 0688e6f..0000000 --- a/libtnsl/src/reflect/lib.tnsl +++ /dev/null @@ -1,26 +0,0 @@ -/## - 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 -#/ - -: extern const {}_library _LIB_TABLE - -; raw struct _library { - -} \ No newline at end of file diff --git a/libtnsl/src/reflect/method.tnsl b/libtnsl/src/reflect/method.tnsl deleted file mode 100644 index d346464..0000000 --- a/libtnsl/src/reflect/method.tnsl +++ /dev/null @@ -1,20 +0,0 @@ -/## - 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 -#/ \ No newline at end of file diff --git a/libtnsl/src/reflect/reflect.tnsl b/libtnsl/src/reflect/reflect.tnsl index 3c1d583..b3640c2 100644 --- a/libtnsl/src/reflect/reflect.tnsl +++ b/libtnsl/src/reflect/reflect.tnsl @@ -24,4 +24,10 @@ Type and method resolution, reflection and other required methods such as is #; export module reflect + /: import + "type.tnsl" + "virtual.tnsl" + "resolver.tnsl" + "dispatch.tnsl" + :/ ;/ \ No newline at end of file diff --git a/libtnsl/src/reflect/static.tnsl b/libtnsl/src/reflect/static.tnsl deleted file mode 100644 index d346464..0000000 --- a/libtnsl/src/reflect/static.tnsl +++ /dev/null @@ -1,20 +0,0 @@ -/## - 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 -#/ \ No newline at end of file diff --git a/libtnsl/src/reflect/type.tnsl b/libtnsl/src/reflect/type.tnsl index b36dfc5..7a19b7d 100644 --- a/libtnsl/src/reflect/type.tnsl +++ b/libtnsl/src/reflect/type.tnsl @@ -20,53 +20,21 @@ #/ /## tnsl.reflect._type - Header data which prefixes all non-raw structs. + Header data which non-raw structs point to. Upper limits for classes and libs defined here: - - Max 2^32 libraries - - Max 2^16 classes per library + - Max 2^16 libraries + - Max 2^16 modules/sub-modules per library + - Max 2^16 classes per module - Max 2^8 Generics per class #/ -; raw struct _type(uint8 N) { - uint32 - _lib_index, +; raw struct _type() { uint16 - _type_index, + _library_id, + _module_id, + _type_id, - {N}_type - _generic_list -} - -/## tnsl.reflect._method - Metadata for methods (can be decoded from library - symbol tables). Limits for methods defined here: - - Max 2^8 inputs - - Max 2^8 outputs -#/ -; raw struct _method(uint8 I, O) { - ~{}charp - name, - - {I}_type - inputs, - {O}_type - outputs, - - ~void - address -} - -/## tnsl.reflect._member - Metadata about struct members -#/ -; raw struct _member { - ~{}charp - name, - - uint - offset, - - _type - _member_type + {uint8}_type + _generics } /## tnsl.reflect._type_addresses @@ -74,22 +42,30 @@ in a class #/ ; raw struct _type_addresses { - ~{}uint - _offsets, - _super_offsets, - ~{}_type _supers, + + ~{}uint + _super_offsets, ~{}_method - _methods + _methods, + + ~{}_member + _members } /; method _type - /; _is (_type_header base) + /; _is (_type base) [bool] + ;/ + + /; inline _get (_type t, ~void s, _member m) [~void] + ;/ + + /; inline raw _call (_type t, ~void s, _method m, ~void p) ;/ - /; _get_method () + /; _offset (_type cast) [uint] ;/ ;/ \ No newline at end of file diff --git a/libtnsl/src/reflect/virtual.tnsl b/libtnsl/src/reflect/virtual.tnsl new file mode 100644 index 0000000..8891905 --- /dev/null +++ b/libtnsl/src/reflect/virtual.tnsl @@ -0,0 +1,144 @@ +/## + 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 +#/ + +/## _LIB_TABLE + The array of library export trees. + + Convention: + - index 0 is always reserved for language-specific types + libtnsl + - index 0 module 0 represents the fundimental in-built types like int +#/ +: extern const {}~library _LIB_TABLE + +; raw struct library { + # Version + uint16 + major, + minor, + patch + + ~sym_node + root_node +} + +/## tnsl.reflect._method + Metadata for methods (can be decoded from library + symbol tables). Limits for methods defined here: + - Max 2^8 inputs + - Max 2^8 outputs +#/ +; raw struct _method { + {uint8}charp + name, + + {uint8}~_type + inputs, + outputs, + + ~void + address +} + +/## tnsl.reflect._member + Metadata about struct members +#/ +; raw struct _member { + {uint8}charp + name, + + _type + member_type, + + uint + byte_offset +} + +/## tnsl.reflect.sym_node + Represents a module in a symbol tree +#/ +; raw struct sym_node { + {uint8}charp + name, + + uint16 + id, + + {}~sym_node + sub_modules, + + {}~sym_type + sub_types +} + +/## tnsl.reflect.sym_type + Represents a type in a symbol tree +#/ +; raw struct sym_type { + {uint8}charp + name, + + {uint8}~sym_type + super_types, + +} + +############################### +# Traverse the Library Tree # +############################### + +/; get_sym_node (~sym_node root, uint16 mod_id) [~sym_node] + /;loop (root != null) + /; loop (uint16 sub = 0; sub < len `root.sub_modules) [sub++] + /; if (mod_id < `root.sub_modules{sub}.id) + /; if (sub == 0) + ; return null + ;/ + ;root = `root.sub_modules{sub - 1} + ; continue 1 + ;; else if (mod_id == `root.sub_modules{sub}.id) + ; return `root.sub_modules{sub} + ;/ + ;/ + + ; break + ;/ + + ; return null +;/ + +/; get_sym_node (uint16 lib_id, mod_id) [~sym_node] + + ;~library lib = _LIB_TABLE{lib_id} + + ;return get_sym_node(`lib.root_node, mod_id) +;/ + +/; get_sym_type(uint16 lib_id, mod_id, typ_id) [~sym_type] + + ;~library lib = _LIB_TABLE{lib_id} + ;~sym_node mod = get_sym_node(`lib.root_node, mod_id) + + ;return `mod.sub_types{typ_id} +;/ + +/; get_sym_type(`const {}charp path) [~sym_type] + +;/ \ No newline at end of file diff --git a/logo/tnsl-logo.png b/logo/tnsl-logo.png new file mode 100644 index 0000000..ff3eb12 Binary files /dev/null and b/logo/tnsl-logo.png differ diff --git a/logo/tnsl-logo.svg b/logo/tnsl-logo.svg new file mode 100644 index 0000000..38134c6 --- /dev/null +++ b/logo/tnsl-logo.svg @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + diff --git a/spec/4 - fip.md b/spec/4 - fip.md index dee037c..c5a0259 100644 --- a/spec/4 - fip.md +++ b/spec/4 - fip.md @@ -6,19 +6,23 @@ To use higher level features in TNSL, an implimentation of libtnsl must be in pl ## Section 2 - libtnsl and Types -`libtnsl` has the authority to define how types are stored in memory (to some extent) and how method resolution works on static and dynamic structs. `libtnsl` *must* provide certain methods for some language features to be available. These functions, and their uses are now listed, but a comprehensive list of language keywords can be found in Appendix B. +`libtnsl` has the authority to define how types are stored in memory (to some extent) and how method resolution works on static and dynamic structs. `libtnsl` *must* provide certain methods for some language features to be available. These functions, and their uses are now listed. A comprehensive list of language keywords can be found in Appendix B. + +### 2.0 - nullptr + +`tnsl._null` *must* be defined as a universal null pointer value. **No type except pointers may be `null`**, but pointers *must* have a null value to distinguish if they point to a meaningful position in memory. ### 2.1 - The libtnsl Type Extension `tnsl.reflect._type` *must* be defined as a raw struct which contains minimum information for type identification. This information is stored with every static or dynamic struct so that programs can reflect type information. -`tnsl.reflect._member` *must* be defined as a raw struct which contains minimum information for member variable identification within a type. The information need not be stored with every member variable, but should be stored somewhere such that the `tnsl.reflect._get` method can make use of it. +`tnsl.reflect._member` *should* be defined as a raw struct which contains minimum information for member variable identification within a type. The information need not be stored with every member variable, but should be stored somewhere such that the `tnsl.reflect._get` method can make use of it. `tnsl.reflect._method` *must* be defined as a raw struct which contains minimum information for method identification within a type. The information need not be stored with every member function, but should be stored somewhere such that the `tnsl.reflect._call` method can make use of it. `tnsl.reflect._is` *must* be defined as a function taking two parameters of type `tnsl.reflect._type` and returning a single `bool` as output. This function is called when the `is` operator is envoked. -`tnsl.reflect._get` *must* be defined as a function taking three parameters. The first parameter will be of type `tnsl.reflect._type`, the second parameter will be of type `~void`, and the third parameter will be of type `tnsl.reflect._member`. The function will return a single `~void` as output. +`tnsl.reflect._get` *should* be defined as a function taking three parameters. The first parameter will be of type `tnsl.reflect._type`, the second parameter will be of type `~void`, and the third parameter will be of type `tnsl.reflect._member`. The function will return a single `~void` as output. In the parameters, the first relates to the type of the struct given, or at least how the callee views the struct. The second is a pointer to the struct itself. The third is the requested member to get. The `~void` returned must point to the requested value. @@ -34,11 +38,11 @@ In the parameters, the first relates to the type of the struct given, or at leas `tnsl.algo._dealloc` *must* be defined as a function taking a single parameter of type `~void` as the pointer to a chunk of allocated memory. The function should deallocate the memory. -### 2.3 - Extra Types Extension +### 2.3 - Expanded Types Extension `tnsl.box._vect` *must* be a raw struct which vector or simd instructions can be preformed on. -`tnsl.box._string` *must* be a raw struct which stores a string of text. This text may be ASCII or Unicode, but reguardless must be stored as `charp` values internally. +`tnsl.box._string` *must* be a raw struct which stores a string of text. This text may be ASCII or Unicode, and should be stored as `charp` values internally. ## Section 3 - Cross calling C diff --git a/spec/Appendices.md b/spec/Appendices.md index 1caccc7..cd161e9 100644 --- a/spec/Appendices.md +++ b/spec/Appendices.md @@ -201,6 +201,8 @@ len - size (in elements) of an array + null - represents a broken pointer. This value only has context for pointers and is defined as a ~void. + User defined types: diff --git a/tnslc/src/compile/arch/arch.tnsl b/tnslc/src/compile/arch/arch.tnsl index bcabbfa..5e81673 100644 --- a/tnslc/src/compile/arch/arch.tnsl +++ b/tnslc/src/compile/arch/arch.tnsl @@ -14,9 +14,7 @@ EXPRESS OR IMPLIED #/ -/; export module arch - :import "common.tnsl" - :import "isa_arm.tnsl" - :import "isa_risc_v.tnsl" - :import "isa_x86.tnsl" +/; module arch + :import "compile/arch/common.tnsl" + :import "compile/arch/isa_x86.tnsl" ;/ \ No newline at end of file diff --git a/tnslc/src/compile/compile.tnsl b/tnslc/src/compile/compile.tnsl index 0fef36c..263dc59 100644 --- a/tnslc/src/compile/compile.tnsl +++ b/tnslc/src/compile/compile.tnsl @@ -14,9 +14,8 @@ EXPRESS OR IMPLIED #/ -/; export module compile - /: include - "arch" - "format" - :/ +/; module compile + :include "compile/arch/arch.tnsl" + :include "compile/format/format.tnsl" + ;/ diff --git a/tnslc/src/compile/format/format.tnsl b/tnslc/src/compile/format/format.tnsl index e69de29..2d4ed4b 100644 --- a/tnslc/src/compile/format/format.tnsl +++ b/tnslc/src/compile/format/format.tnsl @@ -0,0 +1,20 @@ +/## + 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 received a copy of the License 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 + + THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO + WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE + EXPRESS OR IMPLIED +#/ + +/; module format + :include "compile/format/out.tnsl" + :include "compile/format/elf.tnsl" +;/ \ No newline at end of file diff --git a/tnslc/src/parse/token.tnsl b/tnslc/src/parse/token.tnsl index cbbb31f..21abe7b 100644 --- a/tnslc/src/parse/token.tnsl +++ b/tnslc/src/parse/token.tnsl @@ -41,14 +41,14 @@ /; method Token /; operator delete - ;delete this.data + ;delete self.data ;/ - /; add_char (`{}charp part) - ;uint l = len `this.data - ;realloc this.data, l + len part - /;loop (uint i = 0; i < len part) [i++] - `this.data{l + i} = part{i} + /; add_char (~{}charp part) + ;uint l = len self.data` + ;realloc self.data, l + len part + /;loop (uint i = 0) [i++; i < len part] + ;self.data`{l + i} = part{i} ;/ ;/ ;/ @@ -212,7 +212,7 @@ /## Checks if the character point p is in the string cmp -#; is_in_string (`const {}charp cmp, charp p) [bool] +#; is_in_string (const {}charp` cmp, charp p) [bool] /; loop (int i = 0; i < len cmp) [i++] @@ -228,7 +228,7 @@ /## Checks if the string s is in the list cmp -#; is_in_string_list (`const {}{}charp cmp, `{}charp s) [bool] +#; is_in_string_list (const {}{}charp` cmp, {}charp` s) [bool] /; loop (int i = 0; i < len cmp) [i++] @@ -253,7 +253,7 @@ /# Get the token_type value for a given string of character points -#; get_token_type (`{}charp s) [int] +#; get_token_type ({}charp` s) [int] /; if (len s > 1) diff --git a/tnslc/src/tnslc.tnsl b/tnslc/src/tnslc.tnsl index 617e9e7..212819e 100644 --- a/tnslc/src/tnslc.tnsl +++ b/tnslc/src/tnslc.tnsl @@ -14,32 +14,25 @@ EXPRESS OR IMPLIED #/ -/; export module tnslc - :import "flags" - :import "parse" - :import "ast" - :import "compile" +/; module tnslc + :import "flags/flags.tnsl" + :import "parse/parse.tnsl" + :import "ast/ast.tnsl" + :import "compile/compile.tnsl" ;/ -:using 'tnsl' -:using 'tnslc' /; main (~{}{}char args) [int] - ;var arg_list = flags.parse(args) + ;tnslc.flags.Flags argList = tnslc.flags.parse(args) - ;var token_list = parse.tokenize(arg_list) + ;{}tnslc.parse.Token tokenList = tnslc.parse.tokenize(argList) - ;var ast = ast.generate(token_list) + ;tnslc.ast.Node ast = ast.generate(tokenList) - /; try - ;var out_file = file.open(arg_list.output_file_path) - ;var data = compile.generate(arg_list, ast) - - ;out_file.write(data) - ;out_file.close() + ;tnsl.io.File outFile = tnsl.io.open_file(argList.outPath) + ;[]uint8 data = tnslc.compile.generate(argList, ast) + + ;outFile.write(data) - ;; catch (error e) - ;io.stdout.write(e.msg) - ;return e.code - ;/ -;/ \ No newline at end of file + ;outFile.close() +;/ -- cgit v1.2.3