Struct LossyTreeSink

Source
pub struct LossyTreeSink<'a> { /* private fields */ }
Expand description

Structure to convert events to a lossy syntax tree which does not preserve whitespace.

Implementations§

Source§

impl<'a> LossyTreeSink<'a>

Source

pub fn new(text: &'a str, tokens: &'a [Token]) -> Self

Source

pub fn with_offset( text: &'a str, tokens: &'a [Token], token_start: usize, ) -> Self

Make a new tree sink but start the sink at a specific token, this is used for making completed markers into AST nodes for rules which need them.

§Panics

Panics if the token start does not line up to a token’s start index or is out of bounds

Source

pub fn finish(self) -> (GreenNode, Vec<ParserError>)

Trait Implementations§

Source§

impl<'a> Debug for LossyTreeSink<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> TreeSink for LossyTreeSink<'a>

Source§

fn consume_multiple_tokens(&mut self, amount: u8, kind: SyntaxKind)

Consume multiple tokens and glue them into one kind
Source§

fn token(&mut self, kind: SyntaxKind)

Adds new token to the current branch.
Source§

fn start_node(&mut self, kind: SyntaxKind)

Start new branch and make it current.
Source§

fn finish_node(&mut self)

Finish current branch and restore previous branch as current.
Source§

fn errors(&mut self, errors: Vec<ParserError>)

Emit errors

Auto Trait Implementations§

§

impl<'a> Freeze for LossyTreeSink<'a>

§

impl<'a> RefUnwindSafe for LossyTreeSink<'a>

§

impl<'a> Send for LossyTreeSink<'a>

§

impl<'a> Sync for LossyTreeSink<'a>

§

impl<'a> Unpin for LossyTreeSink<'a>

§

impl<'a> !UnwindSafe for LossyTreeSink<'a>

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> Erasable for T

Source§

const ACK_1_1_0: bool = true

Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more
Source§

unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>

Unerase this erased pointer. Read more
Source§

fn erase(this: NonNull<Self>) -> NonNull<Erased>

Turn this erasable pointer into an erased pointer. 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.