This commit is contained in:
Folkert 2021-02-26 22:22:15 +01:00
parent 5b3c7eeee3
commit 64eed62b69
3 changed files with 9 additions and 7 deletions

View file

@ -107,7 +107,7 @@ fn chomp_number_dec<'a>(
} }
} }
fn chomp_number<'a>(mut bytes: &'a [u8]) -> (bool, usize) { fn chomp_number(mut bytes: &[u8]) -> (bool, usize) {
let start_bytes_len = bytes.len(); let start_bytes_len = bytes.len();
let mut is_float = false; let mut is_float = false;

View file

@ -896,14 +896,14 @@ pub fn unexpected_eof<'a>(
state: State<'a>, state: State<'a>,
chars_consumed: usize, chars_consumed: usize,
) -> (Progress, SyntaxError<'a>, State<'a>) { ) -> (Progress, SyntaxError<'a>, State<'a>) {
checked_unexpected(state, chars_consumed, |region| SyntaxError::Eof(region)) checked_unexpected(state, chars_consumed, SyntaxError::Eof)
} }
pub fn unexpected<'a>( pub fn unexpected(
chars_consumed: usize, chars_consumed: usize,
_attempting: Attempting, _attempting: Attempting,
state: State<'a>, state: State,
) -> (Progress, SyntaxError<'a>, State<'a>) { ) -> (Progress, SyntaxError, State) {
// NOTE state is the last argument because chars_consumed often depends on the state's fields // NOTE state is the last argument because chars_consumed often depends on the state's fields
// having state be the final argument prevents borrowing issues // having state be the final argument prevents borrowing issues
checked_unexpected(state, chars_consumed, |region| { checked_unexpected(state, chars_consumed, |region| {
@ -946,7 +946,7 @@ where
} }
} }
fn line_too_long_e<'a, TE, E>(state: State<'a>, to_error: TE) -> (Progress, E, State<'a>) fn line_too_long_e<TE, E>(state: State, to_error: TE) -> (Progress, E, State)
where where
TE: Fn(Row, Col) -> E, TE: Fn(Row, Col) -> E,
{ {
@ -971,7 +971,7 @@ where
(Progress::NoProgress, problem, state) (Progress::NoProgress, problem, state)
} }
fn line_too_long<'a>(state: State<'a>) -> (Progress, SyntaxError<'a>, State<'a>) { fn line_too_long(state: State) -> (Progress, SyntaxError, State) {
line_too_long_e(state, |line, _| SyntaxError::LineTooLong(line)) line_too_long_e(state, |line, _| SyntaxError::LineTooLong(line))
} }

View file

@ -151,6 +151,8 @@ pub fn parse<'a>() -> impl Parser<'a, StrLiteral<'a>, EString<'a>> {
return Ok((MadeProgress, PlainLine(""), advance_state!(state, 1)?)); return Ok((MadeProgress, PlainLine(""), advance_state!(state, 1)?));
} }
} else { } else {
// the string is non-empty, which means we need to convert any previous segments
// and the current segment into a string literal
if is_multiline { if is_multiline {
if bytes.as_slice().starts_with(b"\"\"") { if bytes.as_slice().starts_with(b"\"\"") {
end_segment!(StrSegment::Plaintext); end_segment!(StrSegment::Plaintext);