librustc: Make self
and static
into keywords
This commit is contained in:
parent
06ef889cdc
commit
5d3559e645
51 changed files with 700 additions and 610 deletions
|
@ -26,7 +26,7 @@ use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body};
|
|||
use ast::{expr_field, expr_fn_block, expr_if, expr_index};
|
||||
use ast::{expr_lit, expr_log, expr_loop, expr_loop_body, expr_mac};
|
||||
use ast::{expr_method_call, expr_paren, expr_path, expr_repeat};
|
||||
use ast::{expr_ret, expr_struct, expr_tup, expr_unary};
|
||||
use ast::{expr_ret, expr_self, expr_struct, expr_tup, expr_unary};
|
||||
use ast::{expr_vec, expr_vstore, expr_vstore_mut_box};
|
||||
use ast::{expr_vstore_slice, expr_vstore_box};
|
||||
use ast::{expr_vstore_mut_slice, expr_while, extern_fn, field, fn_decl};
|
||||
|
@ -430,8 +430,12 @@ pub impl Parser {
|
|||
lifetimes: lifetimes,
|
||||
});
|
||||
|
||||
fn parse_onceness(self: &Parser) -> Onceness {
|
||||
if self.eat_keyword(&~"once") { Once } else { Many }
|
||||
fn parse_onceness(this: &Parser) -> Onceness {
|
||||
if this.eat_keyword(&~"once") {
|
||||
Once
|
||||
} else {
|
||||
Many
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1224,6 +1228,9 @@ pub impl Parser {
|
|||
expr_block(blk));
|
||||
} else if token::is_bar(&*self.token) {
|
||||
return self.parse_lambda_expr();
|
||||
} else if self.eat_keyword(&~"self") {
|
||||
ex = expr_self;
|
||||
hi = self.span.hi;
|
||||
} else if self.eat_keyword(&~"if") {
|
||||
return self.parse_if_expr();
|
||||
} else if self.eat_keyword(&~"for") {
|
||||
|
@ -2984,9 +2991,7 @@ pub impl Parser {
|
|||
}
|
||||
}
|
||||
|
||||
fn maybe_parse_borrowed_self_ty(
|
||||
self: &Parser
|
||||
) -> ast::self_ty_ {
|
||||
fn maybe_parse_borrowed_self_ty(this: &Parser) -> ast::self_ty_ {
|
||||
// The following things are possible to see here:
|
||||
//
|
||||
// fn(&self)
|
||||
|
@ -2996,37 +3001,29 @@ pub impl Parser {
|
|||
//
|
||||
// We already know that the current token is `&`.
|
||||
|
||||
if (
|
||||
self.token_is_keyword(&~"self", &self.look_ahead(1)))
|
||||
{
|
||||
self.bump();
|
||||
self.expect_self_ident();
|
||||
if (this.token_is_keyword(&~"self", &this.look_ahead(1))) {
|
||||
this.bump();
|
||||
this.expect_self_ident();
|
||||
sty_region(None, m_imm)
|
||||
} else if (
|
||||
self.token_is_mutability(&self.look_ahead(1)) &&
|
||||
self.token_is_keyword(&~"self", &self.look_ahead(2)))
|
||||
{
|
||||
self.bump();
|
||||
let mutability = self.parse_mutability();
|
||||
self.expect_self_ident();
|
||||
} else if (this.token_is_mutability(&this.look_ahead(1)) &&
|
||||
this.token_is_keyword(&~"self", &this.look_ahead(2))) {
|
||||
this.bump();
|
||||
let mutability = this.parse_mutability();
|
||||
this.expect_self_ident();
|
||||
sty_region(None, mutability)
|
||||
} else if (
|
||||
self.token_is_lifetime(&self.look_ahead(1)) &&
|
||||
self.token_is_keyword(&~"self", &self.look_ahead(2)))
|
||||
{
|
||||
self.bump();
|
||||
let lifetime = @self.parse_lifetime();
|
||||
self.expect_self_ident();
|
||||
} else if (this.token_is_lifetime(&this.look_ahead(1)) &&
|
||||
this.token_is_keyword(&~"self", &this.look_ahead(2))) {
|
||||
this.bump();
|
||||
let lifetime = @this.parse_lifetime();
|
||||
this.expect_self_ident();
|
||||
sty_region(Some(lifetime), m_imm)
|
||||
} else if (
|
||||
self.token_is_lifetime(&self.look_ahead(1)) &&
|
||||
self.token_is_mutability(&self.look_ahead(2)) &&
|
||||
self.token_is_keyword(&~"self", &self.look_ahead(3)))
|
||||
{
|
||||
self.bump();
|
||||
let lifetime = @self.parse_lifetime();
|
||||
let mutability = self.parse_mutability();
|
||||
self.expect_self_ident();
|
||||
} else if (this.token_is_lifetime(&this.look_ahead(1)) &&
|
||||
this.token_is_mutability(&this.look_ahead(2)) &&
|
||||
this.token_is_keyword(&~"self", &this.look_ahead(3))) {
|
||||
this.bump();
|
||||
let lifetime = @this.parse_lifetime();
|
||||
let mutability = this.parse_mutability();
|
||||
this.expect_self_ident();
|
||||
sty_region(Some(lifetime), mutability)
|
||||
} else {
|
||||
sty_static
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue