parser

Struct Input

source
pub struct Input { /* private fields */ }
Expand description

Input for the parser – a sequence of tokens.

As of now, parser doesn’t have access to the text of the tokens, and makes decisions based solely on their classification. Unlike LexerToken, the Tokens doesn’t include whitespace and comments. Main input to the parser.

Struct of arrays internally, but this shouldn’t really matter.

Implementations§

source§

impl Input

pub impl used by callers to create Tokens.

source

pub fn push(&mut self, kind: SyntaxKind)

source

pub fn push_ident(&mut self, contextual_kind: SyntaxKind)

source

pub fn was_joint(&mut self)

Sets jointness for the last token we’ve pushed.

This is a separate API rather than an argument to the push to make it convenient both for textual and mbe tokens. With text, you know whether the previous token was joint, with mbe, you know whether the current one is joint. This API allows for styles of usage:

// In text:
tokens.was_joint(prev_joint);
tokens.push(curr);

// In MBE:
token.push(curr);
tokens.push(curr_joint)

Trait Implementations§

source§

impl Default for Input

source§

fn default() -> Input

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Input

§

impl RefUnwindSafe for Input

§

impl Send for Input

§

impl Sync for Input

§

impl Unpin for Input

§

impl UnwindSafe for Input

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more