Skip to content

Commit 6aae149

Browse files
authored
Add syntactic to whitelist (#4597)
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
1 parent 16b1b15 commit 6aae149

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

k-frontend/src/main/java/org/kframework/compile/checks/CheckAtt.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ private void checkRule(Rule rule) {
6060
checkNonExecutable(rule);
6161
checkSimplification(rule);
6262
checkSymbolic(rule);
63+
checkSyntactic(rule);
6364
}
6465

6566
private void checkProduction(Production prod) {
@@ -151,6 +152,14 @@ private void checkSymbolic(Rule rule) {
151152
}
152153
}
153154

155+
private void checkSyntactic(Rule rule) {
156+
if (rule.att().contains(Att.SYNTACTIC()) && !rule.att().contains(Att.SIMPLIFICATION())) {
157+
errors.add(
158+
KEMException.compilerError(
159+
"syntactic attribute is only supported on simplification rules."));
160+
}
161+
}
162+
154163
private void checkHookedSortConstructors(Production prod) {
155164
if (prod.sort().equals(Sorts.KItem())) {
156165
return;

k-frontend/src/main/scala/org/kframework/attributes/Att.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ object Att {
416416
onlyon3[Module, Production, Rule],
417417
KeyRange.WholePipeline
418418
)
419+
final val SYNTACTIC =
420+
Key.builtin("syntactic", KeyParameter.Required, onlyon[Rule], KeyRange.WholePipeline)
419421
final val TOKEN = Key.builtin(
420422
"token",
421423
KeyParameter.Forbidden,

0 commit comments

Comments
 (0)