Skip to content

Commit 7d24dc6

Browse files
committed
implement the discussion of KaKeY
1 parent d498451 commit 7d24dc6

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

key.core/src/main/java/de/uka/ilkd/key/nparser/builder/DeclarationBuilder.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
import de.uka.ilkd.key.nparser.ParsingFacade;
1919
import de.uka.ilkd.key.rule.RuleSet;
2020

21+
import de.uka.ilkd.key.util.parsing.BuildingIssue;
2122
import org.key_project.util.collection.DefaultImmutableSet;
2223
import org.key_project.util.collection.ImmutableSet;
2324

2425
import org.antlr.v4.runtime.Token;
26+
import org.slf4j.Logger;
27+
import org.slf4j.LoggerFactory;
28+
import recoder.util.Debug;
2529

2630
/**
2731
* This visitor evaluates all basic (level 0) declarations. This includes:
@@ -41,6 +45,7 @@
4145
*/
4246
public class DeclarationBuilder extends DefaultBuilder {
4347
private final Map<String, String> category2Default = new HashMap<>();
48+
private static final Logger LOGGER = LoggerFactory.getLogger(DeclarationBuilder.class);
4449

4550
public DeclarationBuilder(Services services, NamespaceSet nss) {
4651
super(services, nss);
@@ -154,7 +159,11 @@ public Object visitOne_sort_decl(KeYParser.One_sort_declContext ctx) {
154159
sorts().add(s);
155160
createdSorts.add(s);
156161
} else {
157-
addWarning(ctx, "Sort declaration is ignored, due to collision.");
162+
// weigl: agreement on KaKeY meeting: this should be ignored until we finally have local namespaces
163+
// for generic sorts
164+
//addWarning(ctx, "Sort declaration is ignored, due to collision.");
165+
LOGGER.info("Sort declaration is ignored, due to collision in {}",
166+
BuilderHelpers.getPosition(ctx));
158167
}
159168
}
160169
return createdSorts;

key.core/src/main/java/de/uka/ilkd/key/nparser/builder/FunctionPredicateBuilder.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public Object visitPred_decl(KeYParser.Pred_declContext ctx) {
8686
public Object visitFunc_decl(KeYParser.Func_declContext ctx) {
8787
boolean unique = ctx.UNIQUE() != null;
8888
Sort retSort = accept(ctx.sortId());
89-
String func_name = accept(ctx.funcpred_name());
89+
String funcName = accept(ctx.funcpred_name());
9090
List<Boolean[]> whereToBind = accept(ctx.where_to_bind());
9191
List<Sort> argSorts = accept(ctx.arg_sorts());
9292
assert argSorts != null;
@@ -96,11 +96,11 @@ public Object visitFunc_decl(KeYParser.Func_declContext ctx) {
9696
}
9797

9898
Function f = null;
99-
assert func_name != null;
100-
int separatorIndex = func_name.indexOf("::");
99+
assert funcName != null;
100+
int separatorIndex = funcName.indexOf("::");
101101
if (separatorIndex > 0) {
102-
String sortName = func_name.substring(0, separatorIndex);
103-
String baseName = func_name.substring(separatorIndex + 2);
102+
String sortName = funcName.substring(0, separatorIndex);
103+
String baseName = funcName.substring(separatorIndex + 2);
104104
Sort genSort = lookupSort(sortName);
105105
if (genSort instanceof GenericSort) {
106106
f = SortDependingFunction.createFirstInstance((GenericSort) genSort,
@@ -109,14 +109,15 @@ public Object visitFunc_decl(KeYParser.Func_declContext ctx) {
109109
}
110110

111111
if (f == null) {
112-
f = new Function(new Name(func_name), retSort, argSorts.toArray(new Sort[0]),
112+
f = new Function(new Name(funcName), retSort, argSorts.toArray(new Sort[0]),
113113
whereToBind == null ? null : whereToBind.toArray(new Boolean[0]), unique);
114114
}
115115

116116
if (lookup(f.name()) == null) {
117117
functions().add(f);
118118
} else {
119-
addWarning(ctx, "Function '" + func_name + "' is already defined!");
119+
// weigl: agreement on KaKeY meeting: this should be an error.
120+
semanticError(ctx, "Function '" + funcName + "' is already defined!");
120121
}
121122
return f;
122123
}

0 commit comments

Comments
 (0)