about summary refs log tree commit diff
path: root/src/comp/syntax/parse
diff options
context:
space:
mode:
authorPaul Woolcock <pwoolcoc+github@gmail.com>2012-01-30 11:40:54 -0500
committerMarijn Haverbeke <marijnh@gmail.com>2012-01-30 18:21:19 +0100
commit6ba3d2435556ae4ea72eeb6095e95b5c14a3c1f7 (patch)
tree31aa2e040ad356b1d6c2dc34dadbd4970d39eaea /src/comp/syntax/parse
parenta02493b96919bae8c27a2508a08709dbabdfc744 (diff)
downloadrust-6ba3d2435556ae4ea72eeb6095e95b5c14a3c1f7.tar.gz
rust-6ba3d2435556ae4ea72eeb6095e95b5c14a3c1f7.zip
Remove ternary operator
`expr_ternary`, `ternary_to_if`, and all parses & lexer definitions have
been removed.
Diffstat (limited to 'src/comp/syntax/parse')
-rw-r--r--src/comp/syntax/parse/lexer.rs4
-rw-r--r--src/comp/syntax/parse/parser.rs15
-rw-r--r--src/comp/syntax/parse/token.rs2
3 files changed, 1 insertions, 20 deletions
diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs
index c7c0f32cff9..ae31f1b3434 100644
--- a/src/comp/syntax/parse/lexer.rs
+++ b/src/comp/syntax/parse/lexer.rs
@@ -328,10 +328,6 @@ fn next_token_inner(rdr: reader) -> token::token {
 
 
       // One-byte tokens.
-      '?' {
-        rdr.bump();
-        ret token::QUES;
-      }
       ';' { rdr.bump(); ret token::SEMI; }
       ',' { rdr.bump(); ret token::COMMA; }
       '.' {
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 9678c69b1df..272d65707dd 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -1097,18 +1097,6 @@ fn parse_prefix_expr(p: parser) -> pexpr {
     ret mk_pexpr(p, lo, hi, ex);
 }
 
-fn parse_ternary(p: parser) -> @ast::expr {
-    let cond_expr = parse_binops(p);
-    if p.token == token::QUES {
-        p.bump();
-        let then_expr = parse_expr(p);
-        expect(p, token::COLON);
-        let else_expr = parse_expr(p);
-        ret mk_expr(p, cond_expr.span.lo, else_expr.span.hi,
-                    ast::expr_ternary(cond_expr, then_expr, else_expr));
-    } else { ret cond_expr; }
-}
-
 type op_spec = {tok: token::token, op: ast::binop, prec: int};
 
 
@@ -1143,7 +1131,6 @@ fn parse_binops(p: parser) -> @ast::expr {
 const unop_prec: int = 100;
 
 const as_prec: int = 5;
-const ternary_prec: int = 0;
 
 fn parse_more_binops(p: parser, plhs: pexpr, min_prec: int) ->
    @ast::expr {
@@ -1174,7 +1161,7 @@ fn parse_more_binops(p: parser, plhs: pexpr, min_prec: int) ->
 
 fn parse_assign_expr(p: parser) -> @ast::expr {
     let lo = p.span.lo;
-    let lhs = parse_ternary(p);
+    let lhs = parse_binops(p);
     alt p.token {
       token::EQ {
         p.bump();
diff --git a/src/comp/syntax/parse/token.rs b/src/comp/syntax/parse/token.rs
index 0965697f8c8..3b38f314ecf 100644
--- a/src/comp/syntax/parse/token.rs
+++ b/src/comp/syntax/parse/token.rs
@@ -43,7 +43,6 @@ enum token {
     SEMI,
     COLON,
     MOD_SEP,
-    QUES,
     RARROW,
     LARROW,
     DARROW,
@@ -114,7 +113,6 @@ fn to_str(r: reader, t: token) -> str {
       SEMI { ret ";"; }
       COLON { ret ":"; }
       MOD_SEP { ret "::"; }
-      QUES { ret "?"; }
       RARROW { ret "->"; }
       LARROW { ret "<-"; }
       DARROW { ret "<->"; }