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

the current token:

the span of the current token:

Whether to parse sub-modules in other files.

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.

Whether we should configure out of line modules as we parse.

Methods

impl<'a> Parser<'a>
[src]

Convert the current token to a string using self's reader

Expect and consume the token t. Signal an error if the next token is not t.

Consume token 'tok' if it exists. Returns true if the given token was present, false otherwise.

If the next token is the given keyword, eat it and return true. Otherwise, return false.

Parse a sequence, including the closing delimiter. The function f must consume tokens until reaching the next separator or closing bracket.

Parse a sequence, not including the closing delimiter. The function f must consume tokens until reaching the next separator or closing bracket.

Advance the parser by one token

Parse the items in a trait declaration

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)

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.

Parse an async move {...} expression

Parse an expression

Parse a pattern.

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.

Parse a block. No inner attrs are allowed.

Parse an impl item.

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.

Returns either a path to a module, or .

Parses a source module as a crate. This is the main entry point for the parser.

impl<'a> Parser<'a>
[src]

Matches attribute = # ! [ meta_item ]

If permit_inner is true, then a leading ! indicates an inner attribute

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]

Trait Implementations

impl<'a> Clone for Parser<'a>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<'a> !Send for Parser<'a>

impl<'a> !Sync for Parser<'a>