pub use self::Lit::*;
pub use self::Token::*;
-use ast;
+use ast::{self, BinOpKind};
use ext::mtwt;
use ptr::P;
use util::interner::{RcStr, StrInterner};
}
}
+ /// Returns `true` if the token is interpolated.
+ pub fn is_interpolated(&self) -> bool {
+ match *self {
+ Interpolated(..) => true,
+ _ => false,
+ }
+ }
+
/// Returns `true` if the token is an interpolated path.
pub fn is_path(&self) -> bool {
match *self {
}
/// Maps a token to its corresponding binary operator.
- pub fn to_binop(&self) -> Option<ast::BinOp_> {
+ pub fn to_binop(&self) -> Option<BinOpKind> {
match *self {
- BinOp(Star) => Some(ast::BiMul),
- BinOp(Slash) => Some(ast::BiDiv),
- BinOp(Percent) => Some(ast::BiRem),
- BinOp(Plus) => Some(ast::BiAdd),
- BinOp(Minus) => Some(ast::BiSub),
- BinOp(Shl) => Some(ast::BiShl),
- BinOp(Shr) => Some(ast::BiShr),
- BinOp(And) => Some(ast::BiBitAnd),
- BinOp(Caret) => Some(ast::BiBitXor),
- BinOp(Or) => Some(ast::BiBitOr),
- Lt => Some(ast::BiLt),
- Le => Some(ast::BiLe),
- Ge => Some(ast::BiGe),
- Gt => Some(ast::BiGt),
- EqEq => Some(ast::BiEq),
- Ne => Some(ast::BiNe),
- AndAnd => Some(ast::BiAnd),
- OrOr => Some(ast::BiOr),
+ BinOp(Star) => Some(BinOpKind::Mul),
+ BinOp(Slash) => Some(BinOpKind::Div),
+ BinOp(Percent) => Some(BinOpKind::Rem),
+ BinOp(Plus) => Some(BinOpKind::Add),
+ BinOp(Minus) => Some(BinOpKind::Sub),
+ BinOp(Shl) => Some(BinOpKind::Shl),
+ BinOp(Shr) => Some(BinOpKind::Shr),
+ BinOp(And) => Some(BinOpKind::BitAnd),
+ BinOp(Caret) => Some(BinOpKind::BitXor),
+ BinOp(Or) => Some(BinOpKind::BitOr),
+ Lt => Some(BinOpKind::Lt),
+ Le => Some(BinOpKind::Le),
+ Ge => Some(BinOpKind::Ge),
+ Gt => Some(BinOpKind::Gt),
+ EqEq => Some(BinOpKind::Eq),
+ Ne => Some(BinOpKind::Ne),
+ AndAnd => Some(BinOpKind::And),
+ OrOr => Some(BinOpKind::Or),
_ => None,
}
}
impl Deref for InternedString {
type Target = str;
- fn deref(&self) -> &str { &*self.string }
+ fn deref(&self) -> &str { &self.string }
}
impl fmt::Debug for InternedString {