Output

Struct Output 

Source
pub struct Output {
    event: Vec<u32>,
    error: Vec<String>,
}
Expand description

Output of the parser – a DFS traversal of a concrete syntax tree.

Use the Output::iter method to iterate over traversal steps and consume a syntax tree.

In a sense, this is just a sequence of SyntaxKind-colored parenthesis interspersed into the original crate::Input. The output is fundamentally coordinated with the input and n_input_tokens refers to the number of times crate::Input::push was called.

Fields§

§event: Vec<u32>

32-bit encoding of events. If LSB is zero, then that’s an index into the error vector. Otherwise, it’s one of the thee other variants, with data encoded as

|16 bit kind|8 bit n_input_tokens|4 bit tag|4 bit leftover|
§error: Vec<String>

Implementations§

Source§

impl Output

Source

const EVENT_MASK: u32 = 1u32

Source

const TAG_MASK: u32 = 240u32

Source

const N_INPUT_TOKEN_MASK: u32 = 65_280u32

Source

const KIND_MASK: u32 = 4_294_901_760u32

Source

const ERROR_SHIFT: u32 = 1u32

Source

const TAG_SHIFT: u32 = 4u32

Source

const N_INPUT_TOKEN_SHIFT: u32 = 8u32

Source

const KIND_SHIFT: u32 = 16u32

Source

const TOKEN_EVENT: u8 = 0u8

Source

const ENTER_EVENT: u8 = 1u8

Source

const EXIT_EVENT: u8 = 2u8

Source

const SPLIT_EVENT: u8 = 3u8

Source

pub fn iter(&self) -> impl Iterator<Item = Step<'_>>

Source

pub(crate) fn token(&mut self, kind: SyntaxKind, n_tokens: u8)

Source

pub(crate) fn float_split_hack(&mut self, ends_in_dot: bool)

Source

pub(crate) fn enter_node(&mut self, kind: SyntaxKind)

Source

pub(crate) fn leave_node(&mut self)

Source

pub(crate) fn error(&mut self, error: String)

Trait Implementations§

Source§

impl Default for Output

Source§

fn default() -> Output

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

Auto Trait Implementations§

§

impl Freeze for Output

§

impl RefUnwindSafe for Output

§

impl Send for Output

§

impl Sync for Output

§

impl Unpin for Output

§

impl UnwindSafe for Output

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