paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Data Fields
mp_ast_node Struct Reference

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...
 

Detailed Description

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).

Field Documentation

◆ id

int id

Corresponds to a token type, for example LESS_OR_EQUAL.

◆ children

struct mp_ast_node** children

Pointers to the child nodes (interior nodes only).

◆ sv

Leaf nodes only.

◆ @1

union { ... }

◆ num_children

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.


The documentation for this struct was generated from the following file: