diff options
| author | Graydon Hoare <[email protected]> | 2010-09-23 13:15:51 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-09-23 13:15:51 -0700 |
| commit | 2c514f33f2ebba03ca06368b3405ce0d7cc93c54 (patch) | |
| tree | 3bee92c42cc3d3465e2814b0d157203c38befb97 /src/comp/fe/parser.rs | |
| parent | Flesh out rustc.me.trans to construct functions, basic blocks and builders of... (diff) | |
| download | rust-2c514f33f2ebba03ca06368b3405ce0d7cc93c54.tar.xz rust-2c514f33f2ebba03ca06368b3405ce0d7cc93c54.zip | |
More fleshing-out on rustc.me.trans. Emitting modules and fns corresponding to parsed input now.
Diffstat (limited to 'src/comp/fe/parser.rs')
| -rw-r--r-- | src/comp/fe/parser.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/comp/fe/parser.rs b/src/comp/fe/parser.rs index 248d60f4..ab2e15e3 100644 --- a/src/comp/fe/parser.rs +++ b/src/comp/fe/parser.rs @@ -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; |