Expand description
Rustlr is an LR-style parser generator for Rust. Advanced features include:
-
Option to automatically generate the AST datatypes and semantic actions, with manual overrides possible. Rustlr’s grammar format contains a sublanguage that controls how ASTS are created, so that the generated types do not necessarily reflect the format of the grammar.
-
Option to use bumpalo to create ASTS types that enable nested pattern matching against recursive types.
-
Recognizes regex-style operators
*
,+
and?
, which simplify the writing of grammars and allow better ASTs to be created. -
An experimental feature that recognizes Selective Marcus-Leermakers grammars. This is a class of unambiguous grammars that’s larger than traditional LR grammars. They are especially helpful in avoiding conflicts when new production rules are added to a grammar.
-
The ability to train the parser interactively for better error reporting
-
Also generates parsers for F# and other .Net languages
A tutorial is separately available that will explain the format of grammars and how to generate and deploy parsers for several examples. The documentation found here should be used as a technical reference.
Rustlr should be installed as an executable (cargo install rustlr), although parser generation can also be invoked with the rustle function. Many of the items exported by this crate are only required by the parsers that are generated, and are not intended to be used in other programs. However, rustlr uses traits and trait objects to loosely couple the various components of the runtime parser so that custom interfaces, such as those for graphical IDEs, can built around a basic ZCParser::parse_core function.
Re-exports
pub use runtime_parser::RuntimeParser;
pub use runtime_parser::RProduction;
pub use zc_parser::ZCParser;
pub use zc_parser::ZCRProduction;
pub use lexer_interface::*;
pub use generic_absyn::*;
Modules
Macros
LBox<dyn Any>
to LBox<A>
for some
concrete type A. Must be called
from within the semantic actions of grammar productions. Warning:
unwrap is called within the macroLBox<dyn Any>
structures that can encapsulate any type
as abstract syntax. Must be called from within the semantic actions of
a grammar production rule.