Expand description
Trampoline Parser Generator
A DSL for generating fully trampoline-based scannerless parsers.
§Example
use trampoline_parser::Grammar;
let grammar = Grammar::new()
.rule("number", |r| {
r.capture(r.one_or_more(r.digit()))
})
.rule("expr", |r| {
r.sequence((
r.parse("number"),
r.lit("+"),
r.parse("number"),
))
})
.build();
let code = grammar.generate();Re-exports§
pub use prefix_factoring::BacktrackingSeverity;pub use prefix_factoring::BacktrackingWarning;pub use prefix_factoring::identify_memoization_candidates;
Modules§
- grammars
- Grammar definitions
- prefix_
factoring - Automatic detection and rewriting of exponential backtracking patterns.
Structs§
- AstConfig
- Configuration for AST integration
- AstConfig
Builder - Builder for AST configuration
- Code
Generator - Code generator
- Combinator
Index - Index of all combinators in the grammar
- Compiled
CapDef - Compiled capture definition for generated code
- Compiled
Choice Def - Compiled choice definition for generated code
- Compiled
Grammar - Compiled grammar ready for code generation
- Compiled
Infix Op - Compiled infix operator
- Compiled
Look Def - Compiled lookahead definition (for NotFollowedBy and FollowedBy)
- Compiled
Loop Def - Compiled loop definition for generated code (used by ZeroOrMore and OneOrMore)
- Compiled
MapDef - Compiled mapped combinator definition
- Compiled
Memo Def - Compiled memoize definition
- Compiled
OptDef - Compiled optional definition for generated code
- Compiled
Pratt Def - Compiled Pratt expression parser definition
- Compiled
Prefix Op - Compiled prefix operator
- Compiled
Rule Def - Compiled rule definition
- Compiled
SepBy Def - Compiled separated-by definition
- Compiled
SeqDef - Compiled sequence definition for generated code
- Compiled
Skip Def - Compiled skip definition
- Compiled
Ternary Op - Compiled ternary operator
- Grammar
- Main grammar builder
- InfixOp
- Infix operator definition
- Pattern
Info - Information extracted from an operator pattern
- PosInfo
- Compact position info for Pratt parsing work items
- Pratt
Builder - Builder for Pratt parsing operators
- Pratt
Def - Pratt parsing definition for expression parsing Pratt expression parser definition.
- Prefix
Op - Prefix operator definition
- Result
Variant - A custom ParseResult variant for typed AST nodes
- Rule
Builder - Builder for parser rules
- RuleDef
- A parser rule definition
- Ternary
Op - Ternary operator definition
- Token
Stream - An abstract stream of tokens, or more concretely a sequence of token trees.
Enums§
- Assoc
- Operator associativity for Pratt parsing
- Char
Class - Built-in character classes
- CombRef
- Reference to a combinator by its type and index. Used in generated static tables to reference child combinators.
- Combinator
- Parser combinators for scannerless parsing
- Compiled
Postfix Op - Compiled postfix operator
- Leading
Rule Context - Leading rule context for Pratt work items
- Postfix
Op - Postfix operator definition
- Postfix
Variant - Postfix variant tag for work items
- Ternary
Stage - Ternary stage for work items
- Validation
Error - Validation errors for grammar
Traits§
- Combinator
Ext - Extension trait for Combinator to add AST mapping
- Into
Combinators Vec - Trait for converting tuples to Vec
Functions§
- validate_
grammar - Validate a grammar and return any errors found