aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front/parser.rs
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2010-11-24 16:52:49 -0800
committerPatrick Walton <[email protected]>2010-11-24 16:52:49 -0800
commitc1916adc7e16bd7ecd3ca8dbbe985ec75d0c825a (patch)
treed69d2e25a0a016c8c798d9a416b628d9f907a2d1 /src/comp/front/parser.rs
parentrustc: Don't require a semicolon after an "alt" statement (diff)
downloadrust-c1916adc7e16bd7ecd3ca8dbbe985ec75d0c825a.tar.xz
rust-c1916adc7e16bd7ecd3ca8dbbe985ec75d0c825a.zip
rustc: Parse type-parametric functions
Diffstat (limited to 'src/comp/front/parser.rs')
-rw-r--r--src/comp/front/parser.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index 598b04af..66529c69 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -1020,7 +1020,7 @@ impure fn parse_block(parser p) -> ast.block {
}
case (ast.decl_item(?it)) {
alt (it.node) {
- case (ast.item_fn(?i, _, _, _)) {
+ case (ast.item_fn(?i, _, _, _, _)) {
index.insert(i, u-1u);
}
case (ast.item_mod(?i, _, _)) {
@@ -1043,6 +1043,14 @@ impure fn parse_item_fn(parser p) -> tup(ast.ident, @ast.item) {
auto lo = p.get_span();
expect(p, token.FN);
auto id = parse_ident(p);
+
+ let vec[ast.ty_param] ty_params = vec();
+ if (p.peek() == token.LBRACKET) {
+ auto pg = parse_ident; // FIXME: pass as lval directly
+ ty_params = parse_seq[ast.ty_param](token.LBRACKET, token.RBRACKET,
+ some(token.COMMA), pg, p).node;
+ }
+
auto pf = parse_arg;
let util.common.spanned[vec[ast.arg]] inputs =
// FIXME: passing parse_arg as an lval doesn't work at the
@@ -1067,7 +1075,7 @@ impure fn parse_item_fn(parser p) -> tup(ast.ident, @ast.item) {
output = output,
body = body);
- auto item = ast.item_fn(id, f, p.next_def_id(), ast.ann_none);
+ auto item = ast.item_fn(id, f, ty_params, p.next_def_id(), ast.ann_none);
ret tup(id, @spanned(lo, body.span, item));
}