Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<'de, 'a> Deserializer<'de> for JSONValueDeserializer<'a> {
visitor.visit_u64(u)
} else {
// fallback: treat as a string or produce an error
Err(de::Error::custom(format!("Invalid integer {}", s)))
Err(de::Error::custom(format!("Invalid integer literal: {}", s)))
}
}
}
Expand Down
23 changes: 13 additions & 10 deletions src/tokenize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,22 @@ impl <'input> Tokenizer<'input> {

fn process_number(&mut self) -> Result<TokenSpan, TokenizationError>{
let (start_idx, start_char) = self.lookahead.expect("Unexpected end of input, was expecting numeric char");
let mut last_index = start_idx;
let mut decimal_seen: bool = false;
let mut exponent_seen: bool = false;
let mut unary_seen: bool = false;
if start_char == '.' {
decimal_seen = true
}

let maybe_second_char = self.chars.peek();
match maybe_second_char {
None => return Ok((start_idx, TokType::Integer, start_idx + 1)),
None => {
if decimal_seen {
return Err(self.make_error("Lone decimal is an invalid literal".to_string(), start_idx))
}
return Ok((start_idx, TokType::Integer, start_idx + 1))
},
Some((_second_idx, second_char)) if start_char == '0' => {
match second_char {
'x' | 'X' => {return self.process_hexadecimal()}
Expand All @@ -240,15 +252,6 @@ impl <'input> Tokenizer<'input> {
_ => {}
}

let mut last_index = start_idx;
let mut decimal_seen: bool = false;
let mut exponent_seen: bool = false;
let mut unary_seen: bool = false;
match start_char {
'.' => {decimal_seen = true}
'+' | '-' => {unary_seen = true}
_ => {}
}
loop {
match self.chars.peek() {
None => {
Expand Down