Skip to main content

Crate trampoline_parser

Crate trampoline_parser 

Source
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::identify_memoization_candidates;
pub use prefix_factoring::BacktrackingSeverity;
pub use prefix_factoring::BacktrackingWarning;

Modules§

grammars
Grammar definitions
prefix_factoring
Automatic detection and rewriting of exponential backtracking patterns.

Structs§

AstConfig
Configuration for AST integration
AstConfigBuilder
Builder for AST configuration
CodeGenerator
Code generator
CombinatorIndex
Index of all combinators in the grammar
CompiledCapDef
Compiled capture definition for generated code
CompiledChoiceDef
Compiled choice definition for generated code
CompiledGrammar
Compiled grammar ready for code generation
CompiledInfixOp
Compiled infix operator
CompiledLookDef
Compiled lookahead definition (for NotFollowedBy and FollowedBy)
CompiledLoopDef
Compiled loop definition for generated code (used by ZeroOrMore and OneOrMore)
CompiledMapDef
Compiled mapped combinator definition
CompiledMemoDef
Compiled memoize definition
CompiledOptDef
Compiled optional definition for generated code
CompiledPrattDef
Compiled Pratt expression parser definition
CompiledPrefixOp
Compiled prefix operator
CompiledRuleDef
Compiled rule definition
CompiledSepByDef
Compiled separated-by definition
CompiledSeqDef
Compiled sequence definition for generated code
CompiledSkipDef
Compiled skip definition
CompiledTernaryOp
Compiled ternary operator
Grammar
Main grammar builder
InfixOp
Infix operator definition
PatternInfo
Information extracted from an operator pattern
PosInfo
Compact position info for Pratt parsing work items
PrattBuilder
Builder for Pratt parsing operators
PrattDef
Pratt parsing definition for expression parsing Pratt expression parser definition.
PrefixOp
Prefix operator definition
ResultVariant
A custom ParseResult variant for typed AST nodes
RuleBuilder
Builder for parser rules
RuleDef
A parser rule definition
TernaryOp
Ternary operator definition

Enums§

Assoc
Operator associativity for Pratt parsing
CharClass
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
CompiledPostfixOp
Compiled postfix operator
LeadingRuleContext
Leading rule context for Pratt work items
PostfixOp
Postfix operator definition
PostfixVariant
Postfix variant tag for work items
TernaryStage
Ternary stage for work items
ValidationError
Validation errors for grammar

Traits§

CombinatorExt
Extension trait for Combinator to add AST mapping
IntoCombinatorsVec
Trait for converting tuples to Vec

Functions§

validate_grammar
Validate a grammar and return any errors found

Type Aliases§

CapId
ChoiceId
LitId
LookId
LoopId
MapId
MemoId
OptId
PrattId
RuleId
ID types for indexing combinators in generated code. Using u16 to keep Work enum variants compact while supporting up to 65535 combinators.
SepById
SeqId
SkipId