KCC - Kayte C Compiler 1.10.0
A C compiler implementation with preprocessor, lexer, parser, and code generator
Loading...
Searching...
No Matches
ast.h
1#ifndef AST_H
2#define AST_H
3
4#include "types.h"
5
6
7// AST creation functions
8ASTNode *ast_create_program(void);
9ASTNode *ast_create_function_decl(DataType return_type, const char *name, ASTNode **params, ASTNode *body);
10ASTNode *ast_create_var_decl(DataType var_type, const char *name, ASTNode *initializer);
11ASTNode *ast_create_parameter(DataType param_type, const char *name);
12ASTNode *ast_create_compound_stmt(void);
13ASTNode *ast_create_expression_stmt(ASTNode *expression);
14ASTNode *ast_create_return_stmt(ASTNode *expression);
15ASTNode *ast_create_if_stmt(ASTNode *condition, ASTNode *then_stmt, ASTNode *else_stmt);
16ASTNode *ast_create_while_stmt(ASTNode *condition, ASTNode *body);
17ASTNode *ast_create_for_stmt(ASTNode *init, ASTNode *condition, ASTNode *update, ASTNode *body);
18ASTNode *ast_create_break_stmt(void);
19ASTNode *ast_create_continue_stmt(void);
20ASTNode *ast_create_binary_expr(TokenType operator, ASTNode *left, ASTNode *right);
21ASTNode *ast_create_unary_expr(TokenType operator, ASTNode *operand);
22ASTNode *ast_create_call_expr(const char *function_name);
23ASTNode *ast_create_identifier(const char *name);
24ASTNode *ast_create_number(int value);
25ASTNode *ast_create_string(const char *value);
26ASTNode *ast_create_assignment(const char *variable, ASTNode *value);
27
28// AST manipulation functions
29void ast_add_declaration(ASTNode *program, ASTNode *declaration);
30void ast_add_parameter(ASTNode *function, ASTNode *parameter);
31void ast_add_statement(ASTNode *compound_stmt, ASTNode *statement);
32void ast_add_argument(ASTNode *call_expr, ASTNode *argument);
33
34// AST utility functions
35void ast_destroy(ASTNode *node);
36// In the ast.c header file
37void ast_print(ASTNode *node, int indent);
38const char *ast_node_type_to_string(ASTNodeType type);
39const char *data_type_to_string(DataType type);
40DataType token_to_data_type(TokenType token);
41
42#endif // AST_H
AST Node structure.
Definition types.h:333
Type definitions for KCC compiler with Objective-C support.
ASTNodeType
AST Node types.
Definition types.h:215
TokenType
Token types for lexical analysis.
Definition types.h:24
DataType
Data types supported by the compiler.
Definition types.h:193