diff options
| author | Ibrahim Muftee <ibrahim@muftee.net> | 2026-07-14 22:18:38 -0500 |
|---|---|---|
| committer | Ibrahim Muftee <ibrahim@muftee.net> | 2026-07-14 22:21:59 -0500 |
| commit | baa37871d9b71d3f94cc8acca8d375ee1232d7f0 (patch) | |
| tree | d74f48479d28380fb2f53cb61c91727d0b6632ec /token | |
chapter 01
Diffstat (limited to 'token')
| -rw-r--r-- | token/token.odin | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/token/token.odin b/token/token.odin new file mode 100644 index 0000000..20efd6f --- /dev/null +++ b/token/token.odin @@ -0,0 +1,84 @@ +package token + +Token :: union { + Asterisk, + Bang, + Comma, + EOF, + Else, + Equal_Sign, + Equals, + False, + Forward_Slash, + Function, + Greater_Than, + Identifier, + If, + Illegal, + Integer, + Left_Brace, + Left_Parenthesis, + Less_Than, + Let, + Minus, + Not_Equals, + Plus, + Return, + Right_Brace, + Right_Parenthesis, + Semicolon, + True, +} + +Asterisk :: struct {} +Bang :: struct {} +Comma :: struct {} +EOF :: struct {} +Else :: struct {} +Equal_Sign :: struct {} +Equals :: struct {} +False :: struct {} +Forward_Slash :: struct {} +Function :: struct {} +Greater_Than :: struct {} +Identifier :: struct { + literal: string, +} +If :: struct {} +Illegal :: struct {} +Integer :: struct { + literal: int, +} +Left_Brace :: struct {} +Left_Parenthesis :: struct {} +Less_Than :: struct {} +Let :: struct {} +Minus :: struct {} +Not_Equals :: struct {} +Plus :: struct {} +Return :: struct {} +Right_Brace :: struct {} +Right_Parenthesis :: struct {} +Semicolon :: struct {} +True :: struct {} + +lookup_identifier :: proc(ident: string) -> Token { + switch ident { + case "fn": + return Function{} + case "let": + return Let{} + case "if": + return If{} + case "else": + return Else{} + case "true": + return True{} + case "false": + return False{} + case "return": + return Return{} + case: + return Identifier{ident} + } +} |
