diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2021-11-23 13:05:49 -0500 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2021-11-23 13:05:49 -0500 |
commit | 5eeec21759dc49252ebbcdb5e0d9336f68d0a51e (patch) | |
tree | f3b5b759a1f68962a77608e816bbc5d2702ac78b /tnslc | |
parent | 6444b3faef696b044d391b98151ebeb90eb3bb7f (diff) |
Some changes, plus a logo.
Diffstat (limited to 'tnslc')
-rw-r--r-- | tnslc/src/compile/arch/arch.tnsl | 8 | ||||
-rw-r--r-- | tnslc/src/compile/compile.tnsl | 9 | ||||
-rw-r--r-- | tnslc/src/compile/format/format.tnsl | 20 | ||||
-rw-r--r-- | tnslc/src/parse/token.tnsl | 18 | ||||
-rw-r--r-- | tnslc/src/tnslc.tnsl | 35 |
5 files changed, 50 insertions, 40 deletions
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() +;/ |