(up_to_n: int, prefix_with_sep: bool = False)
| 188 | ) |
| 189 | |
| 190 | def opt_repetitions(up_to_n: int, prefix_with_sep: bool = False) -> str: |
| 191 | content = ( |
| 192 | f"{separator_rule} {item_rule}" |
| 193 | if prefix_with_sep and separator_rule |
| 194 | else item_rule |
| 195 | ) |
| 196 | if up_to_n == 0: |
| 197 | return "" |
| 198 | if up_to_n == 1: |
| 199 | return f"({content})?" |
| 200 | if separator_rule and not prefix_with_sep: |
| 201 | return f"({content} {opt_repetitions(up_to_n - 1, prefix_with_sep=True)})?" |
| 202 | return (f"({content} " * up_to_n).rstrip() + (")?" * up_to_n) |
| 203 | |
| 204 | if min_items > 0 and max_items != min_items: |
| 205 | result += " " |
nothing calls this directly
no test coverage detected