Parser

Trait Parser 

Source
pub trait Parser<L: Language> {
    // Required method
    fn parse_incremental(
        &self,
        text: impl Source,
        changed: usize,
        cache: IncrementalCache<'_, L>,
    ) -> ParseOutput<L>;

    // Provided method
    fn parse(&self, text: impl Source) -> ParseOutput<L> { ... }
}
Expand description

Parser trait for converting tokens into kind trees.

This trait provides a unified interface for parsing source text into green kind trees, supporting both full parsing and incremental updates.

Required Methods§

Source

fn parse_incremental( &self, text: impl Source, changed: usize, cache: IncrementalCache<'_, L>, ) -> ParseOutput<L>

Parses source text incrementally using an existing cache.

This method enables efficient re-parsing by reusing information from previous parsing operations, only processing the changed portions of the source text.

§Arguments
  • text - The source text to parse
  • changed - The number of bytes that have changed since the last parse
  • cache - The incremental cache containing previous parsing results
§Returns

A parse output containing either the green kind tree or errors

Provided Methods§

Source

fn parse(&self, text: impl Source) -> ParseOutput<L>

Parses source text into a kind tree.

This method performs a full parse of the source text, creating a new kind tree from scratch. It uses a default cache configuration.

§Arguments
  • text - The source text to parse
§Returns

A parse output containing either the green kind tree or errors

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§