From dfb151e2a3fad5e49fc14c8f22dd28bc0707a40a Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sat, 25 Feb 2023 14:48:44 -0800 Subject: [PATCH] More work on seq representation --- src/sequence/mod.rs | 9 +++++++-- tests/json_parser.rs | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sequence/mod.rs b/src/sequence/mod.rs index 08bebad..a982a51 100644 --- a/src/sequence/mod.rs +++ b/src/sequence/mod.rs @@ -1,4 +1,4 @@ -use crate::parser::{ParseResult, Parser, ParserInput}; +use crate::parser::{ParseResult, Parser, ParserInput, Representation}; pub fn tuple2(parser1: P1, parser2: P2) -> impl Parser where @@ -14,7 +14,9 @@ where I: ParserInput, T: Sequence, { - 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 { fn parse(&self, input: I) -> ParseResult; + fn representation(&self) -> Representation { + Representation::new("SEQ NOT DONE YET") + } } impl Sequence for (P1, P2) diff --git a/tests/json_parser.rs b/tests/json_parser.rs index f57daa7..d7b4971 100644 --- a/tests/json_parser.rs +++ b/tests/json_parser.rs @@ -244,4 +244,5 @@ fn test_representations() { json_bool().representation(), Representation::new("true | false") ); + assert_eq!(json_number().representation(), Representation::new("null")); }