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

pub struct Parser<'a> {
    pub sess: &'a ParseSess,
    pub token: Token,
    pub span: Span,
    pub last_span: Span,
    pub cfg: CrateConfig,
    pub last_token: Option<Box<Token>>,
    pub buffer: [TokenAndSpan, ..4],
    pub buffer_start: int,
    pub buffer_end: int,
    pub tokens_consumed: uint,
    pub restriction: restriction,
    pub quote_depth: uint,
    pub reader: Box<Reader>,
    pub interner: Rc<IdentInterner>,
    pub obsolete_set: HashSet<ObsoleteSyntax>,
    pub mod_path_stack: Vec<InternedString>,
    pub open_braces: Vec<Span>,
    pub owns_directory: bool,
    pub root_module_name: Option<String>,
}

Fields

sess
token
span
last_span
cfg
last_token
buffer
buffer_start
buffer_end
tokens_consumed
restriction
quote_depth
reader
interner
obsolete_set

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

mod_path_stack

Used to determine the path to externally loaded source files

open_braces

Stack of spans of open delimiters. Used for error message.

owns_directory

Flag if this parser "owns" the directory that it is currently parsing in. This will affect how nested files are looked up.

root_module_name

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.

Methods

impl<'a> Parser<'a>

fn new(sess: &'a ParseSess, cfg: CrateConfig, rdr: Box<Reader>) -> Parser<'a>

fn token_to_str(token: &Token) -> String

fn this_token_to_str(&mut self) -> String

fn unexpected_last(&mut self, t: &Token) -> !

fn unexpected(&mut self) -> !

fn expect(&mut self, t: &Token)

fn expect_one_of(&mut self, edible: &[Token], inedible: &[Token])

fn check_for_erroneous_unit_struct_expecting(&mut self, expected: &[Token]) -> bool

fn commit_expr(&mut self, e: Gc<Expr>, edible: &[Token], inedible: &[Token])

fn commit_expr_expecting(&mut self, e: Gc<Expr>, edible: Token)

fn commit_stmt(&mut self, s: Gc<Stmt>, edible: &[Token], inedible: &[Token])

fn commit_stmt_expecting(&mut self, s: Gc<Stmt>, edible: Token)

fn parse_ident(&mut self) -> Ident

fn parse_path_list_ident(&mut self) -> PathListIdent

fn eat(&mut self, tok: &Token) -> bool

fn is_keyword(&mut self, kw: Keyword) -> bool

fn eat_keyword(&mut self, kw: Keyword) -> bool

fn expect_keyword(&mut self, kw: Keyword)

fn check_strict_keywords(&mut self)

fn check_reserved_keywords(&mut self)

fn expect_gt(&mut self)

fn parse_seq_to_before_gt<T>(&mut self, sep: Option<Token>, f: |&mut Parser| -> T) -> OwnedSlice<T>

fn parse_seq_to_gt<T>(&mut self, sep: Option<Token>, f: |&mut Parser| -> T) -> OwnedSlice<T>

fn parse_seq_to_end<T>(&mut self, ket: &Token, sep: SeqSep, f: |&mut Parser| -> T) -> Vec<T>

fn parse_seq_to_before_end<T>(&mut self, ket: &Token, sep: SeqSep, f: |&mut Parser| -> T) -> Vec<T>

fn parse_unspanned_seq<T>(&mut self, bra: &Token, ket: &Token, sep: SeqSep, f: |&mut Parser| -> T) -> Vec<T>

fn parse_enum_variant_seq<T>(&mut self, bra: &Token, ket: &Token, sep: SeqSep, f: |&mut Parser| -> T) -> Vec<T>

fn parse_seq<T>(&mut self, bra: &Token, ket: &Token, sep: SeqSep, f: |&mut Parser| -> T) -> Spanned<Vec<T>>

fn bump(&mut self)

fn bump_and_get(&mut self) -> Token

fn replace_token(&mut self, next: Token, lo: BytePos, hi: BytePos)

fn buffer_length(&mut self) -> int

fn look_ahead<R>(&mut self, distance: uint, f: |&Token| -> R) -> R

fn fatal(&mut self, m: &str) -> !

fn span_fatal(&mut self, sp: Span, m: &str) -> !

fn span_note(&mut self, sp: Span, m: &str)

fn bug(&mut self, m: &str) -> !

fn warn(&mut self, m: &str)

fn span_warn(&mut self, sp: Span, m: &str)

fn span_err(&mut self, sp: Span, m: &str)

fn abort_if_errors(&mut self)

fn id_to_interned_str(&mut self, id: Ident) -> InternedString

fn token_is_bare_fn_keyword(&mut self) -> bool

fn token_is_closure_keyword(&mut self) -> bool

fn token_is_old_style_closure_keyword(&mut self) -> bool

fn token_is_lifetime(tok: &Token) -> bool

fn get_lifetime(&mut self) -> Ident

fn parse_ty_bare_fn(&mut self) -> Ty_

fn parse_proc_type(&mut self) -> Ty_

fn parse_ty_closure(&mut self) -> Ty_

fn parse_unsafety(&mut self) -> FnStyle

fn parse_ty_fn_decl(&mut self, allow_variadic: bool) -> (P<FnDecl>, Vec<Lifetime>)

fn parse_trait_methods(&mut self) -> Vec<TraitMethod>

fn parse_mt(&mut self) -> MutTy

fn parse_ty_field(&mut self) -> TypeField

fn parse_ret_ty(&mut self) -> (RetStyle, P<Ty>)

fn parse_ty(&mut self, plus_allowed: bool) -> P<Ty>

Parse a type.

The second parameter specifies whether the + binary operator is allowed in the type grammar.

fn parse_borrowed_pointee(&mut self) -> Ty_

fn parse_ptr(&mut self) -> MutTy

fn is_named_argument(&mut self) -> bool

fn parse_arg_general(&mut self, require_name: bool) -> Arg

fn parse_arg(&mut self) -> Arg

fn parse_fn_block_arg(&mut self) -> Arg

fn maybe_parse_fixed_vstore(&mut self) -> Option<Gc<Expr>>

fn lit_from_token(&mut self, tok: &Token) -> Lit_

fn parse_lit(&mut self) -> Lit

fn parse_literal_maybe_minus(&mut self) -> Gc<Expr>

fn parse_path(&mut self, mode: PathParsingMode) -> PathAndBounds

Parses a path and optional type parameter bounds, depending on the mode. The mode parameter determines whether lifetimes, types, and/or bounds are permitted and whether :: must precede type parameter groups.

fn parse_opt_lifetime(&mut self) -> Option<Lifetime>

parses 0 or 1 lifetime

fn parse_lifetime(&mut self) -> Lifetime

Parses a single lifetime

fn parse_lifetimes(&mut self) -> Vec<Lifetime>

Parses zero or more comma separated lifetimes. Expects each lifetime to be followed by either a comma or >. Used when parsing type parameter lists, where we expect something like <'a, 'b, T>.

fn token_is_mutability(tok: &Token) -> bool

fn parse_mutability(&mut self) -> Mutability

fn parse_field(&mut self) -> Field

fn mk_expr(&mut self, lo: BytePos, hi: BytePos, node: Expr_) -> Gc<Expr>

fn mk_unary(&mut self, unop: UnOp, expr: Gc<Expr>) -> Expr_

fn mk_binary(&mut self, binop: BinOp, lhs: Gc<Expr>, rhs: Gc<Expr>) -> Expr_

fn mk_call(&mut self, f: Gc<Expr>, args: Vec<Gc<Expr>>) -> Expr_

fn mk_index(&mut self, expr: Gc<Expr>, idx: Gc<Expr>) -> Expr_

fn mk_field(&mut self, expr: Gc<Expr>, ident: SpannedIdent, tys: Vec<P<Ty>>) -> Expr_

fn mk_assign_op(&mut self, binop: BinOp, lhs: Gc<Expr>, rhs: Gc<Expr>) -> Expr_

fn mk_mac_expr(&mut self, lo: BytePos, hi: BytePos, m: Mac_) -> Gc<Expr>

fn mk_lit_u32(&mut self, i: u32) -> Gc<Expr>

fn parse_bottom_expr(&mut self) -> Gc<Expr>

fn parse_block_expr(&mut self, lo: BytePos, blk_mode: BlockCheckMode) -> Gc<Expr>

fn parse_dot_or_call_expr(&mut self) -> Gc<Expr>

fn parse_dot_or_call_expr_with(&mut self, e0: Gc<Expr>) -> Gc<Expr>

fn parse_sep_and_zerok(&mut self) -> (Option<Token>, bool)

fn parse_token_tree(&mut self) -> TokenTree

fn parse_all_token_trees(&mut self) -> Vec<TokenTree>

fn parse_matchers(&mut self) -> Vec<Matcher>

fn parse_matcher_subseq_upto(&mut self, name_idx: &mut uint, ket: &Token) -> Vec<Matcher>

fn parse_matcher(&mut self, name_idx: &mut uint) -> Matcher

fn parse_prefix_expr(&mut self) -> Gc<Expr>

fn parse_binops(&mut self) -> Gc<Expr>

fn parse_more_binops(&mut self, lhs: Gc<Expr>, min_prec: uint) -> Gc<Expr>

fn parse_assign_expr(&mut self) -> Gc<Expr>

fn parse_if_expr(&mut self) -> Gc<Expr>

fn parse_lambda_block_expr(&mut self) -> Gc<Expr>

fn parse_lambda_expr(&mut self) -> Gc<Expr>

fn parse_lambda_expr_(&mut self, parse_decl: |&mut Parser| -> P<FnDecl>, parse_body: |&mut Parser| -> Gc<Expr>) -> Gc<Expr>

fn parse_else_expr(&mut self) -> Gc<Expr>

fn parse_for_expr(&mut self, opt_ident: Option<Ident>) -> Gc<Expr>

fn parse_while_expr(&mut self) -> Gc<Expr>

fn parse_loop_expr(&mut self, opt_ident: Option<Ident>) -> Gc<Expr>

fn parse_expr(&mut self) -> Gc<Expr>

fn parse_expr_res(&mut self, r: restriction) -> Gc<Expr>

fn parse_pat(&mut self) -> Gc<Pat>

fn parse_stmt(&mut self, item_attrs: Vec<Attribute>) -> Gc<Stmt>

fn parse_block(&mut self) -> P<Block>

fn parse_generics(&mut self) -> Generics

fn parse_fn_decl(&mut self, allow_variadic: bool) -> P<FnDecl>

fn parse_single_struct_field(&mut self, vis: Visibility, attrs: Vec<Attribute>) -> StructField

fn parse_item_with_outer_attributes(&mut self) -> Option<Gc<Item>>

fn parse_item(&mut self, attrs: Vec<Attribute>) -> Option<Gc<Item>>

fn parse_crate_mod(&mut self) -> Crate

fn parse_optional_str(&mut self) -> Option<(InternedString, StrStyle)>

fn parse_str(&mut self) -> (InternedString, StrStyle)

Trait Implementations

impl<'a> ParserAttr for Parser<'a>

fn parse_outer_attributes(&mut self) -> Vec<Attribute>

fn parse_attribute(&mut self, permit_inner: bool) -> Attribute

fn parse_inner_attrs_and_next(&mut self) -> (Vec<Attribute>, Vec<Attribute>)

fn parse_meta_item(&mut self) -> Gc<MetaItem>

fn parse_meta_seq(&mut self) -> Vec<Gc<MetaItem>>

fn parse_optional_meta(&mut self) -> Vec<Gc<MetaItem>>

impl<'a> ParserObsoleteMethods for Parser<'a>

fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax)

Reports an obsolete syntax non-fatal error.

fn obsolete_expr(&mut self, sp: Span, kind: ObsoleteSyntax) -> Gc<Expr>

fn report(&mut self, sp: Span, kind: ObsoleteSyntax, kind_str: &str, desc: &str)

fn is_obsolete_ident(&mut self, ident: &str) -> bool

fn eat_obsolete_ident(&mut self, ident: &str) -> bool