aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2010-11-24 18:01:20 -0800
committerPatrick Walton <[email protected]>2010-11-24 18:01:20 -0800
commit78ec07790a90813cf4f42df0246ea9c27892745f (patch)
tree65133255d56aab5c582942aefb9d4ed5293bdb17 /src/comp/front
parentrustc: Parse type-parametric typedefs (diff)
downloadrust-78ec07790a90813cf4f42df0246ea9c27892745f.tar.xz
rust-78ec07790a90813cf4f42df0246ea9c27892745f.zip
rustc: Assign definition IDs to type params
Diffstat (limited to 'src/comp/front')
-rw-r--r--src/comp/front/ast.rs3
-rw-r--r--src/comp/front/parser.rs7
2 files changed, 8 insertions, 2 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs
index 7da857b4..3c2af3c8 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/front/ast.rs
@@ -7,7 +7,6 @@ import util.common.spanned;
import util.common.ty_mach;
type ident = str;
-type ty_param = ident;
type name_ = rec(ident ident, vec[@ty] types);
type name = spanned[name_];
@@ -17,6 +16,8 @@ type crate_num = int;
type def_num = int;
type def_id = tup(crate_num, def_num);
+type ty_param = rec(ident ident, def_id id);
+
// Annotations added during successive passes.
tag ann {
ann_none;
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index f4874733..261ea1ad 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -1039,10 +1039,15 @@ impure fn parse_block(parser p) -> ast.block {
ret spanned(stmts.span, stmts.span, b);
}
+impure fn parse_ty_param(parser p) -> ast.ty_param {
+ auto ident = parse_ident(p);
+ ret rec(ident=ident, id=p.next_def_id());
+}
+
impure fn parse_ty_params(parser p) -> vec[ast.ty_param] {
let vec[ast.ty_param] ty_params = vec();
if (p.peek() == token.LBRACKET) {
- auto f = parse_ident; // FIXME: pass as lval directly
+ auto f = parse_ty_param; // FIXME: pass as lval directly
ty_params = parse_seq[ast.ty_param](token.LBRACKET, token.RBRACKET,
some(token.COMMA), f, p).node;
}