Skip to contents

Build an Abstract Syntax Tree (AST)

tree_new()
Create a syntax tree
tree_rewrite()
Rewrite the tree with a list of replacements
tree_root()
Get the root of the syntax tree
node_kind()
Find the kind of a node
node_find() node_find_all()
Find node(s) matching a pattern
node_get_root()
Recover the tree root from a node
node_get_match() node_get_multiple_matches()
Get the match(es) from a meta-variable
node_matches() node_inside() node_has() node_precedes() node_follows()
Get more precise information on a node
node_is_leaf() node_is_named() node_is_named_leaf()
Get information on nodes
node_range() node_range_all()
Get the start and end positions of a node
node_text() node_text_all()
Extract the code corresponding to one or several nodes
node_parent() node_child() node_ancestors() node_children() node_next() node_next_all() node_prev() node_prev_all()
Navigate the tree

Modify the AST

node_replace() node_replace_all()
Change the code in the tree

Building rules

ast_rule()
Build a rule
pattern_rule()
Build a pattern rule
relational_rule()
Build a relational rule