diff --git a/AlgebraicDataflowArchitectureModel/models/CustomerOffice.model b/AlgebraicDataflowArchitectureModel/models/CustomerOffice.model deleted file mode 100644 index dced55e..0000000 --- a/AlgebraicDataflowArchitectureModel/models/CustomerOffice.model +++ /dev/null @@ -1,33 +0,0 @@ -channel C_CustomerAOff_In { - out customerA_off(c:String, setOff(x)) = x - out customerA_off(c, e) = c -} - -channel C_CustomerBOff_In { - out customerB_off(c:String, setOff(x)) = x - out customerB_off(c, e) = c -} - -channel C_CompanyC1Add_In { - out companyC1_add(a:String, setAdd(y)) = y - out companyC1_add(a, e) = a -} - -channel C_CompanyC2Add_In { - out companyC2_add(a:String, setAdd(y)) = y - out companyC2_add(a, e) = a -} - -channel CA { - in customerA_off(c, sync(z, u, v)) = z - in companyC1_add(a1, sync(z, u, v)) = u - in companyC2_add(a2, sync(z, u, v)) = v - out customerA_add(a3:String, sync(z, u, v)) = if(z == C1, u, if(z == C2, v, null)) -} - -channel CB { - in customerB_off(c, sync(z, u, v)) = z - in companyC1_add(a1, sync(z, u, v)) = u - in companyC2_add(a2, sync(z, u, v)) = v - out customerB_add(a3:String, sync(z, u, v)) = if(z == C1, u, if(z == C2, v, null)) -} diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/DataTransferModelingCellEditor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/DataTransferModelingCellEditor.java index b4d81a6..1fe7ae7 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/DataTransferModelingCellEditor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/DataTransferModelingCellEditor.java @@ -30,6 +30,7 @@ import models.visualModel.FormulaChannel; import parser.Parser; import parser.Parser.TokenStream; +import parser.exceptions.ExpectedDoubleQuotation; import parser.exceptions.ExpectedRightBracket; public class DataTransferModelingCellEditor implements mxICellEditor { @@ -123,7 +124,7 @@ Expression exp = parser.parseTerm(stream, editor.getModel()); ((FormulaChannel) ch).setFormula(formula); ((FormulaChannel) ch).setFormulaTerm(exp); - } catch (ExpectedRightBracket e) { + } catch (ExpectedRightBracket | ExpectedDoubleQuotation e) { e.printStackTrace(); } } diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java index b285ce0..0fc9a85 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java @@ -50,6 +50,7 @@ import parser.exceptions.ExpectedAssignment; import parser.exceptions.ExpectedChannel; import parser.exceptions.ExpectedChannelName; +import parser.exceptions.ExpectedDoubleQuotation; import parser.exceptions.ExpectedEquals; import parser.exceptions.ExpectedFormulaChannel; import parser.exceptions.ExpectedGeometry; @@ -185,7 +186,7 @@ return model; } catch (ExpectedChannel | ExpectedChannelName | ExpectedLeftCurlyBracket | ExpectedInOrOutOrRefKeyword | ExpectedStateTransition | ExpectedEquals | ExpectedRHSExpression | WrongLHSExpression - | WrongRHSExpression | ExpectedRightBracket | ExpectedAssignment | ExpectedModel | ExpectedGeometry | ExpectedNode | ExpectedResource | ExpectedFormulaChannel | ExpectedIoChannel e) { + | WrongRHSExpression | ExpectedRightBracket | ExpectedAssignment | ExpectedModel | ExpectedGeometry | ExpectedNode | ExpectedResource | ExpectedFormulaChannel | ExpectedIoChannel | ExpectedDoubleQuotation e) { e.printStackTrace(); } } @@ -218,7 +219,7 @@ return model; } catch (ExpectedChannel | ExpectedChannelName | ExpectedLeftCurlyBracket | ExpectedInOrOutOrRefKeyword | ExpectedStateTransition | ExpectedEquals | ExpectedRHSExpression | WrongLHSExpression - | WrongRHSExpression | ExpectedRightBracket | ExpectedAssignment e) { + | WrongRHSExpression | ExpectedRightBracket | ExpectedAssignment | ExpectedDoubleQuotation e) { e.printStackTrace(); } } catch (FileNotFoundException e) { @@ -649,7 +650,7 @@ resetDataFlowGraph(); } catch (ExpectedRightBracket | ExpectedChannel | ExpectedChannelName | ExpectedLeftCurlyBracket | ExpectedInOrOutOrRefKeyword | ExpectedStateTransition | ExpectedEquals | ExpectedRHSExpression - | WrongLHSExpression | WrongRHSExpression | ExpectedAssignment e) { + | WrongLHSExpression | WrongRHSExpression | ExpectedAssignment | ExpectedDoubleQuotation e) { e.printStackTrace(); } } diff --git a/AlgebraicDataflowArchitectureModel/src/models/algebra/Constant.java b/AlgebraicDataflowArchitectureModel/src/models/algebra/Constant.java index 5f533a7..50207b6 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/algebra/Constant.java +++ b/AlgebraicDataflowArchitectureModel/src/models/algebra/Constant.java @@ -9,7 +9,7 @@ } public Constant(String value, Type type) { - super(new Symbol(value, 0), new ArrayList()); + super(new Symbol((type == null ? value: type.valueToRepresentation(value)), 0), new ArrayList()); symbol.setSignature(new Type[] {type}); } @@ -34,6 +34,13 @@ return symbol.getName(); } + public Object getValue() { + if (getType() != null) { + return getType().representationToValue(symbol.getName()); + } + return symbol.getName(); + } + public String toImplementation(String[] sideEffects) { if (symbol.isImplGenerative()) { String exp = symbol.generate(getType(), new Type[] {}, new String[] {}, new String[] {}, sideEffects); diff --git a/AlgebraicDataflowArchitectureModel/src/models/algebra/Type.java b/AlgebraicDataflowArchitectureModel/src/models/algebra/Type.java index 50b0285..b888df9 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/algebra/Type.java +++ b/AlgebraicDataflowArchitectureModel/src/models/algebra/Type.java @@ -80,6 +80,15 @@ return false; } + public String valueToRepresentation(Object value) { + if (value instanceof String) return (String) value; + return value.toString(); + } + + public Object representationToValue(String representation) { + return representation; + } + public Memento createMemento() { return new Memento(implementationTypeName, interfaceTypeName, parentTypes); } diff --git a/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/DataConstraintModel.java b/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/DataConstraintModel.java index c2ce3fd..612e37f 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/DataConstraintModel.java +++ b/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/DataConstraintModel.java @@ -1,486 +1,511 @@ -package models.dataConstraintModel; - -import java.util.Collection; -import java.util.HashMap; - -import models.algebra.Expression; -import models.algebra.LambdaAbstraction; -import models.algebra.Symbol; -import models.algebra.Term; -import models.algebra.Type; -import models.algebra.Variable; -import parser.Parser; - -public class DataConstraintModel { - protected HashMap resourcePaths = null; - protected HashMap channels = null; - protected HashMap ioChannels = null; - protected HashMap types = null; - protected HashMap symbols = null; - public static final Type typeInt = new Type("Int", "int"); - public static final Type typeLong = new Type("Long", "long", typeInt); - public static final Type typeFloat = new Type("Float", "float", typeInt); - public static final Type typeDouble = new Type("Double", "double", typeFloat); - public static final Type typeBoolean = new Type("Bool", "boolean"); - public static final Type typeString = new Type("Str", "String"); - public static final Type typeList = new Type("List", "ArrayList", "List"); - public static final Type typeListInt = new Type("List", "ArrayList<>", "List", typeList); - public static final Type typeListStr = new Type("List", "ArrayList<>", "List", typeList); - public static final Type typeTuple = new Type("Tuple", "AbstractMap.SimpleEntry", "Map.Entry"); - public static final Type typePair = new Type("Pair", "Pair", "Pair"); - public static final Type typePairInt = new Type("Pair", "Pair", "Pair", typePair); - public static final Type typePairStr = new Type("Pair", "Pair", "Pair", typePair); - public static final Type typePairDouble = new Type("Pair", "Pair", "Pair", typePair); - public static final Type typeMap = new Type("Map", "HashMap", "Map"); - public static final Symbol add = new Symbol(Parser.ADD, 2, Symbol.Type.INFIX); - public static final Symbol mul = new Symbol(Parser.MUL, 2, Symbol.Type.INFIX);; - public static final Symbol sub = new Symbol(Parser.SUB, 2, Symbol.Type.INFIX); - public static final Symbol div = new Symbol(Parser.DIV, 2, Symbol.Type.INFIX); - public static final Symbol minus = new Symbol(Parser.MINUS, 1); - public static final Symbol mod = new Symbol(Parser.MOD, 2, Symbol.Type.INFIX, "%", Symbol.Type.INFIX); - public static final Symbol eq = new Symbol(Parser.EQ, 2, Symbol.Type.INFIX, "==", Symbol.Type.INFIX); - public static final Symbol neq = new Symbol(Parser.NEQ, 2, Symbol.Type.INFIX, "!=", Symbol.Type.INFIX); - public static final Symbol gt = new Symbol(Parser.GT, 2, Symbol.Type.INFIX, ">", Symbol.Type.INFIX); - public static final Symbol lt = new Symbol(Parser.LT, 2, Symbol.Type.INFIX, "<", Symbol.Type.INFIX); - public static final Symbol ge = new Symbol(Parser.GE, 2, Symbol.Type.INFIX, ">=", Symbol.Type.INFIX); - public static final Symbol le = new Symbol(Parser.LE, 2, Symbol.Type.INFIX, "<=", Symbol.Type.INFIX); - public static final Symbol and = new Symbol(Parser.AND, 2, Symbol.Type.INFIX, "&&", Symbol.Type.INFIX); - public static final Symbol or = new Symbol(Parser.OR, 2, Symbol.Type.INFIX, "||", Symbol.Type.INFIX); - public static final Symbol neg = new Symbol(Parser.NEG, 1, Symbol.Type.INFIX, "!", Symbol.Type.PREFIX); - public static final Symbol cons = new Symbol("cons", 2, Symbol.Type.PREFIX, "($x,$y)->$x.add(0, $y)", Symbol.Type.LAMBDA_WITH_SIDE_EFFECT, new int[] {1, 0}); - public static final Symbol append = new Symbol("append", 2, Symbol.Type.PREFIX, "add", Symbol.Type.METHOD_WITH_SIDE_EFFECT); - public static final Symbol remove = new Symbol("remove", 2, Symbol.Type.PREFIX, "remove", Symbol.Type.METHOD_WITH_SIDE_EFFECT); - public static final Symbol head = new Symbol("head", 1, Symbol.Type.PREFIX, "($x)->$x.get(0)", Symbol.Type.LAMBDA); - public static final Symbol tail = new Symbol("tail", 1, Symbol.Type.PREFIX, "($x)->$x.subList(1, $x.size())", Symbol.Type.LAMBDA); - public static final Symbol length = new Symbol("length", 1, Symbol.Type.PREFIX, "($x)->$x.size()", Symbol.Type.LAMBDA); - public static final Symbol get = new Symbol("get", 2, Symbol.Type.PREFIX, "get", Symbol.Type.METHOD); - public static final Symbol set = new Symbol("set", 3, Symbol.Type.PREFIX, "set", Symbol.Type.METHOD_WITH_SIDE_EFFECT); - public static final Symbol contains = new Symbol("contains", 2, Symbol.Type.PREFIX, new Symbol.IImplGenerator() { - @Override - public String generate(Type type, Type[] childrenTypes, String[] childrenImpl, String[] childrenSideEffects, String[] sideEffect) { - for (String s: childrenSideEffects) { - sideEffect[0] += s; - } - if (childrenTypes[0] != null && typeMap.isAncestorOf(childrenTypes[0])) { - return childrenImpl[0] + "." + "containsKey(" + childrenImpl[1] + ")"; - } - return childrenImpl[0] + "." + "contains(" + childrenImpl[1] + ")"; - } - }); - public static final Symbol nil = new Symbol("nil", 0, Symbol.Type.PREFIX, new Symbol.IImplGenerator() { - @Override - public String generate(Type type, Type[] childrenTypes, String[] childrenImpl, String[] childrenSideEffects, String[] sideEffect) { - String compType = ""; - if (type != null) { - String temp = "temp_nil"; - String interfaceType = type.getInterfaceTypeName(); - if (interfaceType.contains("<")) { - compType = interfaceType.substring(interfaceType.indexOf("<") + 1, interfaceType.lastIndexOf(">")); - } - String implType = type.getImplementationTypeName(); - if (implType.indexOf('<') >= 0) { - implType = implType.substring(0, implType.indexOf('<')); - } - sideEffect[0] = interfaceType + " " + temp + " = " + "new " + implType + "<" + compType + ">();\n"; - return temp; - } - return "new ArrayList<" + compType + ">()"; - } - }); - public static final Symbol null_ = new Symbol("null", 0, Symbol.Type.PREFIX, "null", Symbol.Type.PREFIX); - public static final Symbol true_ = new Symbol("true", 0, Symbol.Type.PREFIX, "true", Symbol.Type.PREFIX); - public static final Symbol false_ = new Symbol("false", 0, Symbol.Type.PREFIX, "false", Symbol.Type.PREFIX); - public static final Symbol cond = new Symbol("if", 3, Symbol.Type.PREFIX, new Symbol.IImplGenerator() { - final int count[] = {0}; - @Override - public String generate(Type type, Type[] childrenTypes, String[] childrenImpl, String[] childrenSideEffects, String[] sideEffect) { - String temp = "temp_if" + count[0]; - String impl = ""; - - impl += type.getInterfaceTypeName() + " " + temp + ";\n"; - if (childrenSideEffects[0] != null && childrenSideEffects[0].length() > 0) impl += childrenSideEffects[0]; - impl += "if (" + childrenImpl[0] + ") {\n"; - if (childrenSideEffects[1] != null && childrenSideEffects[1].length() > 0) impl += "\t" + childrenSideEffects[1]; - impl += "\t" + temp + " = " + childrenImpl[1] + ";\n"; - impl += "} else {\n"; - if (childrenSideEffects[2] != null && childrenSideEffects[2].length() > 0) impl += "\t" + childrenSideEffects[2]; - impl += "\t" + temp + " = " + childrenImpl[2] + ";\n"; - impl += "}\n"; - - sideEffect[0] += impl; - - count[0]++; - return temp; - } - }); - public static final Symbol pair = new Symbol("pair", -1, Symbol.Type.PREFIX, new Symbol.IImplGenerator() { - @Override - public String generate(Type type, Type[] childrenTypes, String[] childrenImpl, String[] childrenSideEffects, String[] sideEffect) { - for (String s: childrenSideEffects) { - sideEffect[0] += s; - } - String impl = "new Pair<>(" + childrenImpl[0] + "," + childrenImpl[1] + ")"; - return impl; - } - }); - public static final Symbol tuple = new Symbol("tuple", -1, Symbol.Type.PREFIX, new Symbol.IImplGenerator() { - @Override - public String generate(Type type, Type[] childrenTypes, String[] childrenImpl, String[] childrenSideEffects, String[] sideEffect) { - for (String s: childrenSideEffects) { - sideEffect[0] += s; - } - String impl = "new AbstractMap.SimpleEntry<>(" + childrenImpl[0] + "$x)"; - for (int i = 1; i < childrenImpl.length - 1; i++) { - impl = impl.replace("$x", ", new AbstractMap.SimpleEntry<>(" + childrenImpl[i] + "$x)"); - } - impl = impl.replace("$x", ", " + childrenImpl[childrenImpl.length - 1]); - return impl; - } - }); - public static final Symbol fst = new Symbol("fst", 1, Symbol.Type.PREFIX, "getKey", Symbol.Type.METHOD); - public static final Symbol snd = new Symbol("snd", 1, Symbol.Type.PREFIX, "getValue", Symbol.Type.METHOD); - public static final Symbol left = new Symbol("left", 1, Symbol.Type.PREFIX, "getLeft", Symbol.Type.METHOD); - public static final Symbol right = new Symbol("right", 1, Symbol.Type.PREFIX, "getRight", Symbol.Type.METHOD); - public static final Symbol insert = new Symbol("insert", 3, Symbol.Type.PREFIX, "put", Symbol.Type.METHOD_WITH_SIDE_EFFECT); - public static final Symbol delete = new Symbol("delete", 2, Symbol.Type.PREFIX, "remove", Symbol.Type.METHOD_WITH_SIDE_EFFECT); - public static final Symbol lookup = new Symbol("lookup", 2, Symbol.Type.PREFIX, new Symbol.IImplGenerator() { - final int count[] = {0}; - @Override - public String generate(Type type, Type[] childrenTypes, String[] childrenImpl, String[] childrenSideEffects, String[] sideEffect) { - String temp = "temp_get" + count[0]; - String impl = childrenSideEffects[0] + childrenSideEffects[1]; - impl += type.getInterfaceTypeName() + " " + temp + ";\n"; - impl += "if (" + childrenImpl[0] + ".get(" + childrenImpl[1] + ") != null) {\n"; - impl += "\t" + temp + " = " + childrenImpl[0] + ".get(" + childrenImpl[1] + ");\n"; - impl += "} else {\n"; - impl += "\t" + temp + " = " + getDefaultValue(type) + ";\n"; - impl += "}"; - sideEffect[0] = impl; - count[0]++; - return temp; - } - }); - public static final Symbol pi = new Symbol("PI", 0, Symbol.Type.PREFIX, "Math.PI", Symbol.Type.PREFIX); - public static final Symbol E = new Symbol("E", 0, Symbol.Type.PREFIX, "Math.E", Symbol.Type.PREFIX); - public static final Symbol sqrt = new Symbol("sqrt", 1, Symbol.Type.PREFIX, "Math.sqrt", Symbol.Type.PREFIX); - public static final Symbol sin = new Symbol("sin", 1, Symbol.Type.PREFIX, "Math.sin", Symbol.Type.PREFIX); - public static final Symbol cos = new Symbol("cos", 1, Symbol.Type.PREFIX, "Math.cos", Symbol.Type.PREFIX); - public static final Symbol tan = new Symbol("tan", 1, Symbol.Type.PREFIX, "Math.tan", Symbol.Type.PREFIX); - public static final Symbol asin = new Symbol("asin", 1, Symbol.Type.PREFIX, "Math.asin", Symbol.Type.PREFIX); - public static final Symbol acos = new Symbol("acos", 1, Symbol.Type.PREFIX, "Math.acos", Symbol.Type.PREFIX); - public static final Symbol atan = new Symbol("atan", 1, Symbol.Type.PREFIX, "Math.atan", Symbol.Type.PREFIX); - public static final Symbol pow = new Symbol("pow", 2, Symbol.Type.PREFIX, "Math.pow", Symbol.Type.PREFIX); - public static final Symbol exp = new Symbol("exp", 1, Symbol.Type.PREFIX, "Math.exp", Symbol.Type.PREFIX); - public static final Symbol log = new Symbol("log", 1, Symbol.Type.PREFIX, "Math.log", Symbol.Type.PREFIX); - public static final Symbol abs = new Symbol("abs", 1, Symbol.Type.PREFIX, "Math.abs", Symbol.Type.PREFIX); - - static { - add.setInverses(new Symbol[] {sub, sub}); - mul.setInverses(new Symbol[] {div, div}); - sub.setInverses(new Symbol[] {add}); - div.setInverses(new Symbol[] {mul}); - minus.setInverses(new Symbol[] {minus}); - mod.setSignature(new Type[] {typeInt, null, null}); - eq.setSignature(new Type[] {typeBoolean, null, null}); - neq.setSignature(new Type[] {typeBoolean, null, null}); - gt.setSignature(new Type[] {typeBoolean, null, null}); - lt.setSignature(new Type[] {typeBoolean, null, null}); - ge.setSignature(new Type[] {typeBoolean, null, null}); - le.setSignature(new Type[] {typeBoolean, null, null}); - and.setSignature(new Type[] {typeBoolean, typeBoolean, typeBoolean}); - or.setSignature(new Type[] {typeBoolean, typeBoolean, typeBoolean}); - neg.setSignature(new Type[] {typeBoolean, typeBoolean}); - cons.setInverses(new Symbol[] {head, tail}); - cons.setSignature(new Type[] {typeList, null, typeList}); - append.setSignature(new Type[] {typeList, typeList, null}); - remove.setSignature(new Type[] {typeList, typeList, typeInt}); - head.setSignature(new Type[] {null, typeList}); - tail.setSignature(new Type[] {typeList, typeList}); - contains.setSignature(new Type[] {typeBoolean, null, null}); - length.setSignature(new Type[] {typeInt, null}); - get.setSignature(new Type[] {null, typeList, typeInt}); - set.setSignature(new Type[] {typeList, typeList, typeInt, null}); - null_.setSignature(new Type[] {null}); - true_.setSignature(new Type[] {typeBoolean}); - false_.setSignature(new Type[] {typeBoolean}); - pair.setSignature(new Type[] {typePair,null,null}); - pair.setInverses(new Symbol[] {left, right}); - left.setSignature(new Type[] {null, typePair}); - right.setSignature(new Type[] {null, typePair}); - tuple.setSignature(new Type[] {typeTuple, null, null}); - tuple.setInverses(new Symbol[] {fst, snd}); - fst.setSignature(new Type[] {null, typeTuple}); - fst.setInverses(new Symbol[] {new LambdaAbstraction(new Variable("x"), new Term(tuple, new Expression[] {new Variable("x"), new Variable("y")}))}); - snd.setSignature(new Type[] {null, typeTuple}); - snd.setInverses(new Symbol[] {new LambdaAbstraction(new Variable("y"), new Term(tuple, new Expression[] {new Variable("x"), new Variable("y")}))}); - insert.setSignature(new Type[] {typeMap, typeMap, null, null}); - delete.setSignature(new Type[] {typeMap, typeMap, null}); - lookup.setSignature(new Type[] {null, typeMap, null}); - pi.setSignature(new Type[] {typeDouble}); - E.setSignature(new Type[] {typeDouble}); - sqrt.setSignature(new Type[] {typeDouble, typeDouble}); - sin.setSignature(new Type[] {typeDouble, typeDouble}); - cos.setSignature(new Type[] {typeDouble, typeDouble}); - tan.setSignature(new Type[] {typeDouble, typeDouble}); - asin.setSignature(new Type[] {typeDouble, typeDouble}); - asin.setInverses(new Symbol[] {sin}); - acos.setSignature(new Type[] {typeDouble, typeDouble}); - acos.setInverses(new Symbol[] {cos}); - atan.setSignature(new Type[] {typeDouble, typeDouble}); - atan.setInverses(new Symbol[] {tan}); - pow.setSignature(new Type[] {typeDouble, typeDouble, typeDouble}); - exp.setSignature(new Type[] {typeDouble, typeDouble}); - exp.setInverses(new Symbol[] {log}); - log.setSignature(new Type[] {typeDouble, typeDouble}); - log.setInverses(new Symbol[] {exp}); - abs.setSignature(new Type[] {typeDouble, typeDouble}); - } - - public DataConstraintModel() { - resourcePaths = new HashMap<>(); - channels = new HashMap<>(); - ioChannels = new HashMap<>(); - types = new HashMap<>(); - addType(typeInt); - addType(typeLong); - addType(typeFloat); - addType(typeDouble); - addType(typeBoolean); - addType(typeString); - addType(typeList); - addType(typePair); - addType(typeTuple); - addType(typeMap); - symbols = new HashMap<>(); - addSymbol(add); - addSymbol(mul); - addSymbol(sub); - addSymbol(div); - addSymbol(minus); - addSymbol(mod); - addSymbol(eq); - addSymbol(neq); - addSymbol(gt); - addSymbol(lt); - addSymbol(ge); - addSymbol(le); - addSymbol(and); - addSymbol(or); - addSymbol(neg); - addSymbol(cons); - addSymbol(append); - addSymbol(remove); - addSymbol(head); - addSymbol(tail); - addSymbol(length); - addSymbol(contains); - addSymbol(get); - addSymbol(set); - addSymbol(cond); - addSymbol(nil); - addSymbol(null_); - addSymbol(true_); - addSymbol(false_); - addSymbol(pair); - addSymbol(left); - addSymbol(right); - addSymbol(tuple); - addSymbol(fst); - addSymbol(snd); - addSymbol(insert); - addSymbol(delete); - addSymbol(lookup); - addSymbol(pi); - addSymbol(E); - addSymbol(sqrt); - addSymbol(sin); - addSymbol(cos); - addSymbol(tan); - addSymbol(asin); - addSymbol(acos); - addSymbol(atan); - addSymbol(pow); - addSymbol(exp); - addSymbol(log); - addSymbol(abs); - } - - public Collection getResourcePaths() { - return resourcePaths.values(); - } - - public ResourcePath getResourcePath(String resourceName) { - return resourcePaths.get(resourceName); - } - - public void addResourcePath(ResourcePath resourcePath) { - resourcePaths.put(resourcePath.getResourceName(), resourcePath); - } - - public void setResourcePaths(HashMap resourcePaths) { - this.resourcePaths = resourcePaths; - } - - public void removeResourcePath(String resourceName) { - ResourcePath id = resourcePaths.get(resourceName); - resourcePaths.remove(resourceName); - for (Channel ch: channels.values()) { - ch.removeChannelMember(id); - } - for (Channel ch: ioChannels.values()) { - ch.removeChannelMember(id); - } - } - - public Collection getChannels() { - return channels.values(); - } - - public Channel getChannel(String channelName) { - return channels.get(channelName); - } - - public void setChannels(HashMap channels) { - this.channels = channels; - for (Channel g: channels.values()) { - for (ResourcePath id: g.getResources()) { - resourcePaths.put(id.getResourceName(), id); - } - } - } - - public void addChannel(Channel channel) { - channels.put(channel.getChannelName(), channel); - for (ResourcePath id: channel.getResources()) { - resourcePaths.put(id.getResourceName(), id); - } - } - - public void removeChannel(String channelName) { - channels.remove(channelName); - } - - public Collection getIOChannels() { - return ioChannels.values(); - } - - public Channel getIOChannel(String channelName) { - return ioChannels.get(channelName); - } - - public void setIOChannels(HashMap ioChannels) { - this.ioChannels = ioChannels; - for (Channel g: ioChannels.values()) { - for (ResourcePath id: g.getResources()) { - resourcePaths.put(id.getResourceName(), id); - } - } - } - - public void addIOChannel(Channel ioChannel) { - ioChannels.put(ioChannel.getChannelName(), ioChannel); - for (ResourcePath id: ioChannel.getResources()) { - resourcePaths.put(id.getResourceName(), id); - } - } - - public void removeIOChannel(String ioChannelName) { - ioChannels.remove(ioChannelName); - } - - public void addType(Type type) { - types.put(type.getTypeName(), type); - } - - public Type getType(String name) { - return types.get(name); - } - - public void addSymbol(Symbol symbol) { - symbols.put(symbol.getName(), symbol); - } - - public Symbol getSymbol(String name) { - return symbols.get(name); - } - - public static String getWrapperType(Type type) { - if (type == typeInt) { - return "Integer"; - } else if (type == typeLong) { - return "Long"; - } else if (type == typeFloat) { - return "Float"; - } else if (type == typeDouble) { - return "Double"; - } else if (type == typeBoolean) { - return "Boolean"; - } - return null; - } - - public boolean isPrimitiveType(Type type) { - if (type == typeInt - || type == typeLong - || type == typeFloat - || type == typeDouble - || type == typeBoolean) { - return true; - } - return false; - } - - public static boolean isListType(Type type) { - return typeList.isAncestorOf(type); - } - - public static String getDefaultValue(Type type) { - if (type == typeInt) { - return "0"; - } else if (type == typeLong) { - return "0L"; - } else if (type == typeFloat) { - return "0.0f"; - } else if (type == typeDouble) { - return "0.0"; - } else if (type == typeBoolean) { - return "false"; - } else if (type == typeString) { - return "\"\""; - } - return "new " + type.getImplementationTypeName() + "()"; - } - - @Override - public String toString() { - String out = ""; - for (Channel channel: ioChannels.values()) { - out += channel.toString(); - } - for (Channel channel: channels.values()) { - out += channel.toString(); - } - return out; - } - - public String getSourceText() { - String out = ""; - String init = ""; - for (ResourcePath resource: resourcePaths.values()) { - String initializer = resource.getInitText(); - if (initializer != null) { - init += initializer; - } - } - if (init.length() > 0) { - out += "init {\n" + init + "}\n"; - } - for (Channel channel: ioChannels.values()) { - out += channel.getSourceText(); - } - for (Channel channel: channels.values()) { - out += channel.getSourceText(); - } - return out; - } -} +package models.dataConstraintModel; + +import java.util.Collection; +import java.util.HashMap; + +import models.algebra.Expression; +import models.algebra.LambdaAbstraction; +import models.algebra.Symbol; +import models.algebra.Term; +import models.algebra.Type; +import models.algebra.Variable; +import parser.Parser; + +public class DataConstraintModel { + protected HashMap resourcePaths = null; + protected HashMap channels = null; + protected HashMap ioChannels = null; + protected HashMap types = null; + protected HashMap symbols = null; + public static final Type typeInt = new Type("Int", "int"); + public static final Type typeLong = new Type("Long", "long", typeInt); + public static final Type typeFloat = new Type("Float", "float", typeInt); + public static final Type typeDouble = new Type("Double", "double", typeFloat); + public static final Type typeBoolean = new Type("Bool", "boolean"); + public static final Type typeString = new Type("Str", "String") { + public String valueToRepresentation(Object value) { + if (value instanceof String) { + return Parser.DOUBLE_QUOT + (String) value + Parser.DOUBLE_QUOT; + } + return value.toString(); + } + public Object representationToValue(String representation) { + if (representation.startsWith(Parser.DOUBLE_QUOT) && representation.endsWith(Parser.DOUBLE_QUOT)) { + return representation.substring(1, representation.length() - 1); + } + return representation; + } + }; + public static final Type typeList = new Type("List", "ArrayList", "List"); + public static final Type typeListInt = new Type("List", "ArrayList<>", "List", typeList); + public static final Type typeListStr = new Type("List", "ArrayList<>", "List", typeList); + public static final Type typeTuple = new Type("Tuple", "AbstractMap.SimpleEntry", "Map.Entry"); + public static final Type typePair = new Type("Pair", "Pair", "Pair"); + public static final Type typePairInt = new Type("Pair", "Pair", "Pair", typePair); + public static final Type typePairStr = new Type("Pair", "Pair", "Pair", typePair); + public static final Type typePairDouble = new Type("Pair", "Pair", "Pair", typePair); + public static final Type typeMap = new Type("Map", "HashMap", "Map"); + public static final Symbol add = new Symbol(Parser.ADD, 2, Symbol.Type.INFIX); + public static final Symbol mul = new Symbol(Parser.MUL, 2, Symbol.Type.INFIX);; + public static final Symbol sub = new Symbol(Parser.SUB, 2, Symbol.Type.INFIX); + public static final Symbol div = new Symbol(Parser.DIV, 2, Symbol.Type.INFIX); + public static final Symbol minus = new Symbol(Parser.MINUS, 1); + public static final Symbol mod = new Symbol(Parser.MOD, 2, Symbol.Type.INFIX, "%", Symbol.Type.INFIX); + public static final Symbol eq = new Symbol(Parser.EQ, 2, Symbol.Type.INFIX, new Symbol.IImplGenerator() { + @Override + public String generate(Type type, Type[] childrenTypes, String[] children, String[] childrenSideEffects, String[] sideEffect) { + for (String s: childrenSideEffects) { + sideEffect[0] += s; + } + if (childrenTypes[0].equals(typeString) && childrenTypes[1].equals(typeString)) { + return children[0] + ".equals(" + children[1] + ")"; + } + return "(" + children[0] + "==" + children[1] + ")"; + } + + }); + public static final Symbol neq = new Symbol(Parser.NEQ, 2, Symbol.Type.INFIX, "!=", Symbol.Type.INFIX); + public static final Symbol gt = new Symbol(Parser.GT, 2, Symbol.Type.INFIX, ">", Symbol.Type.INFIX); + public static final Symbol lt = new Symbol(Parser.LT, 2, Symbol.Type.INFIX, "<", Symbol.Type.INFIX); + public static final Symbol ge = new Symbol(Parser.GE, 2, Symbol.Type.INFIX, ">=", Symbol.Type.INFIX); + public static final Symbol le = new Symbol(Parser.LE, 2, Symbol.Type.INFIX, "<=", Symbol.Type.INFIX); + public static final Symbol and = new Symbol(Parser.AND, 2, Symbol.Type.INFIX, "&&", Symbol.Type.INFIX); + public static final Symbol or = new Symbol(Parser.OR, 2, Symbol.Type.INFIX, "||", Symbol.Type.INFIX); + public static final Symbol neg = new Symbol(Parser.NEG, 1, Symbol.Type.INFIX, "!", Symbol.Type.PREFIX); + public static final Symbol cons = new Symbol("cons", 2, Symbol.Type.PREFIX, "($x,$y)->$x.add(0, $y)", Symbol.Type.LAMBDA_WITH_SIDE_EFFECT, new int[] {1, 0}); + public static final Symbol append = new Symbol("append", 2, Symbol.Type.PREFIX, "add", Symbol.Type.METHOD_WITH_SIDE_EFFECT); + public static final Symbol remove = new Symbol("remove", 2, Symbol.Type.PREFIX, "remove", Symbol.Type.METHOD_WITH_SIDE_EFFECT); + public static final Symbol head = new Symbol("head", 1, Symbol.Type.PREFIX, "($x)->$x.get(0)", Symbol.Type.LAMBDA); + public static final Symbol tail = new Symbol("tail", 1, Symbol.Type.PREFIX, "($x)->$x.subList(1, $x.size())", Symbol.Type.LAMBDA); + public static final Symbol length = new Symbol("length", 1, Symbol.Type.PREFIX, "($x)->$x.size()", Symbol.Type.LAMBDA); + public static final Symbol get = new Symbol("get", 2, Symbol.Type.PREFIX, "get", Symbol.Type.METHOD); + public static final Symbol set = new Symbol("set", 3, Symbol.Type.PREFIX, "set", Symbol.Type.METHOD_WITH_SIDE_EFFECT); + public static final Symbol contains = new Symbol("contains", 2, Symbol.Type.PREFIX, new Symbol.IImplGenerator() { + @Override + public String generate(Type type, Type[] childrenTypes, String[] childrenImpl, String[] childrenSideEffects, String[] sideEffect) { + for (String s: childrenSideEffects) { + sideEffect[0] += s; + } + if (childrenTypes[0] != null && typeMap.isAncestorOf(childrenTypes[0])) { + return childrenImpl[0] + "." + "containsKey(" + childrenImpl[1] + ")"; + } + return childrenImpl[0] + "." + "contains(" + childrenImpl[1] + ")"; + } + }); + public static final Symbol nil = new Symbol("nil", 0, Symbol.Type.PREFIX, new Symbol.IImplGenerator() { + @Override + public String generate(Type type, Type[] childrenTypes, String[] childrenImpl, String[] childrenSideEffects, String[] sideEffect) { + String compType = ""; + if (type != null) { + String temp = "temp_nil"; + String interfaceType = type.getInterfaceTypeName(); + if (interfaceType.contains("<")) { + compType = interfaceType.substring(interfaceType.indexOf("<") + 1, interfaceType.lastIndexOf(">")); + } + String implType = type.getImplementationTypeName(); + if (implType.indexOf('<') >= 0) { + implType = implType.substring(0, implType.indexOf('<')); + } + sideEffect[0] = interfaceType + " " + temp + " = " + "new " + implType + "<" + compType + ">();\n"; + return temp; + } + return "new ArrayList<" + compType + ">()"; + } + }); + public static final Symbol null_ = new Symbol("null", 0, Symbol.Type.PREFIX, "null", Symbol.Type.PREFIX); + public static final Symbol true_ = new Symbol("true", 0, Symbol.Type.PREFIX, "true", Symbol.Type.PREFIX); + public static final Symbol false_ = new Symbol("false", 0, Symbol.Type.PREFIX, "false", Symbol.Type.PREFIX); + public static final Symbol cond = new Symbol("if", 3, Symbol.Type.PREFIX, new Symbol.IImplGenerator() { + final int count[] = {0}; + @Override + public String generate(Type type, Type[] childrenTypes, String[] childrenImpl, String[] childrenSideEffects, String[] sideEffect) { + String temp = "temp_if" + count[0]; + String impl = ""; + + impl += type.getInterfaceTypeName() + " " + temp + ";\n"; + if (childrenSideEffects[0] != null && childrenSideEffects[0].length() > 0) impl += childrenSideEffects[0]; + impl += "if (" + childrenImpl[0] + ") {\n"; + if (childrenSideEffects[1] != null && childrenSideEffects[1].length() > 0) impl += "\t" + childrenSideEffects[1]; + impl += "\t" + temp + " = " + childrenImpl[1] + ";\n"; + impl += "} else {\n"; + if (childrenSideEffects[2] != null && childrenSideEffects[2].length() > 0) impl += "\t" + childrenSideEffects[2]; + impl += "\t" + temp + " = " + childrenImpl[2] + ";\n"; + impl += "}\n"; + + sideEffect[0] += impl; + + count[0]++; + return temp; + } + }); + public static final Symbol pair = new Symbol("pair", -1, Symbol.Type.PREFIX, new Symbol.IImplGenerator() { + @Override + public String generate(Type type, Type[] childrenTypes, String[] childrenImpl, String[] childrenSideEffects, String[] sideEffect) { + for (String s: childrenSideEffects) { + sideEffect[0] += s; + } + String impl = "new Pair<>(" + childrenImpl[0] + "," + childrenImpl[1] + ")"; + return impl; + } + }); + public static final Symbol tuple = new Symbol("tuple", -1, Symbol.Type.PREFIX, new Symbol.IImplGenerator() { + @Override + public String generate(Type type, Type[] childrenTypes, String[] childrenImpl, String[] childrenSideEffects, String[] sideEffect) { + for (String s: childrenSideEffects) { + sideEffect[0] += s; + } + String impl = "new AbstractMap.SimpleEntry<>(" + childrenImpl[0] + "$x)"; + for (int i = 1; i < childrenImpl.length - 1; i++) { + impl = impl.replace("$x", ", new AbstractMap.SimpleEntry<>(" + childrenImpl[i] + "$x)"); + } + impl = impl.replace("$x", ", " + childrenImpl[childrenImpl.length - 1]); + return impl; + } + }); + public static final Symbol fst = new Symbol("fst", 1, Symbol.Type.PREFIX, "getKey", Symbol.Type.METHOD); + public static final Symbol snd = new Symbol("snd", 1, Symbol.Type.PREFIX, "getValue", Symbol.Type.METHOD); + public static final Symbol left = new Symbol("left", 1, Symbol.Type.PREFIX, "getLeft", Symbol.Type.METHOD); + public static final Symbol right = new Symbol("right", 1, Symbol.Type.PREFIX, "getRight", Symbol.Type.METHOD); + public static final Symbol insert = new Symbol("insert", 3, Symbol.Type.PREFIX, "put", Symbol.Type.METHOD_WITH_SIDE_EFFECT); + public static final Symbol delete = new Symbol("delete", 2, Symbol.Type.PREFIX, "remove", Symbol.Type.METHOD_WITH_SIDE_EFFECT); + public static final Symbol lookup = new Symbol("lookup", 2, Symbol.Type.PREFIX, new Symbol.IImplGenerator() { + final int count[] = {0}; + @Override + public String generate(Type type, Type[] childrenTypes, String[] childrenImpl, String[] childrenSideEffects, String[] sideEffect) { + String temp = "temp_get" + count[0]; + String impl = childrenSideEffects[0] + childrenSideEffects[1]; + impl += type.getInterfaceTypeName() + " " + temp + ";\n"; + impl += "if (" + childrenImpl[0] + ".get(" + childrenImpl[1] + ") != null) {\n"; + impl += "\t" + temp + " = " + childrenImpl[0] + ".get(" + childrenImpl[1] + ");\n"; + impl += "} else {\n"; + impl += "\t" + temp + " = " + getDefaultValue(type) + ";\n"; + impl += "}"; + sideEffect[0] = impl; + count[0]++; + return temp; + } + }); + public static final Symbol pi = new Symbol("PI", 0, Symbol.Type.PREFIX, "Math.PI", Symbol.Type.PREFIX); + public static final Symbol E = new Symbol("E", 0, Symbol.Type.PREFIX, "Math.E", Symbol.Type.PREFIX); + public static final Symbol sqrt = new Symbol("sqrt", 1, Symbol.Type.PREFIX, "Math.sqrt", Symbol.Type.PREFIX); + public static final Symbol sin = new Symbol("sin", 1, Symbol.Type.PREFIX, "Math.sin", Symbol.Type.PREFIX); + public static final Symbol cos = new Symbol("cos", 1, Symbol.Type.PREFIX, "Math.cos", Symbol.Type.PREFIX); + public static final Symbol tan = new Symbol("tan", 1, Symbol.Type.PREFIX, "Math.tan", Symbol.Type.PREFIX); + public static final Symbol asin = new Symbol("asin", 1, Symbol.Type.PREFIX, "Math.asin", Symbol.Type.PREFIX); + public static final Symbol acos = new Symbol("acos", 1, Symbol.Type.PREFIX, "Math.acos", Symbol.Type.PREFIX); + public static final Symbol atan = new Symbol("atan", 1, Symbol.Type.PREFIX, "Math.atan", Symbol.Type.PREFIX); + public static final Symbol pow = new Symbol("pow", 2, Symbol.Type.PREFIX, "Math.pow", Symbol.Type.PREFIX); + public static final Symbol exp = new Symbol("exp", 1, Symbol.Type.PREFIX, "Math.exp", Symbol.Type.PREFIX); + public static final Symbol log = new Symbol("log", 1, Symbol.Type.PREFIX, "Math.log", Symbol.Type.PREFIX); + public static final Symbol abs = new Symbol("abs", 1, Symbol.Type.PREFIX, "Math.abs", Symbol.Type.PREFIX); + + static { + add.setInverses(new Symbol[] {sub, sub}); + mul.setInverses(new Symbol[] {div, div}); + sub.setInverses(new Symbol[] {add}); + div.setInverses(new Symbol[] {mul}); + minus.setInverses(new Symbol[] {minus}); + mod.setSignature(new Type[] {typeInt, null, null}); + eq.setSignature(new Type[] {typeBoolean, null, null}); + neq.setSignature(new Type[] {typeBoolean, null, null}); + gt.setSignature(new Type[] {typeBoolean, null, null}); + lt.setSignature(new Type[] {typeBoolean, null, null}); + ge.setSignature(new Type[] {typeBoolean, null, null}); + le.setSignature(new Type[] {typeBoolean, null, null}); + and.setSignature(new Type[] {typeBoolean, typeBoolean, typeBoolean}); + or.setSignature(new Type[] {typeBoolean, typeBoolean, typeBoolean}); + neg.setSignature(new Type[] {typeBoolean, typeBoolean}); + cons.setInverses(new Symbol[] {head, tail}); + cons.setSignature(new Type[] {typeList, null, typeList}); + append.setSignature(new Type[] {typeList, typeList, null}); + remove.setSignature(new Type[] {typeList, typeList, typeInt}); + head.setSignature(new Type[] {null, typeList}); + tail.setSignature(new Type[] {typeList, typeList}); + contains.setSignature(new Type[] {typeBoolean, null, null}); + length.setSignature(new Type[] {typeInt, null}); + get.setSignature(new Type[] {null, typeList, typeInt}); + set.setSignature(new Type[] {typeList, typeList, typeInt, null}); + null_.setSignature(new Type[] {null}); + true_.setSignature(new Type[] {typeBoolean}); + false_.setSignature(new Type[] {typeBoolean}); + pair.setSignature(new Type[] {typePair,null,null}); + pair.setInverses(new Symbol[] {left, right}); + left.setSignature(new Type[] {null, typePair}); + right.setSignature(new Type[] {null, typePair}); + tuple.setSignature(new Type[] {typeTuple, null, null}); + tuple.setInverses(new Symbol[] {fst, snd}); + fst.setSignature(new Type[] {null, typeTuple}); + fst.setInverses(new Symbol[] {new LambdaAbstraction(new Variable("x"), new Term(tuple, new Expression[] {new Variable("x"), new Variable("y")}))}); + snd.setSignature(new Type[] {null, typeTuple}); + snd.setInverses(new Symbol[] {new LambdaAbstraction(new Variable("y"), new Term(tuple, new Expression[] {new Variable("x"), new Variable("y")}))}); + insert.setSignature(new Type[] {typeMap, typeMap, null, null}); + delete.setSignature(new Type[] {typeMap, typeMap, null}); + lookup.setSignature(new Type[] {null, typeMap, null}); + pi.setSignature(new Type[] {typeDouble}); + E.setSignature(new Type[] {typeDouble}); + sqrt.setSignature(new Type[] {typeDouble, typeDouble}); + sin.setSignature(new Type[] {typeDouble, typeDouble}); + cos.setSignature(new Type[] {typeDouble, typeDouble}); + tan.setSignature(new Type[] {typeDouble, typeDouble}); + asin.setSignature(new Type[] {typeDouble, typeDouble}); + asin.setInverses(new Symbol[] {sin}); + acos.setSignature(new Type[] {typeDouble, typeDouble}); + acos.setInverses(new Symbol[] {cos}); + atan.setSignature(new Type[] {typeDouble, typeDouble}); + atan.setInverses(new Symbol[] {tan}); + pow.setSignature(new Type[] {typeDouble, typeDouble, typeDouble}); + exp.setSignature(new Type[] {typeDouble, typeDouble}); + exp.setInverses(new Symbol[] {log}); + log.setSignature(new Type[] {typeDouble, typeDouble}); + log.setInverses(new Symbol[] {exp}); + abs.setSignature(new Type[] {typeDouble, typeDouble}); + } + + public DataConstraintModel() { + resourcePaths = new HashMap<>(); + channels = new HashMap<>(); + ioChannels = new HashMap<>(); + types = new HashMap<>(); + addType(typeInt); + addType(typeLong); + addType(typeFloat); + addType(typeDouble); + addType(typeBoolean); + addType(typeString); + addType(typeList); + addType(typePair); + addType(typeTuple); + addType(typeMap); + symbols = new HashMap<>(); + addSymbol(add); + addSymbol(mul); + addSymbol(sub); + addSymbol(div); + addSymbol(minus); + addSymbol(mod); + addSymbol(eq); + addSymbol(neq); + addSymbol(gt); + addSymbol(lt); + addSymbol(ge); + addSymbol(le); + addSymbol(and); + addSymbol(or); + addSymbol(neg); + addSymbol(cons); + addSymbol(append); + addSymbol(remove); + addSymbol(head); + addSymbol(tail); + addSymbol(length); + addSymbol(contains); + addSymbol(get); + addSymbol(set); + addSymbol(cond); + addSymbol(nil); + addSymbol(null_); + addSymbol(true_); + addSymbol(false_); + addSymbol(pair); + addSymbol(left); + addSymbol(right); + addSymbol(tuple); + addSymbol(fst); + addSymbol(snd); + addSymbol(insert); + addSymbol(delete); + addSymbol(lookup); + addSymbol(pi); + addSymbol(E); + addSymbol(sqrt); + addSymbol(sin); + addSymbol(cos); + addSymbol(tan); + addSymbol(asin); + addSymbol(acos); + addSymbol(atan); + addSymbol(pow); + addSymbol(exp); + addSymbol(log); + addSymbol(abs); + } + + public Collection getResourcePaths() { + return resourcePaths.values(); + } + + public ResourcePath getResourcePath(String resourceName) { + return resourcePaths.get(resourceName); + } + + public void addResourcePath(ResourcePath resourcePath) { + resourcePaths.put(resourcePath.getResourceName(), resourcePath); + } + + public void setResourcePaths(HashMap resourcePaths) { + this.resourcePaths = resourcePaths; + } + + public void removeResourcePath(String resourceName) { + ResourcePath id = resourcePaths.get(resourceName); + resourcePaths.remove(resourceName); + for (Channel ch: channels.values()) { + ch.removeChannelMember(id); + } + for (Channel ch: ioChannels.values()) { + ch.removeChannelMember(id); + } + } + + public Collection getChannels() { + return channels.values(); + } + + public Channel getChannel(String channelName) { + return channels.get(channelName); + } + + public void setChannels(HashMap channels) { + this.channels = channels; + for (Channel g: channels.values()) { + for (ResourcePath id: g.getResources()) { + resourcePaths.put(id.getResourceName(), id); + } + } + } + + public void addChannel(Channel channel) { + channels.put(channel.getChannelName(), channel); + for (ResourcePath id: channel.getResources()) { + resourcePaths.put(id.getResourceName(), id); + } + } + + public void removeChannel(String channelName) { + channels.remove(channelName); + } + + public Collection getIOChannels() { + return ioChannels.values(); + } + + public Channel getIOChannel(String channelName) { + return ioChannels.get(channelName); + } + + public void setIOChannels(HashMap ioChannels) { + this.ioChannels = ioChannels; + for (Channel g: ioChannels.values()) { + for (ResourcePath id: g.getResources()) { + resourcePaths.put(id.getResourceName(), id); + } + } + } + + public void addIOChannel(Channel ioChannel) { + ioChannels.put(ioChannel.getChannelName(), ioChannel); + for (ResourcePath id: ioChannel.getResources()) { + resourcePaths.put(id.getResourceName(), id); + } + } + + public void removeIOChannel(String ioChannelName) { + ioChannels.remove(ioChannelName); + } + + public void addType(Type type) { + types.put(type.getTypeName(), type); + } + + public Type getType(String name) { + return types.get(name); + } + + public void addSymbol(Symbol symbol) { + symbols.put(symbol.getName(), symbol); + } + + public Symbol getSymbol(String name) { + return symbols.get(name); + } + + public static String getWrapperType(Type type) { + if (type == typeInt) { + return "Integer"; + } else if (type == typeLong) { + return "Long"; + } else if (type == typeFloat) { + return "Float"; + } else if (type == typeDouble) { + return "Double"; + } else if (type == typeBoolean) { + return "Boolean"; + } + return null; + } + + public boolean isPrimitiveType(Type type) { + if (type == typeInt + || type == typeLong + || type == typeFloat + || type == typeDouble + || type == typeBoolean) { + return true; + } + return false; + } + + public static boolean isListType(Type type) { + return typeList.isAncestorOf(type); + } + + public static String getDefaultValue(Type type) { + if (type == typeInt) { + return "0"; + } else if (type == typeLong) { + return "0L"; + } else if (type == typeFloat) { + return "0.0f"; + } else if (type == typeDouble) { + return "0.0"; + } else if (type == typeBoolean) { + return "false"; + } else if (type == typeString) { + return "\"\""; + } + return "new " + type.getImplementationTypeName() + "()"; + } + + @Override + public String toString() { + String out = ""; + for (Channel channel: ioChannels.values()) { + out += channel.toString(); + } + for (Channel channel: channels.values()) { + out += channel.toString(); + } + return out; + } + + public String getSourceText() { + String out = ""; + String init = ""; + for (ResourcePath resource: resourcePaths.values()) { + String initializer = resource.getInitText(); + if (initializer != null) { + init += resource.toString() + " := " + initializer + "\n"; + } + } + if (init.length() > 0) { + out += "init {\n" + init + "}\n"; + } + for (Channel channel: ioChannels.values()) { + out += channel.getSourceText(); + } + for (Channel channel: channels.values()) { + out += channel.getSourceText(); + } + return out; + } +} diff --git a/AlgebraicDataflowArchitectureModel/src/parser/Parser.java b/AlgebraicDataflowArchitectureModel/src/parser/Parser.java index b8ec54f..8f2ba8c 100644 --- a/AlgebraicDataflowArchitectureModel/src/parser/Parser.java +++ b/AlgebraicDataflowArchitectureModel/src/parser/Parser.java @@ -17,9 +17,11 @@ import models.dataConstraintModel.StateTransition; import models.dataFlowModel.DataTransferModel; import models.dataFlowModel.DataTransferChannel; +import parser.Parser.Token; import parser.exceptions.ExpectedAssignment; import parser.exceptions.ExpectedChannel; import parser.exceptions.ExpectedChannelName; +import parser.exceptions.ExpectedDoubleQuotation; import parser.exceptions.ExpectedEquals; import parser.exceptions.ExpectedInOrOutOrRefKeyword; import parser.exceptions.ExpectedLeftCurlyBracket; @@ -69,7 +71,7 @@ public static final String ASSIGNMENT = "="; public static final String COMMA = ","; public static final String COLON = ":"; - + public static final String DOUBLE_QUOT = "\""; public Parser(final TokenStream stream) { this.stream = stream; @@ -89,12 +91,12 @@ } public DataTransferModel doParse() - throws ExpectedRightBracket, ExpectedChannel, ExpectedChannelName, ExpectedLeftCurlyBracket, ExpectedInOrOutOrRefKeyword, ExpectedStateTransition, ExpectedEquals, ExpectedRHSExpression, WrongLHSExpression, WrongRHSExpression, ExpectedAssignment { + throws ExpectedRightBracket, ExpectedChannel, ExpectedChannelName, ExpectedLeftCurlyBracket, ExpectedInOrOutOrRefKeyword, ExpectedStateTransition, ExpectedEquals, ExpectedRHSExpression, WrongLHSExpression, WrongRHSExpression, ExpectedAssignment, ExpectedDoubleQuotation { return parseDataFlowModel(); } public DataTransferModel parseDataFlowModel() - throws ExpectedRightBracket, ExpectedChannel, ExpectedChannelName, ExpectedLeftCurlyBracket, ExpectedInOrOutOrRefKeyword, ExpectedStateTransition, ExpectedEquals, ExpectedRHSExpression, WrongLHSExpression, WrongRHSExpression, ExpectedAssignment { + throws ExpectedRightBracket, ExpectedChannel, ExpectedChannelName, ExpectedLeftCurlyBracket, ExpectedInOrOutOrRefKeyword, ExpectedStateTransition, ExpectedEquals, ExpectedRHSExpression, WrongLHSExpression, WrongRHSExpression, ExpectedAssignment, ExpectedDoubleQuotation { DataTransferModel model = new DataTransferModel(); DataTransferChannel channel; while ((channel = parseChannel(model)) != null) { @@ -112,7 +114,7 @@ ExpectedLeftCurlyBracket, ExpectedRightBracket, ExpectedAssignment, ExpectedRHSExpression, WrongLHSExpression, WrongRHSExpression, ExpectedChannel, ExpectedChannelName, ExpectedInOrOutOrRefKeyword, - ExpectedStateTransition, ExpectedEquals + ExpectedStateTransition, ExpectedEquals, ExpectedDoubleQuotation { if (!stream.hasNext()) return null; if (stream.checkNext().equals(RIGHT_CURLY_BRACKET)) return null; @@ -162,7 +164,7 @@ public void parseInit(DataTransferModel model) throws - ExpectedLeftCurlyBracket, ExpectedAssignment, ExpectedRHSExpression, WrongRHSExpression, ExpectedRightBracket + ExpectedLeftCurlyBracket, ExpectedAssignment, ExpectedRHSExpression, WrongRHSExpression, ExpectedRightBracket, ExpectedDoubleQuotation { String leftBracket = stream.next(); if (!leftBracket.equals(LEFT_CURLY_BRACKET)) throw new ExpectedLeftCurlyBracket(stream.getLine()); @@ -196,7 +198,7 @@ public ChannelMember parseChannelMember(DataTransferModel model, final String inOrOutOrRef) throws ExpectedRightBracket, ExpectedStateTransition, ExpectedEquals, - ExpectedRHSExpression, WrongLHSExpression, WrongRHSExpression + ExpectedRHSExpression, WrongLHSExpression, WrongRHSExpression, ExpectedDoubleQuotation { if (!stream.hasNext()) throw new ExpectedStateTransition(stream.getLine()); Expression leftTerm = parseTerm(stream, model); @@ -249,8 +251,7 @@ return channelMember; } - public Expression parseTerm(TokenStream stream, DataTransferModel model) - throws ExpectedRightBracket + public Expression parseTerm(TokenStream stream, DataTransferModel model) throws ExpectedRightBracket, ExpectedDoubleQuotation { ArrayList expressions = new ArrayList<>(); ArrayList operators = new ArrayList<>(); @@ -271,6 +272,10 @@ } else if (leftBracketOrMinusOrNeg.equals(NEG)) { minusOrNeg = DataTransferModel.neg; symbolName = stream.next(); + } else if (leftBracketOrMinusOrNeg.equals(DOUBLE_QUOT)) { + symbolName = DOUBLE_QUOT + stream.next() + DOUBLE_QUOT; + String doubleQuot = stream.next(); + if (!doubleQuot.equals(DOUBLE_QUOT)) throw new ExpectedDoubleQuotation(stream.getLine()); } else { symbolName = leftBracketOrMinusOrNeg; } @@ -310,9 +315,9 @@ } } } catch (NumberFormatException e) { - if (symbolName.startsWith("\"") && symbolName.endsWith("\"")) { + if (symbolName.startsWith(DOUBLE_QUOT) && symbolName.endsWith(DOUBLE_QUOT)) { // a string value - exp = new Constant(symbolName, DataTransferModel.typeString); + exp = new Constant(symbolName.substring(1, symbolName.length() - 1), DataTransferModel.typeString); } else { // a variable if (stream.checkNext() != null && stream.checkNext().equals(COLON)) { @@ -406,14 +411,14 @@ // lower priority than add and sub if (first != null) monomials.add(first); Expression firstMonomial = monomials.get(0); - int j = 1; + i = 1; for (Symbol op2: addSubs) { - Expression secondMonomial = monomials.get(j); + Expression secondMonomial = monomials.get(i); Term term = new Term(op2); term.addChild(firstMonomial); term.addChild(secondMonomial); firstMonomial = term; - j++; + i++; } if (rootTerm == null) { rootTerm = new Term(op); @@ -426,7 +431,6 @@ } monomials.clear(); addSubs.clear(); - first = second; } else { // add or sub ==> new monomial monomials.add(first); @@ -486,81 +490,31 @@ public void addLine(String line) { lines.add(line); line = line.trim(); - tokens.add( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - splitBy( - line.split("[ \t]"), - ADD, - ADD_REGX), - MUL, - MUL_REGX), - SUB, - SUB_REGX), - DIV, - DIV_REGX), - MOD, - MOD), - EQ, - EQ), - NEQ, - NEQ), - GE, - GE), - LE, - LE), - GT, - GT), - LT, - LT), - AND, - AND), - OR, - OR_REGX), - NEG, - NEG), - COMMA, - COMMA), - COLON, - COLON), - LEFT_BRACKET, - LEFT_BRACKET_REGX), - RIGHT_BRACKET, - RIGHT_BRACKET_REGX), - EQUALS, - EQUALS), - LEFT_CURLY_BRACKET, - LEFT_CURLY_BRACKET_REGX), - RIGHT_CURLY_BRACKET, - RIGHT_CURLY_BRACKET_REGX)); + ArrayList tokenList = splitByDoubleQuotation(line); + tokenList = splitBy(tokenList, ADD, ADD_REGX); + tokenList = splitBy(tokenList, MUL, MUL_REGX); + tokenList = splitBy(tokenList, SUB, SUB_REGX); + tokenList = splitBy(tokenList, DIV, DIV_REGX); + tokenList = splitBy(tokenList, MOD, MOD); + tokenList = splitBy(tokenList, EQ, EQ); + tokenList = splitBy(tokenList, NEQ,NEQ); + tokenList = splitBy(tokenList, GE, GE); + tokenList = splitBy(tokenList, LE, LE); + tokenList = splitBy(tokenList, GT, GT); + tokenList = splitBy(tokenList, LT, LT); + tokenList = splitBy(tokenList, AND, AND); + tokenList = splitBy(tokenList, OR, OR_REGX); + tokenList = splitBy(tokenList, NEG, NEG); + tokenList = splitBy(tokenList, COMMA, COMMA); + tokenList = splitBy(tokenList, COLON, COLON); + tokenList = splitBy(tokenList, LEFT_BRACKET, LEFT_BRACKET_REGX); + tokenList = splitBy(tokenList, RIGHT_BRACKET, RIGHT_BRACKET_REGX); + tokenList = splitBy(tokenList, EQUALS, EQUALS); + tokenList = splitBy(tokenList, LEFT_CURLY_BRACKET, LEFT_CURLY_BRACKET_REGX); + tokenList = splitBy(tokenList, RIGHT_CURLY_BRACKET, RIGHT_CURLY_BRACKET_REGX); + tokens.add(tokenList); } - private ArrayList splitBy(String[] tokens, final String delimiter, final String delimiterRegx) { - ArrayList newTokens = new ArrayList<>(); - for (String token: tokens) { - newTokens.add(new Token(token)); - } - return splitBy(newTokens, delimiter, delimiterRegx); - } - private ArrayList splitBy(final List tokens, final String delimiter, final String delimiterRegx) { ArrayList newTokens = new ArrayList<>(); for (Token token: tokens) { @@ -586,6 +540,33 @@ } return newTokens; } + + private ArrayList splitByDoubleQuotation(String line) { + ArrayList newTokens = new ArrayList<>(); + String[] tokens = line.split(DOUBLE_QUOT); + boolean fFirstToken = true; + for (int i = 0; i < tokens.length; i++) { + String token = tokens[i]; + if (!fFirstToken) { + newTokens.add(new Token(DOUBLE_QUOT, true)); + } + if (!fFirstToken || token.length() > 0) { + if (i % 2 == 0) { + for (String t: token.split("[ \t]")) { + newTokens.add(new Token(t)); + } + } else { + // string literal + newTokens.add(new Token(token, true)); + } + } + fFirstToken = false; + } + if (line.endsWith(DOUBLE_QUOT)) { + newTokens.add(new Token(DOUBLE_QUOT, true)); + } + return newTokens; + } public String next() { if (line >= tokens.size()) return null; diff --git a/AlgebraicDataflowArchitectureModel/src/parser/ParserDTRAM.java b/AlgebraicDataflowArchitectureModel/src/parser/ParserDTRAM.java index 830bd5f..d76e3ba 100644 --- a/AlgebraicDataflowArchitectureModel/src/parser/ParserDTRAM.java +++ b/AlgebraicDataflowArchitectureModel/src/parser/ParserDTRAM.java @@ -14,6 +14,7 @@ import parser.exceptions.ExpectedAssignment; import parser.exceptions.ExpectedChannel; import parser.exceptions.ExpectedChannelName; +import parser.exceptions.ExpectedDoubleQuotation; import parser.exceptions.ExpectedEquals; import parser.exceptions.ExpectedFormulaChannel; import parser.exceptions.ExpectedGeometry; @@ -63,7 +64,7 @@ * @param reader */ public DataTransferModel doParseModel() - throws ExpectedRightBracket, ExpectedChannel, ExpectedChannelName, ExpectedLeftCurlyBracket, ExpectedInOrOutOrRefKeyword, ExpectedStateTransition, ExpectedEquals, ExpectedRHSExpression, WrongLHSExpression, WrongRHSExpression, ExpectedAssignment, ExpectedModel, ExpectedGeometry { + throws ExpectedRightBracket, ExpectedChannel, ExpectedChannelName, ExpectedLeftCurlyBracket, ExpectedInOrOutOrRefKeyword, ExpectedStateTransition, ExpectedEquals, ExpectedRHSExpression, WrongLHSExpression, WrongRHSExpression, ExpectedAssignment, ExpectedModel, ExpectedGeometry, ExpectedDoubleQuotation { DataTransferModel model = getParsedModel(); return model; } @@ -85,7 +86,7 @@ * @param stream */ private DataTransferModel getParsedModel() - throws ExpectedRightBracket, ExpectedChannel, ExpectedChannelName, ExpectedLeftCurlyBracket, ExpectedInOrOutOrRefKeyword, ExpectedStateTransition, ExpectedEquals, ExpectedRHSExpression, WrongLHSExpression, WrongRHSExpression, ExpectedAssignment, ExpectedModel, ExpectedGeometry { + throws ExpectedRightBracket, ExpectedChannel, ExpectedChannelName, ExpectedLeftCurlyBracket, ExpectedInOrOutOrRefKeyword, ExpectedStateTransition, ExpectedEquals, ExpectedRHSExpression, WrongLHSExpression, WrongRHSExpression, ExpectedAssignment, ExpectedModel, ExpectedGeometry, ExpectedDoubleQuotation { if (!stream.hasNext()) throw new NullPointerException(); diff --git a/AlgebraicDataflowArchitectureModel/src/parser/exceptions/ExpectedDoubleQuotation.java b/AlgebraicDataflowArchitectureModel/src/parser/exceptions/ExpectedDoubleQuotation.java new file mode 100644 index 0000000..434bec3 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/parser/exceptions/ExpectedDoubleQuotation.java @@ -0,0 +1,8 @@ +package parser.exceptions; + +public class ExpectedDoubleQuotation extends ParseException { + + public ExpectedDoubleQuotation(int line) { + super(line); + } +} diff --git a/AlgebraicDataflowArchitectureModel/src/tests/CodeGeneratorTest.java b/AlgebraicDataflowArchitectureModel/src/tests/CodeGeneratorTest.java index a89ea3c..46f9f2a 100644 --- a/AlgebraicDataflowArchitectureModel/src/tests/CodeGeneratorTest.java +++ b/AlgebraicDataflowArchitectureModel/src/tests/CodeGeneratorTest.java @@ -17,6 +17,7 @@ import parser.exceptions.ExpectedAssignment; import parser.exceptions.ExpectedChannel; import parser.exceptions.ExpectedChannelName; +import parser.exceptions.ExpectedDoubleQuotation; import parser.exceptions.ExpectedEquals; import parser.exceptions.ExpectedInOrOutOrRefKeyword; import parser.exceptions.ExpectedLeftCurlyBracket; @@ -41,7 +42,7 @@ System.out.println(codetree); } catch (ExpectedChannel | ExpectedChannelName | ExpectedLeftCurlyBracket | ExpectedInOrOutOrRefKeyword | ExpectedStateTransition | ExpectedEquals | ExpectedRHSExpression | WrongLHSExpression - | WrongRHSExpression | ExpectedRightBracket | ExpectedAssignment e) { + | WrongRHSExpression | ExpectedRightBracket | ExpectedAssignment | ExpectedDoubleQuotation e) { e.printStackTrace(); } } catch (FileNotFoundException e) { diff --git a/AlgebraicDataflowArchitectureModel/src/tests/DataStorageDecisionTest.java b/AlgebraicDataflowArchitectureModel/src/tests/DataStorageDecisionTest.java index 9d28936..988748b 100644 --- a/AlgebraicDataflowArchitectureModel/src/tests/DataStorageDecisionTest.java +++ b/AlgebraicDataflowArchitectureModel/src/tests/DataStorageDecisionTest.java @@ -13,6 +13,7 @@ import parser.exceptions.ExpectedAssignment; import parser.exceptions.ExpectedChannel; import parser.exceptions.ExpectedChannelName; +import parser.exceptions.ExpectedDoubleQuotation; import parser.exceptions.ExpectedEquals; import parser.exceptions.ExpectedInOrOutOrRefKeyword; import parser.exceptions.ExpectedLeftCurlyBracket; @@ -39,7 +40,7 @@ } } catch (ExpectedChannel | ExpectedChannelName | ExpectedLeftCurlyBracket | ExpectedInOrOutOrRefKeyword | ExpectedStateTransition | ExpectedEquals | ExpectedRHSExpression | WrongLHSExpression - | WrongRHSExpression | ExpectedRightBracket | ExpectedAssignment e) { + | WrongRHSExpression | ExpectedRightBracket | ExpectedAssignment | ExpectedDoubleQuotation e) { e.printStackTrace(); } } catch (FileNotFoundException e) { diff --git a/AlgebraicDataflowArchitectureModel/src/tests/DataStorageNecessityTest.java b/AlgebraicDataflowArchitectureModel/src/tests/DataStorageNecessityTest.java index 9a7c300..c1a3cde 100644 --- a/AlgebraicDataflowArchitectureModel/src/tests/DataStorageNecessityTest.java +++ b/AlgebraicDataflowArchitectureModel/src/tests/DataStorageNecessityTest.java @@ -12,6 +12,7 @@ import parser.exceptions.ExpectedAssignment; import parser.exceptions.ExpectedChannel; import parser.exceptions.ExpectedChannelName; +import parser.exceptions.ExpectedDoubleQuotation; import parser.exceptions.ExpectedEquals; import parser.exceptions.ExpectedInOrOutOrRefKeyword; import parser.exceptions.ExpectedLeftCurlyBracket; @@ -39,7 +40,7 @@ } } catch (ExpectedChannel | ExpectedChannelName | ExpectedLeftCurlyBracket | ExpectedInOrOutOrRefKeyword | ExpectedStateTransition | ExpectedEquals | ExpectedRHSExpression | WrongLHSExpression - | WrongRHSExpression | ExpectedRightBracket | ExpectedAssignment e) { + | WrongRHSExpression | ExpectedRightBracket | ExpectedAssignment | ExpectedDoubleQuotation e) { e.printStackTrace(); } } catch (FileNotFoundException e) { diff --git a/AlgebraicDataflowArchitectureModel/src/tests/EdgeTransitionSelectableTest.java b/AlgebraicDataflowArchitectureModel/src/tests/EdgeTransitionSelectableTest.java index 847fb6f..e18b409 100644 --- a/AlgebraicDataflowArchitectureModel/src/tests/EdgeTransitionSelectableTest.java +++ b/AlgebraicDataflowArchitectureModel/src/tests/EdgeTransitionSelectableTest.java @@ -12,6 +12,7 @@ import parser.exceptions.ExpectedAssignment; import parser.exceptions.ExpectedChannel; import parser.exceptions.ExpectedChannelName; +import parser.exceptions.ExpectedDoubleQuotation; import parser.exceptions.ExpectedEquals; import parser.exceptions.ExpectedInOrOutOrRefKeyword; import parser.exceptions.ExpectedLeftCurlyBracket; @@ -38,7 +39,7 @@ } } catch (ExpectedChannel | ExpectedChannelName | ExpectedLeftCurlyBracket | ExpectedInOrOutOrRefKeyword | ExpectedStateTransition | ExpectedEquals | ExpectedRHSExpression | WrongLHSExpression - | WrongRHSExpression | ExpectedRightBracket | ExpectedAssignment e) { + | WrongRHSExpression | ExpectedRightBracket | ExpectedAssignment | ExpectedDoubleQuotation e) { e.printStackTrace(); } } catch (FileNotFoundException e) { diff --git a/AlgebraicDataflowArchitectureModel/src/tests/InverseTest.java b/AlgebraicDataflowArchitectureModel/src/tests/InverseTest.java index 85644fc..485fb49 100644 --- a/AlgebraicDataflowArchitectureModel/src/tests/InverseTest.java +++ b/AlgebraicDataflowArchitectureModel/src/tests/InverseTest.java @@ -19,6 +19,7 @@ import models.dataFlowModel.DataTransferModel; import parser.Parser; import parser.Parser.TokenStream; +import parser.exceptions.ExpectedDoubleQuotation; import parser.exceptions.ExpectedRightBracket; public class InverseTest { @@ -83,7 +84,7 @@ assertFalse(inv.contains(v)); System.out.println(rhsVars3.get(vPos) + " = " + inv); } - } catch (ExpectedRightBracket e) { + } catch (ExpectedRightBracket | ExpectedDoubleQuotation e) { e.printStackTrace(); } } diff --git a/AlgebraicDataflowArchitectureModel/src/tests/UpdateConflictCheckTest.java b/AlgebraicDataflowArchitectureModel/src/tests/UpdateConflictCheckTest.java index 5f51af7..353dd86 100644 --- a/AlgebraicDataflowArchitectureModel/src/tests/UpdateConflictCheckTest.java +++ b/AlgebraicDataflowArchitectureModel/src/tests/UpdateConflictCheckTest.java @@ -11,6 +11,7 @@ import parser.exceptions.ExpectedAssignment; import parser.exceptions.ExpectedChannel; import parser.exceptions.ExpectedChannelName; +import parser.exceptions.ExpectedDoubleQuotation; import parser.exceptions.ExpectedEquals; import parser.exceptions.ExpectedInOrOutOrRefKeyword; import parser.exceptions.ExpectedLeftCurlyBracket; @@ -61,6 +62,9 @@ } catch (ExpectedAssignment e) { // TODO Auto-generated catch block e.printStackTrace(); + } catch (ExpectedDoubleQuotation e) { + // TODO Auto-generated catch block + e.printStackTrace(); } } catch (FileNotFoundException e) { e.printStackTrace(); diff --git a/AlgebraicDataflowArchitectureModel/src/tests/parser/ParseTest.java b/AlgebraicDataflowArchitectureModel/src/tests/parser/ParseTest.java index a1ea0a3..d78e16a 100644 --- a/AlgebraicDataflowArchitectureModel/src/tests/parser/ParseTest.java +++ b/AlgebraicDataflowArchitectureModel/src/tests/parser/ParseTest.java @@ -17,6 +17,7 @@ import parser.exceptions.ExpectedAssignment; import parser.exceptions.ExpectedChannel; import parser.exceptions.ExpectedChannelName; +import parser.exceptions.ExpectedDoubleQuotation; import parser.exceptions.ExpectedEquals; import parser.exceptions.ExpectedInOrOutOrRefKeyword; import parser.exceptions.ExpectedLeftCurlyBracket; @@ -54,7 +55,7 @@ | ExpectedStateTransition | ExpectedEquals | ExpectedRHSExpression | WrongLHSExpression | WrongRHSExpression | ExpectedRightBracket | ParameterizedIdentifierIsFutureWork | ResolvingMultipleDefinitionIsFutureWork | InvalidMessage - | UnificationFailed | ValueUndefined | ExpectedAssignment e) { + | UnificationFailed | ValueUndefined | ExpectedAssignment | ExpectedDoubleQuotation e) { e.printStackTrace(); } } catch (FileNotFoundException e) {