More fleshing-out on rustc.me.trans. Emitting modules and fns corresponding to parsed input now.

This commit is contained in:
Graydon Hoare 2010-09-23 13:15:51 -07:00
parent 04a55df54b
commit 2c514f33f2
3 changed files with 72 additions and 24 deletions

View file

@ -218,11 +218,27 @@ state fn parse_fn(parser p) -> tup(ast.ident, ast.item) {
ret tup(id, ast.item_fn(@f));
}
state fn parse_mod(parser p) -> tup(ast.ident, ast.item) {
expect(p, token.MOD);
auto id = parse_ident(p);
expect(p, token.LBRACE);
let ast._mod m = new_str_hash[ast.item]();
while (p.peek() != token.RBRACE) {
auto i = parse_item(p);
m.insert(i._0, i._1);
}
expect(p, token.RBRACE);
ret tup(id, ast.item_mod(@m));
}
state fn parse_item(parser p) -> tup(ast.ident, ast.item) {
alt (p.peek()) {
case (token.FN) {
ret parse_fn(p);
}
case (token.MOD) {
ret parse_mod(p);
}
}
p.err("expectied item");
fail;