aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-11-19 10:41:32 -0800
committerGraydon Hoare <[email protected]>2010-11-19 10:41:32 -0800
commite94af48bc9d9b2b1bec39368614af14cdb3a296a (patch)
tree7c6f66afefcf6f679a0b71613bcedd216dcbe2dd /src/comp/front
parentrustboot: Don't use walk to traverse statements in type.ml; fixes redundant c... (diff)
downloadrust-e94af48bc9d9b2b1bec39368614af14cdb3a296a.tar.xz
rust-e94af48bc9d9b2b1bec39368614af14cdb3a296a.zip
Work around Yet Another Typestate Lifecycle Bug in rustboot.
Diffstat (limited to 'src/comp/front')
-rw-r--r--src/comp/front/parser.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index 2382efc1..63e43067 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -198,6 +198,17 @@ impure fn parse_arg(parser p) -> ast.arg {
ret rec(mode=m, ty=t, ident=i, id=p.next_def_id());
}
+// FIXME: workaround for a bug in the typestate walk of
+// the while-graph; the while-loop header doesn't drop
+// its slots, so "while (p.peek() ...) { ... }" leaks.
+
+fn peeking_at(parser p, token.token t) -> bool {
+ if (p.peek() == t) {
+ ret true;
+ }
+ ret false;
+}
+
impure fn parse_seq[T](token.token bra,
token.token ket,
option.t[token.token] sep,
@@ -207,7 +218,7 @@ impure fn parse_seq[T](token.token bra,
auto lo = p.get_span();
expect(p, bra);
let vec[T] v = vec();
- while (p.peek() != ket) {
+ while (!peeking_at(p, ket)) {
alt(sep) {
case (some[token.token](?t)) {
if (first) {
@@ -925,7 +936,7 @@ impure fn parse_mod_items(parser p, token.token term) -> ast._mod {
let vec[@ast.item] items = vec();
let hashmap[ast.ident,uint] index = new_str_hash[uint]();
let uint u = 0u;
- while (p.peek() != term) {
+ while (!peeking_at(p, term)) {
auto pair = parse_item(p);
append[@ast.item](items, pair._1);
index.insert(pair._0, u);