]> git.lizzy.rs Git - rust.git/commitdiff
preserve context in parsing of `self` varref
authorJohn Clements <clements@racket-lang.org>
Sun, 6 Jul 2014 22:11:44 +0000 (15:11 -0700)
committerJohn Clements <clements@racket-lang.org>
Tue, 8 Jul 2014 22:14:46 +0000 (15:14 -0700)
src/libsyntax/parse/parser.rs

index 2f6555dcb69d51caa0474a26dea3ccbce83deca4..d0e44b20139ead0d423db61f50b9d580c799da0f 100644 (file)
@@ -541,12 +541,13 @@ pub fn is_keyword(&mut self, kw: keywords::Keyword) -> bool {
     // if the next token is the given keyword, eat it and return
     // true. Otherwise, return false.
     pub fn eat_keyword(&mut self, kw: keywords::Keyword) -> bool {
-        let is_kw = match self.token {
-            token::IDENT(sid, false) => kw.to_ident().name == sid.name,
+        match self.token {
+            token::IDENT(sid, false) if kw.to_ident().name == sid.name => {
+                self.bump();
+                true
+            }
             _ => false
-        };
-        if is_kw { self.bump() }
-        is_kw
+        }
     }
 
     // if the given word is not a keyword, signal an error.
@@ -1917,7 +1918,7 @@ pub fn parse_bottom_expr(&mut self) -> Gc<Expr> {
                 return self.mk_expr(blk.span.lo, blk.span.hi,
                                     ExprBlock(blk));
             },
-            _ if token::is_bar(&self.token) => {
+            token::BINOP(token::OR) |  token::OROR => {
                 return self.parse_lambda_expr();
             },
             _ if self.eat_keyword(keywords::Proc) => {
@@ -1933,8 +1934,9 @@ pub fn parse_bottom_expr(&mut self) -> Gc<Expr> {
                     });
                 return self.mk_expr(lo, body.span.hi, ExprProc(decl, fakeblock));
             },
-            _ if self.eat_keyword(keywords::Self) => {
-                let path = ast_util::ident_to_path(mk_sp(lo, hi), special_idents::self_);
+            token::IDENT(id @ ast::Ident{name:token::SELF_KEYWORD_NAME,ctxt:_},false) => {
+                self.bump();
+                let path = ast_util::ident_to_path(mk_sp(lo, hi), id);
                 ex = ExprPath(path);
                 hi = self.last_span.hi;
             }
@@ -1982,7 +1984,7 @@ pub fn parse_bottom_expr(&mut self) -> Gc<Expr> {
             },
             token::LBRACKET => {
                 self.bump();
-                
+
                 if self.token == token::RBRACKET {
                     // Empty vector.
                     self.bump();