Skip to content

Commit 88c07fb

Browse files
authored
Fix field names in Isabelle translation (#3795)
2 parents 1031e0f + 7ec539f commit 88c07fb

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

keyext.isabelletranslation/src/main/java/org/key_project/isabelletranslation/translation/FieldHandler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.regex.Pattern;
1313

1414
import de.uka.ilkd.key.java.Services;
15+
import de.uka.ilkd.key.logic.JavaDLFieldNames;
1516

1617
import org.key_project.logic.Name;
1718
import org.key_project.logic.Namespace;
@@ -58,8 +59,11 @@ public boolean canHandle(Operator op) {
5859
public StringBuilder handle(IsabelleMasterHandler trans, Term term) {
5960
if (trans.isNewSymbol(term)) {
6061
Operator op = term.op();
61-
Matcher m = Pattern.compile("<(.*?)>").matcher(op.name().toString());
62-
String fieldName = op.name().toString().replace("::$", "_").replace(".", "_");
62+
Matcher m =
63+
Pattern.compile(Pattern.quote("" + JavaDLFieldNames.IMPLICIT_NAME_PREFIX) + "(.*?)")
64+
.matcher(op.name().toString());
65+
String fieldName = op.name().toString()
66+
.replace(JavaDLFieldNames.IMPLICIT_FIELD_INFIX, "_").replace(".", "_");
6367
if (m.find()) {
6468
fieldName = m.group(1);
6569
}

keyext.isabelletranslation/src/main/java/org/key_project/isabelletranslation/translation/ObserverFunctionHandler.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.regex.Pattern;
1010

1111
import de.uka.ilkd.key.java.Services;
12+
import de.uka.ilkd.key.logic.JavaDLFieldNames;
1213
import de.uka.ilkd.key.logic.op.ObserverFunction;
1314

1415
import org.key_project.logic.Term;
@@ -33,16 +34,23 @@ public boolean canHandle(Operator op) {
3334
@Override
3435
public StringBuilder handle(IsabelleMasterHandler trans, Term term) {
3536
if (trans.isNewSymbol(term)) {
36-
Operator op = term.op();
37-
Matcher m = Pattern.compile("<(.*?)>").matcher(op.name().toString());
37+
String opName = term.op().name().toString();
38+
Matcher m = Pattern
39+
.compile(Pattern.quote("" + JavaDLFieldNames.IMPLICIT_NAME_PREFIX) + "(.*?)")
40+
.matcher(opName);
3841
String functionName;
3942
if (m.find()) {
4043
functionName =
41-
op.name().toString().replace("<" + m.group(1) + ">", "_" + m.group(1))
42-
.replace("::", "_").replace("$", "").replace(".", "_");
44+
opName.replace(JavaDLFieldNames.IMPLICIT_NAME_PREFIX + m.group(1),
45+
"_" + m.group(1))
46+
.replace(JavaDLFieldNames.SEPARATOR, "_")
47+
.replace(JavaDLFieldNames.IMPLICIT_NAME_PREFIX + "", "")
48+
.replace(".", "_");
4349
} else {
4450
functionName =
45-
op.name().toString().replace("::", "_").replace("$", "").replace(".", "_");
51+
opName.replace(JavaDLFieldNames.SEPARATOR, "_")
52+
.replace(JavaDLFieldNames.FIELD_PREFIX + "", "")
53+
.replace(".", "_");
4654
}
4755
trans.addSymbolAndDeclaration(term, new StringBuilder(functionName));
4856
}

0 commit comments

Comments
 (0)