libsyntax: use tuple indexing
This commit is contained in:
parent
4fd6a99851
commit
c434954b27
2 changed files with 10 additions and 10 deletions
|
@ -431,7 +431,7 @@ pub fn str_lit(lit: &str) -> String {
|
||||||
/// Eat everything up to a non-whitespace
|
/// Eat everything up to a non-whitespace
|
||||||
fn eat<'a>(it: &mut iter::Peekable<(uint, char), str::CharOffsets<'a>>) {
|
fn eat<'a>(it: &mut iter::Peekable<(uint, char), str::CharOffsets<'a>>) {
|
||||||
loop {
|
loop {
|
||||||
match it.peek().map(|x| x.val1()) {
|
match it.peek().map(|x| x.1) {
|
||||||
Some(' ') | Some('\n') | Some('\r') | Some('\t') => {
|
Some(' ') | Some('\n') | Some('\r') | Some('\t') => {
|
||||||
it.next();
|
it.next();
|
||||||
},
|
},
|
||||||
|
@ -448,7 +448,7 @@ pub fn str_lit(lit: &str) -> String {
|
||||||
'\\' => {
|
'\\' => {
|
||||||
let ch = chars.peek().unwrap_or_else(|| {
|
let ch = chars.peek().unwrap_or_else(|| {
|
||||||
panic!("{}", error(i).as_slice())
|
panic!("{}", error(i).as_slice())
|
||||||
}).val1();
|
}).1;
|
||||||
|
|
||||||
if ch == '\n' {
|
if ch == '\n' {
|
||||||
eat(&mut chars);
|
eat(&mut chars);
|
||||||
|
@ -456,7 +456,7 @@ pub fn str_lit(lit: &str) -> String {
|
||||||
chars.next();
|
chars.next();
|
||||||
let ch = chars.peek().unwrap_or_else(|| {
|
let ch = chars.peek().unwrap_or_else(|| {
|
||||||
panic!("{}", error(i).as_slice())
|
panic!("{}", error(i).as_slice())
|
||||||
}).val1();
|
}).1;
|
||||||
|
|
||||||
if ch != '\n' {
|
if ch != '\n' {
|
||||||
panic!("lexer accepted bare CR");
|
panic!("lexer accepted bare CR");
|
||||||
|
@ -474,7 +474,7 @@ pub fn str_lit(lit: &str) -> String {
|
||||||
'\r' => {
|
'\r' => {
|
||||||
let ch = chars.peek().unwrap_or_else(|| {
|
let ch = chars.peek().unwrap_or_else(|| {
|
||||||
panic!("{}", error(i).as_slice())
|
panic!("{}", error(i).as_slice())
|
||||||
}).val1();
|
}).1;
|
||||||
|
|
||||||
if ch != '\n' {
|
if ch != '\n' {
|
||||||
panic!("lexer accepted bare CR");
|
panic!("lexer accepted bare CR");
|
||||||
|
@ -600,7 +600,7 @@ pub fn binary_lit(lit: &str) -> Rc<Vec<u8>> {
|
||||||
/// Eat everything up to a non-whitespace
|
/// Eat everything up to a non-whitespace
|
||||||
fn eat<'a, I: Iterator<(uint, u8)>>(it: &mut iter::Peekable<(uint, u8), I>) {
|
fn eat<'a, I: Iterator<(uint, u8)>>(it: &mut iter::Peekable<(uint, u8), I>) {
|
||||||
loop {
|
loop {
|
||||||
match it.peek().map(|x| x.val1()) {
|
match it.peek().map(|x| x.1) {
|
||||||
Some(b' ') | Some(b'\n') | Some(b'\r') | Some(b'\t') => {
|
Some(b' ') | Some(b'\n') | Some(b'\r') | Some(b'\t') => {
|
||||||
it.next();
|
it.next();
|
||||||
},
|
},
|
||||||
|
@ -615,11 +615,11 @@ pub fn binary_lit(lit: &str) -> Rc<Vec<u8>> {
|
||||||
match chars.next() {
|
match chars.next() {
|
||||||
Some((i, b'\\')) => {
|
Some((i, b'\\')) => {
|
||||||
let em = error(i);
|
let em = error(i);
|
||||||
match chars.peek().expect(em.as_slice()).val1() {
|
match chars.peek().expect(em.as_slice()).1 {
|
||||||
b'\n' => eat(&mut chars),
|
b'\n' => eat(&mut chars),
|
||||||
b'\r' => {
|
b'\r' => {
|
||||||
chars.next();
|
chars.next();
|
||||||
if chars.peek().expect(em.as_slice()).val1() != b'\n' {
|
if chars.peek().expect(em.as_slice()).1 != b'\n' {
|
||||||
panic!("lexer accepted bare CR");
|
panic!("lexer accepted bare CR");
|
||||||
}
|
}
|
||||||
eat(&mut chars);
|
eat(&mut chars);
|
||||||
|
@ -637,7 +637,7 @@ pub fn binary_lit(lit: &str) -> Rc<Vec<u8>> {
|
||||||
},
|
},
|
||||||
Some((i, b'\r')) => {
|
Some((i, b'\r')) => {
|
||||||
let em = error(i);
|
let em = error(i);
|
||||||
if chars.peek().expect(em.as_slice()).val1() != b'\n' {
|
if chars.peek().expect(em.as_slice()).1 != b'\n' {
|
||||||
panic!("lexer accepted bare CR");
|
panic!("lexer accepted bare CR");
|
||||||
}
|
}
|
||||||
chars.next();
|
chars.next();
|
||||||
|
|
|
@ -1740,8 +1740,8 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
token::Literal(lit, suf) => {
|
token::Literal(lit, suf) => {
|
||||||
let (suffix_illegal, out) = match lit {
|
let (suffix_illegal, out) = match lit {
|
||||||
token::Byte(i) => (true, LitByte(parse::byte_lit(i.as_str()).val0())),
|
token::Byte(i) => (true, LitByte(parse::byte_lit(i.as_str()).0)),
|
||||||
token::Char(i) => (true, LitChar(parse::char_lit(i.as_str()).val0())),
|
token::Char(i) => (true, LitChar(parse::char_lit(i.as_str()).0)),
|
||||||
|
|
||||||
// there are some valid suffixes for integer and
|
// there are some valid suffixes for integer and
|
||||||
// float literals, so all the handling is done
|
// float literals, so all the handling is done
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue