Struct syntax::parse::parser::Parser   [−][src]
pub struct Parser<'a> {
    pub sess: &'a ParseSess,
    pub token: Token,
    pub span: Span,
    pub prev_span: Span,
    pub recurse_into_file_modules: bool,
    pub root_module_name: Option<String>,
    pub cfg_mods: bool,
    // some fields omitted
}Fields
sess: &'a ParseSess
                           
                           
                           
                           token: Token
                           the current token:
span: Span
                           the span of the current token:
prev_span: Span
                           
                           
                           
                           recurse_into_file_modules: bool
                           Whether to parse sub-modules in other files.
root_module_name: Option<String>
                           Name of the root module this parser originated from. If None, then the
name is not known. This does not change while the parser is descending
into modules, and sub-parsers have new values for this name.
cfg_mods: bool
                           Whether we should configure out of line modules as we parse.
Methods
impl<'a> Parser<'a>[src] 
impl<'a> Parser<'a>pub fn new(
    sess: &'a ParseSess, 
    tokens: TokenStream, 
    directory: Option<Directory<'a>>, 
    recurse_into_file_modules: bool, 
    desugar_doc_comments: bool
) -> Self[src] 
pub fn new(
    sess: &'a ParseSess, 
    tokens: TokenStream, 
    directory: Option<Directory<'a>>, 
    recurse_into_file_modules: bool, 
    desugar_doc_comments: bool
) -> Selfpub fn this_token_to_string(&self) -> String[src] 
pub fn this_token_to_string(&self) -> StringConvert the current token to a string using self's reader
pub fn expect(&mut self, t: &Token) -> PResult<'a, ()>[src] 
pub fn expect(&mut self, t: &Token) -> PResult<'a, ()>Expect and consume the token t. Signal an error if the next token is not t.
pub fn parse_ident(&mut self) -> PResult<'a, Ident>[src] 
pub fn parse_ident(&mut self) -> PResult<'a, Ident>pub fn eat(&mut self, tok: &Token) -> bool[src] 
pub fn eat(&mut self, tok: &Token) -> boolConsume token 'tok' if it exists. Returns true if the given token was present, false otherwise.
pub fn eat_keyword(&mut self, kw: Keyword) -> bool[src] 
pub fn eat_keyword(&mut self, kw: Keyword) -> boolIf the next token is the given keyword, eat it and return true. Otherwise, return false.
pub fn parse_seq_to_end<T, F>(
    &mut self, 
    ket: &Token, 
    sep: SeqSep, 
    f: F
) -> PResult<'a, Vec<T>> where
    F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, [src] 
pub fn parse_seq_to_end<T, F>(
    &mut self, 
    ket: &Token, 
    sep: SeqSep, 
    f: F
) -> PResult<'a, Vec<T>> where
    F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, Parse a sequence, including the closing delimiter. The function f must consume tokens until reaching the next separator or closing bracket.
pub fn parse_seq_to_before_end<T, F>(
    &mut self, 
    ket: &Token, 
    sep: SeqSep, 
    f: F
) -> PResult<'a, Vec<T>> where
    F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, [src] 
pub fn parse_seq_to_before_end<T, F>(
    &mut self, 
    ket: &Token, 
    sep: SeqSep, 
    f: F
) -> PResult<'a, Vec<T>> where
    F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, Parse a sequence, not including the closing delimiter. The function f must consume tokens until reaching the next separator or closing bracket.
pub fn bump(&mut self)[src] 
pub fn bump(&mut self)Advance the parser by one token
pub fn look_ahead<R, F>(&self, dist: usize, f: F) -> R where
    F: FnOnce(&Token) -> R, [src] 
pub fn look_ahead<R, F>(&self, dist: usize, f: F) -> R where
    F: FnOnce(&Token) -> R, pub fn fatal(&self, m: &str) -> DiagnosticBuilder<'a>[src] 
pub fn fatal(&self, m: &str) -> DiagnosticBuilder<'a>pub fn span_fatal<S: Into<MultiSpan>>(
    &self, 
    sp: S, 
    m: &str
) -> DiagnosticBuilder<'a>[src] 
pub fn span_fatal<S: Into<MultiSpan>>(
    &self, 
    sp: S, 
    m: &str
) -> DiagnosticBuilder<'a>pub fn parse_trait_item(&mut self, at_end: &mut bool) -> PResult<'a, TraitItem>[src] 
pub fn parse_trait_item(&mut self, at_end: &mut bool) -> PResult<'a, TraitItem>Parse the items in a trait declaration
pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>>[src] 
pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>>pub fn parse_path(&mut self, style: PathStyle) -> PResult<'a, Path>[src] 
pub fn parse_path(&mut self, style: PathStyle) -> PResult<'a, Path>Parses simple paths.
path = [::] segment+
segment = ident | ident[::]<args> | ident[::](args) [-> type]
Examples
a::b::C<D> (without disambiguator)
a::b::C::<D> (with disambiguator)
Fn(Args) (without disambiguator)
Fn::(Args) (with disambiguator)
pub fn parse_path_allowing_meta(
    &mut self, 
    style: PathStyle
) -> PResult<'a, Path>[src] 
pub fn parse_path_allowing_meta(
    &mut self, 
    style: PathStyle
) -> PResult<'a, Path>Like parse_path, but also supports parsing Word meta items into paths for back-compat.
This is used when parsing derive macro paths in #[derive] attributes.
pub fn mk_mac_expr(
    &mut self, 
    span: Span, 
    m: Mac_, 
    attrs: ThinVec<Attribute>
) -> P<Expr>[src] 
pub fn mk_mac_expr(
    &mut self, 
    span: Span, 
    m: Mac_, 
    attrs: ThinVec<Attribute>
) -> P<Expr>pub fn parse_all_token_trees(&mut self) -> PResult<'a, Vec<TokenTree>>[src] 
pub fn parse_all_token_trees(&mut self) -> PResult<'a, Vec<TokenTree>>pub fn parse_tokens(&mut self) -> TokenStream[src] 
pub fn parse_tokens(&mut self) -> TokenStreampub fn parse_async_block(
    &mut self, 
    attrs: ThinVec<Attribute>
) -> PResult<'a, P<Expr>>[src] 
pub fn parse_async_block(
    &mut self, 
    attrs: ThinVec<Attribute>
) -> PResult<'a, P<Expr>>Parse an async move {...} expression
pub fn parse_expr(&mut self) -> PResult<'a, P<Expr>>[src] 
pub fn parse_expr(&mut self) -> PResult<'a, P<Expr>>Parse an expression
pub fn parse_pat(&mut self) -> PResult<'a, P<Pat>>[src] 
pub fn parse_pat(&mut self) -> PResult<'a, P<Pat>>Parse a pattern.
pub fn parse_stmt(&mut self) -> PResult<'a, Option<Stmt>>[src] 
pub fn parse_stmt(&mut self) -> PResult<'a, Option<Stmt>>Parse a statement. This stops just before trailing semicolons on everything but items.
e.g. a StmtKind::Semi parses to a StmtKind::Expr, leaving the trailing ; unconsumed.
pub fn parse_block(&mut self) -> PResult<'a, P<Block>>[src] 
pub fn parse_block(&mut self) -> PResult<'a, P<Block>>Parse a block. No inner attrs are allowed.
pub fn parse_impl_item(&mut self, at_end: &mut bool) -> PResult<'a, ImplItem>[src] 
pub fn parse_impl_item(&mut self, at_end: &mut bool) -> PResult<'a, ImplItem>Parse an impl item.
pub fn parse_visibility(
    &mut self, 
    can_take_tuple: bool
) -> PResult<'a, Visibility>[src] 
pub fn parse_visibility(
    &mut self, 
    can_take_tuple: bool
) -> PResult<'a, Visibility>Parse pub, pub(crate) and pub(in path) plus shortcuts pub(self) for pub(in self)
and pub(super) for pub(in super).  If the following element can't be a tuple (i.e. it's
a function definition, it's not a tuple struct field) and the contents within the parens
isn't valid, emit a proper diagnostic.
pub fn submod_path_from_attr(
    attrs: &[Attribute], 
    dir_path: &Path
) -> Option<PathBuf>[src] 
pub fn submod_path_from_attr(
    attrs: &[Attribute], 
    dir_path: &Path
) -> Option<PathBuf>pub fn default_submod_path(
    id: Ident, 
    relative: Option<Ident>, 
    dir_path: &Path, 
    codemap: &CodeMap
) -> ModulePath[src] 
pub fn default_submod_path(
    id: Ident, 
    relative: Option<Ident>, 
    dir_path: &Path, 
    codemap: &CodeMap
) -> ModulePathReturns either a path to a module, or .
pub fn parse_item(&mut self) -> PResult<'a, Option<P<Item>>>[src] 
pub fn parse_item(&mut self) -> PResult<'a, Option<P<Item>>>pub fn parse_crate_mod(&mut self) -> PResult<'a, Crate>[src] 
pub fn parse_crate_mod(&mut self) -> PResult<'a, Crate>Parses a source module as a crate. This is the main entry point for the parser.
pub fn parse_optional_str(&mut self) -> Option<(Symbol, StrStyle, Option<Name>)>[src] 
pub fn parse_optional_str(&mut self) -> Option<(Symbol, StrStyle, Option<Name>)>pub fn parse_str(&mut self) -> PResult<'a, (Symbol, StrStyle)>[src] 
pub fn parse_str(&mut self) -> PResult<'a, (Symbol, StrStyle)>impl<'a> Parser<'a>[src] 
impl<'a> Parser<'a>pub fn parse_attribute(&mut self, permit_inner: bool) -> PResult<'a, Attribute>[src] 
pub fn parse_attribute(&mut self, permit_inner: bool) -> PResult<'a, Attribute>Matches attribute = # ! [ meta_item ]
If permit_inner is true, then a leading ! indicates an inner
attribute
pub fn parse_meta_item(&mut self) -> PResult<'a, MetaItem>[src] 
pub fn parse_meta_item(&mut self) -> PResult<'a, MetaItem>Per RFC#1559, matches the following grammar:
meta_item : IDENT ( '=' UNSUFFIXED_LIT | '(' meta_item_inner? ')' )? ; meta_item_inner : (meta_item | UNSUFFIXED_LIT) (',' meta_item_inner)? ;
impl<'a> Parser<'a>[src] 
impl<'a> Parser<'a>pub fn parse_ast_fragment(
    &mut self, 
    kind: AstFragmentKind, 
    macro_legacy_warnings: bool
) -> PResult<'a, AstFragment>[src] 
pub fn parse_ast_fragment(
    &mut self, 
    kind: AstFragmentKind, 
    macro_legacy_warnings: bool
) -> PResult<'a, AstFragment>pub fn ensure_complete_parse(
    &mut self, 
    macro_path: &Path, 
    kind_name: &str, 
    span: Span
)[src] 
pub fn ensure_complete_parse(
    &mut self, 
    macro_path: &Path, 
    kind_name: &str, 
    span: Span
)