summary refs log tree commit diff
path: root/src/comp/front/parser.rs
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2011-02-24 15:54:55 -0800
committerGraydon Hoare <graydon@mozilla.com>2011-02-24 15:55:10 -0800
commitb2a09562a6c0683ca528c866abc1ecc99b4bdcf0 (patch)
tree9af4389c4f5b857890575954e247c07fb6f5b536 /src/comp/front/parser.rs
parentdcd65fac199d3caac4b1019304ef5e1b480f31ff (diff)
Factor crate expr evaluator out of parser, expand to simple scalars and ops, if, alt.
Diffstat (limited to 'src/comp/front/parser.rs')
-rw-r--r--src/comp/front/parser.rs82
1 files changed, 3 insertions, 79 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index 944e14240ba..3579a3a087f 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -2111,80 +2111,6 @@ impure fn parse_crate_from_source_file(parser p) -> @ast.crate {
 //
 // Each directive imperatively extends its environment with 0 or more items.
 
-impure fn eval_crate_directives(parser p,
-                                vec[@ast.crate_directive] cdirs,
-                                str prefix) -> ast._mod {
-    let vec[@ast.item] items = vec();
-    auto index = new_str_hash[ast.mod_index_entry]();
-    auto view_items = parse_view(p, index);
-
-    for (@ast.crate_directive sub_cdir in cdirs) {
-        eval_crate_directive(p, sub_cdir, prefix,
-                             view_items, items, index);
-    }
-
-    ret rec(view_items=view_items, items=items, index=index);
-}
-
-impure fn eval_crate_directive(parser p,
-                               @ast.crate_directive cdir,
-                               str prefix,
-                               &mutable vec[@ast.view_item] view_items,
-                               &mutable vec[@ast.item] items,
-                               hashmap[ast.ident,ast.mod_index_entry] index) {
-    alt (cdir.node) {
-        case (ast.cdir_expr(?e)) {}
-        case (ast.cdir_const(?i)) {}
-
-        case (ast.cdir_src_mod(?id, ?file_opt)) {
-
-            auto file_path = id + ".rs";
-            alt (file_opt) {
-                case (some[filename](?f)) {
-                    file_path = f;
-                }
-                case (none[filename]) {}
-            }
-
-            auto full_path = prefix + std.os.path_sep() + file_path;
-
-            auto p0 = new_parser(p.get_session(), 0, full_path);
-            auto m0 = parse_mod_items(p0, token.EOF);
-            auto im = ast.item_mod(id, m0, p.next_def_id());
-            auto i = @spanned(cdir.span, cdir.span, im);
-            ast.index_item(index, i);
-            append[@ast.item](items, i);
-        }
-
-        case (ast.cdir_dir_mod(?id, ?dir_opt, ?cdirs)) {
-
-            auto path = id;
-            alt (dir_opt) {
-                case (some[filename](?d)) {
-                    path = d;
-                }
-                case (none[filename]) {}
-            }
-
-            auto full_path = prefix + std.os.path_sep() + path;
-            auto m0 = eval_crate_directives(p, cdirs, path);
-            auto im = ast.item_mod(id, m0, p.next_def_id());
-            auto i = @spanned(cdir.span, cdir.span, im);
-            ast.index_item(index, i);
-            append[@ast.item](items, i);
-        }
-
-        case (ast.cdir_view_item(?vi)) {
-            append[@ast.view_item](view_items, vi);
-            ast.index_view_item(index, vi);
-        }
-
-        case (ast.cdir_meta(?mi)) {}
-        case (ast.cdir_syntax(?pth)) {}
-        case (ast.cdir_auth(?pth, ?eff)) {}
-    }
-}
-
 impure fn parse_crate_directive(parser p) -> ast.crate_directive
 {
     auto lo = p.get_span();
@@ -2201,10 +2127,7 @@ impure fn parse_crate_directive(parser p) -> ast.crate_directive
             expect(p, token.SEMI);
             ret spanned(lo, hi, ast.cdir_auth(n, e));
         }
-        case (token.CONST) {
-            auto c = parse_item_const(p);
-            ret spanned(c.span, c.span, ast.cdir_const(c));
-         }
+
         case (token.MOD) {
             p.bump();
             auto id = parse_ident(p);
@@ -2267,7 +2190,8 @@ impure fn parse_crate_from_crate_file(parser p) -> @ast.crate {
     auto hi = lo;
     auto prefix = std.path.dirname(lo.filename);
     auto cdirs = parse_crate_directives(p, token.EOF);
-    auto m = eval_crate_directives(p, cdirs, prefix);
+    auto m = eval.eval_crate_directives_to_mod(p, eval.mk_env(),
+                                               cdirs, prefix);
     hi = p.get_span();
     expect(p, token.EOF);
     ret @spanned(lo, hi, rec(module=m));