Skip to main content

ParseBackend

Trait ParseBackend 

Source
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§

Source

fn name(&self) -> &'static str

Human-readable backend name (e.g. "antlr4rust").

Source

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_tape such that reconstruct(tape) == input byte-for-byte (the lossless round-trip property).
  • MUST emit at least one diagnostic per syntax error encountered.
  • MUST set recovered = true if recovery was used.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§