Skip to content

Commit 3719adb

Browse files
committedFeb 20, 2024·
Refactor allowed syntax checks for attributes
1 parent 845bca1 commit 3719adb

File tree

2 files changed

+200
-127
lines changed
  • kernel/src/main/java/org/kframework/compile/checks
  • kore/src/main/scala/org/kframework/attributes

2 files changed

+200
-127
lines changed
 

‎kernel/src/main/java/org/kframework/compile/checks/CheckAtt.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,16 @@ private <T extends HasAtt & HasLocation> void checkUnrecognizedAtts(T term) {
8484
}
8585

8686
private <T extends HasAtt & HasLocation> void checkRestrictedAtts(T term) {
87-
Class<?> cls = term.getClass();
88-
Att att = term.att();
89-
Set<Key> keys = stream(att.att().keySet()).map(Tuple2::_1).collect(Collectors.toSet());
90-
keys.removeIf(k -> k.allowedSentences().exists(c -> c.isAssignableFrom(cls)));
91-
if (!keys.isEmpty()) {
92-
List<String> sortedKeys = keys.stream().map(Key::toString).sorted().toList();
87+
Set<Key> badKeys =
88+
stream(term.att().att().keySet())
89+
.map(Tuple2::_1)
90+
.filter(k -> k.visibility().isPermitted(term))
91+
.collect(Collectors.toSet());
92+
if (!badKeys.isEmpty()) {
93+
List<String> sortedKeys = badKeys.stream().map(Key::toString).sorted().toList();
9394
errors.add(
9495
KEMException.compilerError(
95-
cls.getSimpleName() + " cannot have the following attributes: " + sortedKeys, term));
96+
"The following attributes are not permitted here: " + sortedKeys, term));
9697
}
9798
}
9899

0 commit comments

Comments
 (0)
Please sign in to comment.