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<'_>
impl Parser<'_>
pub(super) fn parse_expr( &mut self, trailing: TrailingBlocks, ) -> Result<Expr, Reported>
fn parse_binary( &mut self, min_power: u8, trailing: TrailingBlocks, ) -> Result<Expr, Reported>
fn parse_prefix(&mut self, trailing: TrailingBlocks) -> Result<Expr, Reported>
fn parse_postfix(&mut self, trailing: TrailingBlocks) -> Result<Expr, Reported>
pub(super) fn parse_call( &mut self, callee: Expr, trailing: TrailingBlocks, ) -> Result<Expr, Reported>
fn parse_arg(&mut self) -> Result<Arg, Reported>
fn check_argument_order(&mut self, args: &[Arg])
fn parse_primary(&mut self) -> Result<Expr, Reported>
fn parse_string(&mut self) -> Result<Expr, Reported>
Source§impl Parser<'_>
impl Parser<'_>
pub(super) fn parse_item(&mut self) -> Result<Item, Reported>
Sourcefn parse_named(&mut self) -> Result<NamedElement, Reported>
fn parse_named(&mut self) -> Result<NamedElement, Reported>
element name(…) { … }: the element’s call, with a name between its element and
its arguments.
fn parse_state(&mut self) -> Result<StateDecl, Reported>
fn parse_struct(&mut self) -> Result<StructDecl, Reported>
fn parse_fn(&mut self) -> Result<FnDecl, Reported>
fn parse_view(&mut self) -> Result<ViewDecl, Reported>
fn parse_typed_name(&mut self) -> Result<TypedName, Reported>
Sourcepub(super) fn parse_type_annotation(
&mut self,
) -> Result<Option<TypeExpr>, Reported>
pub(super) fn parse_type_annotation( &mut self, ) -> Result<Option<TypeExpr>, Reported>
An optional : Type.
fn parse_type(&mut self) -> Result<TypeExpr, Reported>
Source§impl Parser<'_>
impl Parser<'_>
pub(super) fn parse_block(&mut self) -> Result<Block, Reported>
pub(super) fn parse_stmt(&mut self) -> Result<Stmt, Reported>
fn parse_let(&mut self) -> Result<StmtKind, Reported>
fn parse_if(&mut self) -> Result<IfStmt, Reported>
fn parse_for(&mut self) -> Result<StmtKind, Reported>
fn parse_iterable(&mut self) -> Result<Iterable, Reported>
fn parse_return(&mut self) -> Result<StmtKind, Reported>
fn parse_expr_or_assign(&mut self) -> Result<StmtKind, Reported>
Source§impl Parser<'_>
impl Parser<'_>
fn parse_file(&mut self) -> File
fn current(&self) -> Token
fn peek(&self) -> TokenKind
fn peek_nth(&self, n: usize) -> TokenKind
fn at(&self, kind: TokenKind) -> bool
fn bump(&mut self) -> Token
fn eat(&mut self, kind: TokenKind) -> Option<Token>
fn expect(&mut self, kind: TokenKind) -> Result<Token, Reported>
fn expect_ident(&mut self) -> Result<Ident, Reported>
Sourcefn unexpected<T>(&mut self, expected: &str) -> Result<T, Reported>
fn unexpected<T>(&mut self, expected: &str) -> Result<T, Reported>
Reports “expected {expected}, found …” at the current token.
fn report(&mut self, message: impl Into<String>, span: Span) -> Reported
fn text(&self, span: Span) -> &str
fn skip_newlines(&mut self)
Sourcefn span_from(&self, start: usize) -> Span
fn span_from(&self, start: usize) -> Span
The span from start to the end of the last consumed token.
Sourcefn finish_line(&mut self)
fn finish_line(&mut self)
A statement must end at a line break, a closing } or the end of the file.
Sourcefn recover_to_line_end(&mut self)
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.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more