lang: add user args to ast iterator; combine pre/post-order traversal modes

the caller can now provide a pointer arg to ivy_ast_node_iterate, which will
be forwarded to the specified callback function each time it is called.

the iterator now behaves similarly to fts, in that it visits each node
in both pre-order and post-order, and indicates to the callback whether
the current iteration is pre- or post-order.
This commit is contained in:
2025-04-14 12:24:42 +01:00
parent 7a9fc1b11c
commit 80e001cdc1
3 changed files with 63 additions and 15 deletions

View File

@@ -1,6 +1,9 @@
#ifndef _AST_ITERATE_H_
#define _AST_ITERATE_H_
struct ivy_ast_node_iterator;
struct ivy_ast_node;
extern void ast_node_iterator_enqueue_node(
struct ivy_ast_node_iterator *it, struct ivy_ast_node *parent,
struct ivy_ast_node *node);