You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-6Lines changed: 3 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,8 +89,8 @@ Click on the type name in the following list to see more detailed documentation
89
89
-[`forest::tree`](docs/forest_tree.md) - a tree extracted from a graph
90
90
-[`tgf`](docs/tgf.md) - Tau Grammar Form parser - reads a grammar in TGF format from a string or a file. An alternative way to describe a grammar instead of creating it programatically.
91
91
-[`traverser`](docs/traverser.md) - struct for traversing and accessing rewriter trees
92
-
- rewriting - API for rewriting a resulting parse tree
93
-
- measure - simple struct for measuring time
92
+
-[`rewriting`](docs/rewriting.md) - API for rewriting a resulting parse tree
93
+
-[`measure`](docs/measure.md) - simple struct for measuring time
94
94
95
95
### Classes and structs usable for building command line interfaces
96
96
@@ -108,21 +108,18 @@ There are several areas covered by functions provided by this library
108
108
-[devhelpers](docs/devhelpers.md) - helper forest transformations to various formats (TML facts, TML rules, DOT) useful when developing a parser
109
109
110
110
111
-
<aname="tau-grammar-form"></a>
112
-
113
111
## TGF - Tau Grammar Form
114
112
115
113
TGF is an EBNF-based form to describe grammars. Specification of the form can be found on page [`Tau Grammar Form`](docs/tau_grammar_form.md)
116
114
117
115
118
-
<aname="tgf-tool"></a>
119
-
120
116
## TGF tool
121
117
122
118
This library comes with a CLI executable `tgf` which features viewing, testing and debugging grammars written in TGF and it can also generate a C++ code from TGF grammar which is then usable in a C++ project.
123
119
124
120
More detailed information about this CLI can be found on page [`TGF tool`](docs/tgf_tool.md)
`forest` is a structure which can contain multiple trees. Nodes can have multiple sets of children where more than one set represents splitting of trees meaning the part from root to the node is shared among all trees splitted.
10
10
11
-
It offers methods for traversal or tree or graph extractions.
11
+
It offers methods counting trees, traversal or tree or graph extractions.
12
12
13
-
`forest` is a generic structure since the type of nodes is templated.
13
+
`forest` is a generic structure since the type of nodes `NodeT`is templated.
14
14
15
15
### parse forest
16
16
17
-
This library uses `forest` to represent all parse trees parsed from a given input. Each `parser<C, T>::parse(...)` call produces a `forest` with a type `std::pair<lit<C, T>, std::array<size_t, 2>>` where `lit<C, T>` is a parsed literal and the array contains starting and ending position of a literal in an input string.
17
+
This library uses `forest` to represent all parse trees parsed from a given input. Each `parser<C, T>::parse(...)` call produces a `parser<C, T>::result` which contins a parsed forest (accessible with `get_forest()`). Parse nodes uses type (`NodeT`) `std::pair<lit<C, T>, std::array<size_t, 2>>` where `lit<C, T>` is a parsed literal and the array contains position span of a literal in an input string.
18
+
19
+
`parser` provides type [`pnode`](parser_pnode.md) for used as `NodeT` templated type and type `pforest` for a parse forest:
18
20
19
-
`parser` declares types `pnode` for a parse node and `pforest` for a parse forest:
if (f->detect_cycle(fg)) cout << "cycle detected\n";
103
-
else cout << "no cycles\n";
104
-
```
105
112
106
113
### bool traverse(...)
107
114
@@ -146,21 +153,21 @@ Traverses the whole forest.
146
153
147
154
`cb_ambig` is called after entering a node which splits into more than one tree. The node is passed as a first argument, a set of vectors of nodes is passed as a second argument representing sets of children nodes where each set member represents a different tree.
148
155
156
+
Example of a traversal printing nodes and ambiguities of a parsed forest
149
157
```
150
-
151
158
function print_node(ostream& os, parser<>::pnode& n) {
Replace each node with its immediate children, assuming its only one pack (unambigous) the caller to ensure the right order to avoid cyclic dependency if any. deletes from graph g as well. return true if any one of the nodes' replacement succeeds
Replaces node 'torep' in one pass with the given nodes 'replacement' everywhere in the forest and returns true if changed. Does not care if its recursive or cyclic, its caller's responsibility to ensure
0 commit comments