aboutsummaryrefslogtreecommitdiff
path: root/src/comp
diff options
context:
space:
mode:
authorRafael Ávila de Espíndola <[email protected]>2011-03-10 17:34:58 -0500
committerRafael Ávila de Espíndola <[email protected]>2011-03-10 17:36:41 -0500
commit4ca0259b20bfc2f33f23e8b82864908fbb3b8133 (patch)
tree1d215874467c4be9db02da596a73d0dea08667a5 /src/comp
parentFix seemingly un-noticed thinko in structural copying code in rustboot. (diff)
downloadrust-4ca0259b20bfc2f33f23e8b82864908fbb3b8133.tar.xz
rust-4ca0259b20bfc2f33f23e8b82864908fbb3b8133.zip
Update the current id when we create sub parsers.
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/driver/rustc.rs6
-rw-r--r--src/comp/front/eval.rs7
-rw-r--r--src/comp/front/parser.rs11
3 files changed, 17 insertions, 7 deletions
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs
index 6366bcaf..f26dd02e 100644
--- a/src/comp/driver/rustc.rs
+++ b/src/comp/driver/rustc.rs
@@ -54,7 +54,8 @@ impure fn compile_input(session.session sess,
eval.env env,
str input, str output,
bool shared) {
- auto p = parser.new_parser(sess, env, 0, input);
+ auto def = tup(0, 0);
+ auto p = parser.new_parser(sess, env, def, input);
auto crate = parse_input(sess, p, input);
crate = resolve.resolve_crate(sess, crate);
crate = typeck.check_crate(sess, crate);
@@ -64,7 +65,8 @@ impure fn compile_input(session.session sess,
impure fn pretty_print_input(session.session sess,
eval.env env,
str input) {
- auto p = front.parser.new_parser(sess, env, 0, input);
+ auto def = tup(0, 0);
+ auto p = front.parser.new_parser(sess, env, def, input);
auto crate = front.parser.parse_crate_from_source_file(p);
pretty.pprust.print_ast(crate.node.module, std.io.stdout_writer());
}
diff --git a/src/comp/front/eval.rs b/src/comp/front/eval.rs
index ac4b704b..efa9aa0d 100644
--- a/src/comp/front/eval.rs
+++ b/src/comp/front/eval.rs
@@ -393,9 +393,12 @@ impure fn eval_crate_directive(parser p,
auto full_path = prefix + std.os.path_sep() + file_path;
- auto p0 = new_parser(p.get_session(), e, 0, full_path);
+ auto start_id = p.next_def_id();
+ auto p0 = new_parser(p.get_session(), e, start_id, full_path);
auto m0 = parse_mod_items(p0, token.EOF);
- auto im = ast.item_mod(id, m0, p.next_def_id());
+ auto next_id = p0.next_def_id();
+ p.set_def(next_id._1);
+ auto im = ast.item_mod(id, m0, next_id);
auto i = @spanned(cdir.span, cdir.span, im);
ast.index_item(index, i);
append[@ast.item](items, i);
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index 71e592ff..2836b120 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -35,12 +35,13 @@ state type parser =
fn get_session() -> session.session;
fn get_span() -> common.span;
fn next_def_id() -> ast.def_id;
+ fn set_def(ast.def_num);
fn get_prec_table() -> vec[op_spec];
};
impure fn new_parser(session.session sess,
eval.env env,
- ast.crate_num crate,
+ ast.def_id initial_def,
str path) -> parser {
state obj stdio_parser(session.session sess,
eval.env env,
@@ -94,6 +95,10 @@ impure fn new_parser(session.session sess,
ret tup(crate, def);
}
+ fn set_def(ast.def_num d) {
+ def = d;
+ }
+
fn get_file_type() -> file_type {
ret ftype;
}
@@ -114,8 +119,8 @@ impure fn new_parser(session.session sess,
auto rdr = lexer.new_reader(srdr, path);
auto npos = rdr.get_curr_pos();
ret stdio_parser(sess, env, ftype, lexer.next_token(rdr),
- npos, npos, 0, UNRESTRICTED, crate, rdr,
- prec_table());
+ npos, npos, initial_def._1, UNRESTRICTED, initial_def._0,
+ rdr, prec_table());
}
impure fn unexpected(parser p, token.token t) {