Skip to content
Snippets Groups Projects
Commit 68ef3e40 authored by hansen's avatar hansen
Browse files

code refactoring

parent c4567f40
Branches
Tags
No related merge requests found
Showing
with 59 additions and 88 deletions
...@@ -185,8 +185,9 @@ public class BOperation extends BuiltInOPs implements ASTConstants, ...@@ -185,8 +185,9 @@ public class BOperation extends BuiltInOPs implements ASTConstants,
if (node instanceof OpApplNode) { if (node instanceof OpApplNode) {
OpApplNode opApplNode = (OpApplNode) node; OpApplNode opApplNode = (OpApplNode) node;
if (opApplNode.getOperator().getKind() == BuiltInKind) { if (opApplNode.getOperator().getKind() == BuiltInKind) {
switch (getOpCode(opApplNode.getOperator().getName())) {
case OPCODE_eq: { if (OPCODE_eq == getOpCode(opApplNode.getOperator()
.getName())) {
ExprOrOpArgNode arg1 = opApplNode.getArgs()[0]; ExprOrOpArgNode arg1 = opApplNode.getArgs()[0];
try { try {
OpApplNode arg11 = (OpApplNode) arg1; OpApplNode arg11 = (OpApplNode) arg1;
...@@ -204,12 +205,9 @@ public class BOperation extends BuiltInOPs implements ASTConstants, ...@@ -204,12 +205,9 @@ public class BOperation extends BuiltInOPs implements ASTConstants,
} }
} catch (ClassCastException e) { } catch (ClassCastException e) {
} }
}
default:
} }
} }
} }
} }
...@@ -263,7 +261,7 @@ public class BOperation extends BuiltInOPs implements ASTConstants, ...@@ -263,7 +261,7 @@ public class BOperation extends BuiltInOPs implements ASTConstants,
beforeAfterPredicates.add(node); beforeAfterPredicates.add(node);
return; return;
} }
//beforeAfterPredicates.add(node); // beforeAfterPredicates.add(node);
} }
private void evalParams() { private void evalParams() {
......
...@@ -14,7 +14,6 @@ import tla2sany.semantic.Context; ...@@ -14,7 +14,6 @@ import tla2sany.semantic.Context;
import tla2sany.semantic.ExprNode; import tla2sany.semantic.ExprNode;
import tla2sany.semantic.ExprOrOpArgNode; import tla2sany.semantic.ExprOrOpArgNode;
import tla2sany.semantic.FormalParamNode; import tla2sany.semantic.FormalParamNode;
import tla2sany.semantic.InstanceNode;
import tla2sany.semantic.LetInNode; import tla2sany.semantic.LetInNode;
import tla2sany.semantic.ModuleNode; import tla2sany.semantic.ModuleNode;
import tla2sany.semantic.NumeralNode; import tla2sany.semantic.NumeralNode;
......
...@@ -20,7 +20,6 @@ import de.tla2b.global.TranslationGlobals; ...@@ -20,7 +20,6 @@ import de.tla2b.global.TranslationGlobals;
import de.tla2b.translation.BDefinitionsFinder; import de.tla2b.translation.BDefinitionsFinder;
import de.tla2b.translation.OperationsFinder; import de.tla2b.translation.OperationsFinder;
import de.tla2b.translation.UsedDefinitionsFinder; import de.tla2b.translation.UsedDefinitionsFinder;
import de.tla2b.types.IType;
import tla2sany.semantic.ASTConstants; import tla2sany.semantic.ASTConstants;
import tla2sany.semantic.ExprNode; import tla2sany.semantic.ExprNode;
import tla2sany.semantic.ExprOrOpArgNode; import tla2sany.semantic.ExprOrOpArgNode;
...@@ -43,8 +42,7 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants, ...@@ -43,8 +42,7 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants,
private OpDefNode expressionOpdefNode; private OpDefNode expressionOpdefNode;
private Hashtable<String, SymbolNode> namingHashTable = new Hashtable<String, SymbolNode>(); private Hashtable<String, SymbolNode> namingHashTable = new Hashtable<String, SymbolNode>();
private final ModuleNode moduleNode; private final ModuleNode moduleNode;
private ExprNode nextExpr; private ExprNode nextExpr;
...@@ -87,18 +85,16 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants, ...@@ -87,18 +85,16 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants,
return specAnalyser; return specAnalyser;
} }
public static SpecAnalyser createSpecAnalyserForTlaExpression(ModuleNode m) {
public static SpecAnalyser createSpecAnalyserForTlaExpression(ModuleNode m){
SpecAnalyser specAnalyser = new SpecAnalyser(m); SpecAnalyser specAnalyser = new SpecAnalyser(m);
specAnalyser.expressionOpdefNode = m.getOpDefs()[m.getOpDefs().length-1]; specAnalyser.expressionOpdefNode = m.getOpDefs()[m.getOpDefs().length - 1];
specAnalyser.usedDefinitions.add(specAnalyser.expressionOpdefNode); specAnalyser.usedDefinitions.add(specAnalyser.expressionOpdefNode);
specAnalyser.bDefinitionsSet.add(specAnalyser.expressionOpdefNode); specAnalyser.bDefinitionsSet.add(specAnalyser.expressionOpdefNode);
return specAnalyser; return specAnalyser;
} }
public static SpecAnalyser createSpecAnalyser(ModuleNode m) { public static SpecAnalyser createSpecAnalyser(ModuleNode m) {
SpecAnalyser specAnalyser = new SpecAnalyser(m); SpecAnalyser specAnalyser = new SpecAnalyser(m);
Hashtable<String, OpDefNode> definitions = new Hashtable<String, OpDefNode>(); Hashtable<String, OpDefNode> definitions = new Hashtable<String, OpDefNode>();
...@@ -109,7 +105,7 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants, ...@@ -109,7 +105,7 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants,
specAnalyser.spec = definitions.get("Spec"); specAnalyser.spec = definitions.get("Spec");
specAnalyser.init = definitions.get("Init"); specAnalyser.init = definitions.get("Init");
specAnalyser.next = definitions.get("Next"); specAnalyser.next = definitions.get("Next");
if(definitions.containsKey("Inv")){ if (definitions.containsKey("Inv")) {
specAnalyser.invariants.add(definitions.get("Inv")); specAnalyser.invariants.add(definitions.get("Inv"));
} }
// TODO are constant in the right order // TODO are constant in the right order
...@@ -132,27 +128,27 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants, ...@@ -132,27 +128,27 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants,
for (OpDefNode inv : new ArrayList<OpDefNode>(invariants)) { for (OpDefNode inv : new ArrayList<OpDefNode>(invariants)) {
try { try {
OpApplNode opApplNode = (OpApplNode) inv.getBody(); OpApplNode opApplNode = (OpApplNode) inv.getBody();
OpDefNode opDefNode = (OpDefNode) opApplNode.getOperator(); OpDefNode opDefNode = (OpDefNode) opApplNode.getOperator();
if (opDefNode.getKind() == UserDefinedOpKind && !BBuiltInOPs.contains(opDefNode.getName())){ if (opDefNode.getKind() == UserDefinedOpKind
&& !BBuiltInOPs.contains(opDefNode.getName())) {
int i = invariants.indexOf(inv); int i = invariants.indexOf(inv);
invariants.set(i, opDefNode); invariants.set(i, opDefNode);
} }
} catch (ClassCastException e) { } catch (ClassCastException e) {
} }
} }
OperationsFinder operationsFinder = new OperationsFinder(this); OperationsFinder operationsFinder = new OperationsFinder(this);
bOperations = operationsFinder.getBOperations(); bOperations = operationsFinder.getBOperations();
UsedDefinitionsFinder definitionFinder = new UsedDefinitionsFinder(this); UsedDefinitionsFinder definitionFinder = new UsedDefinitionsFinder(this);
this.usedDefinitions = definitionFinder.getUsedDefinitions(); this.usedDefinitions = definitionFinder.getUsedDefinitions();
BDefinitionsFinder bDefinitionFinder = new BDefinitionsFinder(this); BDefinitionsFinder bDefinitionFinder = new BDefinitionsFinder(this);
this.bDefinitionsSet = bDefinitionFinder.getBDefinitionsSet(); this.bDefinitionsSet = bDefinitionFinder.getBDefinitionsSet();
//usedDefinitions.addAll(bDefinitionsSet); // usedDefinitions.addAll(bDefinitionsSet);
// test whether there is a init predicate if there is a variable // test whether there is a init predicate if there is a variable
if (moduleNode.getVariableDecls().length > 0 && inits == null) { if (moduleNode.getVariableDecls().length > 0 && inits == null) {
...@@ -170,9 +166,7 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants, ...@@ -170,9 +166,7 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants,
} }
} }
findRecursiveConstructs(); findRecursiveConstructs();
for (OpDeclNode var : moduleNode.getVariableDecls()) { for (OpDeclNode var : moduleNode.getVariableDecls()) {
namingHashTable.put(var.getName().toString(), var); namingHashTable.put(var.getName().toString(), var);
} }
...@@ -182,7 +176,7 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants, ...@@ -182,7 +176,7 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants,
for (OpDefNode def : usedDefinitions) { for (OpDefNode def : usedDefinitions) {
namingHashTable.put(def.getName().toString(), def); namingHashTable.put(def.getName().toString(), def);
} }
} }
private void evalInit() { private void evalInit() {
...@@ -263,12 +257,12 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants, ...@@ -263,12 +257,12 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants,
Set<OpDefNode> set = new HashSet<OpDefNode>(usedDefinitions); Set<OpDefNode> set = new HashSet<OpDefNode>(usedDefinitions);
for (OpDefNode def : set) { for (OpDefNode def : set) {
if (def.getInRecursive()) { if (def.getInRecursive()) {
throw new NotImplementedException("Recursive definitions are currently not supported."); throw new NotImplementedException(
// bDefinitionsSet.remove(def); "Recursive definitions are currently not supported.");
// RecursiveDefinition rd = new RecursiveDefinition(def); // bDefinitionsSet.remove(def);
// recursiveDefinitions.add(rd); // RecursiveDefinition rd = new RecursiveDefinition(def);
} else // recursiveDefinitions.add(rd);
if (def.getBody() instanceof OpApplNode) { } else if (def.getBody() instanceof OpApplNode) {
OpApplNode o = (OpApplNode) def.getBody(); OpApplNode o = (OpApplNode) def.getBody();
switch (getOpCode(o.getOperator().getName())) { switch (getOpCode(o.getOperator().getName())) {
case OPCODE_rfs: { // recursive Function case OPCODE_rfs: { // recursive Function
...@@ -297,7 +291,7 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants, ...@@ -297,7 +291,7 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants,
} }
public Hashtable<OpDefNode, FormalParamNode[]> getLetParams() { public Hashtable<OpDefNode, FormalParamNode[]> getLetParams() {
return letParams; return new Hashtable<OpDefNode, FormalParamNode[]>(letParams);
} }
public ArrayList<String> getDefinitionMacros() { public ArrayList<String> getDefinitionMacros() {
...@@ -320,24 +314,24 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants, ...@@ -320,24 +314,24 @@ public class SpecAnalyser extends BuiltInOPs implements ASTConstants,
return this.moduleNode; return this.moduleNode;
} }
public ConfigfileEvaluator getConfigFileEvaluator(){ public ConfigfileEvaluator getConfigFileEvaluator() {
return configFileEvaluator; return configFileEvaluator;
} }
public ArrayList<OpDefNode> getInvariants(){ public ArrayList<OpDefNode> getInvariants() {
return invariants; return invariants;
} }
public OpDefNode getInitDef(){ public OpDefNode getInitDef() {
return init; return init;
} }
public OpDefNode getExpressionOpdefNode(){ public OpDefNode getExpressionOpdefNode() {
return expressionOpdefNode; return expressionOpdefNode;
} }
public SymbolNode getSymbolNodeByName(String name){ public SymbolNode getSymbolNodeByName(String name) {
return namingHashTable.get(name); return namingHashTable.get(name);
} }
} }
...@@ -45,7 +45,7 @@ import tlc2.tool.BuiltInOPs; ...@@ -45,7 +45,7 @@ import tlc2.tool.BuiltInOPs;
public class TypeChecker extends BuiltInOPs implements ASTConstants, BBuildIns, public class TypeChecker extends BuiltInOPs implements ASTConstants, BBuildIns,
TranslationGlobals { TranslationGlobals {
private final int TEMP_TYPE_ID = 6; private static final int TEMP_TYPE_ID = 6;
private int paramId; private int paramId;
private ArrayList<ExprNode> inits; private ArrayList<ExprNode> inits;
...@@ -461,14 +461,15 @@ public class TypeChecker extends BuiltInOPs implements ASTConstants, BBuildIns, ...@@ -461,14 +461,15 @@ public class TypeChecker extends BuiltInOPs implements ASTConstants, BBuildIns,
} }
TLAType found = ((TLAType) def.getToolObject(TYPE_ID)); TLAType found = ((TLAType) def.getToolObject(TYPE_ID));
if (found == null){ if (found == null) {
found = new UntypedType(); found = new UntypedType();
// throw new RuntimeException(def.getName() + " has no type yet!"); // throw new RuntimeException(def.getName() +
// " has no type yet!");
} }
if(n.getArgs().length != 0){ if (n.getArgs().length != 0) {
found = found.cloneTLAType(); found = found.cloneTLAType();
} }
try { try {
found = found.unify(expected); found = found.unify(expected);
} catch (UnificationException e) { } catch (UnificationException e) {
......
...@@ -13,14 +13,12 @@ import de.be4.classicalb.core.parser.node.AConjunctPredicate; ...@@ -13,14 +13,12 @@ import de.be4.classicalb.core.parser.node.AConjunctPredicate;
import de.be4.classicalb.core.parser.node.ADefinitionExpression; import de.be4.classicalb.core.parser.node.ADefinitionExpression;
import de.be4.classicalb.core.parser.node.ADefinitionPredicate; import de.be4.classicalb.core.parser.node.ADefinitionPredicate;
import de.be4.classicalb.core.parser.node.AExpressionDefinitionDefinition; import de.be4.classicalb.core.parser.node.AExpressionDefinitionDefinition;
import de.be4.classicalb.core.parser.node.AFirstProjectionExpression;
import de.be4.classicalb.core.parser.node.AGeneralSumExpression; import de.be4.classicalb.core.parser.node.AGeneralSumExpression;
import de.be4.classicalb.core.parser.node.AIdentifierExpression; import de.be4.classicalb.core.parser.node.AIdentifierExpression;
import de.be4.classicalb.core.parser.node.ALambdaExpression; import de.be4.classicalb.core.parser.node.ALambdaExpression;
import de.be4.classicalb.core.parser.node.AOperation; import de.be4.classicalb.core.parser.node.AOperation;
import de.be4.classicalb.core.parser.node.AOperationsMachineClause; import de.be4.classicalb.core.parser.node.AOperationsMachineClause;
import de.be4.classicalb.core.parser.node.APredicateDefinitionDefinition; import de.be4.classicalb.core.parser.node.APredicateDefinitionDefinition;
import de.be4.classicalb.core.parser.node.ASecondProjectionExpression;
import de.be4.classicalb.core.parser.node.ASelectSubstitution; import de.be4.classicalb.core.parser.node.ASelectSubstitution;
import de.be4.classicalb.core.parser.node.Node; import de.be4.classicalb.core.parser.node.Node;
import de.be4.classicalb.core.parser.node.PExpression; import de.be4.classicalb.core.parser.node.PExpression;
......
...@@ -12,7 +12,6 @@ import de.tla2b.analysis.AbstractASTVisitor; ...@@ -12,7 +12,6 @@ import de.tla2b.analysis.AbstractASTVisitor;
import de.tla2b.analysis.BOperation; import de.tla2b.analysis.BOperation;
import de.tla2b.analysis.SpecAnalyser; import de.tla2b.analysis.SpecAnalyser;
import de.tla2b.global.TranslationGlobals; import de.tla2b.global.TranslationGlobals;
import de.tla2b.types.IType;
public class BDefinitionsFinder extends AbstractASTVisitor implements public class BDefinitionsFinder extends AbstractASTVisitor implements
ASTConstants, ToolGlobals, TranslationGlobals { ASTConstants, ToolGlobals, TranslationGlobals {
......
...@@ -2,8 +2,6 @@ package de.tla2b.types; ...@@ -2,8 +2,6 @@ package de.tla2b.types;
import de.be4.classicalb.core.parser.node.PExpression; import de.be4.classicalb.core.parser.node.PExpression;
import de.tla2b.exceptions.UnificationException; import de.tla2b.exceptions.UnificationException;
import de.tla2b.output.TypeVisitorInterface;
public abstract class TLAType implements IType { public abstract class TLAType implements IType {
private int kind; private int kind;
......
...@@ -204,7 +204,7 @@ public class TupleOrFunction extends AbstractHasFollowers { ...@@ -204,7 +204,7 @@ public class TupleOrFunction extends AbstractHasFollowers {
public TLAType cloneTLAType() { public TLAType cloneTLAType() {
TupleOrFunction res = new TupleOrFunction(); TupleOrFunction res = new TupleOrFunction();
for (Entry<Integer, TLAType> entry : this.types.entrySet()) { for (Entry<Integer, TLAType> entry : this.types.entrySet()) {
res.types.put(new Integer(entry.getKey().intValue()), entry res.types.put(Integer.valueOf(entry.getKey().intValue()), entry
.getValue().cloneTLAType()); .getValue().cloneTLAType());
} }
return res; return res;
...@@ -390,14 +390,4 @@ public class TupleOrFunction extends AbstractHasFollowers { ...@@ -390,14 +390,4 @@ public class TupleOrFunction extends AbstractHasFollowers {
} }
return true; return true;
} }
private static boolean allTyped(List<TLAType> typeList) {
for (int i = 0; i < typeList.size(); i++) {
if (typeList.get(i).isUntyped()) {
return false;
}
}
return true;
}
} }
...@@ -94,7 +94,6 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals, ...@@ -94,7 +94,6 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals,
ExprNode expr = moduleNode.getOpDefs()[moduleNode.getOpDefs().length - 1] ExprNode expr = moduleNode.getOpDefs()[moduleNode.getOpDefs().length - 1]
.getBody(); .getBody();
System.out.println(expressionIsAPredicate(expr));
if (expressionIsAPredicate(expr)) { if (expressionIsAPredicate(expr)) {
APredicateParseUnit predicateParseUnit = new APredicateParseUnit(); APredicateParseUnit predicateParseUnit = new APredicateParseUnit();
predicateParseUnit.setPredicate(visitExprNodePredicate(expr)); predicateParseUnit.setPredicate(visitExprNodePredicate(expr));
...@@ -832,7 +831,7 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals, ...@@ -832,7 +831,7 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals,
switch (n.getOperator().getKind()) { switch (n.getOperator().getKind()) {
case VariableDeclKind: case VariableDeclKind:
case ConstantDeclKind: case ConstantDeclKind:
case FormalParamKind: { // TODO case FormalParamKind: {
return new AEqualPredicate(createIdentifierNode(n.getOperator()), return new AEqualPredicate(createIdentifierNode(n.getOperator()),
new ABooleanTrueExpression()); new ABooleanTrueExpression());
} }
...@@ -1503,7 +1502,6 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals, ...@@ -1503,7 +1502,6 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals,
case OPCODE_fc: // Represents [x \in S |-> e]. case OPCODE_fc: // Represents [x \in S |-> e].
case OPCODE_rfs: { case OPCODE_rfs: {
FormalParamNode[][] params = n.getBdedQuantSymbolLists(); FormalParamNode[][] params = n.getBdedQuantSymbolLists();
// ExprNode[] bounds = n.getBdedQuantBounds(); TODO
List<PExpression> idList = new ArrayList<PExpression>(); List<PExpression> idList = new ArrayList<PExpression>();
for (int i = 0; i < params.length; i++) { for (int i = 0; i < params.length; i++) {
for (int j = 0; j < params[i].length; j++) { for (int j = 0; j < params[i].length; j++) {
...@@ -1511,9 +1509,7 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals, ...@@ -1511,9 +1509,7 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals,
idList.add(createIdentifierNode(p)); idList.add(createIdentifierNode(p));
} }
} }
boolean[] isTuple = n.isBdedQuantATuple(); boolean[] isTuple = n.isBdedQuantATuple();
ALambdaExpression lambda = new ALambdaExpression(); ALambdaExpression lambda = new ALambdaExpression();
List<PExpression> idList2 = new ArrayList<PExpression>(); List<PExpression> idList2 = new ArrayList<PExpression>();
for (int i = 0; i < params.length; i++) { for (int i = 0; i < params.length; i++) {
...@@ -2137,12 +2133,6 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals, ...@@ -2137,12 +2133,6 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals,
return list; return list;
} }
private List<PExpression> createIdentifierList(SymbolNode symbolNode) {
ArrayList<PExpression> list = new ArrayList<PExpression>();
list.add(createIdentifierNode(getName(symbolNode)));
return list;
}
private PPredicate visitBuiltInKindPredicate(OpApplNode n) { private PPredicate visitBuiltInKindPredicate(OpApplNode n) {
switch (getOpCode(n.getOperator().getName())) { switch (getOpCode(n.getOperator().getName())) {
case OPCODE_land: // \land case OPCODE_land: // \land
......
...@@ -137,7 +137,6 @@ public class ExpressionTranslator implements SyntaxTreeConstants { ...@@ -137,7 +137,6 @@ public class ExpressionTranslator implements SyntaxTreeConstants {
+ "\n" + expr + "\n"; + "\n" + expr + "\n";
throw new ExpressionTranslationException(message); throw new ExpressionTranslationException(message);
} }
SymbolRenamer symRenamer = new SymbolRenamer(moduleNode, specAnalyser); SymbolRenamer symRenamer = new SymbolRenamer(moduleNode, specAnalyser);
symRenamer.start(); symRenamer.start();
BAstCreator bASTCreator = new BAstCreator(moduleNode, specAnalyser); BAstCreator bASTCreator = new BAstCreator(moduleNode, specAnalyser);
......
...@@ -7,11 +7,12 @@ import org.junit.Test; ...@@ -7,11 +7,12 @@ import org.junit.Test;
import de.tla2b.exceptions.TypeErrorException; import de.tla2b.exceptions.TypeErrorException;
public class ModuleAndExpressionTest { public class ModuleAndExpressionTest {
@Test @Test
public void testCon() throws Exception { public void testCon() throws Exception {
String module = "---- MODULE Testing ----\n" + "CONSTANTS k \n" String module = "---- MODULE Testing ----\n" + "CONSTANTS k \n"
+ "ASSUME k = 4" + "==============="; + "ASSUME k = 4" + "===============";
compareExprIncludingModel("bool(k = 1)", "k = 1", module); compareExprIncludingModel("k = 1", "k = 1", module);
} }
@Test(expected = TypeErrorException.class) @Test(expected = TypeErrorException.class)
......
...@@ -10,7 +10,6 @@ import de.tla2b.exceptions.FrontEndException; ...@@ -10,7 +10,6 @@ import de.tla2b.exceptions.FrontEndException;
import de.tla2b.exceptions.TLA2BException; import de.tla2b.exceptions.TLA2BException;
import de.tla2b.global.TranslationGlobals; import de.tla2b.global.TranslationGlobals;
import de.tla2b.types.TLAType; import de.tla2b.types.TLAType;
import de.tla2b.types.TupleOrFunction;
import de.tla2bAst.Translator; import de.tla2bAst.Translator;
import tla2sany.semantic.FormalParamNode; import tla2sany.semantic.FormalParamNode;
import tla2sany.semantic.ModuleNode; import tla2sany.semantic.ModuleNode;
......
...@@ -64,7 +64,7 @@ public class TestUtil { ...@@ -64,7 +64,7 @@ public class TestUtil {
Renamer renamer = new Renamer(resultNode); Renamer renamer = new Renamer(resultNode);
ASTPrettyPrinter aP = new ASTPrettyPrinter(resultNode, renamer); ASTPrettyPrinter aP = new ASTPrettyPrinter(resultNode, renamer);
resultNode.apply(aP); resultNode.apply(aP);
System.out.println(aP.getResultString()); //System.out.println(aP.getResultString());
String bAstString = getAstStringofBExpressionString(bExpr); String bAstString = getAstStringofBExpressionString(bExpr);
String result = getAstStringofBExpressionString(aP.getResultString()); String result = getAstStringofBExpressionString(aP.getResultString());
// String tlaAstString = getTreeAsString(resultNode); // String tlaAstString = getTreeAsString(resultNode);
...@@ -72,11 +72,16 @@ public class TestUtil { ...@@ -72,11 +72,16 @@ public class TestUtil {
} }
public static void compareExprIncludingModel(String bExpr, String tlaExpr, public static void compareExprIncludingModel(String bExpr, String tlaExpr,
String moduleString) throws TLA2BException { String moduleString) throws TLA2BException, BException {
Translator trans = new Translator(moduleString, null); Translator trans = new Translator(moduleString, null);
trans.translate(); trans.translate();
Start result = trans.translateExpression(tlaExpr); Start resultNode = trans.translateExpression(tlaExpr);
// TODO Renamer renamer = new Renamer(resultNode);
ASTPrettyPrinter aP = new ASTPrettyPrinter(resultNode, renamer);
resultNode.apply(aP);
String bAstString = getAstStringofBExpressionString(bExpr);
String result = getAstStringofBExpressionString(aP.getResultString());
assertEquals(bAstString, result);
} }
public static void compare(String bMachine, String tlaModule) public static void compare(String bMachine, String tlaModule)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment