PrattParser

Struct PrattParser 

Source
pub struct PrattParser<L: Language> { /* private fields */ }
Expand description

Pratt parser: supports prefix/infix/postfix (postfix left for language layer special handling)

Implementations§

Source§

impl<L: Language> PrattParser<L>

Source

pub fn new() -> Self

Creates a new Pratt parser

Source

pub fn prefix( &mut self, op: L::SyntaxKind, info: OperatorInfo, node_kind: L::SyntaxKind, ) -> &mut Self

Registers a prefix operator

Source

pub fn infix( &mut self, op: L::SyntaxKind, info: OperatorInfo, node_kind: L::SyntaxKind, ) -> &mut Self

Registers an infix operator

Source

pub fn parse<S, F>( &self, state: &mut ParserState<'_, S, L>, min_bp: Precedence, primary: &F, ) -> Arc<GreenNode<L::SyntaxKind>>
where S: Source, F: Fn(&mut ParserState<'_, S, L>) -> Arc<GreenNode<L::SyntaxKind>>,

Parses expressions using the Pratt algorithm

  • min_bp: Minimum binding strength (precedence)
  • primary: Primary expression parser provided by language layer (includes parentheses, literals, identifiers, and high-binding suffixes like calls/fields)

Auto Trait Implementations§

§

impl<L> Freeze for PrattParser<L>

§

impl<L> RefUnwindSafe for PrattParser<L>

§

impl<L> Send for PrattParser<L>

§

impl<L> Sync for PrattParser<L>
where <L as Language>::SyntaxKind: Sync,

§

impl<L> Unpin for PrattParser<L>
where <L as Language>::SyntaxKind: Unpin,

§

impl<L> UnwindSafe for PrattParser<L>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,