Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove parse value ident #5255

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ pub struct Lifetime {
ident: ident
}

// a "Path" is essentially Rust's notion of a name;
// for instance: core::cmp::Eq . It's represented
// as a sequence of identifiers, along with a bunch
// of supporting information.
#[auto_encode]
#[auto_decode]
#[deriving_eq]
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/tt/transcribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct TtFrame {
pub struct TtReader {
sp_diag: span_handler,
interner: @ident_interner,
// the unzipped tree:
cur: @mut TtFrame,
/* for MBE-style macro transcription */
interpolations: std::oldmap::HashMap<ident, @named_match>,
Expand Down
4 changes: 0 additions & 4 deletions src/libsyntax/parse/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ pub impl Parser {
id: self.get_id() })
}

fn parse_value_ident(&self) -> ast::ident {
return self.parse_ident();
}

// consume token 'tok' if it exists. Returns true if the given
// token was present, false otherwise.
fn eat(&self, tok: &token::Token) -> bool {
Expand Down
52 changes: 16 additions & 36 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ pub impl Parser {
let pur = p.parse_fn_purity();
// NB: at the moment, trait methods are public by default; this
// could change.
let ident = p.parse_method_name();
let ident = p.parse_ident();

let generics = p.parse_generics();

Expand Down Expand Up @@ -893,16 +893,9 @@ pub impl Parser {
codemap::spanned { node: lit, span: mk_sp(lo, self.last_span.hi) }
}

fn parse_path_without_tps(&self) -> @path {
self.parse_path_without_tps_(|p| p.parse_ident(),
|p| p.parse_ident())
}

fn parse_path_without_tps_(
&self,
parse_ident: fn(&Parser) -> ident,
parse_last_ident: fn(&Parser) -> ident
) -> @path {
// parse a path that doesn't have type parameters attached
fn parse_path_without_tps(&self)
-> @ast::path {
maybe_whole!(self, nt_path);
let lo = self.span.lo;
let global = self.eat(&token::MOD_SEP);
Expand All @@ -913,10 +906,10 @@ pub impl Parser {
&& self.look_ahead(1u) == token::MOD_SEP;

if is_not_last {
ids.push(parse_ident(self));
ids.push(self.parse_ident());
self.expect(&token::MOD_SEP);
} else {
ids.push(parse_last_ident(self));
ids.push(self.parse_ident());
break;
}
}
Expand All @@ -927,12 +920,7 @@ pub impl Parser {
types: ~[] }
}

fn parse_value_path(&self) -> @path {
self.parse_path_without_tps_(|p| p.parse_ident(),
|p| p.parse_value_ident())
}

fn parse_path_with_tps(&self, colons: bool) -> @path {
fn parse_path_with_tps(&self, colons: bool) -> @ast::path {
debug!("parse_path_with_tps(colons=%b)", colons);

maybe_whole!(self, nt_path);
Expand Down Expand Up @@ -2114,11 +2102,7 @@ pub impl Parser {
}

let lo1 = self.last_span.lo;
let fieldname = if self.look_ahead(1u) == token::COLON {
self.parse_ident()
} else {
self.parse_value_ident()
};
let fieldname = self.parse_ident();
let hi1 = self.last_span.lo;
let fieldpath = ast_util::ident_to_path(mk_sp(lo1, hi1),
fieldname);
Expand Down Expand Up @@ -2282,7 +2266,7 @@ pub impl Parser {
}

if is_plain_ident(&*self.token) && cannot_be_enum_or_struct {
let name = self.parse_value_path();
let name = self.parse_path_without_tps();
let sub;
if self.eat(&token::AT) {
sub = Some(self.parse_pat(refutable));
Expand Down Expand Up @@ -2355,7 +2339,7 @@ pub impl Parser {
*self.last_span,
~"expected identifier, found path");
}
let name = self.parse_value_path();
let name = self.parse_path_without_tps();
let sub = if self.eat(&token::AT) {
Some(self.parse_pat(refutable))
} else { None };
Expand Down Expand Up @@ -2453,7 +2437,7 @@ pub impl Parser {

// Potential trouble: if we allow macros with paths instead of
// idents, we'd need to look ahead past the whole path here...
let pth = self.parse_value_path();
let pth = self.parse_path_without_tps();
self.bump();

let id = if *self.token == token::LPAREN {
Expand Down Expand Up @@ -2958,7 +2942,7 @@ pub impl Parser {
}

fn parse_fn_header(&self) -> (ident, ast::Generics) {
let id = self.parse_value_ident();
let id = self.parse_ident();
let generics = self.parse_generics();
(id, generics)
}
Expand All @@ -2981,10 +2965,6 @@ pub impl Parser {
(ident, item_fn(decl, purity, generics, body), Some(inner_attrs))
}

fn parse_method_name(&self) -> ident {
self.parse_value_ident()
}

fn parse_method(&self) -> @method {
let attrs = self.parse_outer_attributes();
let lo = self.span.lo;
Expand All @@ -2994,7 +2974,7 @@ pub impl Parser {

let visa = self.parse_visibility();
let pur = self.parse_fn_purity();
let ident = self.parse_method_name();
let ident = self.parse_ident();
let generics = self.parse_generics();
let (self_ty, decl) = do self.parse_fn_decl_with_self() |p| {
p.parse_arg()
Expand Down Expand Up @@ -3118,7 +3098,7 @@ pub impl Parser {
}

fn parse_item_struct(&self) -> item_info {
let class_name = self.parse_value_ident();
let class_name = self.parse_ident();
self.parse_region_param();
let generics = self.parse_generics();
if self.eat(&token::COLON) {
Expand Down Expand Up @@ -3346,7 +3326,7 @@ pub impl Parser {
}

fn parse_item_const(&self) -> item_info {
let id = self.parse_value_ident();
let id = self.parse_ident();
self.expect(&token::COLON);
let ty = self.parse_ty(false);
self.expect(&token::EQ);
Expand Down Expand Up @@ -3744,7 +3724,7 @@ pub impl Parser {
kind = enum_variant_kind(nested_enum_def);
needs_comma = false;
} else {
ident = self.parse_value_ident();
ident = self.parse_ident();
if self.eat(&token::LBRACE) {
// Parse a struct variant.
all_nullary = false;
Expand Down