diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ast.h | 14 | ||||
-rw-r--r-- | include/binop_type.h | 12 | ||||
-rw-r--r-- | include/tokenizer.h | 7 |
3 files changed, 30 insertions, 3 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 diff --git a/include/binop_type.h b/include/binop_type.h new file mode 100644 index 0000000..d04f9d7 --- /dev/null +++ b/include/binop_type.h @@ -0,0 +1,12 @@ +#ifndef AMALGAM_BINOP_TYPE_H +#define AMALGAM_BINOP_TYPE_H + +typedef enum { + BINOP_ADD, + BINOP_SUB, + BINOP_MUL, + BINOP_DIV, + BINOP_DOT +} BinopType; + +#endif
\ No newline at end of file diff --git a/include/tokenizer.h b/include/tokenizer.h index c58917f..21e93ee 100644 --- a/include/tokenizer.h +++ b/include/tokenizer.h @@ -3,6 +3,7 @@ #include "std/buffer_view.h" #include "std/misc.h" +#include "binop_type.h" #define TOKENIZER_OK 0 /* General error */ @@ -25,8 +26,9 @@ typedef enum { TOK_CLOSING_BRACE, TOK_IMPORT, TOK_NUMBER, - TOK_DOT, - TOK_SEMICOLON + TOK_SEMICOLON, + TOK_COLON, + TOK_BINOP } Token; typedef struct { @@ -47,6 +49,7 @@ typedef struct { BufferView string; i64 integer; f64 floating; + BinopType binop_type; } value; bool number_is_integer; } Tokenizer; |