Skip to content

Commit 028eeb1

Browse files
committed
Properly sync macro_parser.rs after it escapes out to the Rust parser. Closes #3201.
1 parent 22ec209 commit 028eeb1

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/libsyntax/ext/expand.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,14 @@ fn core_macros() -> ~str {
244244
return
245245
~"{
246246
macro_rules! ignore (($($x:tt)*) => (()))
247-
#macro[[#error[f, ...], log(core::error, #fmt[f, ...])]];
248-
#macro[[#warn[f, ...], log(core::warn, #fmt[f, ...])]];
249-
#macro[[#info[f, ...], log(core::info, #fmt[f, ...])]];
250-
#macro[[#debug[f, ...], log(core::debug, #fmt[f, ...])]];
247+
macro_rules! error ( ($( $arg:expr ),+) => (
248+
log(core::error, fmt!( $($arg),+ )) ))
249+
macro_rules! warn ( ($( $arg:expr ),+) => (
250+
log(core::warn, fmt!( $($arg),+ )) ))
251+
macro_rules! info ( ($( $arg:expr ),+) => (
252+
log(core::info, fmt!( $($arg),+ )) ))
253+
macro_rules! debug ( ($( $arg:expr ),+) => (
254+
log(core::debug, fmt!( $($arg),+ )) ))
251255
}";
252256
}
253257

src/libsyntax/ext/tt/macro_parser.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
368368
}
369369
cur_eis.push(move ei);
370370
371-
/* this would fail if zero-length tokens existed */
372-
while rdr.peek().sp.lo < rust_parser.span.lo {
373-
rdr.next_token();
374-
} /* except for EOF... */
375-
while rust_parser.token == EOF && rdr.peek().tok != EOF {
371+
for rust_parser.tokens_consumed.times() || {
376372
rdr.next_token();
377373
}
378374
}

src/libsyntax/parse/parser.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ fn Parser(sess: parse_sess, cfg: ast::crate_cfg,
192192
buffer: [mut {tok: tok0.tok, sp: span0}, ..4],
193193
buffer_start: 0,
194194
buffer_end: 0,
195+
tokens_consumed: 0u,
195196
restriction: UNRESTRICTED,
196197
quote_depth: 0u,
197198
keywords: token::keyword_table(),
@@ -210,6 +211,7 @@ struct Parser {
210211
mut buffer: [mut {tok: token::Token, sp: span} * 4],
211212
mut buffer_start: int,
212213
mut buffer_end: int,
214+
mut tokens_consumed: uint,
213215
mut restriction: restriction,
214216
mut quote_depth: uint, // not (yet) related to the quasiquoter
215217
reader: reader,
@@ -236,6 +238,7 @@ impl Parser {
236238
};
237239
self.token = next.tok;
238240
self.span = next.sp;
241+
self.tokens_consumed += 1u;
239242
}
240243
fn swap(next: token::Token, +lo: BytePos, +hi: BytePos) {
241244
self.token = next;

0 commit comments

Comments
 (0)