number parsing with new errors

This commit is contained in:
Folkert 2021-02-26 15:06:24 +01:00
parent d4de440943
commit bb9a2525b5
8 changed files with 187 additions and 263 deletions

View file

@ -371,7 +371,7 @@ pub fn line_comment<'a>() -> impl Parser<'a, &'a str, SyntaxError<'a>> {
}
let comment = &state.bytes[..length];
let state = state.advance_without_indenting(arena, length + 1)?;
let state = state.advance_without_indenting(length + 1)?;
match parse_utf8(comment) {
Ok(comment_str) => Ok((MadeProgress, comment_str, state)),
Err(reason) => state.fail(arena, MadeProgress, reason),
@ -535,7 +535,7 @@ where
.map_err(|(fail, _)| {
(progress, fail, original_state.clone())
})?
.advance_without_indenting_e(arena, 1, space_problem)?;
.advance_without_indenting_e(1, space_problem)?;
// We're now parsing a line comment!
line_state = LineState::Comment;
@ -584,11 +584,7 @@ where
match ch {
' ' => {
// If we're in a line comment, this won't affect indentation anyway.
state = state.advance_without_indenting_e(
arena,
1,
space_problem,
)?;
state = state.advance_without_indenting_e(1, space_problem)?;
if comment_line_buf.len() == 1 {
match comment_line_buf.chars().next() {
@ -650,7 +646,6 @@ where
nonblank => {
// Chars can have btye lengths of more than 1!
state = state.advance_without_indenting_e(
arena,
nonblank.len_utf8(),
space_problem,
)?;
@ -663,11 +658,7 @@ where
match ch {
' ' => {
// If we're in a doc comment, this won't affect indentation anyway.
state = state.advance_without_indenting_e(
arena,
1,
space_problem,
)?;
state = state.advance_without_indenting_e(1, space_problem)?;
comment_line_buf.push(ch);
}
@ -692,11 +683,8 @@ where
));
}
nonblank => {
state = state.advance_without_indenting_e(
arena,
utf8_len,
space_problem,
)?;
state = state
.advance_without_indenting_e(utf8_len, space_problem)?;
comment_line_buf.push(nonblank);
}