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

Control-flow analysis for grid symbols #2

Open
kaya3 opened this issue Sep 4, 2022 · 0 comments
Open

Control-flow analysis for grid symbols #2

kaya3 opened this issue Sep 4, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@kaya3
Copy link
Owner

kaya3 commented Sep 4, 2022

Consider the following program:

grid [BW]
all: [B] -> [W]
one: [BW] -> [WB]

By considering the program's control flow, it is in principle possible to statically determine some facts about the program's behaviour:

  • After one iteration of the all statement, there will be no B symbols in the grid, and therefore this statement cannot repeat.
  • Additionally, since there cannot be any B symbols in the grid at this point, the input pattern [BW] can never have any matches. (This is complicated by the fact that the one statement could itself put some B symbols into the grid, if not for the fact that it can only do so when some B symbols are already present.)

In such cases, a slightly more optimal control-flow graph can be emitted, eliminating some checks which are guaranteed to be true or false, and eliminating dead code. It would also be helpful for the compiler to emit an error or a warning message when an input pattern can never be matched.

If we also consider limits, it would be possible to determine facts such as "at this point in the program, the number of W symbols is between a and b", which could be useful for some other purposes.

@kaya3 kaya3 added the enhancement New feature or request label Sep 4, 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