summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tews <git@tews.dev>2024-06-19 05:12:31 +0200
committerMichael Tews <michael@tews.dev>2026-04-12 11:11:01 +0200
commit4db0592135bea51950110c1abbf223e66da0a4e8 (patch)
treeaa7004a9f880369b396e0540f4f1cd538b3f219e
parent14108f2817d820f4bc679a134b810c1a1c4347da (diff)
feat(lexer): added LookupIdentifier
-rw-r--r--token/token.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/token/token.go b/token/token.go
index 92bc1ee..4cd3a3d 100644
--- a/token/token.go
+++ b/token/token.go
@@ -26,6 +26,19 @@ const (
LET = "LET"
)
+var keywords = map[string]TokenType{
+ "fn": FUNCTION,
+ "let": LET,
+}
+
+func LookupIdentifier(ident string) TokenType {
+ if tok, ok := keywords[ident]; ok {
+ return tok
+ }
+
+ return IDENT
+}
+
type TokenType string
type Token struct {