From 84f31d2352094b1aa0acf8f53dc0194cbec73c51 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Tue, 25 Jul 2017 20:40:03 -0500 Subject: simplify by not creating repeat nodes if min=max=1 --- parse-pattern.y | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'parse-pattern.y') diff --git a/parse-pattern.y b/parse-pattern.y index e5acd3c..2c0556a 100644 --- a/parse-pattern.y +++ b/parse-pattern.y @@ -62,7 +62,13 @@ input: ; molecule: - repeat sequence { $$ = mkatom(&(struct atom) { .type = ATOM_REPETITION, .u = { .repeat = { .counts = $1, .child = $2 } } }); } + repeat sequence { + if ($1.min == 1 && $1.max == 1) { + $$ = $2; + } else { + $$ = mkatom(&(struct atom) { .type = ATOM_REPETITION, .u = { .repeat = { .counts = $1, .child = $2 } } }); + } + } ; repeat: -- cgit v1.2.3