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

Logical operations on input patterns #6

Closed
kaya3 opened this issue Sep 4, 2022 · 1 comment
Closed

Logical operations on input patterns #6

kaya3 opened this issue Sep 4, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@kaya3
Copy link
Owner

kaya3 commented Sep 4, 2022

"Input patterns" are used in rewrite rules, observe rules, and some other places to determine matches; conceptually, an input pattern is used as a boolean test on a grid position, where the test is true whereever the pattern matches and false otherwise. It would be interesting to allow logical operations on patterns, e.g. [W..W] and not [.WW.] would match two W symbols with a gap of 2 between them, but only if they are not connected along that gap by W symbols.

This would expand the expressiveness of the language with, potentially, no performance cost: in the current implementation, each DFA state is mapped to an "accept set" which is a set of patterns matched, so any logical operations could be performed at compile-time when computing these "accept sets". (Care would be needed for patterns like not [W], to ensure the DFA's initial 'zero' state still doesn't match them, otherwise the initial call to gridN_update may not correctly report matches in the empty grid. This should be treated like [.] and not [W].)

Additionally, this would eliminate the need for some statements to check whether an output pattern is already present in the grid: a rewrite rule such as a -> b would be equivalent to a and not b -> b. (Currently, this check is only eliminated when it is statically determined that a and b are mutually exclusive.)

@kaya3 kaya3 added the enhancement New feature or request label Sep 4, 2022
@kaya3
Copy link
Owner Author

kaya3 commented Sep 28, 2022

@kaya3 kaya3 closed this as completed Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant