summaryrefslogtreecommitdiff
path: root/src/compiler/ast-tree.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/ast-tree.h')
-rw-r--r--src/compiler/ast-tree.h29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/compiler/ast-tree.h b/src/compiler/ast-tree.h
index 758d113..23f0b9c 100644
--- a/src/compiler/ast-tree.h
+++ b/src/compiler/ast-tree.h
@@ -6,12 +6,11 @@
typedef enum AstTreeToken {
AST_TREE_TOKEN_FUNCTION,
AST_TREE_TOKEN_KEYWORD_PRINT,
+ AST_TREE_TOKEN_TYPE_FUNCTION,
+ AST_TREE_TOKEN_TYPE_VOID,
AST_TREE_TOKEN_NONE,
} AstTreeToken;
-typedef struct AstTreeType {
-} AstTreeType;
-
typedef struct AstTree {
AstTreeToken token;
void *metadata;
@@ -20,7 +19,7 @@ typedef struct AstTree {
typedef struct AstTreeVariable {
char *name_begin;
char *name_end;
- AstTreeType type;
+ AstTree *type;
AstTree *value;
} AstTreeVariable;
@@ -40,9 +39,22 @@ typedef struct AstTreeScope {
size_t expressions_size;
} AstTreeScope;
+typedef struct AstTreeFunction {
+ AstTreeVariable *arguments;
+ size_t arguments_size;
+ AstTreeScope scope;
+ AstTree *returnType;
+} AstTreeFunction;
+
+typedef struct AstTreeTypeFunction {
+ AstTree **arguments;
+ size_t arguments_size;
+ AstTree *returnType;
+} AstTreeTypeFunction;
+
extern const char *AST_TREE_TOKEN_STRINGS[];
-void astTreePrint(const AstTree *tree,int indent);
+void astTreePrint(const AstTree *tree, int indent);
void astTreeRootPrint(const AstTreeRoot *root);
void astTreeDestroy(AstTree tree);
@@ -62,3 +74,10 @@ AstTree *astTreeParse(ParserNode *parserNode, AstTreeVariables *variables,
AstTree *astTreeParseFunction(ParserNode *parserNode,
AstTreeVariables *variables,
size_t variables_size);
+
+AstTree *astTreeParseTypeFunction(ParserNode *parserNode,
+ AstTreeVariables *variables,
+ size_t variables_size);
+
+bool hasTypeOf(AstTree *value, AstTree *type);
+bool typeIsEqual(AstTree *type0, AstTree *type1);