Skip to main content

Parser

Struct Parser 

Source
struct Parser<'src> {
    file: FileId,
    source: &'src str,
    tokens: Vec<Token>,
    pos: usize,
    diagnostics: Vec<Diagnostic>,
}

Fields§

§file: FileId§source: &'src str§tokens: Vec<Token>

Always ends with Eof, and bump never moves past it.

§pos: usize§diagnostics: Vec<Diagnostic>

Implementations§

Source§

impl Parser<'_>

Source

pub(super) fn parse_expr( &mut self, trailing: TrailingBlocks, ) -> Result<Expr, Reported>

Source

fn parse_binary( &mut self, min_power: u8, trailing: TrailingBlocks, ) -> Result<Expr, Reported>

Source

fn parse_prefix(&mut self, trailing: TrailingBlocks) -> Result<Expr, Reported>

Source

fn parse_postfix(&mut self, trailing: TrailingBlocks) -> Result<Expr, Reported>

Source

pub(super) fn parse_call( &mut self, callee: Expr, trailing: TrailingBlocks, ) -> Result<Expr, Reported>

Source

fn parse_arg(&mut self) -> Result<Arg, Reported>

Source

fn check_argument_order(&mut self, args: &[Arg])

Source

fn parse_primary(&mut self) -> Result<Expr, Reported>

Source

fn parse_string(&mut self) -> Result<Expr, Reported>

Source

fn number_literal<T: FromStr>( &mut self, span: Span, wrap: fn(T) -> ExprKind, problem: &str, ) -> ExprKind

Parses a number token, reporting problem if it doesn’t fit the target type.

Source§

impl Parser<'_>

Source

pub(super) fn parse_item(&mut self) -> Result<Item, Reported>

Source

fn parse_named(&mut self) -> Result<NamedElement, Reported>

element name(…) { … }: the element’s call, with a name between its element and its arguments.

Source

fn parse_state(&mut self) -> Result<StateDecl, Reported>

Source

fn parse_struct(&mut self) -> Result<StructDecl, Reported>

Source

fn parse_fn(&mut self) -> Result<FnDecl, Reported>

Source

fn parse_view(&mut self) -> Result<ViewDecl, Reported>

Source

fn parse_typed_name(&mut self) -> Result<TypedName, Reported>

Source

pub(super) fn parse_type_annotation( &mut self, ) -> Result<Option<TypeExpr>, Reported>

An optional : Type.

Source

fn parse_type(&mut self) -> Result<TypeExpr, Reported>

Source§

impl Parser<'_>

Source§

impl Parser<'_>

Source

fn parse_file(&mut self) -> File

Source

fn current(&self) -> Token

Source

fn peek(&self) -> TokenKind

Source

fn peek_nth(&self, n: usize) -> TokenKind

Source

fn at(&self, kind: TokenKind) -> bool

Source

fn bump(&mut self) -> Token

Source

fn eat(&mut self, kind: TokenKind) -> Option<Token>

Source

fn expect(&mut self, kind: TokenKind) -> Result<Token, Reported>

Source

fn expect_ident(&mut self) -> Result<Ident, Reported>

Source

fn unexpected<T>(&mut self, expected: &str) -> Result<T, Reported>

Reports “expected {expected}, found …” at the current token.

Source

fn report(&mut self, message: impl Into<String>, span: Span) -> Reported

Source

fn text(&self, span: Span) -> &str

Source

fn skip_newlines(&mut self)

Source

fn span_from(&self, start: usize) -> Span

The span from start to the end of the last consumed token.

Source

fn finish_line(&mut self)

A statement must end at a line break, a closing } or the end of the file.

Source

fn recover_to_line_end(&mut self)

Skips to the next line break or the } closing the current block, ignoring any nested in brackets along the way.

Source

fn comma_list<T>( &mut self, close: TokenKind, item: impl FnMut(&mut Self) -> Result<T, Reported>, ) -> Result<Vec<T>, Reported>

Parses item (, item)* ,? close after the opening bracket; newlines are free inside.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<'src> UnsafeUnpin for Parser<'src>

§

impl<'src> UnwindSafe for Parser<'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, 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.