diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2012-02-09 11:50:54 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2012-02-09 11:58:08 +0100 |
| commit | 50fb4c30ed02e72a715e093c8f87b0c179fb3ccb (patch) | |
| tree | f94ca4759ed236f088971717c3d1cc4182002ac2 /src/comp/syntax | |
| parent | 1dc5e1aa94d1c82d12385dfcb95c75cbaaa318a9 (diff) | |
| download | rust-50fb4c30ed02e72a715e093c8f87b0c179fb3ccb.tar.gz rust-50fb4c30ed02e72a715e093c8f87b0c179fb3ccb.zip | |
Increase precedence of as operator
Closes #1717
Diffstat (limited to 'src/comp/syntax')
| -rw-r--r-- | src/comp/syntax/ast_util.rs | 6 | ||||
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/comp/syntax/ast_util.rs b/src/comp/syntax/ast_util.rs index d0cfb5ee848..88148b990f8 100644 --- a/src/comp/syntax/ast_util.rs +++ b/src/comp/syntax/ast_util.rs @@ -269,9 +269,9 @@ fn eval_const_expr(e: @expr) -> const_val { mul { const_uint(a * b) } div { const_uint(a / b) } rem { const_uint(a % b) } and | bitand { const_uint(a & b) } or | bitor { const_uint(a | b) } bitxor { const_uint(a ^ b) } - lsl { const_int(a << b as i64) } - lsr { const_int(a >> b as i64) } - asr { const_int(a >>> b as i64) } + lsl { const_int((a << b) as i64) } + lsr { const_int((a >> b) as i64) } + asr { const_int((a >>> b) as i64) } eq { fromb(a == b) } lt { fromb(a < b) } le { fromb(a <= b) } ne { fromb(a != b) } ge { fromb(a >= b) } gt { fromb(a > b) } diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index d15c333c5fe..a988557b84d 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -1123,7 +1123,8 @@ type op_spec = {tok: token::token, op: ast::binop, prec: int}; // FIXME make this a const, don't store it in parser state fn prec_table() -> @[op_spec] { - ret @[{tok: token::BINOP(token::STAR), op: ast::mul, prec: 11}, + ret @[// 'as' sits between here with 12 + {tok: token::BINOP(token::STAR), op: ast::mul, prec: 11}, {tok: token::BINOP(token::SLASH), op: ast::div, prec: 11}, {tok: token::BINOP(token::PERCENT), op: ast::rem, prec: 11}, {tok: token::BINOP(token::PLUS), op: ast::add, prec: 10}, @@ -1134,7 +1135,6 @@ fn prec_table() -> @[op_spec] { {tok: token::BINOP(token::AND), op: ast::bitand, prec: 8}, {tok: token::BINOP(token::CARET), op: ast::bitxor, prec: 7}, {tok: token::BINOP(token::OR), op: ast::bitor, prec: 6}, - // 'as' sits between here with 5 {tok: token::LT, op: ast::lt, prec: 4}, {tok: token::LE, op: ast::le, prec: 4}, {tok: token::GE, op: ast::ge, prec: 4}, @@ -1151,7 +1151,7 @@ fn parse_binops(p: parser) -> @ast::expr { const unop_prec: int = 100; -const as_prec: int = 5; +const as_prec: int = 12; fn parse_more_binops(p: parser, plhs: pexpr, min_prec: int) -> @ast::expr { |
