-
-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Could you support:
rule = {expression}{7} ;
or
rule = {expression}{2,5} ;
Example from the re syntax:
https://docs.python.org/3/library/re.html#regular-expression-syntax, search for "Repetition qualifiers"
I'm sometimes parsing log files, textified pdf, scanned docs or other things not designed to be parsed. One of the reasons I like TatSu for this is you can be sure you really understood the format within a section and can occasionally explain what you're doing to a non-programmer. In contrast when I do the same with regular expressions, I sometimes find myself silently skipping bits (and it's very hard to read!). Such formats often have fixed numbers of repetitions - and it's interesting to know if ones assumption always holds about the number of repetitions.
Also one sometimes gets cases where you have a repetitions followed by up to b repetitions followed by c repetitions where each group is of a different kind - possibly a harder case to manage.
rule = {int}{4} {int}{2,4} {int}{2} ;
Of course I can just measure the list length in semantics, but I feel this is more properly part of the grammar. So this is low priority.