The existing :cardinality key was not expressive enough to capture the semantics of sequence schemas (namely, that if you don't generate an s/optional element, you have to stop there.
This PR replaces :cardinality with a nested structure of optional tails that can properly express the semantics of existing collection schemas for the purpose of generation. It also slightly generalizes the types of schemas that can be expressed with the collection spec, although probably not in a way that's useful to anyone.
The changes feel a bit heavyweight for what's accomplished, but I tried a few alternatives and couldn't get them to work without reasonable performance (and really didn't feel good about the option of adding another pseudo-:cardinality that expressed the missing constraint. Suggestions for alternative approaches very welcome!
The existing
:cardinality
key was not expressive enough to capture the semantics of sequence schemas (namely, that if you don't generate ans/optional
element, you have to stop there.This PR replaces
:cardinality
with a nested structure of optional tails that can properly express the semantics of existing collection schemas for the purpose of generation. It also slightly generalizes the types of schemas that can be expressed with the collection spec, although probably not in a way that's useful to anyone.The changes feel a bit heavyweight for what's accomplished, but I tried a few alternatives and couldn't get them to work without reasonable performance (and really didn't feel good about the option of adding another pseudo-
:cardinality
that expressed the missing constraint. Suggestions for alternative approaches very welcome!