diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-03-03 13:18:08 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | b3b0c807a75c4f854495b547d8e00a598979cbf6 (patch) | |
tree | e42017c2f5b87a939d103f48d5f90dd93193ebcc /include/ast.h | |
parent | 4c5ffb35d50d514e3df4788e7cf38245c0127883 (diff) |
Add arithmetic (binop) parsing
Diffstat (limited to 'include/ast.h')
-rw-r--r-- | include/ast.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/include/ast.h b/include/ast.h index fb0f275..05bb6ee 100644 --- a/include/ast.h +++ b/include/ast.h @@ -5,6 +5,7 @@ #include "std/buffer.h" #include "std/misc.h" #include "std/scoped_allocator.h" +#include "binop_type.h" typedef struct FunctionDecl FunctionDecl; typedef struct FunctionCall FunctionCall; @@ -13,6 +14,7 @@ typedef struct Import Import; typedef struct String String; typedef struct Variable Variable; typedef struct Number Number; +typedef struct Binop Binop; typedef union { FunctionDecl *func_decl; @@ -22,6 +24,7 @@ typedef union { String *string; Number *number; Variable *variable; + Binop *binop; } AstValue; typedef enum { @@ -32,7 +35,8 @@ typedef enum { AST_IMPORT, AST_STRING, AST_NUMBER, - AST_VARIABLE + AST_VARIABLE, + AST_BINOP } AstType; typedef struct { @@ -52,6 +56,7 @@ struct FunctionCall { struct LhsExpr { int isConst; + BufferView type_name; BufferView var_name; Ast rhs_expr; }; @@ -76,6 +81,12 @@ struct Variable { BufferView name; }; +struct Binop { + Ast lhs; + Ast rhs; + BinopType type; +}; + Ast ast_none(); CHECK_RESULT int funcdecl_init(FunctionDecl *self, ScopedAllocator *allocator); @@ -85,5 +96,6 @@ void lhsexpr_init(LhsExpr *self, int isConst, BufferView var_name); void import_init(Import *self, BufferView path); CHECK_RESULT int string_init(String *self, BufferView str); void number_init(Number *self, i64 value, bool is_integer); +void binop_init(Binop *self); #endif |