implemented array subscript parsing

This commit is contained in:
Lorenzo Torres 2025-12-01 11:02:13 +01:00
parent 403b2b7161
commit c566f7d490
4 changed files with 25 additions and 4 deletions

5
lc.c
View file

@ -77,6 +77,11 @@ void print_ast(ast_node *node, int depth) {
print_ast(node->expr.binary.left, depth + 1);
print_ast(node->expr.binary.right, depth + 1);
break;
case NODE_ARRAY_SUBSCRIPT:
printf("Array subscript\n");
print_ast(node->expr.subscript.expr, depth + 1);
print_ast(node->expr.subscript.index, depth + 1);
break;
case NODE_UNARY:
printf("UnaryOp (%s)\n", get_uop_str(node->expr.unary.operator));
print_ast(node->expr.unary.right, depth + 1);