From 46aa6b65376ea62deb1d5ea1611b59dc222a5141 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Mon, 2 May 2022 02:57:49 -0400 Subject: [TNSLC] AST Updates - Change how string_equate works - Call AST Node generator from main - Flush out ast.tnsl - Add a few initial methods to AST - Move some code from token.tnsl to parse.tnsl --- tnslc/parse/token.tnsl | 56 +++----------------------------------------------- 1 file changed, 3 insertions(+), 53 deletions(-) (limited to 'tnslc/parse/token.tnsl') diff --git a/tnslc/parse/token.tnsl b/tnslc/parse/token.tnsl index ce2bcdb..92748d8 100644 --- a/tnslc/parse/token.tnsl +++ b/tnslc/parse/token.tnsl @@ -14,58 +14,6 @@ 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 - - /; print - ;tnsl.io.print("{ ") - ;tnsl.io.print(self.token_type) - ;tnsl.io.print(" ") - ;tnsl.io.print(self.data`) - ;tnsl.io.print(" ") - ;tnsl.io.print(self.line) - ;tnsl.io.print(" ") - ;tnsl.io.print(self.col) - ;tnsl.io.print(" } ") - ;/ - - /; 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. @@ -142,6 +90,7 @@ "raw", "asm", "inline", + "virtual", "delete", @@ -151,7 +100,8 @@ ;{}{}charp LITERALS = { "true", - "false" + "false", + "null" } ;{}charp RESERVED = "`~!#%^&*()-=+[]{}|;:,.<>/" -- cgit v1.2.3