summaryrefslogtreecommitdiff
path: root/consts.py
diff options
context:
space:
mode:
Diffstat (limited to 'consts.py')
-rw-r--r--consts.py33
1 files changed, 29 insertions, 4 deletions
diff --git a/consts.py b/consts.py
index 86a8eef..0a595c2 100644
--- a/consts.py
+++ b/consts.py
@@ -4,18 +4,43 @@ class State:
class TokenType:
(
- LEFT_PARENTHESIS, RIGHT_PARENTHESIS, NUMBER, OPERATOR, SEMICOLON, COMMA, SYMBOL, *_
+ LEFT_PARENTHESIS, RIGHT_PARENTHESIS,
+ LEFT_BRACE, RIGHT_BRACE,
+ NUMBER, OPERATOR, SYMBOL, KEYWORD, UNARY,
+ SEMICOLON, COMMA, EQUALS, *_
) = range(100)
-UNARY = "unary"
-FUNCALL = "funcall"
+class NodeType:
+ (
+ NUMBER, OPERATOR, SYMBOL, FUNCALL, UNARY, ASSIGNMENT, *_
+ ) = range(100)
+
+
+class Keyword:
+ LET, STRUCT, FN, RETURN, IF, ELSE, FOR, WHILE, CONTINUE, BREAK, *_ = range(100)
+
+
+keywords = {
+ "let": Keyword.LET, "struct": Keyword.STRUCT,
+ "fn": Keyword.FN, "return": Keyword.RETURN,
+ "if": Keyword.IF, "else": Keyword.ELSE,
+ "for": Keyword.FOR, "while": Keyword.WHILE, "continue": Keyword.CONTINUE, "break": Keyword.BREAK,
+}
+
+keywords_repr = {keywords[i]: i for i in keywords}
+
+types = [
+ "i8", "i16", "i32", "i64",
+ "f32", "f64",
+]
+
PRECEDENCE = {
"+": 10,
"-": 10,
"*": 20,
"^": 30,
- UNARY: 40,
+ NodeType.UNARY: 40,
}
OPERATOR_CHARS = "*+-/%&~^|#$.:<=>@"