diff options
| author | Michael Sullivan <sully@msully.net> | 2012-05-22 14:59:15 -0700 |
|---|---|---|
| committer | Michael Sullivan <sully@msully.net> | 2012-05-22 14:59:15 -0700 |
| commit | 15cef374b9a16a0f8b40665dbafdf725e9456ffd (patch) | |
| tree | 8d817652bb982c05294fb01ff8a80a1ab0689316 /src/librustsyntax/parse | |
| parent | 8d7f3bd1ca622e6ddc03f4592eb8a451fbf850ab (diff) | |
| download | rust-15cef374b9a16a0f8b40665dbafdf725e9456ffd.tar.gz rust-15cef374b9a16a0f8b40665dbafdf725e9456ffd.zip | |
Get rid of the >>> operator and make >> logical or arithmetic depending on the signedness. Closes #2417.
Diffstat (limited to 'src/librustsyntax/parse')
| -rw-r--r-- | src/librustsyntax/parse/common.rs | 7 | ||||
| -rw-r--r-- | src/librustsyntax/parse/lexer.rs | 9 | ||||
| -rw-r--r-- | src/librustsyntax/parse/parser.rs | 5 | ||||
| -rw-r--r-- | src/librustsyntax/parse/prec.rs | 5 | ||||
| -rw-r--r-- | src/librustsyntax/parse/token.rs | 10 |
5 files changed, 12 insertions, 24 deletions
diff --git a/src/librustsyntax/parse/common.rs b/src/librustsyntax/parse/common.rs index b50c2b7e7f3..a4d30cf2627 100644 --- a/src/librustsyntax/parse/common.rs +++ b/src/librustsyntax/parse/common.rs @@ -114,10 +114,8 @@ fn check_restricted_keywords_(p: parser, w: ast::ident) { fn expect_gt(p: parser) { if p.token == token::GT { p.bump(); - } else if p.token == token::BINOP(token::LSR) { + } else if p.token == token::BINOP(token::SHR) { p.swap(token::GT, p.span.lo + 1u, p.span.hi); - } else if p.token == token::BINOP(token::ASR) { - p.swap(token::BINOP(token::LSR), p.span.lo + 1u, p.span.hi); } else { let mut s: str = "expecting "; s += token_to_str(p.reader, token::GT); @@ -132,8 +130,7 @@ fn parse_seq_to_before_gt<T: copy>(sep: option<token::token>, p: parser) -> [T] { let mut first = true; let mut v = []; - while p.token != token::GT && p.token != token::BINOP(token::LSR) && - p.token != token::BINOP(token::ASR) { + while p.token != token::GT && p.token != token::BINOP(token::SHR) { alt sep { some(t) { if first { first = false; } else { expect(p, t); } } _ { } diff --git a/src/librustsyntax/parse/lexer.rs b/src/librustsyntax/parse/lexer.rs index e486355501f..dd1d624d1cf 100644 --- a/src/librustsyntax/parse/lexer.rs +++ b/src/librustsyntax/parse/lexer.rs @@ -392,7 +392,7 @@ fn next_token_inner(rdr: reader) -> token::token { rdr.bump(); alt rdr.curr { '=' { rdr.bump(); ret token::LE; } - '<' { ret binop(rdr, token::LSL); } + '<' { ret binop(rdr, token::SHL); } '-' { rdr.bump(); alt rdr.curr { @@ -407,12 +407,7 @@ fn next_token_inner(rdr: reader) -> token::token { rdr.bump(); alt rdr.curr { '=' { rdr.bump(); ret token::GE; } - '>' { - if rdr.next() == '>' { - rdr.bump(); - ret binop(rdr, token::ASR); - } else { ret binop(rdr, token::LSR); } - } + '>' { ret binop(rdr, token::SHR); } _ { ret token::GT; } } } diff --git a/src/librustsyntax/parse/parser.rs b/src/librustsyntax/parse/parser.rs index 48d31a8c35c..bf55ebf43c6 100644 --- a/src/librustsyntax/parse/parser.rs +++ b/src/librustsyntax/parse/parser.rs @@ -1119,9 +1119,8 @@ fn parse_assign_expr(p: parser) -> @expr { token::CARET { aop = bitxor; } token::AND { aop = bitand; } token::OR { aop = bitor; } - token::LSL { aop = lsl; } - token::LSR { aop = lsr; } - token::ASR { aop = asr; } + token::SHL { aop = shl; } + token::SHR { aop = shr; } } p.get_id(); // see ast_util::op_expr_callee_id ret mk_expr(p, lo, rhs.span.hi, expr_assign_op(aop, lhs, rhs)); diff --git a/src/librustsyntax/parse/prec.rs b/src/librustsyntax/parse/prec.rs index 6933ebb19d8..e2e35447af3 100644 --- a/src/librustsyntax/parse/prec.rs +++ b/src/librustsyntax/parse/prec.rs @@ -25,9 +25,8 @@ fn token_to_binop(tok: token) -> option<ast::binop> { // 'as' sits between here with 11 BINOP(PLUS) { some(add) } BINOP(MINUS) { some(subtract) } - BINOP(LSL) { some(lsl) } - BINOP(LSR) { some(lsr) } - BINOP(ASR) { some(asr) } + BINOP(SHL) { some(shl) } + BINOP(SHR) { some(shr) } BINOP(AND) { some(bitand) } BINOP(CARET) { some(bitxor) } BINOP(OR) { some(bitor) } diff --git a/src/librustsyntax/parse/token.rs b/src/librustsyntax/parse/token.rs index ca3e0d0d87d..1c6f240cf82 100644 --- a/src/librustsyntax/parse/token.rs +++ b/src/librustsyntax/parse/token.rs @@ -14,9 +14,8 @@ enum binop { CARET, AND, OR, - LSL, - LSR, - ASR, + SHL, + SHR, } enum token { @@ -78,9 +77,8 @@ fn binop_to_str(o: binop) -> str { CARET { ret "^"; } AND { ret "&"; } OR { ret "|"; } - LSL { ret "<<"; } - LSR { ret ">>"; } - ASR { ret ">>>"; } + SHL { ret "<<"; } + SHR { ret ">>"; } } } |
