diff --git a/abnf_to_regexp/nested_python.py b/abnf_to_regexp/nested_python.py index 3102c1e..e7e081f 100644 --- a/abnf_to_regexp/nested_python.py +++ b/abnf_to_regexp/nested_python.py @@ -314,7 +314,7 @@ def visit_repetition(self, element: Repetition) -> None: and element.max_occurrences is not None and element.max_occurrences > 0 ): - suffix = f"{{{element.max_occurrences}}}" + suffix = f"{{,{element.max_occurrences}}}" elif ( element.min_occurrences is not None and element.min_occurrences > 0 diff --git a/test_data/nested-python/bcp47/expected.py b/test_data/nested-python/bcp47/expected.py index 26dd2ee..fee2d36 100644 --- a/test_data/nested-python/bcp47/expected.py +++ b/test_data/nested-python/bcp47/expected.py @@ -1,7 +1,7 @@ alphanum = '[a-zA-Z0-9]' singleton = '[0-9A-WY-Za-wy-z]' extension = f'{singleton}(-({alphanum}){{2,8}})+' -extlang = '[a-zA-Z]{3}(-[a-zA-Z]{3}){2}' +extlang = '[a-zA-Z]{3}(-[a-zA-Z]{3}){,2}' irregular = ( '(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|' 'i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|' diff --git a/test_data/nested-python/rfc3986/expected.py b/test_data/nested-python/rfc3986/expected.py index 4fdd6a4..08bd820 100644 --- a/test_data/nested-python/rfc3986/expected.py +++ b/test_data/nested-python/rfc3986/expected.py @@ -9,9 +9,10 @@ ls32 = f'({h16}:{h16}|{ipv4address})' ipv6address = ( f'(({h16}:){{6}}{ls32}|::({h16}:){{5}}{ls32}|({h16})?::({h16}:){{4}}' - f'{ls32}|(({h16}:)?{h16})?::({h16}:){{3}}{ls32}|(({h16}:){{2}}{h16})?::' - f'({h16}:){{2}}{ls32}|(({h16}:){{3}}{h16})?::{h16}:{ls32}|(({h16}:){{4}}' - f'{h16})?::{ls32}|(({h16}:){{5}}{h16})?::{h16}|(({h16}:){{6}}{h16})?::)' + f'{ls32}|(({h16}:)?{h16})?::({h16}:){{3}}{ls32}|(({h16}:){{,2}}{h16})?::' + f'({h16}:){{2}}{ls32}|(({h16}:){{,3}}{h16})?::{h16}:{ls32}|(({h16}:){{,4}}' + f'{h16})?::{ls32}|(({h16}:){{,5}}{h16})?::{h16}|(({h16}:){{,6}}{h16})?' + '::)' ) ipvfuture = f'[vV][0-9A-Fa-f]+\\.({unreserved}|{sub_delims}|:)+' ip_literal = f'\\[({ipv6address}|{ipvfuture})\\]' diff --git a/test_data/nested-python/rfc3987/expected.py b/test_data/nested-python/rfc3987/expected.py index f03e4c8..b8cc4c9 100644 --- a/test_data/nested-python/rfc3987/expected.py +++ b/test_data/nested-python/rfc3987/expected.py @@ -19,9 +19,10 @@ ls32 = f'({h16}:{h16}|{ipv4address})' ipv6address = ( f'(({h16}:){{6}}{ls32}|::({h16}:){{5}}{ls32}|({h16})?::({h16}:){{4}}' - f'{ls32}|(({h16}:)?{h16})?::({h16}:){{3}}{ls32}|(({h16}:){{2}}{h16})?::' - f'({h16}:){{2}}{ls32}|(({h16}:){{3}}{h16})?::{h16}:{ls32}|(({h16}:){{4}}' - f'{h16})?::{ls32}|(({h16}:){{5}}{h16})?::{h16}|(({h16}:){{6}}{h16})?::)' + f'{ls32}|(({h16}:)?{h16})?::({h16}:){{3}}{ls32}|(({h16}:){{,2}}{h16})?::' + f'({h16}:){{2}}{ls32}|(({h16}:){{,3}}{h16})?::{h16}:{ls32}|(({h16}:){{,4}}' + f'{h16})?::{ls32}|(({h16}:){{,5}}{h16})?::{h16}|(({h16}:){{,6}}{h16})?' + '::)' ) unreserved = '[a-zA-Z0-9\\-._~]' ipvfuture = f'[vV][0-9A-Fa-f]+\\.({unreserved}|{sub_delims}|:)+' diff --git a/test_data/nested-python/rfc8089/expected.py b/test_data/nested-python/rfc8089/expected.py index b602fe0..9f4147f 100644 --- a/test_data/nested-python/rfc8089/expected.py +++ b/test_data/nested-python/rfc8089/expected.py @@ -4,9 +4,10 @@ ls32 = f'({h16}:{h16}|{ipv4address})' ipv6address = ( f'(({h16}:){{6}}{ls32}|::({h16}:){{5}}{ls32}|({h16})?::({h16}:){{4}}' - f'{ls32}|(({h16}:)?{h16})?::({h16}:){{3}}{ls32}|(({h16}:){{2}}{h16})?::' - f'({h16}:){{2}}{ls32}|(({h16}:){{3}}{h16})?::{h16}:{ls32}|(({h16}:){{4}}' - f'{h16})?::{ls32}|(({h16}:){{5}}{h16})?::{h16}|(({h16}:){{6}}{h16})?::)' + f'{ls32}|(({h16}:)?{h16})?::({h16}:){{3}}{ls32}|(({h16}:){{,2}}{h16})?::' + f'({h16}:){{2}}{ls32}|(({h16}:){{,3}}{h16})?::{h16}:{ls32}|(({h16}:){{,4}}' + f'{h16})?::{ls32}|(({h16}:){{,5}}{h16})?::{h16}|(({h16}:){{,6}}{h16})?' + '::)' ) unreserved = '[a-zA-Z0-9\\-._~]' sub_delims = "[!$&'()*+,;=]"