Ruby: prism/node.h Source File

Ruby 3.4.8p72 (2025-12-17 revision 995b59f66677d44767ce9faac6957e5543617ff9)

node.h
Go to the documentation of this file.
1
6#ifndef PRISM_NODE_H
7#define PRISM_NODE_H
8
9#include "prism/defines.h"
10#include "prism/parser.h"
11#include "prism/util/pm_buffer.h"
12
17#define PM_NODE_LIST_FOREACH(list, index, node) \
18 for (size_t index = 0; index < (list)->size && ((node) = (list)->nodes[index]); index++)
19
26void pm_node_list_append(pm_node_list_t *list, pm_node_t *node);
27
34void pm_node_list_prepend(pm_node_list_t *list, pm_node_t *node);
35
42void pm_node_list_concat(pm_node_list_t *list, pm_node_list_t *other);
43
49void pm_node_list_free(pm_node_list_t *list);
50
57 PRISM_EXPORTED_FUNCTION void pm_node_destroy(pm_parser_t *parser, struct pm_node *node);
58
65 PRISM_EXPORTED_FUNCTION const char * pm_node_type_to_str(pm_node_type_t node_type);
66
116 PRISM_EXPORTED_FUNCTION void pm_visit_node(const pm_node_t *node, bool (*visitor)(const pm_node_t *node, void *data), void *data);
117
127 PRISM_EXPORTED_FUNCTION void pm_visit_child_nodes(const pm_node_t *node, bool (*visitor)(const pm_node_t *node, void *data), void *data);
128
129#endif
parser.h
The parser used to parse Ruby source.
pm_parser_t
struct pm_parser pm_parser_t
The parser used to parse Ruby source.
Definition parser.h:267
pm_buffer.h
A wrapper around a contiguous block of allocated memory.
defines.h
Macro definitions used throughout the prism library.
PRISM_EXPORTED_FUNCTION
#define PRISM_EXPORTED_FUNCTION
By default, we compile with -fvisibility=hidden.
Definition defines.h:53
pm_node_destroy
PRISM_EXPORTED_FUNCTION void pm_node_destroy(pm_parser_t *parser, struct pm_node *node)
Deallocate a node and all of its children.
Definition node.c:116
pm_visit_node
PRISM_EXPORTED_FUNCTION void pm_visit_node(const pm_node_t *node, bool(*visitor)(const pm_node_t *node, void *data), void *data)
Visit each of the nodes in this subtree using the given visitor callback.
Definition node.c:1536
pm_node_list_free
void pm_node_list_free(pm_node_list_t *list)
Free the internal memory associated with the given node list.
Definition node.c:90
pm_visit_child_nodes
PRISM_EXPORTED_FUNCTION void pm_visit_child_nodes(const pm_node_t *node, bool(*visitor)(const pm_node_t *node, void *data), void *data)
Visit the children of the given node with the given callback.
Definition node.c:1546
pm_node_list_prepend
void pm_node_list_prepend(pm_node_list_t *list, pm_node_t *node)
Prepend a new node onto the beginning of the node list.
Definition node.c:67
pm_node_type_to_str
PRISM_EXPORTED_FUNCTION const char * pm_node_type_to_str(pm_node_type_t node_type)
Returns a string representation of the given node type.
Definition node.c:1218
pm_node_list_concat
void pm_node_list_concat(pm_node_list_t *list, pm_node_list_t *other)
Concatenate the given node list onto the end of the other node list.
Definition node.c:79
pm_node_list_append
void pm_node_list_append(pm_node_list_t *list, pm_node_t *node)
Append a new node onto the end of the node list.
Definition node.c:57
pm_node
This is the base structure that represents a node in the syntax tree.
Definition ast.h:1068