]>
git.proxmox.com Git - rustc.git/blob - src/libsyntax/parse/prec.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
14 use parse
::token
::Token
;
18 /// Unary operators have higher precedence than binary
19 pub static unop_prec
: uint
= 100u;
22 * Precedence of the `as` operator, which is a binary operator
23 * but is not represented in the precedence table.
25 pub static as_prec
: uint
= 11u;
28 * Maps a token to a record specifying the corresponding binary
29 * operator and its precedence
31 pub fn token_to_binop(tok
: Token
) -> Option
<ast
::binop
> {
33 BINOP(STAR
) => Some(mul
),
34 BINOP(SLASH
) => Some(div
),
35 BINOP(PERCENT
) => Some(rem
),
36 // 'as' sits between here with 11
37 BINOP(PLUS
) => Some(add
),
38 BINOP(MINUS
) => Some(subtract
),
39 BINOP(SHL
) => Some(shl
),
40 BINOP(SHR
) => Some(shr
),
41 BINOP(AND
) => Some(bitand
),
42 BINOP(CARET
) => Some(bitxor
),
43 BINOP(OR
) => Some(bitor
),