compiler-lightning/include/ast.h
2025-02-03 18:35:31 +13:00

37 lines
854 B
C

#include <slibs/slibs.h>
#include <tokenizer.h>
#ifndef __AST_H__
#define __AST_H__
extern const char* ASTTypeText[];
typedef enum ASTType {
AST_PROGRAM,
AST_CALL_EXPRESSION,
AST_NUMBER_LITERAL,
AST_STRING_LITERAL,
AST_NONE
} ASTType;
typedef sl_vec(struct ASTNode) ASTVec;
typedef struct ASTNode {
ASTType type;
const char* name;
const char* value;
ASTVec body;
ASTVec params;
} ASTNode;
ASTNode ast_parse(TokenVec* tokens);
ASTNode ast_walk(TokenVec* tokens);
void ast_print(ASTNode node, int indent);
ASTNode ast_create_empty(ASTType type);
ASTNode ast_create_program(ASTVec body);
ASTNode ast_create_call_expression(const char* name, ASTVec params);
ASTNode ast_create_number_literal(const char* value);
ASTNode ast_create_string_literal(const char* value);
#endif