From b00a5a1123c920a4fc2737fee68347f6285d9ffd Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Sat, 3 Aug 2024 03:27:48 -0400 Subject: Other type helper funcs --- tasm/README.md | 3 +++ tasm/generation/x86/math.tnsl | 2 ++ tasm/generation/x86/x86.tnsl | 4 ++++ tnslc/parse/ast.tnsl | 34 ++++++++++++++++++++++++++++++++++ tnslc/run.sh | 5 +++++ 5 files changed, 48 insertions(+) create mode 100644 tasm/README.md create mode 100644 tasm/generation/x86/math.tnsl create mode 100644 tasm/generation/x86/x86.tnsl create mode 100755 tnslc/run.sh diff --git a/tasm/README.md b/tasm/README.md new file mode 100644 index 0000000..21f7fad --- /dev/null +++ b/tasm/README.md @@ -0,0 +1,3 @@ +# Toat - Tnsl optimizing assembly translator + +A program to take in IR and produce optimized assembly for any system as an output diff --git a/tasm/generation/x86/math.tnsl b/tasm/generation/x86/math.tnsl new file mode 100644 index 0000000..c042aeb --- /dev/null +++ b/tasm/generation/x86/math.tnsl @@ -0,0 +1,2 @@ +/; addition () +;/ diff --git a/tasm/generation/x86/x86.tnsl b/tasm/generation/x86/x86.tnsl new file mode 100644 index 0000000..45e456e --- /dev/null +++ b/tasm/generation/x86/x86.tnsl @@ -0,0 +1,4 @@ +/; module x86 + include "math.tnsl" + include "call.tnsl" +;/ diff --git a/tnslc/parse/ast.tnsl b/tnslc/parse/ast.tnsl index 3cdf269..60676d4 100644 --- a/tnslc/parse/ast.tnsl +++ b/tnslc/parse/ast.tnsl @@ -135,10 +135,39 @@ struct Node { ;/ /; _type_helper_func (~utils.File fin, ~Node mod, ~Token first) + /; if (first`.eq("(\0") == true) + _ast_list_type(fin, mod, first) + ;/ + /; if (first.eq("[\0") == true) + _ast_list_type(fin, mod, first) + ;/ ;/ /; _type_helper_usertype (~utils.File fin, ~Node mod, ~Token first) + + /; loop (bool run = true; run == true && first`._type !== TTYPE_ERR) + /; if (first`._type == TTYPE_USRWD) + Node utp + utp.init(NTYPE_ID, first`.data) + first` = produce_next_token(fin, first`) + + /; if (first`._type !== TTYPE_AUG || first`.eq(".\0") == false) + run = false + ;; else + Token tmp = produce_next_token(fin, first`) + first`.end() + first` = tmp + ;/ + ;; else + _ast_print_err(first, "Expected identifier in fully qualified type chain\0") + run = false + ;/ + ;/ + + /; if (first`._type == TTYPE_DELIM && first`.eq("(\0") == true) + _ast_list_type(fin, mod, first) + ;/ ;/ /; _ast_type (~utils.File fin, ~Node mod, ~Token first) @@ -151,6 +180,11 @@ struct Node { # Check to see if this is a function pointer type /; if (first`.eq("void\0") && typ.sub.count == 0) + Node ktp + ktp.init(NTYPE_ID, first`.data) + typ.sub.push(~ktp) + first` = produce_next_token(fin, first`) + _type_helper_func(fin, ~typ, first) mod`.sub.push(~typ) return diff --git a/tnslc/run.sh b/tnslc/run.sh new file mode 100755 index 0000000..8010ab6 --- /dev/null +++ b/tnslc/run.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +DIR_L=$(pwd) + +$DIR_L/out/tnslc $1 -- cgit v1.2.3