From 5e1e487624a134e99371fff073862c90da479755 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Wed, 20 Nov 2013 02:15:49 +0900 Subject: Make BytePos 32-bit --- src/libsyntax/parse/lexer.rs | 10 +++++----- src/libsyntax/parse/parser.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 06a2c557e42..2974b90d97e 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -241,7 +241,7 @@ pub fn bump(rdr: &mut StringReader) { let last_char = rdr.curr; let next = rdr.src.char_range_at(current_byte_offset); let byte_offset_diff = next.next - current_byte_offset; - rdr.pos = rdr.pos + BytePos(byte_offset_diff); + rdr.pos = rdr.pos + Pos::from_uint(byte_offset_diff); rdr.curr = next.ch; rdr.col = rdr.col + CharPos(1u); if last_char == '\n' { @@ -251,7 +251,7 @@ pub fn bump(rdr: &mut StringReader) { if byte_offset_diff > 1 { rdr.filemap.record_multibyte_char( - BytePos(current_byte_offset), byte_offset_diff); + Pos::from_uint(current_byte_offset), byte_offset_diff); } } else { rdr.curr = unsafe { transmute(-1u32) }; // FIXME: #8971: unsound @@ -327,7 +327,7 @@ fn consume_any_line_comment(rdr: @mut StringReader) bump(rdr); // line comments starting with "///" or "//!" are doc-comments if rdr.curr == '/' || rdr.curr == '!' { - let start_bpos = rdr.pos - BytePos(3u); + let start_bpos = rdr.pos - BytePos(3); while rdr.curr != '\n' && !is_eof(rdr) { bump(rdr); } @@ -381,7 +381,7 @@ fn consume_block_comment(rdr: @mut StringReader) -> Option { // block comments starting with "/**" or "/*!" are doc-comments let is_doc_comment = rdr.curr == '*' || rdr.curr == '!'; - let start_bpos = rdr.pos - BytePos(if is_doc_comment {3u} else {2u}); + let start_bpos = rdr.pos - BytePos(if is_doc_comment {3} else {2}); let mut level: int = 1; while level > 0 { @@ -809,7 +809,7 @@ fn next_token_inner(rdr: @mut StringReader) -> token::Token { // Byte offsetting here is okay because the // character before position `start` is an // ascii single quote. - start - BytePos(1u), + start - BytePos(1), rdr.last_pos, ~"unterminated character constant"); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2ea6878f4a3..2a270b392bc 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -608,7 +608,7 @@ impl Parser { token::GT => self.bump(), token::BINOP(token::SHR) => self.replace_token( token::GT, - self.span.lo + BytePos(1u), + self.span.lo + BytePos(1), self.span.hi ), _ => self.fatal(format!("expected `{}`, found `{}`", -- cgit 1.4.1-3-g733a5 From f4c1f49049c1d01a09599aa2b7ea4a6523045d38 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Thu, 21 Nov 2013 01:32:29 +0900 Subject: Fix parsing tests --- src/libsyntax/parse/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 0e9a529f950..018cb40e6b7 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -354,7 +354,7 @@ mod test { } // produce a codemap::span - fn sp (a: uint, b: uint) -> Span { + fn sp(a: u32, b: u32) -> Span { Span{lo:BytePos(a),hi:BytePos(b),expn_info:None} } -- cgit 1.4.1-3-g733a5