pub_just::parser

Struct Parser

Source
pub struct Parser<'run, 'src> { /* private fields */ }
Expand description

Just language parser

The parser is a (hopefully) straightforward recursive descent parser.

It uses a few tokens of lookahead to disambiguate different constructs.

The expect_* and presume_* methods are similar in that they assert the type of unparsed tokens and consume them. However, upon encountering an unexpected token, the expect_* methods return an unexpected token error, whereas the presume_* tokens return an internal error.

The presume_* methods are used when the token stream has been inspected in some other way, and thus encountering an unexpected token is a bug in Just, and not a syntax error.

All methods starting with parse_* parse and return a language construct.

The parser tracks an expected set of tokens as it parses. This set contains all tokens which would have been accepted at the current point in the parse. Whenever the parser tests for a token that would be accepted, but does not find it, it adds that token to the set. When the parser accepts a token, the set is cleared. If the parser finds a token which is unexpected, the elements of the set are printed in the resultant error message.

Implementationsยง

Sourceยง

impl<'run, 'src> Parser<'run, 'src>

Source

pub fn parse( file_depth: u32, import_offsets: &[usize], module_namepath: &'run Namepath<'src>, tokens: &'run [Token<'src>], working_directory: &'run Path, ) -> Result<Ast<'src>, CompileError<'src>>

Parse tokens into an Ast

Auto Trait Implementationsยง

ยง

impl<'run, 'src> Freeze for Parser<'run, 'src>

ยง

impl<'run, 'src> RefUnwindSafe for Parser<'run, 'src>

ยง

impl<'run, 'src> Send for Parser<'run, 'src>

ยง

impl<'run, 'src> Sync for Parser<'run, 'src>

ยง

impl<'run, 'src> Unpin for Parser<'run, 'src>

ยง

impl<'run, 'src> UnwindSafe for Parser<'run, 'src>

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

Sourceยง

const ALIGN: usize = _

The alignment of pointer.
Sourceยง

type Init = T

The type for initializers.
Sourceยง

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Sourceยง

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Sourceยง

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Sourceยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Sourceยง

fn vzip(self) -> V