From d0213b4202ac12d7e92f7125e87c31d9ecb637dd Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Mon, 11 Apr 2022 18:50:08 -0400 Subject: Remove src folders --- tnslc/ast/ast.tnsl | 19 +++ tnslc/ast/node.tnsl | 85 ++++++++++ tnslc/compile/arch/arch.tnsl | 20 +++ tnslc/compile/arch/common.tnsl | 17 ++ tnslc/compile/arch/isa_arm.tnsl | 15 ++ tnslc/compile/arch/isa_risc_v.tnsl | 15 ++ tnslc/compile/arch/isa_x86.tnsl | 15 ++ tnslc/compile/compile.tnsl | 21 +++ tnslc/compile/format/elf.tnsl | 151 +++++++++++++++++ tnslc/compile/format/format.tnsl | 20 +++ tnslc/compile/format/iex.tnsl | 0 tnslc/compile/format/out.tnsl | 0 tnslc/compile/format/pe.tnsl | 0 tnslc/flags/flags.tnsl | 16 ++ tnslc/parse/parse.tnsl | 20 +++ tnslc/parse/token.tnsl | 295 +++++++++++++++++++++++++++++++++ tnslc/parse/tokenizer.tnsl | 53 ++++++ tnslc/src/ast/ast.tnsl | 19 --- tnslc/src/ast/node.tnsl | 85 ---------- tnslc/src/compile/arch/arch.tnsl | 20 --- tnslc/src/compile/arch/common.tnsl | 17 -- tnslc/src/compile/arch/isa_arm.tnsl | 15 -- tnslc/src/compile/arch/isa_risc_v.tnsl | 15 -- tnslc/src/compile/arch/isa_x86.tnsl | 15 -- tnslc/src/compile/compile.tnsl | 21 --- tnslc/src/compile/format/elf.tnsl | 151 ----------------- tnslc/src/compile/format/format.tnsl | 20 --- tnslc/src/compile/format/iex.tnsl | 0 tnslc/src/compile/format/out.tnsl | 0 tnslc/src/compile/format/pe.tnsl | 0 tnslc/src/flags/flags.tnsl | 16 -- tnslc/src/parse/parse.tnsl | 22 --- tnslc/src/parse/token.tnsl | 295 --------------------------------- tnslc/src/parse/tokenizer.tnsl | 38 ----- tnslc/src/tnslc.tnsl | 38 ----- tnslc/tnslc.tnsl | 41 +++++ 36 files changed, 803 insertions(+), 787 deletions(-) create mode 100644 tnslc/ast/ast.tnsl create mode 100644 tnslc/ast/node.tnsl create mode 100644 tnslc/compile/arch/arch.tnsl create mode 100644 tnslc/compile/arch/common.tnsl create mode 100644 tnslc/compile/arch/isa_arm.tnsl create mode 100644 tnslc/compile/arch/isa_risc_v.tnsl create mode 100644 tnslc/compile/arch/isa_x86.tnsl create mode 100644 tnslc/compile/compile.tnsl create mode 100644 tnslc/compile/format/elf.tnsl create mode 100644 tnslc/compile/format/format.tnsl create mode 100644 tnslc/compile/format/iex.tnsl create mode 100644 tnslc/compile/format/out.tnsl create mode 100644 tnslc/compile/format/pe.tnsl create mode 100644 tnslc/flags/flags.tnsl create mode 100644 tnslc/parse/parse.tnsl create mode 100644 tnslc/parse/token.tnsl create mode 100644 tnslc/parse/tokenizer.tnsl delete mode 100644 tnslc/src/ast/ast.tnsl delete mode 100644 tnslc/src/ast/node.tnsl delete mode 100644 tnslc/src/compile/arch/arch.tnsl delete mode 100644 tnslc/src/compile/arch/common.tnsl delete mode 100644 tnslc/src/compile/arch/isa_arm.tnsl delete mode 100644 tnslc/src/compile/arch/isa_risc_v.tnsl delete mode 100644 tnslc/src/compile/arch/isa_x86.tnsl delete mode 100644 tnslc/src/compile/compile.tnsl delete mode 100644 tnslc/src/compile/format/elf.tnsl delete mode 100644 tnslc/src/compile/format/format.tnsl delete mode 100644 tnslc/src/compile/format/iex.tnsl delete mode 100644 tnslc/src/compile/format/out.tnsl delete mode 100644 tnslc/src/compile/format/pe.tnsl delete mode 100644 tnslc/src/flags/flags.tnsl delete mode 100644 tnslc/src/parse/parse.tnsl delete mode 100644 tnslc/src/parse/token.tnsl delete mode 100644 tnslc/src/parse/tokenizer.tnsl delete mode 100644 tnslc/src/tnslc.tnsl create mode 100644 tnslc/tnslc.tnsl (limited to 'tnslc') diff --git a/tnslc/ast/ast.tnsl b/tnslc/ast/ast.tnsl new file mode 100644 index 0000000..405a94a --- /dev/null +++ b/tnslc/ast/ast.tnsl @@ -0,0 +1,19 @@ +/## + 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 +#/ + +/; export module ast + :import "node.tnsl" +;/ \ No newline at end of file diff --git a/tnslc/ast/node.tnsl b/tnslc/ast/node.tnsl new file mode 100644 index 0000000..5eeac91 --- /dev/null +++ b/tnslc/ast/node.tnsl @@ -0,0 +1,85 @@ +/## + 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 +#/ + +# AST node (non-block) +;struct Node { + tnslc.parse.Token + # associated token to the node + data, + + ~{}Node + # sub-nodes + sub +} + +# AST node (block) +;struct BlockNode extends Node { + super, + + ~{}Node + # block inputs and outputs + blockIn, + blockOut, + + ~{}tnslc.parse.Token + # block qualifiers + blockQs +} + +# Node methods +/; method Node + + /; operator delete + ;delete this.data, this.sub + ;/ + + /; push_sub (Node node) [uint] + ;uint len = this.sub.length + ;alloc this.sub, len + 1 + ;this.sub{len} = node + ;return len + 1 + ;/ +;/ + +# Extended block node methods +/; method BlockNode + + /; operator delete + ;super() + ;delete this.blockQs, this.blockIn, this.blockOut + ;/ + + /; push_blockQ (tnslc.parse.Token token) [uint] + ;uint len = this.blockQs.length + ;alloc this.blockQs, len + 1 + ;this.blockQs{len} = token + ;return len + 1 + ;/ + + /; push_blockIn (Node node) [uint] + ;uint len = this.blockIn.length + ;alloc this.blockIn, len + 1 + ;this.blockIn{len} = node + ;return len + 1 + ;/ + + /; push_blockOut (Node node) [uint] + ;uint len = this.blockOut.length + ;alloc this.blockOut, len + 1 + ;this.blockOut{len} = node + ;return len + 1 + ;/ +;/ \ No newline at end of file diff --git a/tnslc/compile/arch/arch.tnsl b/tnslc/compile/arch/arch.tnsl new file mode 100644 index 0000000..5e81673 --- /dev/null +++ b/tnslc/compile/arch/arch.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 arch + :import "compile/arch/common.tnsl" + :import "compile/arch/isa_x86.tnsl" +;/ \ No newline at end of file diff --git a/tnslc/compile/arch/common.tnsl b/tnslc/compile/arch/common.tnsl new file mode 100644 index 0000000..cba0d9f --- /dev/null +++ b/tnslc/compile/arch/common.tnsl @@ -0,0 +1,17 @@ +/## + 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 +#/ + +; struct instruction {} \ No newline at end of file diff --git a/tnslc/compile/arch/isa_arm.tnsl b/tnslc/compile/arch/isa_arm.tnsl new file mode 100644 index 0000000..0dc3468 --- /dev/null +++ b/tnslc/compile/arch/isa_arm.tnsl @@ -0,0 +1,15 @@ +/## + 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 +#/ diff --git a/tnslc/compile/arch/isa_risc_v.tnsl b/tnslc/compile/arch/isa_risc_v.tnsl new file mode 100644 index 0000000..0dc3468 --- /dev/null +++ b/tnslc/compile/arch/isa_risc_v.tnsl @@ -0,0 +1,15 @@ +/## + 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 +#/ diff --git a/tnslc/compile/arch/isa_x86.tnsl b/tnslc/compile/arch/isa_x86.tnsl new file mode 100644 index 0000000..0dc3468 --- /dev/null +++ b/tnslc/compile/arch/isa_x86.tnsl @@ -0,0 +1,15 @@ +/## + 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 +#/ diff --git a/tnslc/compile/compile.tnsl b/tnslc/compile/compile.tnsl new file mode 100644 index 0000000..263dc59 --- /dev/null +++ b/tnslc/compile/compile.tnsl @@ -0,0 +1,21 @@ +/## + 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 compile + :include "compile/arch/arch.tnsl" + :include "compile/format/format.tnsl" + +;/ diff --git a/tnslc/compile/format/elf.tnsl b/tnslc/compile/format/elf.tnsl new file mode 100644 index 0000000..8490180 --- /dev/null +++ b/tnslc/compile/format/elf.tnsl @@ -0,0 +1,151 @@ +/## + 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 +#/ + +# Constants and values used in ELF files + +# File signature +;const {4}uint8 SIGNATURE_ELF = {0x7F, 'E', 'L', 'F'} + +# ELF version always 1 +;const uint8 VERSION_ELF = 1 + +# OS identifiers (from wikipedia) +;enum ABI_ELF [uint8] { + SystemV = 0x0, + HP_UX = 0x1, + NetBSD = 0x2, + Linux = 0x3, + GNUHurd = 0x4, + Solaris = 0x6, + AIX = 0x7, + IRIX = 0x8, + FreeBSD = 0x9, + Tru64 = 0xA, + OpenBSD = 0xC, + OpenVMS = 0xD +} + +# ELF file types (from wikipedia) +;enum TYPE_ELF [uint16] { + ET_NONE = 0x0, + ET_REL = 0x1, + ET_EXEC = 0x2, + ET_DYN = 0x3, + ET_CORE = 0x4, + ET_LOOS = 0xFE00, + ET_HIOS = 0xFEFF, + ET_LOPROC = 0xFF00, + ET_HIPROC = 0xFFFF +} + +# ISA (from wikipedia) +;enum ARCH_ELF [uint16] { + NONE = 0x0, + SPARC = 0x2, + x86_32 = 0x3, + MIPS = 0x8, + PowerPC = 0x14, + PowerPC64 = 0x15, + ARM = 0x28, + SPARC9 = 0x2B, + IA_64 = 0x32, + x86_64 = 0x3E, + ARM64 = 0xB7, + RISC_V = 0xF3 +} + +# Some zeros to fill out the pad in the header +;const {7}uint8 PAD_ZEROS_ELF = {0, 0, 0, 0, 0, 0, 0} + + + +# Internal file structures + +# Identity inside header +;raw struct IdentityELF { + {4}uint8 + signature, + + uint8 + class, + data, + version, + abi, + + # Usually zero + abiVersion, + + {7}uint8 + # Filled with zeros, use PAD_ZEROS_ELF to fill out + pad +} + +# Main header (32 bit) +;raw struct HeaderELF32 { + IdentityELF + identity, + + uint16 + fileType, + arch, + + {4}uint8 + version, + entry, + programHeader, + sectionHeader, + + {4}uint8 + flags, + + uint16 + headerSize, + programHeaderSize, + programHeaderEntries, + sectionHeaderSize, + sectionHeaderEntries, + shNameIndex +} + +# Main header (64 bit) +;raw struct HeaderELF64 { + IdentityELF + identity, + + uint16 + fileType, + arch, + + {4}uint8 + version, + + {8}uint8 + entry, + programHeader, + sectionHeader, + + {4}uint8 + flags, + + uint16 + headerSize, + programHeaderSize, + programHeaderEntries, + sectionHeaderSize, + sectionHeaderEntries, + shNameIndex +} + diff --git a/tnslc/compile/format/format.tnsl b/tnslc/compile/format/format.tnsl new file mode 100644 index 0000000..2d4ed4b --- /dev/null +++ b/tnslc/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/compile/format/iex.tnsl b/tnslc/compile/format/iex.tnsl new file mode 100644 index 0000000..e69de29 diff --git a/tnslc/compile/format/out.tnsl b/tnslc/compile/format/out.tnsl new file mode 100644 index 0000000..e69de29 diff --git a/tnslc/compile/format/pe.tnsl b/tnslc/compile/format/pe.tnsl new file mode 100644 index 0000000..e69de29 diff --git a/tnslc/flags/flags.tnsl b/tnslc/flags/flags.tnsl new file mode 100644 index 0000000..bc5d43f --- /dev/null +++ b/tnslc/flags/flags.tnsl @@ -0,0 +1,16 @@ +/## + 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 +#/ + diff --git a/tnslc/parse/parse.tnsl b/tnslc/parse/parse.tnsl new file mode 100644 index 0000000..ec65f7b --- /dev/null +++ b/tnslc/parse/parse.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 parse + :include "tnslc/parse/token.tnsl" + :include "tnslc/parse/tokenizer.tnsl" +;/ \ No newline at end of file diff --git a/tnslc/parse/token.tnsl b/tnslc/parse/token.tnsl new file mode 100644 index 0000000..0134483 --- /dev/null +++ b/tnslc/parse/token.tnsl @@ -0,0 +1,295 @@ +/# + 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 +#/ + +/# The various types of tokens #/ +; enum TOKEN_TYPE [int] { + LINESEP = 0, + INLNSEP = 1, + DELIMIT = 2, + AUGMENT = 3, + LITERAL = 4, + KEYTYPE = 5, + PREWORD = 6, + KEYWORD = 7, + DEFWORD = 8 +} + +/# Token struct definition #/ +; struct Token { + int + token_type, + line, + col, + + ~{}charp + data +} + +/; method Token + + /; operator delete + ;delete self.data + ;/ + + /; add_char (~{}charp part) + # ;uint l = len self.data` + # ;realloc self.data, l + len part + /;loop (int i = 0; i < len part`) [i++] + # ;self.data`{l + i} = part{i} + ;self.data`.append(part`{i}) + ;/ + ;/ +;/ + +/# + Reserved words and characters, as well as + helper funcs for checking their token types. +#/ + +;{}{}charp PREWORDS = { + "include", + "define", + "extern", + "size", + "align", + "address", + "rootfile", + "if", + "else", + "abi" +} + +;const {}{}charp KEYTYPES = { + "bool", + "char", + "charp", + + "int8", + "int16", + "int32", + "int64", + "int", + "uint8", + "uint16", + "uint32", + "uint64", + "uint", + + "float32", + "float64", + "float", + + "void", + "type" +} + +;{}{}charp KEYWORDS = { + "struct", + "interface", + "enum", + "is", + "extends", + + "loop", + "continue", + "break", + + "match", + "case", + "default", + + "label", + "goto", + + "if", + "else", + + "const", + "static", + "volatile", + + "method", + "override", + "self", + "super", + "operator", + + "raw", + "asm", + "inline", + + "delete", + + "module", + "export" +} + +;{}{}charp LITERALS = { + "true", + "false" +} + +;{}charp RESERVED = "`~!#%^&*()-=+[]{}|;:,.<>/" + +;{}charp DELIMITS = "()[]{}" +;{}charp LINESEPS = ";:#" +;{}charp INLNSEPS = "," +;{}charp AUGMENTS = "~`.&|^>>", + + # PREaugmented augmentors + "&=", + "|=", + "^=", + "+=", + "-=", + "*=", + "/=", + "%=", + "~=", + "`=", + + # POSTaugmented augmentors + "!&", + "!|", + "!^", + "!==", + "!&&", + "!||", + "!>", + "!<", + ">==", + "<==", + + # Increment and De-increment + "++", + "--" +} + +;int MAX_MRESERVED = 3 + +/## + Checks if the character point p is in the string cmp + +#; is_in_string (~{}charp cmp, charp p) [bool] + + /; loop (int i = 0; i < len cmp`) [i++] + /; if (s == cmp`{i}) + ;return true + ;/ + ;/ + + ;return false +;/ + +/## + Checks if the string s is in the list cmp + +#; is_in_string_list (~{}{}charp cmp, ~{}charp s) [bool] + + /; loop (int i = 0; i < len cmp`) [i++] + + /; if (len s == len cmp`{i}) + + /; loop (int j = 0; j < len s`) [j++] + + /; if (s`{j} !== cmp`{i}{j}) + ;break 1 + ;/ + ;/ + + ;return true + ;/ + + ;/ + + ;return false +;/ + +/# + Get the token_type value for a given string of character points + +#; get_token_type (~{}charp s) [int] + + /; if (len s > 1) + + /; if (is_in_string_list(~PREWORDS, s)) + ;return TOKEN_TYPE.PREWORD + ;; else if (is_in_string_list(~KEYTYPES, s)) + ;return TOKEN_TYPE.KEYTYPE + ;; else if (is_in_string_list(~KEYWORDS, s)) + ;return TOKEN_TYPE.KEYWORD + ;; else if (is_in_string_list(~LITERALS, s)) + ;return TOKEN_TYPE.LITERAL + ;; else if (is_in_string_list(~MDELIMITS, s)) + ;return TOKEN_TYPE.DELIMIT + ;; else if (is_in_string_list(~MAUGMENTS, s)) + ;return TOKEN_TYPE.AUGMENT + ;/ + + ;return TOKEN_TYPE.DEFWORD + + ;;else if (len s` == 1) + + /; if (is_in_string(~DELIMITS, s`{0})) + ;return TOKEN_TYPE.DELIMIT + ;; else if (is_in_string(~LINESEPS, s`{0})) + ;return TOKEN_TYPE.LINESEP + ;; else if (is_in_string(~INLNSEPS, s`{0})) + ;return TOKEN_TYPE.INLNSEP + ;; else if (is_in_string(~AUGMENTS, s`{0})) + ;return TOKEN_TYPE.AUGMENT + ;/ + + ;return TOKEN_TYPE.DEFWORD + ;/ + + # What, we just produce vacant tokens now? + # Something has gone wrong. + + ;return -1 +;/ \ No newline at end of file diff --git a/tnslc/parse/tokenizer.tnsl b/tnslc/parse/tokenizer.tnsl new file mode 100644 index 0000000..54671fe --- /dev/null +++ b/tnslc/parse/tokenizer.tnsl @@ -0,0 +1,53 @@ +/# + 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 +#/ + +/; is_space (charp c) [bool] + ;return c == '\t' || c == '\n' || c == ' ' +;/ + +/; break_token ({}charp dat, charp c) [bool] + /; if (len dat == 0) + ;return false + + ;/ + ;return is_space(c) +;/ + +/; parse_reserved ({}charp dat) [{}Token] + +;/ + +/; tokenize (tnsl.io.File fstr) [~{}Token] + ;{}Token out = {} + ;{}charp tdat = {} + + /; loop (int i = fstr.read(); i !== -1) [i = fstr.read()] + /; if (break_token(tdat, i)) + /; if (len tdat > 0) + ;{}charp tmp = tdat + ;Token ttk = {0, 0, 0, ~tmp} + ;out.append(ttk) + ;tdat = {} + ;/ + ;; else if ( !is_space(i) ) + ;tdat.append(i) + ;/ + ;/ + + ;tnsl.io.println(tdat) + + ;return ~out +;/ diff --git a/tnslc/src/ast/ast.tnsl b/tnslc/src/ast/ast.tnsl deleted file mode 100644 index 405a94a..0000000 --- a/tnslc/src/ast/ast.tnsl +++ /dev/null @@ -1,19 +0,0 @@ -/## - 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 -#/ - -/; export module ast - :import "node.tnsl" -;/ \ No newline at end of file diff --git a/tnslc/src/ast/node.tnsl b/tnslc/src/ast/node.tnsl deleted file mode 100644 index 5eeac91..0000000 --- a/tnslc/src/ast/node.tnsl +++ /dev/null @@ -1,85 +0,0 @@ -/## - 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 -#/ - -# AST node (non-block) -;struct Node { - tnslc.parse.Token - # associated token to the node - data, - - ~{}Node - # sub-nodes - sub -} - -# AST node (block) -;struct BlockNode extends Node { - super, - - ~{}Node - # block inputs and outputs - blockIn, - blockOut, - - ~{}tnslc.parse.Token - # block qualifiers - blockQs -} - -# Node methods -/; method Node - - /; operator delete - ;delete this.data, this.sub - ;/ - - /; push_sub (Node node) [uint] - ;uint len = this.sub.length - ;alloc this.sub, len + 1 - ;this.sub{len} = node - ;return len + 1 - ;/ -;/ - -# Extended block node methods -/; method BlockNode - - /; operator delete - ;super() - ;delete this.blockQs, this.blockIn, this.blockOut - ;/ - - /; push_blockQ (tnslc.parse.Token token) [uint] - ;uint len = this.blockQs.length - ;alloc this.blockQs, len + 1 - ;this.blockQs{len} = token - ;return len + 1 - ;/ - - /; push_blockIn (Node node) [uint] - ;uint len = this.blockIn.length - ;alloc this.blockIn, len + 1 - ;this.blockIn{len} = node - ;return len + 1 - ;/ - - /; push_blockOut (Node node) [uint] - ;uint len = this.blockOut.length - ;alloc this.blockOut, len + 1 - ;this.blockOut{len} = node - ;return len + 1 - ;/ -;/ \ No newline at end of file diff --git a/tnslc/src/compile/arch/arch.tnsl b/tnslc/src/compile/arch/arch.tnsl deleted file mode 100644 index 5e81673..0000000 --- a/tnslc/src/compile/arch/arch.tnsl +++ /dev/null @@ -1,20 +0,0 @@ -/## - 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 arch - :import "compile/arch/common.tnsl" - :import "compile/arch/isa_x86.tnsl" -;/ \ No newline at end of file diff --git a/tnslc/src/compile/arch/common.tnsl b/tnslc/src/compile/arch/common.tnsl deleted file mode 100644 index cba0d9f..0000000 --- a/tnslc/src/compile/arch/common.tnsl +++ /dev/null @@ -1,17 +0,0 @@ -/## - 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 -#/ - -; struct instruction {} \ No newline at end of file diff --git a/tnslc/src/compile/arch/isa_arm.tnsl b/tnslc/src/compile/arch/isa_arm.tnsl deleted file mode 100644 index 0dc3468..0000000 --- a/tnslc/src/compile/arch/isa_arm.tnsl +++ /dev/null @@ -1,15 +0,0 @@ -/## - 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 -#/ diff --git a/tnslc/src/compile/arch/isa_risc_v.tnsl b/tnslc/src/compile/arch/isa_risc_v.tnsl deleted file mode 100644 index 0dc3468..0000000 --- a/tnslc/src/compile/arch/isa_risc_v.tnsl +++ /dev/null @@ -1,15 +0,0 @@ -/## - 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 -#/ diff --git a/tnslc/src/compile/arch/isa_x86.tnsl b/tnslc/src/compile/arch/isa_x86.tnsl deleted file mode 100644 index 0dc3468..0000000 --- a/tnslc/src/compile/arch/isa_x86.tnsl +++ /dev/null @@ -1,15 +0,0 @@ -/## - 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 -#/ diff --git a/tnslc/src/compile/compile.tnsl b/tnslc/src/compile/compile.tnsl deleted file mode 100644 index 263dc59..0000000 --- a/tnslc/src/compile/compile.tnsl +++ /dev/null @@ -1,21 +0,0 @@ -/## - 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 compile - :include "compile/arch/arch.tnsl" - :include "compile/format/format.tnsl" - -;/ diff --git a/tnslc/src/compile/format/elf.tnsl b/tnslc/src/compile/format/elf.tnsl deleted file mode 100644 index 8490180..0000000 --- a/tnslc/src/compile/format/elf.tnsl +++ /dev/null @@ -1,151 +0,0 @@ -/## - 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 -#/ - -# Constants and values used in ELF files - -# File signature -;const {4}uint8 SIGNATURE_ELF = {0x7F, 'E', 'L', 'F'} - -# ELF version always 1 -;const uint8 VERSION_ELF = 1 - -# OS identifiers (from wikipedia) -;enum ABI_ELF [uint8] { - SystemV = 0x0, - HP_UX = 0x1, - NetBSD = 0x2, - Linux = 0x3, - GNUHurd = 0x4, - Solaris = 0x6, - AIX = 0x7, - IRIX = 0x8, - FreeBSD = 0x9, - Tru64 = 0xA, - OpenBSD = 0xC, - OpenVMS = 0xD -} - -# ELF file types (from wikipedia) -;enum TYPE_ELF [uint16] { - ET_NONE = 0x0, - ET_REL = 0x1, - ET_EXEC = 0x2, - ET_DYN = 0x3, - ET_CORE = 0x4, - ET_LOOS = 0xFE00, - ET_HIOS = 0xFEFF, - ET_LOPROC = 0xFF00, - ET_HIPROC = 0xFFFF -} - -# ISA (from wikipedia) -;enum ARCH_ELF [uint16] { - NONE = 0x0, - SPARC = 0x2, - x86_32 = 0x3, - MIPS = 0x8, - PowerPC = 0x14, - PowerPC64 = 0x15, - ARM = 0x28, - SPARC9 = 0x2B, - IA_64 = 0x32, - x86_64 = 0x3E, - ARM64 = 0xB7, - RISC_V = 0xF3 -} - -# Some zeros to fill out the pad in the header -;const {7}uint8 PAD_ZEROS_ELF = {0, 0, 0, 0, 0, 0, 0} - - - -# Internal file structures - -# Identity inside header -;raw struct IdentityELF { - {4}uint8 - signature, - - uint8 - class, - data, - version, - abi, - - # Usually zero - abiVersion, - - {7}uint8 - # Filled with zeros, use PAD_ZEROS_ELF to fill out - pad -} - -# Main header (32 bit) -;raw struct HeaderELF32 { - IdentityELF - identity, - - uint16 - fileType, - arch, - - {4}uint8 - version, - entry, - programHeader, - sectionHeader, - - {4}uint8 - flags, - - uint16 - headerSize, - programHeaderSize, - programHeaderEntries, - sectionHeaderSize, - sectionHeaderEntries, - shNameIndex -} - -# Main header (64 bit) -;raw struct HeaderELF64 { - IdentityELF - identity, - - uint16 - fileType, - arch, - - {4}uint8 - version, - - {8}uint8 - entry, - programHeader, - sectionHeader, - - {4}uint8 - flags, - - uint16 - headerSize, - programHeaderSize, - programHeaderEntries, - sectionHeaderSize, - sectionHeaderEntries, - shNameIndex -} - diff --git a/tnslc/src/compile/format/format.tnsl b/tnslc/src/compile/format/format.tnsl deleted file mode 100644 index 2d4ed4b..0000000 --- a/tnslc/src/compile/format/format.tnsl +++ /dev/null @@ -1,20 +0,0 @@ -/## - 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/compile/format/iex.tnsl b/tnslc/src/compile/format/iex.tnsl deleted file mode 100644 index e69de29..0000000 diff --git a/tnslc/src/compile/format/out.tnsl b/tnslc/src/compile/format/out.tnsl deleted file mode 100644 index e69de29..0000000 diff --git a/tnslc/src/compile/format/pe.tnsl b/tnslc/src/compile/format/pe.tnsl deleted file mode 100644 index e69de29..0000000 diff --git a/tnslc/src/flags/flags.tnsl b/tnslc/src/flags/flags.tnsl deleted file mode 100644 index bc5d43f..0000000 --- a/tnslc/src/flags/flags.tnsl +++ /dev/null @@ -1,16 +0,0 @@ -/## - 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 -#/ - diff --git a/tnslc/src/parse/parse.tnsl b/tnslc/src/parse/parse.tnsl deleted file mode 100644 index e10ab4c..0000000 --- a/tnslc/src/parse/parse.tnsl +++ /dev/null @@ -1,22 +0,0 @@ -/## - 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 -#/ - -/; export module parse - /:import - "token.tnsl" - "tokenizer.tnsl" - :/ -;/ \ No newline at end of file diff --git a/tnslc/src/parse/token.tnsl b/tnslc/src/parse/token.tnsl deleted file mode 100644 index 21abe7b..0000000 --- a/tnslc/src/parse/token.tnsl +++ /dev/null @@ -1,295 +0,0 @@ -/# - 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 -#/ - -/# The various types of tokens #/ -; enum TOKEN_TYPE [uint] { - LINESEP = 0, - INLNSEP = 1, - DELIMIT = 2, - AUGMENT = 3, - LITERAL = 4, - KEYTYPE = 5, - PREWORD = 6, - KEYWORD = 7, - DEFWORD = 8 -} - -/# Token struct definition #/ -;raw struct Token { - uint - token_type, - line, - col, - - ~{}charp - data -} - -/; method Token - - /; operator delete - ;delete self.data - ;/ - - /; 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} - ;/ - ;/ -;/ - -/# - Reserved words and characters, as well as - helper funcs for checking their token types. -#/ - -;const {}{}charp PREWORDS = { - "include", - "define", - "extern", - "size", - "align", - "address", - "rootfile", - "if", - "else", - "abi" -} - -;const {}{}charp KEYTYPES = { - "bool", - "char", - "charp", - - "int8", - "int16", - "int32", - "int64", - "int", - "uint8", - "uint16", - "uint32", - "uint64", - "uint", - - "float32", - "float64", - "float", - - "void", - "type" -} - -;const {}{}charp KEYWORDS = { - "struct", - "interface", - "enum", - "is", - "extends", - - "loop", - "continue", - "break", - - "match", - "case", - "default", - - "label", - "goto", - - "if", - "else", - - "const", - "static", - "volatile", - - "method", - "override", - "self", - "super", - "operator", - - "raw", - "asm", - "inline", - - "delete", - - "module", - "export", -} - -;const {}{}charp LITERALS = { - "true", - "false" -} - -;const {}charp DELIMITS = "()[]{}" -;const {}charp LINESEPS = ";:#" -;const {}charp INLNSEPS = "," -;const {}charp AUGMENTS = "~`.&|^>>", - - # PREaugmented augmentors - "&=", - "|=", - "^=", - "+=", - "-=", - "*=", - "/=", - "%=", - "~=", - "`=", - - # POSTaugmented augmentors - "!&", - "!|", - "!^", - "!==", - "!&&", - "!||", - "!>", - "!<", - ">==", - "<==", - - # Increment and De-increment - "++", - "--" -} - -; const uint MAX_MRESERVED = 3 - -/## - Checks if the character point p is in the string cmp - -#; is_in_string (const {}charp` cmp, charp p) [bool] - - /; loop (int i = 0; i < len cmp) [i++] - - /; if (s == cmp{i}) - ;return true - ;/ - ;/ - - ;return false -;/ - - -/## - Checks if the string s is in the list cmp - -#; is_in_string_list (const {}{}charp` cmp, {}charp` s) [bool] - - /; loop (int i = 0; i < len cmp) [i++] - - /; if (len s == len cmp{i}) - - /; loop (int j = 0; j < len s) [j++] - - /; if (s{j} !== cmp{i}{j}) - ;goto cont_outer - ;/ - ;/ - - ;return true - ;/ - - ;label cont_outer - ;/ - - ;return false -;/ - -/# - Get the token_type value for a given string of character points - -#; get_token_type ({}charp` s) [int] - - /; if (len s > 1) - - /; if (is_in_string_list(~PREWORDS, ~s)) - ;return TOKEN_TYPE.PREWORD - ;; else if (is_in_string_list(~KEYTYPES, ~s)) - ;return TOKEN_TYPE.KEYTYPE - ;; else if (is_in_string_list(~KEYWORDS, ~s)) - ;return TOKEN_TYPE.KEYWORD - ;; else if (is_in_string_list(~LITERALS, ~s)) - ;return TOKEN_TYPE.LITERAL - ;; else if (is_in_string_list(~MDELIMITS, ~s)) - ;return TOKEN_TYPE.DELIMIT - ;; else if (is_in_string_list(~MAUGMENTS, ~s)) - ;return TOKEN_TYPE.AUGMENT - ;/ - - ;return TOKEN_TYPE.DEFWORD - - ;;else if (len s == 1) - - /; if (is_in_string(~DELIMITS, s{0})) - ;return TOKEN_TYPE.DELIMIT - ;; else if (is_in_string(~LINESEPS, s{0})) - ;return TOKEN_TYPE.LINESEP - ;; else if (is_in_string(~INLNSEPS, s{0})) - ;return TOKEN_TYPE.INLNSEP - ;; else if (is_in_string(~AUGMENTS, s{0})) - ;return TOKEN_TYPE.AUGMENT - ;/ - - ;return TOKEN_TYPE.DEFWORD - ;/ - - # What, we just produce vacant tokens now? - # Something has gone wrong. - - ;return -1 -;/ \ No newline at end of file diff --git a/tnslc/src/parse/tokenizer.tnsl b/tnslc/src/parse/tokenizer.tnsl deleted file mode 100644 index 4e5eeb7..0000000 --- a/tnslc/src/parse/tokenizer.tnsl +++ /dev/null @@ -1,38 +0,0 @@ -/# - 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 -#/ - -:using 'tnsl' - -/## - parse.numeric_literal tokenizes the next numeric literal value in a file. - Returns a token with the proper data as well as the number of characters read - -#; numeric_literal (io.text_stream fstream) [Token, uint] - ;Token out = {token_type: TOKEN_TYPE.LITERAL} - ;uint counter = 0 - - ;bool l, d, run = false, false, true - ;~{}charp num - - ;num, run = fstream.read_number() - - /; loop (run) [num, run = fstream.read_number()] - ;out.add_data(num) - ;delete num - ;/ - - ;return out, counter -;/ \ No newline at end of file diff --git a/tnslc/src/tnslc.tnsl b/tnslc/src/tnslc.tnsl deleted file mode 100644 index 212819e..0000000 --- a/tnslc/src/tnslc.tnsl +++ /dev/null @@ -1,38 +0,0 @@ -/## - 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 tnslc - :import "flags/flags.tnsl" - :import "parse/parse.tnsl" - :import "ast/ast.tnsl" - :import "compile/compile.tnsl" -;/ - - -/; main (~{}{}char args) [int] - ;tnslc.flags.Flags argList = tnslc.flags.parse(args) - - ;{}tnslc.parse.Token tokenList = tnslc.parse.tokenize(argList) - - ;tnslc.ast.Node ast = ast.generate(tokenList) - - ;tnsl.io.File outFile = tnsl.io.open_file(argList.outPath) - ;[]uint8 data = tnslc.compile.generate(argList, ast) - - ;outFile.write(data) - - ;outFile.close() -;/ diff --git a/tnslc/tnslc.tnsl b/tnslc/tnslc.tnsl new file mode 100644 index 0000000..99be327 --- /dev/null +++ b/tnslc/tnslc.tnsl @@ -0,0 +1,41 @@ +/## + 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 tnslc + :include "tnslc/parse/parse.tnsl" +;/ + + +/; test + +;/ + +/; main ({}{}charp args) [int] + /; if (len args < 1) + ;tnsl.io.println("Usage: tnslc [File to compile] ") + ;return 1 + ;/ + + ;tnsl.io.File src = tnsl.io.readFile(args{0}) + + ;~{}tnslc.parse.Token psrc = tnslc.parse.tokenize(src) + + ;tnsl.io.println(psrc`) + + ;src.close() + + ;return 0 +;/ -- cgit v1.2.3