glr
GLR parser in Rust.
This crate is most useful when parsers need to be generated at runtime from context-free grammars that depend on user input. In other cases, the LALRPOP crate is likely to be more suitable.
Example
This example shows building a parser for the grammar
S → S S
S → a
S → ε
and using it to parse the input string a:
use ;
let grammar = Grammar ;
let table = new;
let = new
.parse
.ok_or?;
// The family of the root node is three alternative lists of children
let family: = root.family.collect;
// Either a single `a`;
assert_eq!;
// left-recursion; or
assert_eq!;
assert_eq!;
// right recursion.
assert_eq!;
assert_eq!;
Any one of the infinitely many derivation trees can be recovered by unwinding the cycles the right number of times.