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/defines.h"
10#include "prism/parser.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
27
35
43
50
58
66
116PRISM_EXPORTED_FUNCTION void pm_visit_node(const pm_node_t *node, bool (*visitor)(const pm_node_t *node, void *data), void *data);
117
127PRISM_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
uint16_t pm_node_type_t
This is the type of node embedded in the node struct.
Definition ast.h:1034
Macro definitions used throughout the prism library.
#define PRISM_EXPORTED_FUNCTION
By default, we compile with -fvisibility=hidden.
Definition defines.h:50
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:114
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:1534
void pm_node_list_free(pm_node_list_t *list)
Free the internal memory associated with the given node list.
Definition node.c:88
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:1544
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:65
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:1216
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:77
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:55
The parser used to parse Ruby source.
A wrapper around a contiguous block of allocated memory.
A list of nodes in the source, most often used for lists of children.
Definition ast.h:558
This is the base structure that represents a node in the syntax tree.
Definition ast.h:1069
This struct represents the overall parser.
Definition parser.h:640