summaryrefslogtreecommitdiff
path: root/parse-pattern.y
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2017-07-25 20:40:03 -0500
committerBobby Bingham <koorogi@koorogi.info>2017-07-25 20:40:03 -0500
commit84f31d2352094b1aa0acf8f53dc0194cbec73c51 (patch)
treed40ebba29830e9ec2a9842632ce3a80f35f535ad /parse-pattern.y
parent4459545e6528c8f072de79b799b9ae9b85d01dfb (diff)
simplify by not creating repeat nodes if min=max=1
Diffstat (limited to 'parse-pattern.y')
-rw-r--r--parse-pattern.y8
1 files changed, 7 insertions, 1 deletions
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: