Prism Ruby parser
Loading...
Searching...
No Matches
node.h
Go to the documentation of this file.
1
6#ifndef PRISM_NODE_H
7#define PRISM_NODE_H
8
9#include "prism/compiler/exported.h"
10#include "prism/compiler/nonnull.h"
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
35PRISM_EXPORTED_FUNCTION void pm_node_list_append(pm_arena_t *arena, pm_node_list_t *list, pm_node_t *node) PRISM_NONNULL(1, 2, 3);
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
120PRISM_EXPORTED_FUNCTION bool pm_visit_node(const pm_node_t *node, pm_visit_callback_t visitor, void *data) PRISM_NONNULL(1);
121
133PRISM_EXPORTED_FUNCTION bool pm_visit_child_nodes(const pm_node_t *node, pm_visit_callback_t visitor, void *data) PRISM_NONNULL(1);
134
135#ifdef __cplusplus
136}
137#endif
138
139#endif
struct pm_arena_t pm_arena_t
An opaque pointer to an arena that is used for allocations.
Definition arena.h:22
The abstract syntax tree.
pm_node_type
This enum represents every type of node in the Ruby syntax tree.
Definition ast.h:611
uint16_t pm_node_type_t
This is the type of node embedded in the node struct.
Definition ast.h:1076
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.
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.
A list of nodes in the source, most often used for lists of children.
Definition ast.h:597
This is the base structure that represents a node in the syntax tree.
Definition ast.h:1095