6 #include "symbol_table.h"
16 struct AstNode
* parent
;
17 struct AstNode
* children
;
18 struct AstNode
* sibling
;
22 void (*visit_program
)(struct AstNode
*);
23 void (*visit_programdecl
)(struct AstNode
*);
24 void (*visit_vardecl_list
)(struct AstNode
*);
25 void (*visit_vardecl
)(struct AstNode
*);
26 void (*visit_identifier_list
)(struct AstNode
*);
27 void (*visit_identifier
)(struct AstNode
*);
28 void (*visit_procfunc_list
)(struct AstNode
*);
29 void (*visit_procedure
)(struct AstNode
*);
30 void (*visit_function
)(struct AstNode
*);
31 void (*visit_param_list
)(struct AstNode
*);
32 void (*visit_parameter
)(struct AstNode
*);
33 void (*visit_statement_list
)(struct AstNode
*);
34 void (*visit_print_stmt
)(struct AstNode
*);
35 void (*visit_assignment_stmt
)(struct AstNode
*);
36 void (*visit_if_stmt
)(struct AstNode
*);
37 void (*visit_while_stmt
)(struct AstNode
*);
38 void (*visit_for_stmt
)(struct AstNode
*);
39 void (*visit_rel_expr
)(struct AstNode
*);
40 void (*visit_add_expr
)(struct AstNode
*);
41 void (*visit_mul_expr
)(struct AstNode
*);
42 void (*visit_notfactor
)(struct AstNode
*);
43 void (*visit_call
)(struct AstNode
*);
44 void (*visit_callparam_list
)(struct AstNode
*);
45 void (*visit_literal
)(struct AstNode
*);
46 void (*close_group
)();
49 struct AstNode
*ast_node_new(const char* name
, int kind
, int type
,
50 int linenum
, Symbol
*symbol
);
51 void ast_node_destroy(struct AstNode
*self
);
53 void ast_node_add_child(struct AstNode
*self
, struct AstNode
*child
);
54 void ast_node_add_sibling(struct AstNode
*self
, struct AstNode
*sibling
);
55 void ast_node_accept(struct AstNode
*self
, Visitor
*visitor
);