Skip to content

Commit

Permalink
Used inherited mutability in lexer::Reader.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Mar 28, 2014
1 parent b8601a3 commit 7cf4d8b
Show file tree
Hide file tree
Showing 6 changed files with 335 additions and 390 deletions.
4 changes: 2 additions & 2 deletions src/librustdoc/html/highlight.rs
Expand Up @@ -44,7 +44,7 @@ pub fn highlight(src: &str, class: Option<&str>) -> ~str {
/// it's used. All source code emission is done as slices from the source map,
/// not from the tokens themselves, in order to stay true to the original
/// source.
fn doit(sess: &parse::ParseSess, lexer: lexer::StringReader, class: Option<&str>,
fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader, class: Option<&str>,
out: &mut Writer) -> io::IoResult<()> {
use syntax::parse::lexer::Reader;
Expand All @@ -55,7 +55,7 @@ fn doit(sess: &parse::ParseSess, lexer: lexer::StringReader, class: Option<&str>
let mut is_macro_nonterminal = false;
loop {
let next = lexer.next_token();
let test = if next.tok == t::EOF {lexer.pos.get()} else {next.sp.lo};
let test = if next.tok == t::EOF {lexer.pos} else {next.sp.lo};

// The lexer consumes all whitespace and non-doc-comments when iterating
// between tokens. If this token isn't directly adjacent to our last
Expand Down
22 changes: 11 additions & 11 deletions src/libsyntax/ext/tt/macro_parser.rs
Expand Up @@ -204,11 +204,11 @@ pub enum ParseResult {
Error(codemap::Span, ~str)
}

pub fn parse_or_else<R: Reader>(sess: &ParseSess,
cfg: ast::CrateConfig,
rdr: R,
ms: Vec<Matcher> )
-> HashMap<Ident, @NamedMatch> {
pub fn parse_or_else(sess: &ParseSess,
cfg: ast::CrateConfig,
rdr: TtReader,
ms: Vec<Matcher> )
-> HashMap<Ident, @NamedMatch> {
match parse(sess, cfg, rdr, ms.as_slice()) {
Success(m) => m,
Failure(sp, str) => sess.span_diagnostic.span_fatal(sp, str),
Expand All @@ -226,11 +226,11 @@ pub fn token_name_eq(t1 : &Token, t2 : &Token) -> bool {
}
}

pub fn parse<R: Reader>(sess: &ParseSess,
cfg: ast::CrateConfig,
rdr: R,
ms: &[Matcher])
-> ParseResult {
pub fn parse(sess: &ParseSess,
cfg: ast::CrateConfig,
mut rdr: TtReader,
ms: &[Matcher])
-> ParseResult {
let mut cur_eis = Vec::new();
cur_eis.push(initial_matcher_pos(ms.iter()
.map(|x| (*x).clone())
Expand Down Expand Up @@ -395,7 +395,7 @@ pub fn parse<R: Reader>(sess: &ParseSess,
}
rdr.next_token();
} else /* bb_eis.len() == 1 */ {
let mut rust_parser = Parser(sess, cfg.clone(), rdr.dup());
let mut rust_parser = Parser(sess, cfg.clone(), ~rdr.clone());

let mut ei = bb_eis.pop().unwrap();
match ei.elts.get(ei.idx).node {
Expand Down

0 comments on commit 7cf4d8b

Please sign in to comment.