aboutsummaryrefslogtreecommitdiff
path: root/ast.h
diff options
context:
space:
mode:
Diffstat (limited to 'ast.h')
-rw-r--r--ast.h37
1 files changed, 33 insertions, 4 deletions
diff --git a/ast.h b/ast.h
index f6db7da..d438b92 100644
--- a/ast.h
+++ b/ast.h
@@ -1,7 +1,17 @@
-typedef struct {
+#ifndef AST_H
+#define AST_H
+
+#define EXP_POSTFIX 1024
+#define POSTFIX_ARR 1025
+#define POSTFIX_CALL 1026
+#define POSTFIX_DOT 1027
+#define POSTFIX_PTR 1028
+#define EXP_CAST 1029
+
+typedef struct CNode {
enum {
/* Top Level */
- PROG = 1024, FUNC_DEF, PARAMS,
+ PROG, FUNC_DEF, PARAMS,
DECL, /* declaration */
DECLR, /* declarator */
DECLRS,
@@ -18,11 +28,17 @@ typedef struct {
CONT_STMT , BREAK_STMT, RET_STMT, /* 'continue', 'break', 'return' */
/* Expressions (expressions use their token ID to denote their types */
- EXP
+ EXP,
+ TYPE_NAME,
+ ID, /* identifier */
+ INT, /* INT_CONST */
+ CHAR,
+ STR
} type;
union {
int intval;
- char *strvar;
+ int subtype;
+ char *strval;
} rec;
struct CNode *chd, *next;
/* For error reporting */
@@ -30,3 +46,16 @@ typedef struct {
int row, col;
} loc;
} CNode;
+
+CNode *cnode_create_exp(int exp_type, int pnum, ...);
+CNode *cnode_create_type_spec(int spec_type, int pnum, ...);
+CNode *cnode_append(CNode *node, CNode *tail);
+CNode *cnode_create_identifier(char *val);
+CNode *cnode_create_int_const(int val);
+CNode *cnode_create_char_const(int val);
+CNode *cnode_create_str_const(char *val);
+CNode *cnode_debug_print(CNode *ast);
+
+extern CNode *ast_root;
+
+#endif