about summary refs log tree commit diff
path: root/src/librustsyntax/parse
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-04-27 12:22:42 -0700
committerBrian Anderson <banderson@mozilla.com>2012-04-27 16:45:54 -0700
commit8ab9efe262d20be8efc90535aeaf4ed9af47f400 (patch)
tree5ef282631f44128f46e6ee2e9a9c4ce84d930c13 /src/librustsyntax/parse
parentbeece25abefb50cb2db91e5cde1f54e239d6e20a (diff)
downloadrust-8ab9efe262d20be8efc90535aeaf4ed9af47f400.tar.gz
rust-8ab9efe262d20be8efc90535aeaf4ed9af47f400.zip
parser: Rewrite parse_path_without_tps so it knows beforehand which is the last ident
Needed to centralize all keyword-as-value parsing in parse_value_ident
Diffstat (limited to 'src/librustsyntax/parse')
-rw-r--r--src/librustsyntax/parse/parser.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/librustsyntax/parse/parser.rs b/src/librustsyntax/parse/parser.rs
index e2117a27ec3..0c7622fbc13 100644
--- a/src/librustsyntax/parse/parser.rs
+++ b/src/librustsyntax/parse/parser.rs
@@ -511,9 +511,18 @@ fn parse_path_without_tps(p: parser) -> @ast::path {
     let lo = p.span.lo;
     let global = eat(p, token::MOD_SEP);
     let mut ids = [];
-    do {
+    loop {
+        let is_not_last =
+            p.look_ahead(2u) != token::LT
+            && p.look_ahead(1u) == token::MOD_SEP;
+
         ids += [parse_ident(p)];
-    } while p.look_ahead(1u) != token::LT && eat(p, token::MOD_SEP);
+        if is_not_last {
+            expect(p, token::MOD_SEP);
+        } else {
+            break;
+        }
+    }
     @{span: mk_sp(lo, p.last_span.hi), global: global,
       idents: ids, rp: none, types: []}
 }