pub trait ParseBackend: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn parse(
&self,
input: &str,
file_id: FileId,
opts: &ParseOptions,
) -> BackendParseResult;
}Expand description
Backend-independent parser interface (R2 / R20).
Parser backends implement this trait behind the R20 isolation boundary. Backend-internal types (ANTLR parse trees, grammar rule names) are strictly private to the implementing crate.
The conformance test suite in tests/conformance.rs validates that all
backends behave identically on a canonical fixture set.
Required Methods§
Sourcefn parse(
&self,
input: &str,
file_id: FileId,
opts: &ParseOptions,
) -> BackendParseResult
fn parse( &self, input: &str, file_id: FileId, opts: &ParseOptions, ) -> BackendParseResult
Parse the given source text and return a BackendParseResult.
§Contract
- MUST NOT panic on any input (adversarial or otherwise).
- MUST populate
cst.token_tapesuch thatreconstruct(tape) == inputbyte-for-byte (the lossless round-trip property). - MUST emit at least one diagnostic per syntax error encountered.
- MUST set
recovered = trueif recovery was used.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".