Skip to content

Commit

Permalink
Add syntactic to whitelist (#4597)
Browse files Browse the repository at this point in the history
Part of #4579

Adds the `syntactic` attribute to the whitelist, and checks that it is
only applied to simplification rules.

Notably, we still need to:
- Check that the arguments actually refer to existing clauses
- Tag the underlying clauses and re-construct the attribute at the end
of the compilation pipeline because the `requires` clauses may be
manipulated during compilation
  • Loading branch information
Scott-Guest authored Aug 22, 2024
1 parent 16b1b15 commit 6aae149
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private void checkRule(Rule rule) {
checkNonExecutable(rule);
checkSimplification(rule);
checkSymbolic(rule);
checkSyntactic(rule);
}

private void checkProduction(Production prod) {
Expand Down Expand Up @@ -151,6 +152,14 @@ private void checkSymbolic(Rule rule) {
}
}

private void checkSyntactic(Rule rule) {
if (rule.att().contains(Att.SYNTACTIC()) && !rule.att().contains(Att.SIMPLIFICATION())) {
errors.add(
KEMException.compilerError(
"syntactic attribute is only supported on simplification rules."));
}
}

private void checkHookedSortConstructors(Production prod) {
if (prod.sort().equals(Sorts.KItem())) {
return;
Expand Down
2 changes: 2 additions & 0 deletions k-frontend/src/main/scala/org/kframework/attributes/Att.scala
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ object Att {
onlyon3[Module, Production, Rule],
KeyRange.WholePipeline
)
final val SYNTACTIC =
Key.builtin("syntactic", KeyParameter.Required, onlyon[Rule], KeyRange.WholePipeline)
final val TOKEN = Key.builtin(
"token",
KeyParameter.Forbidden,
Expand Down

0 comments on commit 6aae149

Please sign in to comment.