Paraslash Audio Streaming | |
About News Download Documentation Development |
Describes one node of the abstract syntax tree. More...
#include <mp.h>
Data Fields | |
int | id |
Corresponds to a token type, for example LESS_OR_EQUAL. More... | |
union { | |
struct mp_ast_node ** children | |
Pointers to the child nodes (interior nodes only). More... | |
union mp_semantic_value sv | |
Leaf nodes only. More... | |
}; | |
uint8_t | num_children |
The number of children is implicitly given by the id, but we include it here to avoid having to maintain a lookup table. More... | |
Describes one node of the abstract syntax tree.
A node is either interior or a leaf node. Interior nodes have at least one child while leaf nodes have a semantic value and no children.
Examples: (a) STRING_LITERAL has a semantic value (the unescaped string literal) and no children, (b) NEG (unary minus) has no semantic value but one child (the numeric expression that is to be negated), (c) LESS_OR_EQUAL has no semantic value and two children (the two numeric expressions being compared).
int id |
Corresponds to a token type, for example LESS_OR_EQUAL.
struct mp_ast_node** children |
Pointers to the child nodes (interior nodes only).
union mp_semantic_value sv |
Leaf nodes only.
union { ... } |
uint8_t num_children |
The number of children is implicitly given by the id, but we include it here to avoid having to maintain a lookup table.
The AST is usually small, so we can afford to waste a byte per node.