summaryrefslogtreecommitdiff
path: root/src/ast.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast.h')
-rw-r--r--src/ast.h25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/ast.h b/src/ast.h
index fab90c1..1c4bbb8 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -29,7 +29,7 @@ typedef struct ast_visitor_t ast_visitor_t;
typedef struct ast_node_t ast_node_t;
typedef struct ast_return_stmt_t {
- uint32_t number;
+ ast_node_t* argument;
} ast_return_stmt_t;
typedef struct ast_function_declaration_t {
@@ -38,19 +38,35 @@ typedef struct ast_function_declaration_t {
ast_node_t* body;
} ast_function_declaration_t;
+typedef enum {
+ AST_LITERAL_INTEGER
+} ast_literal_kind_t;
+
+typedef union {
+ uint32_t integer;
+} ast_literal_value_t;
+
+typedef struct ast_literal_t {
+ ast_literal_kind_t kind;
+ ast_literal_value_t value;
+} ast_literal_t;
+
typedef struct ast_visitor_t {
void (*visit_function)(struct ast_visitor_t *, ast_function_declaration_t *);
void (*visit_return_stmt)(struct ast_visitor_t *, ast_return_stmt_t *);
+ void (*visit_literal)(struct ast_visitor_t *, ast_literal_t *);
} ast_visitor_t;
typedef enum {
- AST_UNKOWN_NODE,
AST_FUNCTION_DECLARATION,
- AST_RETURN_STMT
+ AST_LITERAL,
+ AST_RETURN_STMT,
+ AST_UNKOWN_NODE
} ast_node_kind_t;
typedef union {
ast_function_declaration_t function;
+ ast_literal_t literal;
ast_return_stmt_t return_stmt;
} ast_node_data_t;
@@ -66,7 +82,8 @@ ast_node_t* ast_node_new();
void ast_node_destroy(ast_node_t *node);
void ast_node_init_function_declaration(ast_node_t* node, string_view_t name, type_t return_type, ast_node_t *body);
-void ast_node_init_return_stmt(ast_node_t* node, uint32_t number);
+void ast_node_init_return_stmt(ast_node_t* node, ast_node_t *argument);
+void ast_literal_integer_create(ast_node_t* node, uint32_t number);
#endif /* AST_H */