RustQ.Rust.AST.Walk (rustq v0.9.2)

Copy Markdown View Source

Generic traversal helpers for RustQ AST nodes.

Traversal is driven by RustQ AST node structs, so passes do not need to hand-maintain structural recursion every time a node gains a field.

Summary

Functions

Returns true when term is one of RustQ's schema-backed AST nodes.

Walks an AST tree in post-order, applying fun after children are visited.

Walks an AST tree in pre-order, applying fun before children are visited.

Reduces an AST tree in pre-order.

Types

ast_node()

@type ast_node() :: struct()

Functions

node?(arg1)

@spec node?(term()) :: boolean()

Returns true when term is one of RustQ's schema-backed AST nodes.

postwalk(term, fun)

@spec postwalk(term(), (term() -> term())) :: term()

Walks an AST tree in post-order, applying fun after children are visited.

prewalk(term, fun)

@spec prewalk(term(), (term() -> term())) :: term()

Walks an AST tree in pre-order, applying fun before children are visited.

reduce(term, acc, fun)

@spec reduce(term(), acc, (term(), acc -> acc)) :: acc when acc: term()

Reduces an AST tree in pre-order.