summaryrefslogtreecommitdiff
path: root/tnslc/parse/token.tnsl
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2022-05-02 02:57:49 -0400
committerKyle Gunger <kgunger12@gmail.com>2022-05-02 02:57:49 -0400
commit46aa6b65376ea62deb1d5ea1611b59dc222a5141 (patch)
treee92b26bc2d2653b9009a230ee1d6b7ed1185e3a0 /tnslc/parse/token.tnsl
parent9478e157ec2cfe4de704b3bd78b07aee8824774f (diff)
[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
Diffstat (limited to 'tnslc/parse/token.tnsl')
-rw-r--r--tnslc/parse/token.tnsl56
1 files changed, 3 insertions, 53 deletions
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 = "`~!#%^&*()-=+[]{}|;:,.<>/"