added more AST elements

This commit is contained in:
Sven Vogel 2024-05-06 10:32:05 +02:00
parent c6d8651ab6
commit 03855c5ae6
1 changed files with 46 additions and 6 deletions

View File

@ -6,18 +6,58 @@
// Syntax elements which are stored in a syntax tree // Syntax elements which are stored in a syntax tree
enum AST_SyntaxElement_t { enum AST_SyntaxElement_t {
AST_Statement, AST_Stmt,
AST_Expression, AST_Expr,
AST_Branch, // Literals
AST_OperatorAdd, AST_Int,
AST_IntegerLiteral AST_Float,
AST_String,
// Control flow
AST_While,
AST_If,
AST_IfElse,
AST_Else,
// Variable management
AST_Decl,
AST_Assign,
AST_Def,
AST_Ident,
// Arithmetic operators
AST_Add,
AST_Sub,
AST_Mul,
AST_Div,
// Bitwise operators
AST_BitAnd,
AST_BitOr,
AST_BitXor,
AST_BitNot,
// Boolean operators
AST_BoolAnd,
AST_BoolOr,
AST_BoolXor,
AST_BoolNot,
// Logical operators
AST_Eq,
AST_Greater,
AST_Less,
// Casts
AST_Typecast, // type cast
AST_Transmute, // reinterpret cast
AST_Call, // function call
AST_Macro, // builtin functions: lineno(), filename(), ...
// Defintions
AST_Typedef,
AST_Box,
AST_Fun,
AST_Import
}; };
struct AST_Node_t { struct AST_Node_t {
// parent node that owns this node // parent node that owns this node
struct AST_Node_t *parent; struct AST_Node_t *parent;
// type of AST node: if, declration, ... // type of AST node: if, declaration, ...
enum AST_SyntaxElement_t kind; enum AST_SyntaxElement_t kind;
// optional value: integer literal, string literal, ... // optional value: integer literal, string literal, ...
const char* value; const char* value;