Skip to content

Support repetition qualifiers for closures #214

@mgrazebrook

Description

@mgrazebrook

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions