Ruby 4.1.0dev (2026-10-27 revision ee55edef0d1f32704d7dfd37c935f9d2c8a55bb1)
node.h
Go to the documentation of this file.
1
6#ifndef PRISM_NODE_H
7#define PRISM_NODE_H
8
11
12#include "prism/ast.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
22#define PM_NODE_LIST_FOREACH(list, index, node) \
23 for (size_t index = 0; index < (list)->size && ((node) = (list)->nodes[index]); index++)
24
36
43PRISM_EXPORTED_FUNCTION const char * pm_node_type(pm_node_type_t node_type);
44
59
65typedef pm_visit_result_t (*pm_visit_callback_t)(const pm_node_t *node, void *data);
66
121
134
135#ifdef __cplusplus
136}
137#endif
138
139#endif
#define PRISM_EXPORTED_FUNCTION
By default, we compile with -fvisibility=hidden.
Definition exported.h:20
#define PRISM_NONNULL(...)
Mark the parameters of a function as non-null.
Definition nonnull.h:13
PRISM_EXPORTED_FUNCTION void pm_node_list_append(pm_arena_t *arena, pm_node_list_t *list, pm_node_t *node) PRISM_NONNULL(1
Append a node to the end of a node list.
pm_visit_result_t(* pm_visit_callback_t)(const pm_node_t *node, void *data)
A callback that is called for each node visited by pm_visit_node and pm_visit_child_nodes.
Definition node.h:65
PRISM_EXPORTED_FUNCTION bool pm_visit_node(const pm_node_t *node, pm_visit_callback_t visitor, void *data) PRISM_NONNULL(1)
Visit each of the nodes in this subtree using the given visitor callback.
Definition node.c:417
pm_visit_result_t
The value returned by a visitor callback, which determines where the walk goes next.
Definition node.h:49
@ PM_VISIT_SKIP
Continue the walk without visiting this node's children.
Definition node.h:51
@ PM_VISIT_STOP
End the walk without visiting any more nodes.
Definition node.h:57
@ PM_VISIT_DESCEND
Continue the walk by visiting this node's children.
Definition node.h:54
PRISM_EXPORTED_FUNCTION bool pm_visit_child_nodes(const pm_node_t *node, pm_visit_callback_t visitor, void *data) PRISM_NONNULL(1)
Visit the children of the given node with the given callback.
Definition node.c:430
A list of nodes in the source, most often used for lists of children.
Definition ast.h:592
This is the base structure that represents a node in the syntax tree.
Definition ast.h:1090