pub struct Parser<'t> { /* private fields */ }
Implementations§
source§impl<'t> Parser<'t>
impl<'t> Parser<'t>
Basic parser functionality
pub fn new(lexer: Lexer<'t>) -> Self
sourcepub fn peek(&mut self, while_parsing: Parsing) -> PResult<&Token>
pub fn peek(&mut self, while_parsing: Parsing) -> PResult<&Token>
Looks ahead one token
Stores the token in an internal lookahead buffer
sourcepub fn consume_peeked(&mut self) -> Option<Token>
pub fn consume_peeked(&mut self) -> Option<Token>
pub fn match_op( &mut self, want: Punct, while_parsing: Parsing ) -> PResult<Token>
source§impl<'t> Parser<'t>
impl<'t> Parser<'t>
Top level parsing
sourcepub fn item(&mut self) -> PResult<Item>
pub fn item(&mut self) -> PResult<Item>
Parses an [Item]
See also: Parser::itemkind
sourcepub fn ty(&mut self) -> PResult<Ty>
pub fn ty(&mut self) -> PResult<Ty>
Parses a [Ty]
See also: Parser::tykind
sourcepub fn path(&mut self) -> PResult<Path>
pub fn path(&mut self) -> PResult<Path>
Parses a [Path]
See also: Parser::path_part, Parser::identifier
[Path] = ::
RelativePath? | RelativePath
RelativePath = [PathPart] (::
[PathPart])*
sourcepub fn stmt(&mut self) -> PResult<Stmt>
pub fn stmt(&mut self) -> PResult<Stmt>
Parses a [Stmt]
See also: Parser::stmtkind
sourcepub fn expr(&mut self) -> PResult<Expr>
pub fn expr(&mut self) -> PResult<Expr>
Parses an [Expr]
See also: Parser::exprkind
source§impl<'t> Parser<'t>
impl<'t> Parser<'t>
Item parsing
sourcepub fn itemkind(&mut self) -> PResult<ItemKind>
pub fn itemkind(&mut self) -> PResult<ItemKind>
Parses an [ItemKind]
See also: Parser::item
sourcepub fn parse_alias(&mut self) -> PResult<Alias>
pub fn parse_alias(&mut self) -> PResult<Alias>
Parses a type
alias
sourcepub fn parse_const(&mut self) -> PResult<Const>
pub fn parse_const(&mut self) -> PResult<Const>
Parses a compile-time constant
sourcepub fn parse_static(&mut self) -> PResult<Static>
pub fn parse_static(&mut self) -> PResult<Static>
Parses a static
item
sourcepub fn parse_module(&mut self) -> PResult<Module>
pub fn parse_module(&mut self) -> PResult<Module>
Parses a [Module]
sourcepub fn modulekind(&mut self) -> PResult<ModuleKind>
pub fn modulekind(&mut self) -> PResult<ModuleKind>
Parses the item list associated with a [Module], if present
sourcepub fn parse_function(&mut self) -> PResult<Function>
pub fn parse_function(&mut self) -> PResult<Function>
Parses a [Function] definition
sourcepub fn parse_params(&mut self) -> PResult<(Vec<Param>, Vec<TyKind>)>
pub fn parse_params(&mut self) -> PResult<(Vec<Param>, Vec<TyKind>)>
Parses the parameters associated with a Function
sourcepub fn parse_param(&mut self) -> PResult<(Param, TyKind)>
pub fn parse_param(&mut self) -> PResult<(Param, TyKind)>
Parses a single function parameter
sourcepub fn parse_struct(&mut self) -> PResult<Struct>
pub fn parse_struct(&mut self) -> PResult<Struct>
Parses a struct
definition
sourcepub fn structkind_tuple(&mut self) -> PResult<StructKind>
pub fn structkind_tuple(&mut self) -> PResult<StructKind>
Parses a tuple-struct
’s members
sourcepub fn structkind_struct(&mut self) -> PResult<StructKind>
pub fn structkind_struct(&mut self) -> PResult<StructKind>
Parses a struct
s members
sourcepub fn struct_member(&mut self) -> PResult<StructMember>
pub fn struct_member(&mut self) -> PResult<StructMember>
Parses a single [StructMember]
sourcepub fn parse_enum(&mut self) -> PResult<Enum>
pub fn parse_enum(&mut self) -> PResult<Enum>
Parses an enum
definition
sourcepub fn enum_variant(&mut self) -> PResult<Variant>
pub fn enum_variant(&mut self) -> PResult<Variant>
Parses an enum
[Variant]
sourcepub fn variantkind_clike(&mut self) -> PResult<VariantKind>
pub fn variantkind_clike(&mut self) -> PResult<VariantKind>
sourcepub fn variantkind_struct(&mut self) -> PResult<VariantKind>
pub fn variantkind_struct(&mut self) -> PResult<VariantKind>
Parses a struct-like enum
[Variant]
sourcepub fn variantkind_tuple(&mut self) -> PResult<VariantKind>
pub fn variantkind_tuple(&mut self) -> PResult<VariantKind>
Parses a tuple-like enum
[Variant]
pub fn parse_impl(&mut self) -> PResult<Impl>
pub fn parse_impl_kind(&mut self) -> PResult<ImplKind>
pub fn parse_use(&mut self) -> PResult<Use>
pub fn parse_use_tree(&mut self) -> PResult<UseTree>
sourcepub fn visibility(&mut self) -> Visibility
pub fn visibility(&mut self) -> Visibility
[Visibility] = pub
?
sourcepub fn mutability(&mut self) -> Mutability
pub fn mutability(&mut self) -> Mutability
[Mutability] = mut
?
source§impl<'t> Parser<'t>
impl<'t> Parser<'t>
§Type parsing
source§impl<'t> Parser<'t>
impl<'t> Parser<'t>
§Path parsing
sourcepub fn path_part(&mut self) -> PResult<PathPart>
pub fn path_part(&mut self) -> PResult<PathPart>
[PathPart] = super
| self
| Identifier
sourcepub fn identifier(&mut self) -> PResult<Sym>
pub fn identifier(&mut self) -> PResult<Sym>
[Sym] = Identifier
source§impl<'t> Parser<'t>
impl<'t> Parser<'t>
§Expression parsing
sourcepub fn expr_from(
&mut self,
f: impl Fn(&mut Self) -> PResult<ExprKind>
) -> PResult<Expr>
pub fn expr_from( &mut self, f: impl Fn(&mut Self) -> PResult<ExprKind> ) -> PResult<Expr>
Creates an [Expr] with the given [ExprKind]-parser
sourcepub fn exprkind(&mut self, power: u8) -> PResult<ExprKind>
pub fn exprkind(&mut self, power: u8) -> PResult<ExprKind>
Parses an [ExprKind]
See also: Parser::expr
pub fn access(&mut self) -> PResult<MemberKind>
sourcepub fn exprkind_pathlike(&mut self) -> PResult<ExprKind>
pub fn exprkind_pathlike(&mut self) -> PResult<ExprKind>
Parses an expression beginning with a [Path] (i.e. [Path] or [Structor])
sourcepub fn structor_body(&mut self, to: Path) -> PResult<Structor>
pub fn structor_body(&mut self, to: Path) -> PResult<Structor>
[Structor]Body = {
([Fielder] ,
)* [Fielder]? }
sourcepub fn fielder(&mut self) -> PResult<Fielder>
pub fn fielder(&mut self) -> PResult<Fielder>
[Fielder] = Identifier
(:
[Expr])?
sourcepub fn exprkind_arraylike(&mut self) -> PResult<ExprKind>
pub fn exprkind_arraylike(&mut self) -> PResult<ExprKind>
[Array] = ‘[’ ([Expr] ‘,’)* [Expr]? ‘]’
Array and ArrayRef are ambiguous until the second token, so they can’t be independent subexpressions
sourcepub fn exprkind_array_rep(&mut self) -> PResult<ExprKind>
pub fn exprkind_array_rep(&mut self) -> PResult<ExprKind>
[ArrayRep] = [
[Expr] ;
[Expr] ]
sourcepub fn exprkind_tuplelike(&mut self) -> PResult<ExprKind>
pub fn exprkind_tuplelike(&mut self) -> PResult<ExprKind>
[Group] = (
(Empty|[Expr]|[Tuple]))
[ExprKind::Empty] and [Group] are special cases of [Tuple]
sourcepub fn exprkind_group(&mut self) -> PResult<ExprKind>
pub fn exprkind_group(&mut self) -> PResult<ExprKind>
[Group] = (
(Empty|[Expr]|[Tuple]))
source§impl<'t> Parser<'t>
impl<'t> Parser<'t>
§Control flow subexpressions
sourcepub fn parse_break(&mut self) -> PResult<Break>
pub fn parse_break(&mut self) -> PResult<Break>
[Break] = break
(unconsumed ;
| [Expr])
sourcepub fn parse_return(&mut self) -> PResult<Return>
pub fn parse_return(&mut self) -> PResult<Return>
[Return] = return
(unconsumed ;
| [Expr])
sourcepub fn parse_while(&mut self) -> PResult<While>
pub fn parse_while(&mut self) -> PResult<While>
[While] = while
[Expr] [Block] [Else]?
sourcepub fn parse_for(&mut self) -> PResult<For>
pub fn parse_for(&mut self) -> PResult<For>
[For]: for
Pattern (TODO) in
[Expr] [Block] [Else]?
sourcepub fn parse_else(&mut self) -> PResult<Else>
pub fn parse_else(&mut self) -> PResult<Else>
[Else]: (else
[Block])?