Struct syntax::parse::parser::Parser [] [src]

pub struct Parser<'a> {
    pub sess: &'a ParseSess,
    pub token: Token,
    pub span: Span,
    pub meta_var_span: Option<Span>,
    pub prev_span: Span,
    pub restrictions: Restrictions,
    pub obsolete_set: HashSet<ObsoleteSyntax>,
    pub directory: Directory,
    pub recurse_into_file_modules: bool,
    pub root_module_name: Option<String>,
    pub expected_tokens: Vec<TokenType>,
    pub desugar_doc_comments: bool,
    pub cfg_mods: bool,
    // some fields omitted
}

Fields

the current token:

the span of the current token:

the span of the previous token:

The set of seen errors about obsolete syntax. Used to suppress extra detail when the same error is seen twice

Used to determine the path to externally loaded source files

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]

[src]

[src]

Convert a token to a string using self's reader

[src]

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

[src]

[src]

[src]

[src]

[src]

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

[src]

Expect next token to be edible or inedible token. If edible, then consume it; if inedible, then return without consuming anything. Signal a fatal error if next token is unexpected.

[src]

[src]

Check if the next token is tok, and return true if so.

This method will automatically add tok to expected_tokens if tok is not encountered.

[src]

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

[src]

[src]

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

[src]

[src]

If the given word is not a keyword, signal an error. If the next token is not the given word, signal an error. Otherwise, eat it.

[src]

[src]

Expect and consume a GT. if a >> is seen, replace it with a single > and continue. If a GT is not seen, signal an error.

[src]

[src]

Parse a sequence bracketed by '<' and '>', stopping before the '>'.

[src]

[src]

[src]

Eat and discard tokens until one of kets is encountered. Respects token trees, passes through any errors encountered. Used for error recovery.

[src]

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

[src]

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

[src]

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

[src]

[src]

Advance the parser by one token

[src]

Advance the parser using provided token as a next one. Use this when consuming a part of a token. For example a single < from <<.

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

Is the current token one of the keywords that signals a bare function type?

[src]

parse a TyKind::BareFn type:

[src]

Parse the items in a trait declaration

[src]

[src]

[src]

This version of parse arg doesn't necessarily require identifier names.

[src]

Parse a single function argument

[src]

Parse an argument in a lambda header e.g. |arg, arg|

[src]

[src]

Matches token_lit = LIT_INTEGER | ...

[src]

Matches lit = true | false | token_lit

[src]

matches '-' lit | lit (cf. ast_validation::AstValidator::check_expr_within_pat)

[src]

[src]

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)

[src]

[src]

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.

[src]

Parse single lifetime 'a or panic.

[src]

[src]

Parse ident (COLON expr)?

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

Parse a block or unsafe block

[src]

parse a.b or a(13) or a[4] or just a

[src]

[src]

[src]

parse a single token tree from the input.

[src]

[src]

[src]

Parse a prefix-unary-operator expr

[src]

Parse an associative expression

This parses an expression accounting for associativity and precedence of the operators in the expression.

[src]

Parse an associative expression with operators of at least min_prec precedence

[src]

Parse an 'if' or 'if let' expression ('if' token already eaten)

[src]

Parse an 'if let' expression ('if' token already eaten)

[src]

[src]

[src]

Parse a 'for' .. 'in' expression ('for' token already eaten)

[src]

Parse a 'while' or 'while let' expression ('while' token already eaten)

[src]

Parse a 'while let' expression ('while' token already eaten)

[src]

[src]

Parse a do catch {...} expression (do catch token already eaten)

[src]

[src]

Parse an expression

[src]

Evaluate the closure with restrictions in place.

After the closure is evaluated, restrictions are reset.

[src]

Parse an expression, subject to the given restrictions

[src]

Parse a pattern.

[src]

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.

[src]

Parse a block. No inner attrs are allowed.

[src]

Parse a statement, including the trailing semicolon.

[src]

Parses (possibly empty) list of lifetime and type parameters, possibly including trailing comma and erroneous trailing attributes.

[src]

Parse a set of optional generic type parameter declarations. Where clauses are not parsed here, and must be added later via parse_where_clause().

matches generics = ( ) | ( < > ) | ( < typaramseq ( , )? > ) | ( < lifetimes ( , )? > ) | ( < lifetimes , typaramseq ( , )? > ) where typaramseq = ( typaram ) | ( typaram , typaramseq )

[src]

Parses an optional where clause and places it in generics.

This example is not tested
where T : Trait<U, V> + 'b, 'a : 'b

[src]

Parse the argument list and result type of a function declaration

[src]

true if we are looking at const ID, false for things like const fn etc

[src]

parses all the "front matter" for a fn declaration, up to and including the fn keyword:

  • const fn
  • unsafe fn
  • const unsafe fn
  • extern fn
  • etc

[src]

Parse an impl item.

[src]

[src]

[src]

Parse a structure field declaration

[src]

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.

[src]

[src]

Returns either a path to a module, or .

[src]

[src]

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

[src]

[src]

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

[src]

Parse attributes that appear before an item

[src]

Matches attribute = # ! [ meta_item ]

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

[src]

[src]

Parse attributes that appear after the opening of an item. These should be preceded by an exclamation mark, but we accept and warn about one terminated by a semicolon. matches inner_attrs*

[src]

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)? ;

[src]

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

[src]

[src]

Trait Implementations

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

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

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

[src]

Reports an obsolete syntax non-fatal error.

[src]

Auto Trait Implementations

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

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