Skip to main content

ShapeExprParser

Trait ShapeExprParser 

Source
pub trait ShapeExprParser: Send + Sync {
    // Required methods
    fn label(&self) -> &str;
    fn parse_expr(&self, source: &str) -> Result<Expr>;

    // Provided method
    fn is_effectful(&self) -> bool { ... }
}
Expand description

A parser that turns shape source text into an Expr for PrattShape.

Implementations plug a concrete grammar (the codec layer, not the kernel) into shape matching; parse_expr should report a parse failure as Error::Eval so the shape rejects rather than aborts.

Required Methods§

Source

fn label(&self) -> &str

A short human-readable name for this parser, shown in shape descriptions.

Source

fn parse_expr(&self, source: &str) -> Result<Expr>

Parse source text into an expression to match against the inner shape.

Provided Methods§

Source

fn is_effectful(&self) -> bool

Whether parsing may run effects; false by default.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§