Skip to content
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

Allow non-contiguous state values. #1279

Merged
merged 2 commits into from
Oct 13, 2023
Merged

Allow non-contiguous state values. #1279

merged 2 commits into from
Oct 13, 2023

Conversation

munificent
Copy link
Member

Requiring the states to be a zero-based and contiguous makes it harder for some pieces to support different sets of different states based on what they contain. For example, an ImportPiece only supports states for splitting the names inside a single combinator when there is more than one combinator.

To model that with contiguous states requires the piece to carefully track how state indexes are shifted or splitting pieces into different classes to handle the different sets of states.

Instead, with this change, we simply allow the piece to return a list of states that may be non-contiguous. They can then omit states that don't make sense given the piece's contents. This makes ImportPiece simpler and I think will be useful for other pieces that have a variety of ways they can split.

Also wrap state values in a class to make things a little clearer and more type safe.

Requiring the states to be a zero-based and contiguous makes it harder
for some pieces to support different sets of different states based on
what they contain. For example, an ImportPiece only supports states for
splitting the names inside a single combinator when there is more than
one combinator.

To model that with contiguous states requires the piece to carefully
track how state indexes are shifted or splitting pieces into different
classes to handle the different sets of states.

Instead, with this change, we simply allow the piece to return a list
of states that may be non-contiguous. They can then omit states that
don't make sense given the piece's contents. This makes ImportPiece
simpler and I think will be useful for other pieces that have a variety
of ways they can split.

Also wrap state values in a class to make things a little clearer and
more type safe.
lib/src/piece/piece.dart Outdated Show resolved Hide resolved
@munificent munificent merged commit 35a26b2 into main Oct 13, 2023
7 checks passed
@munificent munificent deleted the non-contiguous-states branch October 13, 2023 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants