aboutsummaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
authorMustafa Quraish <[email protected]>2022-02-02 19:22:15 -0500
committerMustafa Quraish <[email protected]>2022-02-02 19:22:15 -0500
commite2dbc82213a6e5da74de2220eeeab78da41fb519 (patch)
tree7f6d9a40fde00ec761e100a92bd93f555725d56c /src/ast.c
parentMove type-related stuff to a separate file (diff)
downloadcup-e2dbc82213a6e5da74de2220eeeab78da41fb519.tar.xz
cup-e2dbc82213a6e5da74de2220eeeab78da41fb519.zip
Add initial support for arrays (also no testing)
Usual disclaimer at this point: Quick&Dirty implementation, hasn't been tested other than basic sanity checks. Arrays are automatically decayed into pointers when the identifier is accessed.
Diffstat (limited to 'src/ast.c')
-rw-r--r--src/ast.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ast.c b/src/ast.c
index 3eaaf61..f75e531 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -129,6 +129,12 @@ static void do_print_ast(Node *node, int depth)
for (int i = 0; i < node->block.num_children; i++) {
do_print_ast(node->block.children[i], depth);
}
+ } else if (node->type == OP_DEREF) {
+ printf("DEREF\n");
+ do_print_ast(node->unary_expr, depth + 1);
+ } else if (node->type == OP_ADDROF) {
+ printf("ADDROF\n");
+ do_print_ast(node->unary_expr, depth + 1);
} else if (node->type == AST_BLOCK) {
printf("{\n");
for (int i = 0; i < node->block.num_children; i++) {