From 3574a95ecb54c3e88f2f897ae919435d92ec0241 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Tue, 26 Mar 2024 04:49:17 -0400 Subject: generator func --- tnslc/compile/generator.tnsl | 3 +++ tnslc/file.tnsl | 9 +++++++++ tnslc/tnslc.tnsl | 32 +++++++++++++++++++++++++------- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/tnslc/compile/generator.tnsl b/tnslc/compile/generator.tnsl index e69de29..239b0c3 100644 --- a/tnslc/compile/generator.tnsl +++ b/tnslc/compile/generator.tnsl @@ -0,0 +1,3 @@ +/; generate (utils.File fin, fout) +;/ + diff --git a/tnslc/file.tnsl b/tnslc/file.tnsl index e69de29..0b24aea 100644 --- a/tnslc/file.tnsl +++ b/tnslc/file.tnsl @@ -0,0 +1,9 @@ +struct File { + int i +} + +/; method File + /; init (~uint8 str) + ;/ + +;/ diff --git a/tnslc/tnslc.tnsl b/tnslc/tnslc.tnsl index 89fe80b..6269ef2 100644 --- a/tnslc/tnslc.tnsl +++ b/tnslc/tnslc.tnsl @@ -7,18 +7,36 @@ :import "compile/compile.tnsl" -~uint8 HELLO = "hello world\n\0" +~uint8 DEFAULT_FOUT = "out.asm\0" -/; main [int] - utils.Vector vec +~uint8 USAGE = " +TNSLC v1.0.0 (C) 2024 CircleShift - vec.init(1) +usage: + tnslc [options] (file in) [file out] + + -h print this help text +\0" - vec.push_cstr(HELLO) +/; main (int argc, ~~uint8 argv) [int] + asm "mov r10, rdi" + asm "mov r11, rsi" - _printf(vec.data) + /; if (argc < 2) + _printf(USAGE) + return 1 + ;/ - vec.end() + utils.File in, out + + in.init(argv{1}) + /; if (argc < 3) + out.init(argv{2}) + ;; else + out.init(DEFAULT_FOUT) + ;/ + + compile.generate(in, out) return 0 ;/ -- cgit v1.2.3