about summary refs log tree commit diff
path: root/src/comp/front
diff options
context:
space:
mode:
authorLindsey Kuper <lkuper@mozilla.com>2011-03-29 15:51:53 -0700
committerLindsey Kuper <lkuper@mozilla.com>2011-03-29 15:59:15 -0700
commit55fbed3d8d7078bfd3864e64cc044cbe876c5d1a (patch)
tree3c0a53f8f59dbda781fda2a7ad1e5afcce719de2 /src/comp/front
parentf6490a6f03dd997d7cb801dff9d48a56b336fccc (diff)
downloadrust-55fbed3d8d7078bfd3864e64cc044cbe876c5d1a.tar.gz
rust-55fbed3d8d7078bfd3864e64cc044cbe876c5d1a.zip
Beginnings of support for magical self prefix; nothing profound happening yet.
Diffstat (limited to 'src/comp/front')
-rw-r--r--src/comp/front/ast.rs1
-rw-r--r--src/comp/front/lexer.rs1
-rw-r--r--src/comp/front/parser.rs15
-rw-r--r--src/comp/front/token.rs3
4 files changed, 19 insertions, 1 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs
index 4493bea8739..9e7c3cc144e 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/front/ast.rs
@@ -252,6 +252,7 @@ tag expr_ {
     expr_tup(vec[elt], ann);
     expr_rec(vec[field], option.t[@expr], ann);
     expr_call(@expr, vec[@expr], ann);
+    expr_call_self(@expr, vec[@expr], ann);
     expr_bind(@expr, vec[option.t[@expr]], ann);
     expr_spawn(spawn_dom, option.t[str], @expr, vec[@expr], ann);
     expr_binary(binop, @expr, @expr, ann);
diff --git a/src/comp/front/lexer.rs b/src/comp/front/lexer.rs
index 878940b73bc..86b872da708 100644
--- a/src/comp/front/lexer.rs
+++ b/src/comp/front/lexer.rs
@@ -169,6 +169,7 @@ impure fn new_reader(io.reader rdr, str filename) -> reader
     keywords.insert("any", token.ANY);
 
     keywords.insert("obj", token.OBJ);
+    keywords.insert("self", token.SELF);
 
     keywords.insert("port", token.PORT);
     keywords.insert("chan", token.CHAN);
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index 7bec44e64b5..25c9f4a50fa 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -883,6 +883,20 @@ impure fn parse_bottom_expr(parser p) -> @ast.expr {
             ex = ast.expr_chan(e, ast.ann_none);
         }
 
+        case (token.SELF) {
+            p.bump();
+            expect(p, token.DOT);
+            // The rest is a call expression.
+            auto e = parse_bottom_expr(p);
+            auto pf = parse_expr;
+            auto es = parse_seq[@ast.expr](token.LPAREN,
+                                           token.RPAREN,
+                                           some(token.COMMA),
+                                           pf, p);
+            hi = es.span;
+            auto ex = ast.expr_call_self(e, es.node, ast.ann_none);
+        }
+
         case (_) {
             auto lit = parse_lit(p);
             hi = lit.span;
@@ -1646,6 +1660,7 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool {
                 case (ast.expr_tup(_,_))        { ret true; }
                 case (ast.expr_rec(_,_,_))      { ret true; }
                 case (ast.expr_call(_,_,_))     { ret true; }
+                case (ast.expr_call_self(_,_,_)){ ret true; }
                 case (ast.expr_binary(_,_,_,_)) { ret true; }
                 case (ast.expr_unary(_,_,_))    { ret true; }
                 case (ast.expr_lit(_,_))        { ret true; }
diff --git a/src/comp/front/token.rs b/src/comp/front/token.rs
index bb0cea80bb8..5ac9d662f1c 100644
--- a/src/comp/front/token.rs
+++ b/src/comp/front/token.rs
@@ -160,8 +160,9 @@ tag token {
     FN;
     ITER;
 
-    /* Object type */
+    /* Object type and related keywords */
     OBJ;
+    SELF;
 
     /* Comm and task types */
     CHAN;