Skip to main content

Postlex

Trait Postlex 

pub trait Postlex: Send + Sync {
    // Required methods
    fn session(
        &self,
        names: &[String],
    ) -> Result<Box<dyn PostlexStream>, PostlexError>;
    fn always_accept(&self) -> Vec<String>;
}
Expand description

A postlex configuration — the factory for per-parse sessions plus the always_accept names the contextual lexer unions into every state and the compiler threads into terminal pruning.

Required Methods§

fn session( &self, names: &[String], ) -> Result<Box<dyn PostlexStream>, PostlexError>

Start a session for one lex pass. names is the terminal-name table indexed by TokenId (the session resolves its configured names once). An unknown nl/indent/dedent name is a PostlexError (they are emitted or consumed, so they must exist); unknown paren names are dropped — Lark treats the paren types as matched-only string sets (Lark parity).

names should be the parse table’s id_to_token, not a lexer-local subset: a session may index it by TokenId directly (the indenter’s paren table does). Ids past the end must stay tolerable rather than fatal — Earley’s custom-source arm deliberately mints sentinel ids beyond the table for unknown type names and feeds them through — so treat an out-of-range id as carrying no per-id configuration, never as a panic.

fn always_accept(&self) -> Vec<String>

Terminal names accepted in every parser state (indenter: [NL_type]).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§