2013-05-30 05:16:33 -05:00
|
|
|
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
2012-12-03 18:48:01 -06:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2012-12-23 16:41:37 -06:00
|
|
|
use ast;
|
2013-06-25 13:43:52 -05:00
|
|
|
use ast::{Name, Mrk};
|
2012-12-23 16:41:37 -06:00
|
|
|
use ast_util;
|
|
|
|
use parse::token;
|
2013-05-02 03:16:07 -05:00
|
|
|
use util::interner::StrInterner;
|
2012-12-23 16:41:37 -06:00
|
|
|
use util::interner;
|
|
|
|
|
2013-06-26 12:11:19 -05:00
|
|
|
use std::cast;
|
2013-09-03 18:24:12 -05:00
|
|
|
use std::char;
|
2013-06-24 19:40:33 -05:00
|
|
|
use std::local_data;
|
2010-08-18 13:35:12 -05:00
|
|
|
|
2013-07-02 14:47:32 -05:00
|
|
|
#[deriving(Clone, Encodable, Decodable, Eq, IterBytes)]
|
2013-01-29 15:54:06 -06:00
|
|
|
pub enum binop {
|
2012-01-19 19:56:05 -06:00
|
|
|
PLUS,
|
|
|
|
MINUS,
|
|
|
|
STAR,
|
|
|
|
SLASH,
|
|
|
|
PERCENT,
|
|
|
|
CARET,
|
|
|
|
AND,
|
|
|
|
OR,
|
2012-05-22 16:59:15 -05:00
|
|
|
SHL,
|
|
|
|
SHR,
|
2010-09-09 17:59:29 -05:00
|
|
|
}
|
|
|
|
|
2013-07-02 14:47:32 -05:00
|
|
|
#[deriving(Clone, Encodable, Decodable, Eq, IterBytes)]
|
2013-01-29 15:54:06 -06:00
|
|
|
pub enum Token {
|
2010-09-09 17:59:29 -05:00
|
|
|
/* Expression-operator symbols. */
|
2012-01-19 19:56:05 -06:00
|
|
|
EQ,
|
|
|
|
LT,
|
|
|
|
LE,
|
|
|
|
EQEQ,
|
|
|
|
NE,
|
|
|
|
GE,
|
|
|
|
GT,
|
|
|
|
ANDAND,
|
|
|
|
OROR,
|
|
|
|
NOT,
|
|
|
|
TILDE,
|
|
|
|
BINOP(binop),
|
|
|
|
BINOPEQ(binop),
|
2010-09-09 17:59:29 -05:00
|
|
|
|
|
|
|
/* Structural symbols */
|
2012-01-19 19:56:05 -06:00
|
|
|
AT,
|
|
|
|
DOT,
|
2012-08-03 20:01:30 -05:00
|
|
|
DOTDOT,
|
2012-01-19 19:56:05 -06:00
|
|
|
COMMA,
|
|
|
|
SEMI,
|
|
|
|
COLON,
|
|
|
|
MOD_SEP,
|
|
|
|
RARROW,
|
|
|
|
LARROW,
|
|
|
|
DARROW,
|
2012-06-04 20:34:10 -05:00
|
|
|
FAT_ARROW,
|
2012-01-19 19:56:05 -06:00
|
|
|
LPAREN,
|
|
|
|
RPAREN,
|
|
|
|
LBRACKET,
|
|
|
|
RBRACKET,
|
|
|
|
LBRACE,
|
|
|
|
RBRACE,
|
|
|
|
POUND,
|
2012-04-22 18:58:04 -05:00
|
|
|
DOLLAR,
|
2012-01-25 17:38:09 -06:00
|
|
|
|
2010-09-09 17:59:29 -05:00
|
|
|
/* Literals */
|
2013-09-03 18:24:12 -05:00
|
|
|
LIT_CHAR(u32),
|
2012-01-19 19:56:05 -06:00
|
|
|
LIT_INT(i64, ast::int_ty),
|
|
|
|
LIT_UINT(u64, ast::uint_ty),
|
2012-06-14 21:41:40 -05:00
|
|
|
LIT_INT_UNSUFFIXED(i64),
|
2013-09-01 19:50:59 -05:00
|
|
|
LIT_FLOAT(ast::Ident, ast::float_ty),
|
|
|
|
LIT_FLOAT_UNSUFFIXED(ast::Ident),
|
|
|
|
LIT_STR(ast::Ident),
|
2010-09-09 17:59:29 -05:00
|
|
|
|
|
|
|
/* Name components */
|
2013-02-26 12:15:29 -06:00
|
|
|
// an identifier contains an "is_mod_name" boolean,
|
|
|
|
// indicating whether :: follows this token with no
|
|
|
|
// whitespace in between.
|
2013-09-01 19:50:59 -05:00
|
|
|
IDENT(ast::Ident, bool),
|
2012-01-19 19:56:05 -06:00
|
|
|
UNDERSCORE,
|
2013-09-01 19:50:59 -05:00
|
|
|
LIFETIME(ast::Ident),
|
2012-06-12 12:50:17 -05:00
|
|
|
|
2012-06-29 20:26:34 -05:00
|
|
|
/* For interpolation */
|
2012-07-27 21:14:46 -05:00
|
|
|
INTERPOLATED(nonterminal),
|
2012-06-12 12:50:17 -05:00
|
|
|
|
2013-09-01 19:50:59 -05:00
|
|
|
DOC_COMMENT(ast::Ident),
|
2012-01-19 19:56:05 -06:00
|
|
|
EOF,
|
2010-09-09 17:59:29 -05:00
|
|
|
}
|
2010-08-18 13:35:12 -05:00
|
|
|
|
2013-07-02 14:47:32 -05:00
|
|
|
#[deriving(Clone, Encodable, Decodable, Eq, IterBytes)]
|
2012-07-04 16:53:12 -05:00
|
|
|
/// For interpolation during macro expansion.
|
2013-01-29 15:54:06 -06:00
|
|
|
pub enum nonterminal {
|
2012-07-27 21:14:46 -05:00
|
|
|
nt_item(@ast::item),
|
2013-08-09 12:55:15 -05:00
|
|
|
nt_block(~ast::Block),
|
2013-09-01 20:45:37 -05:00
|
|
|
nt_stmt(@ast::Stmt),
|
|
|
|
nt_pat( @ast::Pat),
|
|
|
|
nt_expr(@ast::Expr),
|
2013-08-09 12:55:15 -05:00
|
|
|
nt_ty( ~ast::Ty),
|
2013-09-01 19:50:59 -05:00
|
|
|
nt_ident(~ast::Ident, bool),
|
2013-08-08 12:28:06 -05:00
|
|
|
nt_attr(@ast::Attribute), // #[foo]
|
2013-08-09 12:55:15 -05:00
|
|
|
nt_path(~ast::Path),
|
2012-07-27 21:14:46 -05:00
|
|
|
nt_tt( @ast::token_tree), //needs @ed to break a circularity
|
|
|
|
nt_matchers(~[ast::matcher])
|
2012-06-12 12:50:17 -05:00
|
|
|
}
|
|
|
|
|
2013-03-22 13:09:13 -05:00
|
|
|
pub fn binop_to_str(o: binop) -> ~str {
|
2012-08-06 14:34:08 -05:00
|
|
|
match o {
|
2012-08-03 21:59:04 -05:00
|
|
|
PLUS => ~"+",
|
|
|
|
MINUS => ~"-",
|
|
|
|
STAR => ~"*",
|
|
|
|
SLASH => ~"/",
|
|
|
|
PERCENT => ~"%",
|
|
|
|
CARET => ~"^",
|
|
|
|
AND => ~"&",
|
|
|
|
OR => ~"|",
|
|
|
|
SHL => ~"<<",
|
|
|
|
SHR => ~">>"
|
2010-08-20 17:57:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:59:59 -05:00
|
|
|
pub fn to_str(input: @ident_interner, t: &Token) -> ~str {
|
2013-02-24 21:54:37 -06:00
|
|
|
match *t {
|
2012-08-03 21:59:04 -05:00
|
|
|
EQ => ~"=",
|
|
|
|
LT => ~"<",
|
|
|
|
LE => ~"<=",
|
|
|
|
EQEQ => ~"==",
|
|
|
|
NE => ~"!=",
|
|
|
|
GE => ~">=",
|
|
|
|
GT => ~">",
|
|
|
|
NOT => ~"!",
|
|
|
|
TILDE => ~"~",
|
|
|
|
OROR => ~"||",
|
|
|
|
ANDAND => ~"&&",
|
|
|
|
BINOP(op) => binop_to_str(op),
|
2013-05-23 11:09:11 -05:00
|
|
|
BINOPEQ(op) => binop_to_str(op) + "=",
|
2011-09-02 17:34:58 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
/* Structural symbols */
|
2012-08-03 21:59:04 -05:00
|
|
|
AT => ~"@",
|
|
|
|
DOT => ~".",
|
|
|
|
DOTDOT => ~"..",
|
|
|
|
COMMA => ~",",
|
|
|
|
SEMI => ~";",
|
|
|
|
COLON => ~":",
|
|
|
|
MOD_SEP => ~"::",
|
|
|
|
RARROW => ~"->",
|
|
|
|
LARROW => ~"<-",
|
|
|
|
DARROW => ~"<->",
|
|
|
|
FAT_ARROW => ~"=>",
|
|
|
|
LPAREN => ~"(",
|
|
|
|
RPAREN => ~")",
|
|
|
|
LBRACKET => ~"[",
|
|
|
|
RBRACKET => ~"]",
|
|
|
|
LBRACE => ~"{",
|
|
|
|
RBRACE => ~"}",
|
|
|
|
POUND => ~"#",
|
|
|
|
DOLLAR => ~"$",
|
2012-01-25 17:38:09 -06:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
/* Literals */
|
2013-09-03 18:24:12 -05:00
|
|
|
LIT_CHAR(c) => {
|
2013-06-28 16:04:13 -05:00
|
|
|
let mut res = ~"'";
|
2013-09-03 18:24:12 -05:00
|
|
|
do char::from_u32(c).unwrap().escape_default |c| {
|
2013-06-28 16:04:13 -05:00
|
|
|
res.push_char(c);
|
|
|
|
}
|
|
|
|
res.push_char('\'');
|
|
|
|
res
|
2011-12-07 14:06:12 -06:00
|
|
|
}
|
2012-08-03 21:59:04 -05:00
|
|
|
LIT_INT(i, t) => {
|
2012-11-29 14:08:59 -06:00
|
|
|
i.to_str() + ast_util::int_ty_to_str(t)
|
2011-07-27 07:19:39 -05:00
|
|
|
}
|
2012-08-03 21:59:04 -05:00
|
|
|
LIT_UINT(u, t) => {
|
2012-11-29 14:08:59 -06:00
|
|
|
u.to_str() + ast_util::uint_ty_to_str(t)
|
2012-06-11 18:31:03 -05:00
|
|
|
}
|
2012-11-29 14:08:59 -06:00
|
|
|
LIT_INT_UNSUFFIXED(i) => { i.to_str() }
|
2013-06-04 14:34:25 -05:00
|
|
|
LIT_FLOAT(ref s, t) => {
|
2013-06-12 12:02:55 -05:00
|
|
|
let mut body = ident_to_str(s).to_owned();
|
2013-05-19 00:07:44 -05:00
|
|
|
if body.ends_with(".") {
|
2013-06-11 21:13:42 -05:00
|
|
|
body.push_char('0'); // `10.f` is not a float literal
|
2012-07-31 13:49:20 -05:00
|
|
|
}
|
|
|
|
body + ast_util::float_ty_to_str(t)
|
|
|
|
}
|
2013-06-04 14:34:25 -05:00
|
|
|
LIT_FLOAT_UNSUFFIXED(ref s) => {
|
2013-06-12 12:02:55 -05:00
|
|
|
let mut body = ident_to_str(s).to_owned();
|
2013-05-19 00:07:44 -05:00
|
|
|
if body.ends_with(".") {
|
2013-06-11 21:13:42 -05:00
|
|
|
body.push_char('0'); // `10.f` is not a float literal
|
2012-11-07 20:40:34 -06:00
|
|
|
}
|
|
|
|
body
|
|
|
|
}
|
2013-06-12 12:02:55 -05:00
|
|
|
LIT_STR(ref s) => { fmt!("\"%s\"", ident_to_str(s).escape_default()) }
|
2012-06-30 05:54:54 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
/* Name components */
|
2013-07-31 16:59:59 -05:00
|
|
|
IDENT(s, _) => input.get(s.name).to_owned(),
|
|
|
|
LIFETIME(s) => fmt!("'%s", input.get(s.name)),
|
2012-08-03 21:59:04 -05:00
|
|
|
UNDERSCORE => ~"_",
|
2012-06-30 05:54:54 -05:00
|
|
|
|
|
|
|
/* Other */
|
2013-06-12 12:02:55 -05:00
|
|
|
DOC_COMMENT(ref s) => ident_to_str(s).to_owned(),
|
2012-08-03 21:59:04 -05:00
|
|
|
EOF => ~"<eof>",
|
2012-12-04 12:50:00 -06:00
|
|
|
INTERPOLATED(ref nt) => {
|
2013-01-22 18:00:07 -06:00
|
|
|
match nt {
|
2013-07-31 16:59:59 -05:00
|
|
|
&nt_expr(e) => ::print::pprust::expr_to_str(e, input),
|
2013-08-08 12:28:06 -05:00
|
|
|
&nt_attr(e) => ::print::pprust::attribute_to_str(e, input),
|
2013-01-22 18:00:07 -06:00
|
|
|
_ => {
|
|
|
|
~"an interpolated " +
|
|
|
|
match (*nt) {
|
|
|
|
nt_item(*) => ~"item",
|
|
|
|
nt_block(*) => ~"block",
|
|
|
|
nt_stmt(*) => ~"statement",
|
|
|
|
nt_pat(*) => ~"pattern",
|
2013-08-08 12:28:06 -05:00
|
|
|
nt_attr(*) => fail!("should have been handled"),
|
2013-05-05 17:18:51 -05:00
|
|
|
nt_expr(*) => fail!("should have been handled above"),
|
2013-01-22 18:00:07 -06:00
|
|
|
nt_ty(*) => ~"type",
|
|
|
|
nt_ident(*) => ~"identifier",
|
|
|
|
nt_path(*) => ~"path",
|
|
|
|
nt_tt(*) => ~"tt",
|
|
|
|
nt_matchers(*) => ~"matcher sequence"
|
|
|
|
}
|
2012-07-06 16:48:01 -05:00
|
|
|
}
|
2013-01-22 18:00:07 -06:00
|
|
|
}
|
2012-06-29 20:26:34 -05:00
|
|
|
}
|
2010-08-20 13:41:34 -05:00
|
|
|
}
|
|
|
|
}
|
2011-07-03 13:48:14 -05:00
|
|
|
|
2013-03-22 13:09:13 -05:00
|
|
|
pub fn can_begin_expr(t: &Token) -> bool {
|
2013-02-24 19:24:28 -06:00
|
|
|
match *t {
|
2012-08-03 21:59:04 -05:00
|
|
|
LPAREN => true,
|
|
|
|
LBRACE => true,
|
|
|
|
LBRACKET => true,
|
|
|
|
IDENT(_, _) => true,
|
|
|
|
UNDERSCORE => true,
|
|
|
|
TILDE => true,
|
2013-09-03 18:24:12 -05:00
|
|
|
LIT_CHAR(_) => true,
|
2012-08-03 21:59:04 -05:00
|
|
|
LIT_INT(_, _) => true,
|
|
|
|
LIT_UINT(_, _) => true,
|
|
|
|
LIT_INT_UNSUFFIXED(_) => true,
|
|
|
|
LIT_FLOAT(_, _) => true,
|
2012-11-07 20:40:34 -06:00
|
|
|
LIT_FLOAT_UNSUFFIXED(_) => true,
|
2012-08-03 21:59:04 -05:00
|
|
|
LIT_STR(_) => true,
|
|
|
|
POUND => true,
|
|
|
|
AT => true,
|
|
|
|
NOT => true,
|
|
|
|
BINOP(MINUS) => true,
|
|
|
|
BINOP(STAR) => true,
|
|
|
|
BINOP(AND) => true,
|
|
|
|
BINOP(OR) => true, // in lambda syntax
|
|
|
|
OROR => true, // in lambda syntax
|
|
|
|
MOD_SEP => true,
|
2012-07-27 21:14:46 -05:00
|
|
|
INTERPOLATED(nt_expr(*))
|
|
|
|
| INTERPOLATED(nt_ident(*))
|
|
|
|
| INTERPOLATED(nt_block(*))
|
2012-08-03 21:59:04 -05:00
|
|
|
| INTERPOLATED(nt_path(*)) => true,
|
|
|
|
_ => false
|
2011-07-03 13:48:14 -05:00
|
|
|
}
|
|
|
|
}
|
2011-10-07 09:22:53 -05:00
|
|
|
|
2012-07-31 15:53:00 -05:00
|
|
|
/// what's the opposite delimiter?
|
2013-02-24 12:00:25 -06:00
|
|
|
pub fn flip_delimiter(t: &token::Token) -> token::Token {
|
|
|
|
match *t {
|
2013-02-24 19:24:28 -06:00
|
|
|
LPAREN => RPAREN,
|
|
|
|
LBRACE => RBRACE,
|
|
|
|
LBRACKET => RBRACKET,
|
|
|
|
RPAREN => LPAREN,
|
|
|
|
RBRACE => LBRACE,
|
|
|
|
RBRACKET => LBRACKET,
|
2013-02-11 21:26:38 -06:00
|
|
|
_ => fail!()
|
2012-07-31 15:53:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-02-24 19:24:28 -06:00
|
|
|
pub fn is_lit(t: &Token) -> bool {
|
|
|
|
match *t {
|
2013-09-03 18:24:12 -05:00
|
|
|
LIT_CHAR(_) => true,
|
2012-08-03 21:59:04 -05:00
|
|
|
LIT_INT(_, _) => true,
|
|
|
|
LIT_UINT(_, _) => true,
|
|
|
|
LIT_INT_UNSUFFIXED(_) => true,
|
|
|
|
LIT_FLOAT(_, _) => true,
|
2012-11-07 20:40:34 -06:00
|
|
|
LIT_FLOAT_UNSUFFIXED(_) => true,
|
2012-08-03 21:59:04 -05:00
|
|
|
LIT_STR(_) => true,
|
|
|
|
_ => false
|
2012-06-11 18:49:35 -05:00
|
|
|
}
|
2012-04-22 16:59:04 -05:00
|
|
|
}
|
|
|
|
|
2013-03-22 13:09:13 -05:00
|
|
|
pub fn is_ident(t: &Token) -> bool {
|
2013-02-24 19:24:28 -06:00
|
|
|
match *t { IDENT(_, _) => true, _ => false }
|
2012-04-17 23:14:40 -05:00
|
|
|
}
|
|
|
|
|
2013-03-22 13:09:13 -05:00
|
|
|
pub fn is_ident_or_path(t: &Token) -> bool {
|
2013-02-24 19:24:28 -06:00
|
|
|
match *t {
|
2012-08-06 15:09:10 -05:00
|
|
|
IDENT(_, _) | INTERPOLATED(nt_path(*)) => true,
|
|
|
|
_ => false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-22 13:09:13 -05:00
|
|
|
pub fn is_plain_ident(t: &Token) -> bool {
|
2013-02-24 19:24:28 -06:00
|
|
|
match *t { IDENT(_, false) => true, _ => false }
|
2012-04-17 23:14:40 -05:00
|
|
|
}
|
|
|
|
|
2013-03-22 13:09:13 -05:00
|
|
|
pub fn is_bar(t: &Token) -> bool {
|
2013-02-24 19:24:28 -06:00
|
|
|
match *t { BINOP(OR) | OROR => true, _ => false }
|
2012-04-17 23:14:40 -05:00
|
|
|
}
|
|
|
|
|
2013-01-29 15:54:06 -06:00
|
|
|
pub mod special_idents {
|
2013-09-01 19:50:59 -05:00
|
|
|
use ast::Ident;
|
2013-01-29 15:54:06 -06:00
|
|
|
|
2013-07-03 17:15:45 -05:00
|
|
|
pub static underscore : Ident = Ident { name: 0, ctxt: 0}; // apparently unused?
|
2013-09-01 19:50:59 -05:00
|
|
|
pub static anon : Ident = Ident { name: 1, ctxt: 0};
|
|
|
|
pub static invalid : Ident = Ident { name: 2, ctxt: 0}; // ''
|
2013-07-03 17:15:45 -05:00
|
|
|
pub static unary : Ident = Ident { name: 3, ctxt: 0}; // apparently unused?
|
|
|
|
pub static not_fn : Ident = Ident { name: 4, ctxt: 0}; // apparently unused?
|
|
|
|
pub static idx_fn : Ident = Ident { name: 5, ctxt: 0}; // apparently unused?
|
|
|
|
pub static unary_minus_fn : Ident = Ident { name: 6, ctxt: 0}; // apparently unused?
|
2013-09-01 19:50:59 -05:00
|
|
|
pub static clownshoes_extensions : Ident = Ident { name: 7, ctxt: 0};
|
2013-05-01 00:42:36 -05:00
|
|
|
|
2013-09-01 19:50:59 -05:00
|
|
|
pub static self_ : Ident = Ident { name: 8, ctxt: 0}; // 'self'
|
2012-07-18 18:18:02 -05:00
|
|
|
|
|
|
|
/* for matcher NTs */
|
2013-07-03 17:15:45 -05:00
|
|
|
// none of these appear to be used, but perhaps references to
|
|
|
|
// these are artificially fabricated by the macro system....
|
2013-09-01 19:50:59 -05:00
|
|
|
pub static item : Ident = Ident { name: 9, ctxt: 0};
|
|
|
|
pub static block : Ident = Ident { name: 10, ctxt: 0};
|
|
|
|
pub static stmt : Ident = Ident { name: 11, ctxt: 0};
|
|
|
|
pub static pat : Ident = Ident { name: 12, ctxt: 0};
|
|
|
|
pub static expr : Ident = Ident { name: 13, ctxt: 0};
|
|
|
|
pub static ty : Ident = Ident { name: 14, ctxt: 0};
|
|
|
|
pub static ident : Ident = Ident { name: 15, ctxt: 0};
|
|
|
|
pub static path : Ident = Ident { name: 16, ctxt: 0};
|
|
|
|
pub static tt : Ident = Ident { name: 17, ctxt: 0};
|
|
|
|
pub static matchers : Ident = Ident { name: 18, ctxt: 0};
|
|
|
|
|
2013-07-03 17:15:45 -05:00
|
|
|
pub static str : Ident = Ident { name: 19, ctxt: 0}; // for the type // apparently unused?
|
2012-07-18 18:18:02 -05:00
|
|
|
|
|
|
|
/* outside of libsyntax */
|
2013-09-01 19:50:59 -05:00
|
|
|
pub static arg : Ident = Ident { name: 20, ctxt: 0};
|
|
|
|
pub static descrim : Ident = Ident { name: 21, ctxt: 0};
|
|
|
|
pub static clownshoe_abi : Ident = Ident { name: 22, ctxt: 0};
|
|
|
|
pub static clownshoe_stack_shim : Ident = Ident { name: 23, ctxt: 0};
|
|
|
|
pub static main : Ident = Ident { name: 24, ctxt: 0};
|
|
|
|
pub static opaque : Ident = Ident { name: 25, ctxt: 0};
|
|
|
|
pub static blk : Ident = Ident { name: 26, ctxt: 0};
|
|
|
|
pub static statik : Ident = Ident { name: 27, ctxt: 0};
|
|
|
|
pub static clownshoes_foreign_mod: Ident = Ident { name: 28, ctxt: 0};
|
|
|
|
pub static unnamed_field: Ident = Ident { name: 29, ctxt: 0};
|
2013-07-03 17:15:45 -05:00
|
|
|
pub static c_abi: Ident = Ident { name: 30, ctxt: 0}; // apparently unused?
|
2013-09-01 19:50:59 -05:00
|
|
|
pub static type_self: Ident = Ident { name: 31, ctxt: 0}; // `Self`
|
2012-08-02 17:34:13 -05:00
|
|
|
}
|
|
|
|
|
2013-07-03 17:15:45 -05:00
|
|
|
// here are the ones that actually occur in the source. Maybe the rest
|
|
|
|
// should be removed?
|
|
|
|
/*
|
|
|
|
special_idents::anon
|
|
|
|
special_idents::arg
|
|
|
|
special_idents::blk
|
|
|
|
special_idents::clownshoe_abi
|
|
|
|
special_idents::clownshoe_stack_shim
|
|
|
|
special_idents::clownshoes_extensions
|
|
|
|
special_idents::clownshoes_foreign_mod
|
|
|
|
special_idents::descrim
|
|
|
|
special_idents::invalid
|
|
|
|
special_idents::main
|
|
|
|
special_idents::matchers
|
|
|
|
special_idents::opaque
|
|
|
|
special_idents::self_
|
|
|
|
special_idents::statik
|
|
|
|
special_idents::tt
|
|
|
|
special_idents::type_self
|
|
|
|
special_idents::unnamed_field
|
|
|
|
*/
|
|
|
|
|
2013-03-29 12:04:48 -05:00
|
|
|
/**
|
|
|
|
* Maps a token to a record specifying the corresponding binary
|
|
|
|
* operator
|
|
|
|
*/
|
2013-09-01 20:45:37 -05:00
|
|
|
pub fn token_to_binop(tok: &Token) -> Option<ast::BinOp> {
|
2013-07-02 14:47:32 -05:00
|
|
|
match *tok {
|
2013-09-01 20:45:37 -05:00
|
|
|
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),
|
2013-03-29 12:04:48 -05:00
|
|
|
_ => None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-26 12:11:19 -05:00
|
|
|
// looks like we can get rid of this completely...
|
|
|
|
pub type ident_interner = StrInterner;
|
2013-06-19 20:12:40 -05:00
|
|
|
|
2013-04-23 12:57:41 -05:00
|
|
|
// return a fresh interner, preloaded with special identifiers.
|
2013-06-19 20:12:40 -05:00
|
|
|
fn mk_fresh_ident_interner() -> @ident_interner {
|
|
|
|
// the indices here must correspond to the numbers in
|
|
|
|
// special_idents.
|
|
|
|
let init_vec = ~[
|
|
|
|
"_", // 0
|
|
|
|
"anon", // 1
|
|
|
|
"", // 2
|
|
|
|
"unary", // 3
|
|
|
|
"!", // 4
|
|
|
|
"[]", // 5
|
|
|
|
"unary-", // 6
|
|
|
|
"__extensions__", // 7
|
|
|
|
"self", // 8
|
|
|
|
"item", // 9
|
|
|
|
"block", // 10
|
|
|
|
"stmt", // 11
|
|
|
|
"pat", // 12
|
|
|
|
"expr", // 13
|
|
|
|
"ty", // 14
|
|
|
|
"ident", // 15
|
|
|
|
"path", // 16
|
|
|
|
"tt", // 17
|
|
|
|
"matchers", // 18
|
|
|
|
"str", // 19
|
2013-06-21 06:01:15 -05:00
|
|
|
"arg", // 20
|
|
|
|
"descrim", // 21
|
|
|
|
"__rust_abi", // 22
|
|
|
|
"__rust_stack_shim", // 23
|
|
|
|
"main", // 24
|
|
|
|
"<opaque>", // 25
|
|
|
|
"blk", // 26
|
|
|
|
"static", // 27
|
|
|
|
"__foreign_mod__", // 28
|
2013-09-02 03:59:51 -05:00
|
|
|
"<unnamed_field>", // 29
|
2013-06-21 06:01:15 -05:00
|
|
|
"C", // 30
|
|
|
|
"Self", // 31
|
|
|
|
|
|
|
|
"as", // 32
|
|
|
|
"break", // 33
|
|
|
|
"const", // 34
|
2013-07-31 16:31:14 -05:00
|
|
|
"do", // 35
|
|
|
|
"else", // 36
|
|
|
|
"enum", // 37
|
|
|
|
"extern", // 38
|
|
|
|
"false", // 39
|
|
|
|
"fn", // 40
|
|
|
|
"for", // 41
|
|
|
|
"if", // 42
|
|
|
|
"impl", // 43
|
|
|
|
"let", // 44
|
2013-08-28 01:12:05 -05:00
|
|
|
"__log_level", // 45
|
2013-07-31 16:31:14 -05:00
|
|
|
"loop", // 46
|
|
|
|
"match", // 47
|
|
|
|
"mod", // 48
|
|
|
|
"mut", // 49
|
|
|
|
"once", // 50
|
|
|
|
"priv", // 51
|
|
|
|
"pub", // 52
|
2013-07-31 17:10:35 -05:00
|
|
|
"ref", // 53
|
|
|
|
"return", // 54
|
2013-06-21 06:01:15 -05:00
|
|
|
"static", // 27 -- also a special ident
|
2013-06-19 20:12:40 -05:00
|
|
|
"self", // 8 -- also a special ident
|
2013-07-31 17:10:35 -05:00
|
|
|
"struct", // 55
|
|
|
|
"super", // 56
|
|
|
|
"true", // 57
|
|
|
|
"trait", // 58
|
|
|
|
"type", // 59
|
|
|
|
"unsafe", // 60
|
|
|
|
"use", // 61
|
|
|
|
"while", // 62
|
|
|
|
"in", // 63
|
|
|
|
|
2013-08-03 11:45:23 -05:00
|
|
|
"be", // 64
|
|
|
|
"pure", // 65
|
2013-08-16 14:49:40 -05:00
|
|
|
"yield", // 66
|
2013-08-22 16:00:02 -05:00
|
|
|
"typeof", // 67
|
2013-06-19 20:12:40 -05:00
|
|
|
];
|
|
|
|
|
2013-06-26 12:11:19 -05:00
|
|
|
@interner::StrInterner::prefill(init_vec)
|
2013-06-19 20:12:40 -05:00
|
|
|
}
|
|
|
|
|
2013-04-23 12:57:41 -05:00
|
|
|
// if an interner exists in TLS, return it. Otherwise, prepare a
|
|
|
|
// fresh one.
|
2013-05-07 14:34:52 -05:00
|
|
|
pub fn get_ident_interner() -> @ident_interner {
|
2013-07-14 03:43:31 -05:00
|
|
|
static key: local_data::Key<@@::parse::token::ident_interner> =
|
|
|
|
&local_data::Key;
|
2013-08-04 16:59:36 -05:00
|
|
|
match local_data::get(key, |k| k.map_move(|k| *k)) {
|
2013-07-12 03:38:44 -05:00
|
|
|
Some(interner) => *interner,
|
|
|
|
None => {
|
|
|
|
let interner = mk_fresh_ident_interner();
|
|
|
|
local_data::set(key, @interner);
|
|
|
|
interner
|
2012-10-08 12:41:02 -05:00
|
|
|
}
|
|
|
|
}
|
2012-08-02 16:33:26 -05:00
|
|
|
}
|
|
|
|
|
2012-07-18 18:18:02 -05:00
|
|
|
/* for when we don't care about the contents; doesn't interact with TLD or
|
|
|
|
serialization */
|
2013-01-29 15:54:06 -06:00
|
|
|
pub fn mk_fake_ident_interner() -> @ident_interner {
|
2013-06-26 12:11:19 -05:00
|
|
|
@interner::StrInterner::new()
|
2012-07-18 18:18:02 -05:00
|
|
|
}
|
|
|
|
|
2013-05-07 14:34:52 -05:00
|
|
|
// maps a string to its interned representation
|
2013-06-04 14:34:25 -05:00
|
|
|
pub fn intern(str : &str) -> Name {
|
|
|
|
let interner = get_ident_interner();
|
|
|
|
interner.intern(str)
|
|
|
|
}
|
|
|
|
|
|
|
|
// gensyms a new uint, using the current interner
|
|
|
|
pub fn gensym(str : &str) -> Name {
|
2013-05-07 14:34:52 -05:00
|
|
|
let interner = get_ident_interner();
|
2013-06-04 14:34:25 -05:00
|
|
|
interner.gensym(str)
|
|
|
|
}
|
|
|
|
|
|
|
|
// map an interned representation back to a string
|
2013-06-12 12:02:55 -05:00
|
|
|
pub fn interner_get(name : Name) -> @str {
|
2013-06-04 14:34:25 -05:00
|
|
|
get_ident_interner().get(name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// maps an identifier to the string that it corresponds to
|
2013-09-01 19:50:59 -05:00
|
|
|
pub fn ident_to_str(id : &ast::Ident) -> @str {
|
2013-06-04 14:34:25 -05:00
|
|
|
interner_get(id.name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// maps a string to an identifier with an empty syntax context
|
2013-09-01 19:50:59 -05:00
|
|
|
pub fn str_to_ident(str : &str) -> ast::Ident {
|
|
|
|
ast::Ident::new(intern(str))
|
2013-06-04 14:34:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// maps a string to a gensym'ed identifier
|
2013-09-01 19:50:59 -05:00
|
|
|
pub fn gensym_ident(str : &str) -> ast::Ident {
|
|
|
|
ast::Ident::new(gensym(str))
|
2013-05-07 14:34:52 -05:00
|
|
|
}
|
|
|
|
|
2013-06-07 12:41:18 -05:00
|
|
|
// create a fresh name that maps to the same string as the old one.
|
2013-06-26 12:11:19 -05:00
|
|
|
// note that this guarantees that str_ptr_eq(ident_to_str(src),interner_get(fresh_name(src)));
|
2013-06-25 18:48:03 -05:00
|
|
|
// that is, that the new name and the old one are connected to ptr_eq strings.
|
2013-06-07 12:41:18 -05:00
|
|
|
pub fn fresh_name(src : &ast::Ident) -> Name {
|
2013-06-26 12:11:19 -05:00
|
|
|
let interner = get_ident_interner();
|
|
|
|
interner.gensym_copy(src.name)
|
2013-06-07 16:53:53 -05:00
|
|
|
// following: debug version. Could work in final except that it's incompatible with
|
|
|
|
// good error messages and uses of struct names in ambiguous could-be-binding
|
2013-06-25 18:48:03 -05:00
|
|
|
// locations. Also definitely destroys the guarantee given above about ptr_eq.
|
2013-06-07 16:53:53 -05:00
|
|
|
/*let num = rand::rng().gen_uint_range(0,0xffff);
|
|
|
|
gensym(fmt!("%s_%u",ident_to_str(src),num))*/
|
2013-05-14 13:34:17 -05:00
|
|
|
}
|
|
|
|
|
2013-06-25 18:48:03 -05:00
|
|
|
// it looks like there oughta be a str_ptr_eq fn, but no one bothered to implement it?
|
|
|
|
|
2013-06-26 12:11:19 -05:00
|
|
|
// determine whether two @str values are pointer-equal
|
|
|
|
pub fn str_ptr_eq(a : @str, b : @str) -> bool {
|
|
|
|
unsafe {
|
|
|
|
let p : uint = cast::transmute(a);
|
|
|
|
let q : uint = cast::transmute(b);
|
|
|
|
let result = p == q;
|
|
|
|
// got to transmute them back, to make sure the ref count is correct:
|
2013-07-12 01:07:34 -05:00
|
|
|
let _junk1 : @str = cast::transmute(p);
|
|
|
|
let _junk2 : @str = cast::transmute(q);
|
2013-06-26 12:11:19 -05:00
|
|
|
result
|
|
|
|
}
|
|
|
|
}
|
2013-06-25 18:48:03 -05:00
|
|
|
|
|
|
|
// return true when two identifiers refer (through the intern table) to the same ptr_eq
|
|
|
|
// string. This is used to compare identifiers in places where hygienic comparison is
|
|
|
|
// not wanted (i.e. not lexical vars).
|
2013-06-26 12:11:19 -05:00
|
|
|
pub fn ident_spelling_eq(a : &ast::Ident, b : &ast::Ident) -> bool {
|
|
|
|
str_ptr_eq(interner_get(a.name),interner_get(b.name))
|
|
|
|
}
|
2013-06-25 18:48:03 -05:00
|
|
|
|
2013-06-25 13:43:52 -05:00
|
|
|
// create a fresh mark.
|
|
|
|
pub fn fresh_mark() -> Mrk {
|
|
|
|
gensym("mark")
|
|
|
|
}
|
|
|
|
|
2012-07-04 16:53:12 -05:00
|
|
|
/**
|
|
|
|
* All the valid words that have meaning in the Rust language.
|
|
|
|
*
|
2013-05-25 10:45:45 -05:00
|
|
|
* Rust keywords are either 'strict' or 'reserved'. Strict keywords may not
|
2012-09-19 13:06:50 -05:00
|
|
|
* appear as identifiers at all. Reserved keywords are not used anywhere in
|
|
|
|
* the language and may not appear as identifiers.
|
2012-07-04 16:53:12 -05:00
|
|
|
*/
|
2013-05-25 10:45:45 -05:00
|
|
|
pub mod keywords {
|
2013-09-01 19:50:59 -05:00
|
|
|
use ast::Ident;
|
2013-05-25 10:45:45 -05:00
|
|
|
|
|
|
|
pub enum Keyword {
|
|
|
|
// Strict keywords
|
|
|
|
As,
|
|
|
|
Break,
|
2013-06-25 20:25:27 -05:00
|
|
|
Const,
|
2013-05-25 10:45:45 -05:00
|
|
|
Do,
|
|
|
|
Else,
|
|
|
|
Enum,
|
|
|
|
Extern,
|
|
|
|
False,
|
|
|
|
Fn,
|
|
|
|
For,
|
|
|
|
If,
|
|
|
|
Impl,
|
2013-07-29 17:15:33 -05:00
|
|
|
In,
|
2013-05-25 10:45:45 -05:00
|
|
|
Let,
|
2013-08-28 01:12:05 -05:00
|
|
|
__LogLevel,
|
2013-05-25 10:45:45 -05:00
|
|
|
Loop,
|
|
|
|
Match,
|
|
|
|
Mod,
|
|
|
|
Mut,
|
|
|
|
Once,
|
|
|
|
Priv,
|
|
|
|
Pub,
|
|
|
|
Ref,
|
|
|
|
Return,
|
|
|
|
Static,
|
|
|
|
Self,
|
|
|
|
Struct,
|
|
|
|
Super,
|
|
|
|
True,
|
|
|
|
Trait,
|
|
|
|
Type,
|
2013-08-22 16:00:02 -05:00
|
|
|
Typeof,
|
2013-05-25 10:45:45 -05:00
|
|
|
Unsafe,
|
|
|
|
Use,
|
|
|
|
While,
|
|
|
|
|
|
|
|
// Reserved keywords
|
|
|
|
Be,
|
2013-08-16 14:49:40 -05:00
|
|
|
Pure,
|
|
|
|
Yield,
|
2013-05-25 10:45:45 -05:00
|
|
|
}
|
2013-03-21 14:41:37 -05:00
|
|
|
|
2013-05-31 17:17:22 -05:00
|
|
|
impl Keyword {
|
2013-09-01 19:50:59 -05:00
|
|
|
pub fn to_ident(&self) -> Ident {
|
2013-06-19 20:12:40 -05:00
|
|
|
match *self {
|
2013-09-01 19:50:59 -05:00
|
|
|
As => Ident { name: 32, ctxt: 0 },
|
|
|
|
Break => Ident { name: 33, ctxt: 0 },
|
|
|
|
Const => Ident { name: 34, ctxt: 0 },
|
|
|
|
Do => Ident { name: 35, ctxt: 0 },
|
|
|
|
Else => Ident { name: 36, ctxt: 0 },
|
|
|
|
Enum => Ident { name: 37, ctxt: 0 },
|
|
|
|
Extern => Ident { name: 38, ctxt: 0 },
|
|
|
|
False => Ident { name: 39, ctxt: 0 },
|
|
|
|
Fn => Ident { name: 40, ctxt: 0 },
|
|
|
|
For => Ident { name: 41, ctxt: 0 },
|
|
|
|
If => Ident { name: 42, ctxt: 0 },
|
|
|
|
Impl => Ident { name: 43, ctxt: 0 },
|
|
|
|
In => Ident { name: 63, ctxt: 0 },
|
|
|
|
Let => Ident { name: 44, ctxt: 0 },
|
2013-08-28 01:12:05 -05:00
|
|
|
__LogLevel => Ident { name: 45, ctxt: 0 },
|
2013-09-01 19:50:59 -05:00
|
|
|
Loop => Ident { name: 46, ctxt: 0 },
|
|
|
|
Match => Ident { name: 47, ctxt: 0 },
|
|
|
|
Mod => Ident { name: 48, ctxt: 0 },
|
|
|
|
Mut => Ident { name: 49, ctxt: 0 },
|
|
|
|
Once => Ident { name: 50, ctxt: 0 },
|
|
|
|
Priv => Ident { name: 51, ctxt: 0 },
|
|
|
|
Pub => Ident { name: 52, ctxt: 0 },
|
|
|
|
Ref => Ident { name: 53, ctxt: 0 },
|
|
|
|
Return => Ident { name: 54, ctxt: 0 },
|
|
|
|
Static => Ident { name: 27, ctxt: 0 },
|
|
|
|
Self => Ident { name: 8, ctxt: 0 },
|
|
|
|
Struct => Ident { name: 55, ctxt: 0 },
|
|
|
|
Super => Ident { name: 56, ctxt: 0 },
|
|
|
|
True => Ident { name: 57, ctxt: 0 },
|
|
|
|
Trait => Ident { name: 58, ctxt: 0 },
|
|
|
|
Type => Ident { name: 59, ctxt: 0 },
|
|
|
|
Typeof => Ident { name: 67, ctxt: 0 },
|
|
|
|
Unsafe => Ident { name: 60, ctxt: 0 },
|
|
|
|
Use => Ident { name: 61, ctxt: 0 },
|
|
|
|
While => Ident { name: 62, ctxt: 0 },
|
|
|
|
Be => Ident { name: 64, ctxt: 0 },
|
|
|
|
Pure => Ident { name: 65, ctxt: 0 },
|
|
|
|
Yield => Ident { name: 66, ctxt: 0 },
|
2013-05-25 10:45:45 -05:00
|
|
|
}
|
|
|
|
}
|
2012-04-17 23:14:40 -05:00
|
|
|
}
|
2013-05-25 10:45:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_keyword(kw: keywords::Keyword, tok: &Token) -> bool {
|
|
|
|
match *tok {
|
2013-05-17 12:18:09 -05:00
|
|
|
token::IDENT(sid, false) => { kw.to_ident().name == sid.name }
|
2013-05-25 10:45:45 -05:00
|
|
|
_ => { false }
|
2013-05-10 17:15:06 -05:00
|
|
|
}
|
2013-05-25 10:45:45 -05:00
|
|
|
}
|
2013-05-10 17:15:06 -05:00
|
|
|
|
2013-06-19 20:12:40 -05:00
|
|
|
pub fn is_any_keyword(tok: &Token) -> bool {
|
|
|
|
match *tok {
|
|
|
|
token::IDENT(sid, false) => match sid.name {
|
2013-08-22 16:00:02 -05:00
|
|
|
8 | 27 | 32 .. 67 => true,
|
2013-06-19 20:12:40 -05:00
|
|
|
_ => false,
|
|
|
|
},
|
|
|
|
_ => false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_strict_keyword(tok: &Token) -> bool {
|
|
|
|
match *tok {
|
|
|
|
token::IDENT(sid, false) => match sid.name {
|
2013-08-03 11:45:23 -05:00
|
|
|
8 | 27 | 32 .. 63 => true,
|
2013-06-19 20:12:40 -05:00
|
|
|
_ => false,
|
|
|
|
},
|
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_reserved_keyword(tok: &Token) -> bool {
|
|
|
|
match *tok {
|
|
|
|
token::IDENT(sid, false) => match sid.name {
|
2013-08-22 16:00:02 -05:00
|
|
|
64 .. 67 => true,
|
2013-06-19 20:12:40 -05:00
|
|
|
_ => false,
|
|
|
|
},
|
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-05 16:15:00 -05:00
|
|
|
pub fn mtwt_token_eq(t1 : &Token, t2 : &Token) -> bool {
|
|
|
|
match (t1,t2) {
|
|
|
|
(&IDENT(id1,_),&IDENT(id2,_)) =>
|
|
|
|
ast_util::mtwt_resolve(id1) == ast_util::mtwt_resolve(id2),
|
|
|
|
_ => *t1 == *t2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-14 13:34:17 -05:00
|
|
|
#[cfg(test)]
|
|
|
|
mod test {
|
|
|
|
use super::*;
|
2013-06-25 18:48:03 -05:00
|
|
|
use ast;
|
|
|
|
use ast_util;
|
|
|
|
|
2013-07-10 18:40:09 -05:00
|
|
|
fn mark_ident(id : ast::Ident, m : ast::Mrk) -> ast::Ident {
|
|
|
|
ast::Ident{name:id.name,ctxt:ast_util::new_mark(m,id.ctxt)}
|
2013-09-05 16:15:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test] fn mtwt_token_eq_test() {
|
|
|
|
assert!(mtwt_token_eq(>,>));
|
|
|
|
let a = str_to_ident("bac");
|
|
|
|
let a1 = mark_ident(a,92);
|
|
|
|
assert!(mtwt_token_eq(&IDENT(a,true),&IDENT(a1,false)));
|
|
|
|
}
|
|
|
|
|
2013-06-25 18:48:03 -05:00
|
|
|
|
2013-06-26 12:11:19 -05:00
|
|
|
#[test] fn str_ptr_eq_tests(){
|
|
|
|
let a = @"abc";
|
|
|
|
let b = @"abc";
|
|
|
|
let c = a;
|
|
|
|
assert!(str_ptr_eq(a,c));
|
|
|
|
assert!(!str_ptr_eq(a,b));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test] fn fresh_name_pointer_sharing() {
|
2013-06-25 18:48:03 -05:00
|
|
|
let ghi = str_to_ident("ghi");
|
|
|
|
assert_eq!(ident_to_str(&ghi),@"ghi");
|
2013-06-26 12:11:19 -05:00
|
|
|
assert!(str_ptr_eq(ident_to_str(&ghi),ident_to_str(&ghi)))
|
2013-06-25 18:48:03 -05:00
|
|
|
let fresh = ast::Ident::new(fresh_name(&ghi));
|
|
|
|
assert_eq!(ident_to_str(&fresh),@"ghi");
|
|
|
|
assert!(str_ptr_eq(ident_to_str(&ghi),ident_to_str(&fresh)));
|
|
|
|
}
|
2013-06-25 13:40:51 -05:00
|
|
|
|
2013-05-14 13:34:17 -05:00
|
|
|
}
|