parameterize Parser on an Error type

This commit is contained in:
Folkert 2021-02-07 22:08:28 +01:00
parent da28486184
commit 148fffe969
17 changed files with 372 additions and 271 deletions

View file

@ -3,12 +3,12 @@ use crate::expr;
use crate::parser::Progress::*;
use crate::parser::{
allocated, ascii_char, ascii_hex_digits, loc, parse_utf8, unexpected, unexpected_eof, Bag,
FailReason, ParseResult, Parser, State,
ParseResult, Parser, State, SyntaxError,
};
use bumpalo::collections::vec::Vec;
use bumpalo::Bump;
pub fn parse<'a>() -> impl Parser<'a, StrLiteral<'a>> {
pub fn parse<'a>() -> impl Parser<'a, StrLiteral<'a>, SyntaxError> {
use StrLiteral::*;
move |arena: &'a Bump, mut state: State<'a>| {
@ -256,7 +256,7 @@ fn parse_block_string<'a, I>(
arena: &'a Bump,
state: State<'a>,
bytes: &mut I,
) -> ParseResult<'a, StrLiteral<'a>>
) -> ParseResult<'a, StrLiteral<'a>, SyntaxError>
where
I: Iterator<Item = &'a u8>,
{
@ -294,7 +294,7 @@ where
Bag::from_state(
arena,
&state,
FailReason::NotYetImplemented(format!(
SyntaxError::NotYetImplemented(format!(
"TODO parse this line in a block string: {:?}",
line
)),