More work on seq representation

This commit is contained in:
Greg Shuflin 2023-02-25 14:48:44 -08:00
parent 9a3745d25c
commit dfb151e2a3
2 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,4 @@
use crate::parser::{ParseResult, Parser, ParserInput};
use crate::parser::{ParseResult, Parser, ParserInput, Representation};
pub fn tuple2<P1, P2, I, O1, O2, E>(parser1: P1, parser2: P2) -> impl Parser<I, (O1, O2), E>
where
@ -14,7 +14,9 @@ where
I: ParserInput,
T: Sequence<I, O, E>,
{
move |input| sequence.parse(input)
let rep = sequence.representation();
let p = move |input| sequence.parse(input);
(p, rep)
}
/* TODO - eventually rewrite this parser combinator in Schala. Seeing what this
@ -24,6 +26,9 @@ where
pub trait Sequence<I, O, E> {
fn parse(&self, input: I) -> ParseResult<I, O, E>;
fn representation(&self) -> Representation {
Representation::new("SEQ NOT DONE YET")
}
}
impl<I, O1, O2, E, P1, P2> Sequence<I, (O1, O2), E> for (P1, P2)

View File

@ -244,4 +244,5 @@ fn test_representations() {
json_bool().representation(),
Representation::new("true | false")
);
assert_eq!(json_number().representation(), Representation::new("null"));
}