From 201830e33ab5c45044e960217e0ac8803e3e134d Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 21 Jul 2023 16:21:00 +0800 Subject: Add variations to the test Add an intentionally ambiguous grammar for testing purposes. It seems to work fine. --- src/lib.rs | 7 +++++-- src/test.c | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index b7252a3..7cc5223 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,6 +32,9 @@ impl Parser { /// format. pub fn new(s: &str) -> Result { let grammar: Grammar = s.parse().map_err(|err| format!("{err}"))?; + + println!("grammar: {grammar}"); + let atom: DefaultAtom = DefaultAtom::from_grammar(grammar).map_err(|err| format!("{err}"))?; @@ -480,8 +483,8 @@ extern "C" fn parser_parse( match forest { Ok(forest) => { - // use graph::Graph; - // forest.print_viz("test forest.gv").unwrap(); + use graph::Graph; + forest.print_viz("test forest.gv").unwrap(); Box::leak(parser_box); diff --git a/src/test.c b/src/test.c index 5a5118d..249eb87 100644 --- a/src/test.c +++ b/src/test.c @@ -23,6 +23,8 @@ main(int argc, char **argv) "\n" "item = header [ price ] *1( note )\n" "\n" +"item =/ header [ note ] *1( price )\n" +"\n" "header = *1star \"SP\" title %xA *( \"SP\" / %xA )\n" "\n" "title = 1*\"TEXT\"\n" @@ -66,13 +68,13 @@ main(int argc, char **argv) return EXIT_FAILURE; } - int input_unenc[10] = { 3, 0, 2, 2, 2, 1, 1, 1, 0, 1 }; + int input_unenc[10] = { 3, 0, 2, 2, 2, 1, 5, 0, 6, 1 }; for (int i = 0; i < 10; i++) to_big_endian(input_unenc[i], input + (8 * i)); unsigned char input_len[8] = { 0 }; - input_len[7] = 8*6; + input_len[7] = 8*10; struct UnsignedVec input_vec = (struct UnsignedVec) { input_len, NULL, input }; -- cgit v1.2.3-18-g5258