Function resolve_lexer
pub fn resolve_lexer(
spec: LexerSpec,
parser: ParserKind,
has_postlex: bool,
) -> Result<ResolvedLexer, FrontendError>Expand description
Resolve lexer='auto' and validate the parser×lexer pairing, in Lark’s
evaluation order:
autoresolves by parser: LALR→contextual; Earley →basicwhen a postlex is present, else →dynamic. An explicit spec passes through unchanged. Differs from Lark: Lark logs aninfonote for that Earley-with-postlex fallback; hyperlark has no logging facility, so it resolves silently.- postlex×dynamic: an explicit
dynamic/dynamic_completewith a postlex is aConfigurationError(“Can’t use postlex with a dynamic lexer. Use basic or contextual instead”). Fires before the matrix, for any parser (solalr+dynamic+postlex yields this, not the matrix message). Unreachable viaauto(Earley+postlex already resolved tobasic). - matrix: LALR
accepts
('basic', 'contextual'); Earley accepts('basic', 'dynamic', 'dynamic_complete'). A miss is aConfigurationErrorwith Lark’s"Parser %r does not support lexer %r, expected one of %s".
The dynamic×lexer_callbacks GrammarError is a separate, later check —
validate_dynamic_lexer_callbacks — because Lark raises it at Earley-parser
construction, after this resolution.