result is a structure returned by a parse call. It contains a parsed forest, input and provides means to extract parsed information, trees and input characters.
found contains true if the starting symbol was successfuly parsed over the whole input.
Otherwise it contains false.
If found is false, parse_error contains information why parsing failed.
Contains information how to shape a parsed tree when using get_shaped_forest_tree()
or get_shaped_bintree() methods.
Returns pointer to the parsed forest. In bintree parse mode the forest is built lazily on first call (recorded as reconstruct_forest in diagnostics).
Returns the parse tree as a bintree (tref). In forest parse mode the tree is extracted lazily on first call (reconstruct_bintree with extract graph, inline grammar, and extract tree2 substeps in diagnostics).
get_tree2() / get_tree2(const pnode& n) are aliases.
result provides two families of tree-access and shaping APIs, distinguished
by the tree representation they operate on:
| Family | Return type | Preferred naming | Legacy names (aliases) |
|---|---|---|---|
| Forest-tree | psptree |
*_forest_tree* |
get_trimmed_tree, get_shaped_tree, get_tree, inline_tree, etc. |
| Bintree | tref |
*_bintree* |
get_tree2, get_shaped_tree2, etc. |
Forest-tree methods work with the parse forest and return psptree (shared
pointer to ptree). Bintree methods work with a binary-tree representation
(tref) and are native when parse_options::tree_path == bintree_path (the
default).
All legacy names remain available as inline wrappers that delegate to the preferred implementations.
Legacy name: get_trimmed_tree (still available as an alias).
Transforms forest into a tree and applies trimming according to grammar options or shaping options provided as an argument.
It also transforms ambiguous nodes as children of __AMB__ nodes.
This is called by get_shaped_forest_tree().
psptree inline_forest_tree_nodes(const psptree& t, psptree& parent, const shaping_options opts) const;
Legacy name: inline_tree_nodes (still available as an alias).
Applies inlining to a tree (w/o tree paths) according to grammar options or shaping options provided as an argument.
This is called by inline_forest_tree().
Legacy name: inline_tree_paths (still available as an alias).
Applies tree paths inlining to a tree according to grammar options or shaping options provided as an argument.
This is called by inline_forest_tree().
Legacy name: inline_tree (still available as an alias).
Applies inlining to a tree according to grammar options or shaping options
provided as an argument. Calls inline_forest_tree_nodes() and
inline_forest_tree_paths().
This is called by get_shaped_forest_tree().
Legacy name: trim_children_terminals (still available as an alias).
Trims children terminals from a tree according to grammar options or shaping options provided as an argument.
This is called by get_shaped_forest_tree().
Legacy name: get_shaped_tree (still available as an alias).
Transforms forest into a tree and applies shaping according to grammar options or shaping options provided as an argument.
Legacy name: get_tree (still available as an alias).
Extracts the first parse tree from the parsed forest.
Legacy name: get_trimmed_tree2 (still available as an alias).
Trims a bintree according to grammar options or shaping options provided as an argument.
This is called by get_shaped_bintree().
Legacy name: inline_tree_nodes2 (still available as an alias).
Applies inlining to a bintree (w/o tree paths) according to grammar options or shaping options provided as an argument.
This is called by inline_bintree().
Legacy name: inline_tree_paths2 (still available as an alias).
Applies tree paths inlining to a bintree according to grammar options or shaping options provided as an argument.
This is called by inline_bintree().
Legacy name: inline_tree2 (still available as an alias).
Applies inlining to a bintree according to grammar options or shaping options
provided as an argument. Calls inline_bintree_nodes() and
inline_bintree_paths().
This is called by get_shaped_bintree().
Legacy name: trim_children_terminals2 (still available as an alias).
Trims children terminals from a bintree according to grammar options or shaping options provided as an argument.
This is called by get_shaped_bintree().
Legacy name: get_shaped_tree2 (still available as an alias).
Transforms forest into a bintree and applies shaping according to grammar
options or shaping options provided as an argument. If no tref argument is
given, uses get_bintree() to obtain the root.
true if input is good = stream is good or mmap is opened.
Returns the input as a string (input's char type, ie. C).
Read terminals from input (input's terminal type, ie. T).
Read terminals from input at position span of a provided node.
Reads terminals of a node and converts them to int. If the conversion fails or the int is out of range returns no value.
Returns true if the parse forest is ambiguous (contains more than one tree).
Returns true if the parse forest is not ambiguous (contains only a single tree).
Returns ambiguous nodes.
Prints ambiguous nodes.
Returns all nodes and edges of the forest. It is a pair of vectors of nodes and edges. edge is defined as a pair of node ids.
using node_edge = std::pair<pnode, pnode>;
using edges = std::vector<typename pforest::edge>;
using nodes_and_edges = std::pair<pnodes, edges>;
Removes all prefixed symbols from the whole graph by replacing them with their immediate children nodes.
Inlines nodes created by EBNF and binarize transformation prefixes.