diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2011-08-16 09:03:58 -0700 |
|---|---|---|
| committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2011-08-16 14:16:14 -0700 |
| commit | 014c6922e12d4faa6a2181674d12a7f487c06bb6 (patch) | |
| tree | 2cee316e045d2742f3007bf884f460326f136606 /src/comp/syntax/parse | |
| parent | 9304b7ee5980b889e941251a8a3990593c496eff (diff) | |
| download | rust-014c6922e12d4faa6a2181674d12a7f487c06bb6.tar.gz rust-014c6922e12d4faa6a2181674d12a7f487c06bb6.zip | |
Change expr foo[T] syntax to foo::<T>.
This preserves the old syntax for now.
Diffstat (limited to 'src/comp/syntax/parse')
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index c629b7eaa4c..2bbebc3c56e 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -643,8 +643,8 @@ fn parse_fn_block_arg(p: &parser) -> ast::arg { ret {mode: m, ty: t, ident: i, id: p.get_id()}; } -fn parse_seq_to_gt[T](sep: option::t[token::token], f: fn(&parser) -> T, - p: &parser) -> [T] { +fn parse_seq_to_before_gt[T](sep: option::t[token::token], + f: fn(&parser) -> T, p: &parser) -> [T] { let first = true; let v = ~[]; while p.peek() != token::GT && @@ -657,11 +657,27 @@ fn parse_seq_to_gt[T](sep: option::t[token::token], f: fn(&parser) -> T, v += ~[f(p)]; } + ret v; +} + +fn parse_seq_to_gt[T](sep: option::t[token::token], f: fn(&parser) -> T, + p: &parser) -> [T] { + let v = parse_seq_to_before_gt(sep, f, p); expect_gt(p); ret v; } +fn parse_seq_lt_gt[T](sep: option::t[token::token], f: fn(&parser) -> T, + p: &parser) -> spanned[[T]] { + let lo = p.get_lo_pos(); + expect(p, token::LT); + let result = parse_seq_to_before_gt[T](sep, f, p); + let hi = p.get_hi_pos(); + expect_gt(p); + ret spanned(lo, hi, result); +} + fn parse_seq_to_end[T](ket: token::token, sep: option::t[token::token], f: fn(&parser) -> T , p: &parser) -> [T] { let val = parse_seq_to_before_end(ket, sep, f, p); @@ -787,6 +803,17 @@ fn parse_path_and_ty_param_substs(p: &parser) -> ast::path { {global: path.node.global, idents: path.node.idents, types: seq.node}); + } else if p.peek() == token::MOD_SEP { + p.bump(); + + let seq = parse_seq_lt_gt(some(token::COMMA), bind parse_ty(_, false), + p); + let hi = seq.span.hi; + path = + spanned(lo, hi, + {global: path.node.global, + idents: path.node.idents, + types: seq.node}); } ret path; } |
