summaryrefslogtreecommitdiff
path: root/src/ast.h
diff options
context:
space:
mode:
authorJohnny Richard <johnny@johnnyrichard.com>2023-04-21 15:11:17 +0200
committerCarlos Maniero <carlosmaniero@gmail.com>2023-04-21 10:29:41 -0300
commitd86d70fc7c6751713a6b9f02d9f77814e2f75718 (patch)
tree15340e4f421628fa79461374c39407997f928d93 /src/ast.h
parent562fa8785f9bc3074e8b2acf524f4120add22752 (diff)
parser: Parse integers arithmetic expression
This patch implements the AST creation for arithmetic expressions. NOTE: The implementation works only for integer numbers. Signed-off-by: Johnny Richard <johnny@johnnyrichard.com> Reviewed-by: Carlos Maniero <carlosmaniero@gmail.com>
Diffstat (limited to 'src/ast.h')
-rw-r--r--src/ast.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ast.h b/src/ast.h
index 1c4bbb8..cb9b8d5 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -38,6 +38,13 @@ typedef struct ast_function_declaration_t {
ast_node_t* body;
} ast_function_declaration_t;
+typedef struct ast_binary_operation_t {
+ // FIXME: We want to use enum to distinguish operators
+ string_view_t op;
+ ast_node_t* left;
+ ast_node_t* right;
+} ast_binary_operation_t;
+
typedef enum {
AST_LITERAL_INTEGER
} ast_literal_kind_t;
@@ -59,6 +66,7 @@ typedef struct ast_visitor_t {
typedef enum {
AST_FUNCTION_DECLARATION,
+ AST_BINARY_OPERATION,
AST_LITERAL,
AST_RETURN_STMT,
AST_UNKOWN_NODE
@@ -66,6 +74,7 @@ typedef enum {
typedef union {
ast_function_declaration_t function;
+ ast_binary_operation_t binary_operation;
ast_literal_t literal;
ast_return_stmt_t return_stmt;
} ast_node_data_t;