aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front/parser.rs
diff options
context:
space:
mode:
authorMarijn Haverbeke <[email protected]>2011-03-24 16:33:20 +0100
committerGraydon Hoare <[email protected]>2011-03-31 14:41:39 +0000
commite7e6f396d888574e7184119818ac3300f10aacbf (patch)
tree143c2c918a5123d6ed07b8ee61909981d3aa47e5 /src/comp/front/parser.rs
parentTweak build command on rustc. (diff)
downloadrust-e7e6f396d888574e7184119818ac3300f10aacbf.tar.xz
rust-e7e6f396d888574e7184119818ac3300f10aacbf.zip
Preserve comments when pretty-printing.
The patch also includes a number of smaller fixes to the pretty-printer that were encountered on the way.
Diffstat (limited to 'src/comp/front/parser.rs')
-rw-r--r--src/comp/front/parser.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index a247c824..82f7712f 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -116,6 +116,8 @@ impure fn new_parser(session.session sess,
}
auto srdr = io.file_reader(path);
auto rdr = lexer.new_reader(srdr, path);
+ // Make sure npos points at first actual token.
+ lexer.consume_any_whitespace(rdr);
auto npos = rdr.get_curr_pos();
ret stdio_parser(sess, env, ftype, lexer.next_token(rdr),
npos, npos, initial_def._1, UNRESTRICTED, initial_def._0,
@@ -1748,8 +1750,8 @@ impure fn parse_block(parser p) -> ast.block {
}
}
- p.bump();
auto hi = p.get_span();
+ p.bump();
auto bloc = index_block(stmts, expr);
ret spanned[ast.block_](lo, hi, bloc);