|
librdesc
|
Macros for accessing fields of node structs. More...
#include "detail.h"#include <stddef.h>Go to the source code of this file.
Macros | |
| #define | rparent(p, node) _rdesc_priv_cst_illegal_access(p, _rdesc_priv_parent_idx(node)) |
Returns parent of the node, or NULL if the node is root. | |
| #define | rtype(node) _rdesc_priv_node_deref(node).n.ty |
| Returns node type (RDESC_TOKEN or RDESC_NONTERMINAL). | |
| #define | rid(node) _rdesc_priv_node_deref(node).n.nt.id |
| Returns the 15-bit identifier for underlying token/nonterminal. | |
| #define | ralt_idx(nt_node) _rdesc_priv_node_deref(nt_node).n.nt.alt_idx |
| Returns index of the nonterminal alternative in production rule. | |
| #define | ralt_id(nt_node) ralt_idx(nt_node) |
| Deprecated. | |
| #define | rseminfo(tk_node) ((void *) &_rdesc_priv_node_deref(tk_node).n.tk.seminfo) |
| Returns a reference to the token's seminfo field. | |
| #define | rchild_count(nt_node) _rdesc_priv_node_deref(nt_node).n.nt.child_count |
| Returns number of the child nodes. | |
| #define | rchild(p, nt_node, child_idx) _rdesc_priv_cst_illegal_access(p, _rdesc_priv_child_idx(nt_node, child_idx)) |
| Returns child of the node by its index. | |
Macros for accessing fields of node structs.
The parser returns opaque CST node pointers that hide memory layout details. This header provides macros to safely access node fields despite the optimized, compact memory representation.
This header undefines its own macros if it is included a second time. You can re-include this header at the end of your file to keep the macro namespace clean and prevent polluting other headers.
Definition in file cst_macros.h.
| #define ralt_id | ( | nt_node | ) | ralt_idx(nt_node) |
| #define ralt_idx | ( | nt_node | ) | _rdesc_priv_node_deref(nt_node).n.nt.alt_idx |
Returns index of the nonterminal alternative in production rule.
Available only for nonterminals.
Definition at line 84 of file cst_macros.h.
| #define rchild | ( | p, | |
| nt_node, | |||
| child_idx | |||
| ) | _rdesc_priv_cst_illegal_access(p, _rdesc_priv_child_idx(nt_node, child_idx)) |
Returns child of the node by its index.
Available only for nonterminals.
Definition at line 115 of file cst_macros.h.
| #define rchild_count | ( | nt_node | ) | _rdesc_priv_node_deref(nt_node).n.nt.child_count |
Returns number of the child nodes.
Available only for nonterminals.
Definition at line 107 of file cst_macros.h.
| #define rid | ( | node | ) | _rdesc_priv_node_deref(node).n.nt.id |
Returns the 15-bit identifier for underlying token/nonterminal.
Can be used both for tokens and nonterminals.
Definition at line 77 of file cst_macros.h.
| #define rparent | ( | p, | |
| node | |||
| ) | _rdesc_priv_cst_illegal_access(p, _rdesc_priv_parent_idx(node)) |
Returns parent of the node, or NULL if the node is root.
Can be used both for tokens and nonterminals.
Definition at line 60 of file cst_macros.h.
| #define rseminfo | ( | tk_node | ) | ((void *) &_rdesc_priv_node_deref(tk_node).n.tk.seminfo) |
Returns a reference to the token's seminfo field.
Available only for tokens.
Definition at line 99 of file cst_macros.h.
| #define rtype | ( | node | ) | _rdesc_priv_node_deref(node).n.ty |
Returns node type (RDESC_TOKEN or RDESC_NONTERMINAL).
Can be used both for tokens and nonterminals.
enum rdesc_grammar_symbol_type Definition at line 70 of file cst_macros.h.