-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added upper bounds for sequences #149
Conversation
I have updated this PR to generalise the |
include/trieste/wf.h
Outdated
Sequence& operator[](size_t new_len) | ||
{ | ||
minlen = new_minlen; | ||
if (!has_minlen) | ||
{ | ||
minlen = new_len; | ||
has_minlen = true; | ||
} | ||
else | ||
{ | ||
maxlen = new_len; | ||
} | ||
return *this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we detect
Foo++[1][2][3]
as an error? Should we error for maxlen < minlen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither of the errors give a strange behavior, but I guess it would be a slightly nicer user experience to check for it. I will add it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree failing silently is in keeping with the codebase. ;)
Added bounds checking ( |
* Added top-level option shape to well-formedness specifications * Replaced Option class by extended Sequence class * Bounds checking for sequences --------- Co-authored-by: Sylvan Clebsch <[email protected]>
This PR adds support for giving upper bounds for sequences in the well-formedness specifications:
One motivating use case is having a top-level optional shape (which is shorthand for
++[0][1]
):Before this, the closest you could get was using
++
, which would mess with fuzz testing. Just as sequences, optional shapes can only be used at the top level of a shape; you still cannot write e.g.Paren <<= Foo * ~Bar
orParen <<= Foo * Bar++
.The JSON parser had
File <<= Group++
even though the initial parse pass can produce at most one group, but I did not find any more interesting usages of this pattern in any other sample or parser. Manual toying around with this seems to suggest that both checking and generation handles the new shape correctly.