Skip to content

Commit e6b7f76

Browse files
committed
Add ty_rec and parse it.
1 parent 3e08171 commit e6b7f76

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/comp/front/ast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ tag ty_ {
153153
ty_box(@ty);
154154
ty_vec(@ty);
155155
ty_tup(vec[@ty]);
156+
ty_rec(vec[tup(ident,@ty)]);
156157
ty_fn(vec[rec(mode mode, @ty ty)], @ty); // TODO: effect
157158
ty_path(path, option.t[def]);
158159
ty_mutable(@ty);

src/comp/front/parser.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,23 @@ impure fn parse_ty(parser p) -> @ast.ty {
187187
t = ast.ty_tup(elems.node);
188188
}
189189

190+
case (token.REC) {
191+
p.bump();
192+
impure fn parse_field(parser p) -> tup(ast.ident, @ast.ty) {
193+
auto ty = parse_ty(p);
194+
auto id = parse_ident(p);
195+
ret tup(id,ty);
196+
}
197+
auto f = parse_field; // FIXME: trans_const_lval bug
198+
auto elems =
199+
parse_seq[tup(ast.ident, @ast.ty)](token.LPAREN,
200+
token.RPAREN,
201+
some(token.COMMA),
202+
f, p);
203+
hi = p.get_span();
204+
t = ast.ty_rec(elems.node);
205+
}
206+
190207
case (token.MUTABLE) {
191208
p.bump();
192209
auto t0 = parse_ty(p);

0 commit comments

Comments
 (0)