diff --git a/src/compiler/prepare_grammar/parse_regex.cc b/src/compiler/prepare_grammar/parse_regex.cc index 8ab84fb2..2b386907 100644 --- a/src/compiler/prepare_grammar/parse_regex.cc +++ b/src/compiler/prepare_grammar/parse_regex.cc @@ -121,7 +121,7 @@ class PatternParser { vector optional_entries(max_count - min_count, Rule::choice({result, Blank{}})); entries.insert(entries.end(), optional_entries.begin(), optional_entries.end()); } else if (has_comma) { - entries.push_back(Rule::repeat(result)); + entries.push_back(Rule::choice({Rule::repeat(result), Blank{} })); } result = Rule::seq(entries); } else if (max_repeat_string.size()) { diff --git a/test/compiler/prepare_grammar/parse_regex_test.cc b/test/compiler/prepare_grammar/parse_regex_test.cc index fe189975..27fd43b1 100644 --- a/test/compiler/prepare_grammar/parse_regex_test.cc +++ b/test/compiler/prepare_grammar/parse_regex_test.cc @@ -305,7 +305,10 @@ describe("parse_regex", []() { CharacterSet{{' '}}, Rule::seq({ CharacterSet{{'b'}}, - Repeat{CharacterSet{{'b'}}}, + Rule::choice({ + Repeat{CharacterSet{{'b'}}}, + Blank{} + }), }), CharacterSet{{' '}}, Rule::seq({