aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front/token.rs
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2011-05-09 14:17:28 -0700
committerGraydon Hoare <[email protected]>2011-05-09 14:17:45 -0700
commitb00f3074d4b4d68b3233a7f062ea13384fdccf2c (patch)
treeefefd439bdbf379f3854b851485b0eed98656a27 /src/comp/front/token.rs
parentrustc: Alias fix part 2 -- Check that the aliasness of function parameters ma... (diff)
downloadrust-b00f3074d4b4d68b3233a7f062ea13384fdccf2c.tar.xz
rust-b00f3074d4b4d68b3233a7f062ea13384fdccf2c.zip
Remove boxes from token.t.
Diffstat (limited to 'src/comp/front/token.rs')
-rw-r--r--src/comp/front/token.rs29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/comp/front/token.rs b/src/comp/front/token.rs
index f0b6c4be..4c2891f3 100644
--- a/src/comp/front/token.rs
+++ b/src/comp/front/token.rs
@@ -5,6 +5,8 @@ import std.Int;
import std.UInt;
import std.Str;
+type str_num = uint;
+
tag binop {
PLUS;
MINUS;
@@ -127,14 +129,14 @@ tag token {
LIT_INT(int);
LIT_UINT(uint);
LIT_MACH_INT(ty_mach, int);
- LIT_FLOAT(str);
- LIT_MACH_FLOAT(ty_mach, str);
- LIT_STR(str);
+ LIT_FLOAT(str_num);
+ LIT_MACH_FLOAT(ty_mach, str_num);
+ LIT_STR(str_num);
LIT_CHAR(char);
LIT_BOOL(bool);
/* Name components */
- IDENT(str);
+ IDENT(str_num);
IDX(int);
UNDERSCORE;
@@ -168,7 +170,7 @@ tag token {
PORT;
TASK;
- BRACEQUOTE(str);
+ BRACEQUOTE(str_num);
EOF;
}
@@ -188,7 +190,7 @@ fn binop_to_str(binop o) -> str {
}
}
-fn to_str(token t) -> str {
+fn to_str(lexer.reader r, token t) -> str {
alt (t) {
case (EQ) { ret "="; }
@@ -301,10 +303,14 @@ fn to_str(token t) -> str {
ret Int.to_str(i, 10u)
+ "_" + ty_mach_to_str(tm);
}
- case (LIT_FLOAT(?s)) { ret s; }
+ case (LIT_MACH_FLOAT(?tm, ?s)) {
+ ret r.get_str(s) + "_" + ty_mach_to_str(tm);
+ }
+
+ case (LIT_FLOAT(?s)) { ret r.get_str(s); }
case (LIT_STR(?s)) {
// FIXME: escape.
- ret "\"" + s + "\"";
+ ret "\"" + r.get_str(s) + "\"";
}
case (LIT_CHAR(?c)) {
// FIXME: escape.
@@ -319,7 +325,11 @@ fn to_str(token t) -> str {
}
/* Name components */
- case (IDENT(?s)) { auto si = "ident:"; si += s; ret si; }
+ case (IDENT(?s)) {
+ auto si = "ident:";
+ si += r.get_str(s);
+ ret si;
+ }
case (IDX(?i)) { ret "_" + Int.to_str(i, 10u); }
case (UNDERSCORE) { ret "_"; }
@@ -360,7 +370,6 @@ fn to_str(token t) -> str {
}
-
// Local Variables:
// fill-column: 78;
// indent-tabs-mode: nil