Skip to content

Commit

Permalink
Rename StringReader::curr as ch.
Browse files Browse the repository at this point in the history
Likewise, rename StringReader::curr_is as ch_is.

This is a [breaking-change] for libsyntax.
  • Loading branch information
nnethercote committed Oct 4, 2016
1 parent cb92f5c commit e263120
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 99 deletions.
30 changes: 15 additions & 15 deletions src/libsyntax/parse/lexer/comments.rs
Expand Up @@ -154,8 +154,8 @@ fn push_blank_line_comment(rdr: &StringReader, comments: &mut Vec<Comment>) {
}

fn consume_whitespace_counting_blank_lines(rdr: &mut StringReader, comments: &mut Vec<Comment>) {
while is_pattern_whitespace(rdr.curr) && !rdr.is_eof() {
if rdr.col == CharPos(0) && rdr.curr_is('\n') {
while is_pattern_whitespace(rdr.ch) && !rdr.is_eof() {
if rdr.col == CharPos(0) && rdr.ch_is('\n') {
push_blank_line_comment(rdr, &mut *comments);
}
rdr.bump();
Expand All @@ -182,7 +182,7 @@ fn read_line_comments(rdr: &mut StringReader,
debug!(">>> line comments");
let p = rdr.pos;
let mut lines: Vec<String> = Vec::new();
while rdr.curr_is('/') && rdr.nextch_is('/') {
while rdr.ch_is('/') && rdr.nextch_is('/') {
let line = rdr.read_one_line_comment();
debug!("{}", line);
// Doc comments are not put in comments.
Expand Down Expand Up @@ -249,9 +249,9 @@ fn read_block_comment(rdr: &mut StringReader,
let mut curr_line = String::from("/*");

// doc-comments are not really comments, they are attributes
if (rdr.curr_is('*') && !rdr.nextch_is('*')) || rdr.curr_is('!') {
while !(rdr.curr_is('*') && rdr.nextch_is('/')) && !rdr.is_eof() {
curr_line.push(rdr.curr.unwrap());
if (rdr.ch_is('*') && !rdr.nextch_is('*')) || rdr.ch_is('!') {
while !(rdr.ch_is('*') && rdr.nextch_is('/')) && !rdr.is_eof() {
curr_line.push(rdr.ch.unwrap());
rdr.bump();
}
if !rdr.is_eof() {
Expand All @@ -271,19 +271,19 @@ fn read_block_comment(rdr: &mut StringReader,
if rdr.is_eof() {
panic!(rdr.fatal("unterminated block comment"));
}
if rdr.curr_is('\n') {
if rdr.ch_is('\n') {
trim_whitespace_prefix_and_push_line(&mut lines, curr_line, col);
curr_line = String::new();
rdr.bump();
} else {
curr_line.push(rdr.curr.unwrap());
if rdr.curr_is('/') && rdr.nextch_is('*') {
curr_line.push(rdr.ch.unwrap());
if rdr.ch_is('/') && rdr.nextch_is('*') {
rdr.bump();
rdr.bump();
curr_line.push('*');
level += 1;
} else {
if rdr.curr_is('*') && rdr.nextch_is('/') {
if rdr.ch_is('*') && rdr.nextch_is('/') {
rdr.bump();
rdr.bump();
curr_line.push('/');
Expand All @@ -305,7 +305,7 @@ fn read_block_comment(rdr: &mut StringReader,
Isolated
};
rdr.consume_non_eol_whitespace();
if !rdr.is_eof() && !rdr.curr_is('\n') && lines.len() == 1 {
if !rdr.is_eof() && !rdr.ch_is('\n') && lines.len() == 1 {
style = Mixed;
}
debug!("<<< block comment");
Expand All @@ -319,11 +319,11 @@ fn read_block_comment(rdr: &mut StringReader,

fn consume_comment(rdr: &mut StringReader, code_to_the_left: bool, comments: &mut Vec<Comment>) {
debug!(">>> consume comment");
if rdr.curr_is('/') && rdr.nextch_is('/') {
if rdr.ch_is('/') && rdr.nextch_is('/') {
read_line_comments(rdr, code_to_the_left, comments);
} else if rdr.curr_is('/') && rdr.nextch_is('*') {
} else if rdr.ch_is('/') && rdr.nextch_is('*') {
read_block_comment(rdr, code_to_the_left, comments);
} else if rdr.curr_is('#') && rdr.nextch_is('!') {
} else if rdr.ch_is('#') && rdr.nextch_is('!') {
read_shebang_comment(rdr, code_to_the_left, comments);
} else {
panic!();
Expand Down Expand Up @@ -357,7 +357,7 @@ pub fn gather_comments_and_literals(span_diagnostic: &errors::Handler,
loop {
let mut code_to_the_left = !first_read;
rdr.consume_non_eol_whitespace();
if rdr.curr_is('\n') {
if rdr.ch_is('\n') {
code_to_the_left = false;
consume_whitespace_counting_blank_lines(&mut rdr, &mut comments);
}
Expand Down

0 comments on commit e263120

Please sign in to comment.