Skip to main content

Crate rhue_parser

Crate rhue_parser 

Source
Expand description

Rhue’s parser. Hand-written recursive descent for statements, Pratt parsing for expressions.

This is part of Rhue’s guts. If you’re embedding Rhue, use the rhue crate, that’s the API that stays stable.

It recovers from errors at statement boundaries, so one run can report a bunch of separate mistakes.

Modules§

ast

Constants§

MAX_DEPTH
Max nesting (recursion plus left-associative operator chains) before the parser gives up, so hostile input can’t build an endlessly deep tree.
MAX_ERRORS
Stop collecting after this many errors, the later ones are usually cascades anyway.

Functions§

parse_chunk
Parses a whole chunk (a file or Engine::eval source). On failure you get every error it found (up to MAX_ERRORS), in source order.
parse_expr
Parses one expression and wraps it as return <expr> so it goes through the same pipeline as a chunk (REPL / eval_expr).
parse_type
Parses a type by itself ((number, string) -> boolean), the way host declarations and definition strings are written.