|
librdesc
|
The Right-Recursive Descent Parser. More...
#include <stdint.h>Go to the source code of this file.
Classes | |
| struct | rdesc |
| Right-recursive descent parser. More... | |
| struct | rdesc_token |
| terminal (token) object for context-free grammar More... | |
| struct | rdesc_nonterminal |
| nonterminal (syntatic variable) object for context-free grammar More... | |
| struct | rdesc_node |
| A node in the CST. More... | |
Macros | |
| #define | RDESC_VERSION_MAJOR 0 |
| major version | |
| #define | RDESC_VERSION_MINOR 1 |
| minor version | |
| #define | RDESC_VERSION_PATCH 0 |
| patch version | |
| #define | RDESC_VERSION_PRE_RELEASE "" |
| prerelase identifier | |
Typedefs | |
| typedef void(* | rdesc_tk_destroyer_func) (struct rdesc_token *) |
| Function pointer type for freeing tokens. | |
Enumerations | |
| enum | rdesc_result { RDESC_READY , RDESC_CONTINUE , RDESC_NOMATCH } |
| parsing status More... | |
Functions | |
| void | rdesc_init (struct rdesc *p, const struct rdesc_cfg *cfg) |
| Initializes a new parser. | |
| void | rdesc_destroy (struct rdesc *p) |
| Frees memory allocated by the parser and destroys the parser instance. | |
| void | rdesc_start (struct rdesc *p, int start_symbol) |
| Sets start symbol for the next match. | |
| void | rdesc_reset (struct rdesc *p, rdesc_tk_destroyer_func free_tk) |
| Resets parser and its state. | |
| enum rdesc_result | rdesc_pump (struct rdesc *p, struct rdesc_node **out, struct rdesc_token *incoming_tk) |
| Drives the parsing process, The Pump. | |
| void | rdesc_node_destroy (struct rdesc_node *n, rdesc_tk_destroyer_func free_tk) |
| Recursively destroys the node and its children. | |
The Right-Recursive Descent Parser.
| enum rdesc_result |
| void rdesc_destroy | ( | struct rdesc * | p | ) |
Frees memory allocated by the parser and destroys the parser instance.
| void rdesc_node_destroy | ( | struct rdesc_node * | n, |
| rdesc_tk_destroyer_func | free_tk | ||
| ) |
Recursively destroys the node and its children.
seminfo field in struct rdesc_token are not freed unless free_tk is set. | enum rdesc_result rdesc_pump | ( | struct rdesc * | p, |
| struct rdesc_node ** | out, | ||
| struct rdesc_token * | incoming_tk | ||
| ) |
Drives the parsing process, The Pump.
As the central engine of the parser, it consumes tokens from either the internal backtracking stack or the provided incoming_tk.
| p | Pointer to the parser instance. |
| out | Output pointer for the resulting CST node (if READY). |
| incoming_tk | Pointer to the next token to consume.
|
| void rdesc_reset | ( | struct rdesc * | p, |
| rdesc_tk_destroyer_func | free_tk | ||
| ) |
Resets parser and its state.
seminfo field in struct rdesc_token are not freed unless free_tk is set.