]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Merged trunk@30111, @30195, @30274, @30356, @30385 to branches/sysdyn-1.8 on 2014...
authorjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 16 Oct 2014 06:55:20 +0000 (06:55 +0000)
committerjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 16 Oct 2014 06:55:20 +0000 (06:55 +0000)
refs #5198
refs #5224

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches/1.8@30413 ac1ea38d-2e2b-0410-8846-a27921b304fc

37 files changed:
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Addition.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Array.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Assignment.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Break.java [new file with mode: 0644]
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Derivate.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Division.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseAddition.java [new file with mode: 0644]
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseDivision.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwisePower.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseProduct.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseSubtraction.java [new file with mode: 0644]
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Environment.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ExecutionException.java [new file with mode: 0644]
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ForStatement.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Function.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/GreaterThan.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IStatement.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IfStatement.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Model.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/MultiStatement.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Multiplication.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Negation.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Parser.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Return.java [new file with mode: 0644]
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Statement.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/StatementList.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Subtraction.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Utils.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Variable.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/VariableBase.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/While.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParser.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParserTokenManager.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jj
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jjt
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/SimpleNode.java

index 8c09ab6f8ad7c812bef468bd4fd25f205dd5cd17..6c531d4149ade70a4a81d9d673e4f6c84997caab 100644 (file)
@@ -12,6 +12,8 @@ package fi.semantum.sysdyn.solver;
 \r
 import java.util.Map;\r
 \r
+import fi.semantum.sysdyn.solver.Array.Modifier2;\r
+\r
 public class Addition implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -38,7 +40,14 @@ public class Addition implements IExpression {
                if(o1 instanceof Array && o2 instanceof Array) {\r
                        Array la = (Array)o1;\r
                        Array ra = (Array)o2;\r
-                       return la.add(ra);\r
+                       return la.copy2(ra, new Modifier2() {\r
+                               \r
+                               @Override\r
+                               public Object modify(Object o1, Object o2) {\r
+                                       if(o1 instanceof Double && o2 instanceof Double) return ((Double)o1)+((Double)o2);\r
+                                       throw new IllegalStateException("Tried to add a non-numerical array");\r
+                               }\r
+                       });\r
                }\r
                throw new IllegalStateException();\r
        }\r
index 68a0504bf4eecfed8c8a037c65c15309d95daf88..cb16d4b9f8b64cc28baeec70c4830fd67392e402 100644 (file)
@@ -16,11 +16,16 @@ import java.util.Iterator;
 import java.util.List;\r
 import java.util.Map;\r
 \r
+/*\r
+ * For matrices first dimension is rows and second is columns i.e. top level elements are rows\r
+ */\r
 public class Array implements IExpression {\r
 \r
        public static final Array FULL = new Array();\r
        \r
        final private ArrayList<Object> elements;\r
+       \r
+       boolean isVector = true;\r
 \r
        public Array() {\r
                elements = new ArrayList<Object>();\r
@@ -32,7 +37,15 @@ public class Array implements IExpression {
 \r
        public Array addElement(Object element) {\r
                if(element instanceof Constant) addElement(((Constant)element).value);\r
-               else elements.add(element);\r
+               else {\r
+                       \r
+//                     if(element instanceof Double)\r
+//                             if(Double.isNaN((Double)element))\r
+//                                     throw new IllegalStateException();\r
+\r
+                       if(element instanceof Array) isVector = false;\r
+                       elements.add(element);\r
+               }\r
                return this;\r
        }\r
        \r
@@ -68,7 +81,15 @@ public class Array implements IExpression {
        }\r
        \r
        public int size(int col) {\r
-               return elements.size();\r
+               \r
+               if(col == 1) return elements.size();\r
+\r
+               if(elements.isEmpty()) throw new IllegalStateException();\r
+               Object elem = element(0);\r
+               if(!(elem instanceof Array)) throw new IllegalStateException();\r
+               \r
+               return ((Array)elem).size(col-1);\r
+               \r
        }\r
        \r
        public Object element(int index) {\r
@@ -283,23 +304,22 @@ public class Array implements IExpression {
                throw new IllegalStateException();\r
                \r
        }\r
-       \r
-       public Array add(Array other) {\r
-               Array result = new Array();\r
+\r
+       /*\r
+        * Both arrays are vectors \r
+        */\r
+       public double inner(Array other) {\r
+               double result = 0;\r
                Collection<Object> lae = elements();\r
                Collection<Object> rae = other.elements();\r
-               if(lae.size() != rae.size()) throw new IllegalStateException();\r
+               if(lae.size() != rae.size()) throw new IllegalStateException("inner product: vector sizes do not match: " + this + " vs. " + other);\r
                Iterator<Object> li = lae.iterator();\r
                Iterator<Object> ri = rae.iterator();\r
                for(int i=0;i<lae.size();i++) {\r
                        Object l = li.next();\r
                        Object r = ri.next();\r
                        if(l instanceof Double && r instanceof Double) {\r
-                               result.addElement(((Double)l)+((Double)r));\r
-                       } else if (l instanceof Array && r instanceof Array) {\r
-                               Array arr = (Array)l;\r
-                               Array otherArr = (Array)r;\r
-                               result.addElement(arr.add(otherArr));\r
+                               result += ((Double)l)*((Double)r);\r
                        } else {\r
                                throw new IllegalStateException();\r
                        }\r
@@ -307,29 +327,37 @@ public class Array implements IExpression {
                return result;\r
        }\r
 \r
-       public Array mul(Array other) {\r
+       /*\r
+        * Other array is vector (this is matrix)\r
+        */\r
+       public Array matrixMulVector(Array other) {\r
                Array result = new Array();\r
-               Collection<Object> lae = elements();\r
-               Collection<Object> rae = other.elements();\r
-               if(lae.size() != rae.size()) throw new IllegalStateException();\r
-               Iterator<Object> li = lae.iterator();\r
-               Iterator<Object> ri = rae.iterator();\r
-               for(int i=0;i<lae.size();i++) {\r
-                       Object l = li.next();\r
-                       Object r = ri.next();\r
-                       if(l instanceof Double && r instanceof Double) {\r
-                               result.addElement(((Double)l)*((Double)r));\r
-                       } else if (l instanceof Array && r instanceof Array) {\r
-                               Array arr = (Array)l;\r
-                               Array otherArr = (Array)r;\r
-                               result.addElement(arr.mul(otherArr));\r
-                       } else {\r
-                               throw new IllegalStateException();\r
-                       }\r
+               for(Object o : elements) {\r
+                       // Objects are rows\r
+                       Array a = (Array)o;\r
+                       result.addElement(a.inner(other));\r
                }\r
                return result;\r
        }\r
 \r
+       /*\r
+        * Other array is matrix (this is matrix)\r
+        */\r
+       public Array matrixMulMatrix(Array other) {\r
+               Array result = new Array();\r
+               Array transposed = other.transposed();\r
+               for(Object rightColumn_ : transposed.elements()) {\r
+                       Array rightColumn = (Array)rightColumn_;\r
+                       Array resultColumn = new Array();\r
+                       for(Object leftRow_ : elements) {\r
+                               Array leftRow = (Array)leftRow_;\r
+                               resultColumn.addElement(leftRow.inner(rightColumn));\r
+                       }\r
+                       result.addElement(resultColumn);\r
+               }\r
+               return result.transposed();\r
+       }\r
+\r
        public Array pow(Array other) {\r
                Array result = new Array();\r
                Collection<Object> lae = elements();\r
@@ -378,5 +406,193 @@ public class Array implements IExpression {
                }\r
                return result;\r
        }\r
+       \r
+       interface Modifier {\r
+               Object modify(Object o);\r
+       }\r
+       \r
+       interface Modifier2 {\r
+               Object modify(Object o1, Object o2);\r
+       }\r
+\r
+       public Array copy(Modifier modifier) {\r
+               Array result = new Array();\r
+               for(Object element : elements) {\r
+                       if(element instanceof Array) {\r
+                               Array sub = (Array)element;\r
+                               result.addElement(sub.copy(modifier));\r
+                       } else {\r
+                               result.addElement(modifier.modify(element));\r
+                       }\r
+               }\r
+               return result;\r
+       }\r
+       \r
+       public Array copy2(Array other, Modifier2 modifier) {\r
+               Array result = new Array();\r
+               Collection<Object> es = elements();\r
+               Collection<Object> oes = other.elements();\r
+               if(es.size() != oes.size()) throw new IllegalStateException("Array dimensions do not match");\r
+               Iterator<Object> e = es.iterator();\r
+               Iterator<Object> oe = oes.iterator();\r
+               for(int i=0;i<es.size();i++) {\r
+                       Object element = e.next();\r
+                       Object otherElement = oe.next();\r
+                       if(element instanceof Array) {\r
+                               if(otherElement instanceof Array) {\r
+                                       result.addElement(((Array)element).copy2((Array)otherElement, modifier));\r
+                               } else {\r
+                                       throw new IllegalStateException("Array dimensions do not match");\r
+                               }\r
+                       } else {\r
+                               if(otherElement instanceof Array) {\r
+                                       throw new IllegalStateException("Array dimensions do not match");\r
+                               } else {\r
+                                       result.addElement(modifier.modify(element, otherElement));\r
+                               }\r
+                       }                               \r
+               }\r
+               return result;\r
+       }\r
+\r
+       public boolean isVector() {\r
+               return isVector;\r
+       }\r
+\r
+       private Object subscript(IEnvironment environment, IExpression[] subscripts, int position) {\r
+               \r
+               IExpression e = subscripts[position];\r
+               Object indexObject = e.evaluate(environment);\r
+               int index = Utils.getIndex(indexObject);\r
+               if(index == -2) {\r
+                       Array ret = new Array();\r
+                       for(Object element : elements) {\r
+                               // Last position should not be array\r
+                               if(position == subscripts.length-1) {\r
+                                       if(element instanceof Array) throw new IllegalStateException();\r
+                                       if(element instanceof IExpression) {\r
+                                               IExpression exp = (IExpression)element;\r
+                                               ret.addElement(exp.evaluate(environment));\r
+                                       } else {\r
+                                               ret.addElement(element);\r
+                                       }\r
+                               } else {\r
+                                       if(element instanceof Array) {\r
+                                               ret.addElement(((Array)element).subscript(environment, subscripts, position+1));\r
+                                       } else {\r
+                                               throw new IllegalStateException();\r
+                                       }\r
+                               }\r
+                       }\r
+                       return ret;\r
+               } else if (index == -3) {\r
+                       \r
+                       Array arr = (Array)indexObject;\r
+                       Array ret = new Array();\r
+                       for(Object indexO : arr.elements()) {\r
+                               index = ((Double)indexO).intValue()-1;\r
+                               Object element = element(index);\r
+                               // Last position should not be array\r
+                               if(position == subscripts.length-1) {\r
+                                       if(element instanceof Array) throw new IllegalStateException();\r
+                                       if(element instanceof IExpression) {\r
+                                               IExpression exp = (IExpression)element;\r
+                                               ret.addElement(exp.evaluate(environment));\r
+                                       } else {\r
+                                               ret.addElement(element);\r
+                                       }\r
+                               } else {\r
+                                       if(element instanceof Array) {\r
+                                               ret.addElement(((Array)element).subscript(environment, subscripts, position+1));\r
+                                       } else {\r
+                                               throw new IllegalStateException();\r
+                                       }\r
+                               }\r
+                       }\r
+                       return ret;\r
+                       \r
+               } else {\r
+                       Object element = element(index);\r
+                       // Last position should not be array\r
+                       if(position == subscripts.length-1) {\r
+                               if(element instanceof Array) throw new ExecutionException("Array size does not match subscripts.");\r
+                               if(element instanceof IExpression) {\r
+                                       IExpression exp = (IExpression)element;\r
+                                       return exp.evaluate(environment);\r
+                               } else {\r
+                                       return element;\r
+                               }\r
+                       } else {\r
+                               if(element instanceof Array) {\r
+                                       return ((Array)element).subscript(environment, subscripts, position+1);\r
+                               } else {\r
+                                       throw new IllegalStateException();\r
+                               }\r
+                       }\r
+               }\r
+               \r
+       }\r
+       \r
+       public Object subscript(IEnvironment environment, IExpression[] subscripts) {\r
+               return subscript(environment, subscripts, 0);\r
+       }\r
+\r
+       public void applyPartial(Array[] indices, Array value, int pos) {\r
+               Array arr = indices[pos];\r
+               if(Array.FULL == arr) {\r
+                       for(int i=0;i<elements.size();i++) {\r
+                               if(pos < (indices.length-1)) {\r
+                                       ((Array)elements.get(i)).applyPartial(indices, (Array)value.element(i), pos+1);\r
+                               } else {\r
+                                       elements.set(i, value.element(i));\r
+                               }\r
+                       }\r
+               } else if(arr.dimension() == 1) {\r
+                       int index = ((Double)arr.element(0)).intValue();\r
+                       if(pos < (indices.length-1)) {\r
+                               ((Array)elements.get(index)).applyPartial(indices, value, pos+1);\r
+                       } else {\r
+                               elements.set(index, (Array)value.element(index));\r
+                       }\r
+               } else {\r
+                       for(Object element : arr.elements) {\r
+                               int i = ((Double)element).intValue();\r
+                               if(pos < (indices.length-1)) {\r
+                                       ((Array)elements.get(i)).applyPartial(indices, (Array)value.element(i), pos+1);\r
+                               } else {\r
+                                       elements.set(i, value.element(i));\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       public void applyPartial(Array[] indices, Array value) {\r
+               applyPartial(indices, value, 0);\r
+       }\r
+       \r
+       public Array transposed() {\r
+               \r
+               List<Object> elements = elements();\r
+               if(elements.isEmpty()) return this;\r
+               \r
+               Array first = (Array)elements.get(0);\r
+               \r
+               Array[] arrs = new Array[first.elements().size()];\r
+               for(int i=0;i<arrs.length;i++) arrs[i] = new Array();\r
+               \r
+               for(int i=0;i<elements.size();i++) {\r
+                       Array a = (Array)elements.get(i);\r
+                       for(int j=0;j<a.elements().size();j++) {\r
+                               Object o = a.element(j);\r
+                               arrs[j].addElement(o);\r
+                       }\r
+               }\r
+\r
+               Array result = new Array();\r
+               for(Array a : arrs) result.addElement(a);\r
+\r
+               return result;\r
+               \r
+       }\r
 \r
 }\r
index 6607c19809bab7536403a1cfe8cfcec1566d4df1..67752379c360df09395883314cd46caa9e80ebdb 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
-\r
 public class Assignment {\r
-       \r
+\r
+       private static final boolean VALIDATE = true;   \r
+\r
+       public IFrame model;\r
        public Variable target;\r
        public IExpression[] subscripts;\r
     public IExpression expression;\r
     public boolean assigned = false;\r
     public boolean isConstant = false;\r
     \r
-    public Assignment(Variable target, IExpression[] subscripts, IExpression expression) {\r
+    public Assignment(IFrame model, Variable target, IExpression[] subscripts, IExpression expression) {\r
+       this.model = model;\r
        this.target = target;\r
        this.subscripts = subscripts;\r
        this.expression = expression;\r
@@ -35,10 +38,46 @@ public class Assignment {
                IExpression[] subscripts2 = new IExpression[subscripts.length];\r
                for(int i=0;i<subscripts.length;i++)\r
                        subscripts2[i] = subscripts[i].withBase(frame, prefix);\r
-               return new Assignment(target.withBase(frame, prefix), subscripts2, expression.withBase(frame, prefix));\r
+               return new Assignment(frame, target.withBase(frame, prefix), subscripts2, expression.withBase(frame, prefix));\r
        } else {\r
-               return new Assignment(target.withBase(frame, prefix), null, expression.withBase(frame, prefix));\r
+               return new Assignment(frame, target.withBase(frame, prefix), null, expression.withBase(frame, prefix));\r
+       }\r
+    }\r
+    \r
+    public void assign(IEnvironment env) {\r
+       try {\r
+                       Object value = expression.evaluate(env);\r
+                       if(value != null) {\r
+                               validate(target, value);\r
+                               target.assign(env, subscripts, value);\r
+                               assigned = true;\r
+                       }\r
+       } catch (ExecutionException e) {\r
+               if(model instanceof Model) {\r
+                       throw new ExecutionException("Line " + (target.line-((Model)model).line) + ": while evaluating " + target.base.name + ": " + e.getMessage());\r
+               } else {\r
+                       throw new ExecutionException("While evaluating " + target.base.name + ": " + e.getMessage());\r
+               }\r
        }\r
     }\r
     \r
+    \r
+       private void validate(Variable var, Object value) {\r
+               if(VALIDATE) {\r
+                       if(value instanceof Double) {\r
+                               if(Double.isNaN((Double)value)) {\r
+                                       System.err.println("value is invalid (NaN): " + var.base.name);\r
+                                       throw new IllegalStateException("value is invalid (NaN)");\r
+                               }\r
+                               if(Double.isInfinite((Double)value)) {\r
+                                       System.err.println("value is invalid (Infinite): " + var.base.name);\r
+                                       throw new IllegalStateException("value is invalid (Infinite)");\r
+                               }\r
+                       }\r
+                       if(value instanceof Array) {\r
+                               for(Object o : ((Array)value).elements()) validate(var, o);\r
+                       }\r
+               }\r
+       }\r
+    \r
 }\r
diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Break.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Break.java
new file mode 100644 (file)
index 0000000..588cfe0
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 Semantum Oy.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+\r
+public class Break implements IStatement {\r
+       \r
+    public Break() {\r
+    }\r
+    \r
+    @Override\r
+    public String toString() {\r
+       return "break";\r
+    }\r
+    \r
+    @Override\r
+    public ReturnValue evaluate(IEnvironment environment) {\r
+       return ReturnValue.BREAK;\r
+    }\r
+    \r
+}\r
index 7d26af5630dc37235d18569a7fcb820211b29d18..b5194f7f0812972cfba07277b4adf044825ab149 100644 (file)
@@ -12,6 +12,8 @@ package fi.semantum.sysdyn.solver;
 \r
 import java.util.Map;\r
 \r
+import fi.semantum.sysdyn.solver.Array.Modifier2;\r
+\r
 public class Derivate implements IExpression {\r
 \r
        private Variable variable;\r
@@ -26,12 +28,32 @@ public class Derivate implements IExpression {
        \r
        @Override\r
        public Object evaluate(IEnvironment _environment) {\r
-               Environment environment = (Environment)_environment;\r
-//             Double old = (Double)environment.getValue(variable.name + variable.subscriptKey());\r
-               Double old = (Double)environment.getValue(variable.base.index(_environment, subscripts));\r
+               final Environment environment = (Environment)_environment;\r
+               Object old = variable.evaluate(environment);\r
+               \r
                // FIXME: should not be fixed like this\r
                if(old == null) old = 0.0;\r
-               return old+environment.step*(Double)e.evaluate(environment);\r
+               Object eval = e.evaluate(environment);\r
+               if(eval instanceof Double) {\r
+                       return ((Double)old)+environment.step*(Double)eval;\r
+               } else if (eval instanceof Array) {\r
+                       Array arr = (Array)eval;\r
+                       Array oldArray = (Array)old;\r
+                       \r
+                       return oldArray.copy2(arr, new Modifier2() {\r
+\r
+                               @Override\r
+                               public Object modify(Object o1, Object o2) {\r
+                                       Double oldValue = (Double)o1;\r
+                                       Double der = (Double)o2;\r
+                                       return oldValue + environment.step*der;\r
+                               }\r
+                               \r
+                       });\r
+                       \r
+               } else {\r
+                       throw new UnsupportedOperationException();\r
+               }\r
        }\r
        \r
        @Override\r
index d8d357feb3d30d9aab731dda97ebf948641916bf..42ce059792b360260257ad30cc2b3ec4733a89cf 100644 (file)
@@ -12,6 +12,8 @@ package fi.semantum.sysdyn.solver;
 \r
 import java.util.Map;\r
 \r
+import fi.semantum.sysdyn.solver.Array.Modifier;\r
+\r
 public class Division implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -27,16 +29,17 @@ public class Division implements IExpression {
        return exp1 + " / " + exp2;\r
     }\r
     \r
-    private Array arrayDiv(Array a, Double d) {\r
-       Array result = new Array();\r
-       for(Object o : a.elements()) {\r
-               if(o instanceof Double) {\r
-                       result.addElement((Double)o/d);\r
-               } else {\r
-                       throw new IllegalStateException();\r
-               }\r
-       }\r
-       return result;\r
+    private Array arrayDiv(Array a, final Double d) {\r
+       return a.copy(new Modifier() {\r
+                       @Override\r
+                       public Object modify(Object o) {\r
+                       if(o instanceof Double) {\r
+                               return ((Double)o)/d;\r
+                       } else {\r
+                               throw new IllegalStateException();\r
+                       }\r
+                       }\r
+               });\r
     }\r
     \r
        @Override\r
diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseAddition.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseAddition.java
new file mode 100644 (file)
index 0000000..ff08ca6
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 Semantum Oy.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+import java.util.Map;\r
+\r
+import fi.semantum.sysdyn.solver.Array.Modifier2;\r
+\r
+public class ElementwiseAddition implements IExpression {\r
+       \r
+    public IExpression exp1;\r
+    public IExpression exp2;\r
+    \r
+    public ElementwiseAddition(IExpression exp1, IExpression exp2) {\r
+       this.exp1 = exp1;\r
+       this.exp2 = exp2;\r
+    }\r
+    \r
+    @Override\r
+    public String toString() {\r
+       return exp1 + " + " + exp2;\r
+    }\r
+    \r
+       @Override\r
+       public Object evaluate(IEnvironment environment) {\r
+               Object o1 = exp1.evaluate(environment);\r
+               Object o2 = exp2.evaluate(environment);\r
+               if(o1 == null || o2 == null) return null; \r
+               if(o1 instanceof Double && o2 instanceof Double) {\r
+                       return (Double)o1 + (Double)o2;\r
+               }\r
+               if(o1 instanceof Array && o2 instanceof Array) {\r
+                       Array la = (Array)o1;\r
+                       Array ra = (Array)o2;\r
+                       return la.copy2(ra, new Modifier2() {\r
+                               \r
+                               @Override\r
+                               public Object modify(Object o1, Object o2) {\r
+                                       if(o1 instanceof Double && o2 instanceof Double) return ((Double)o1)+((Double)o2);\r
+                                       throw new IllegalStateException("Tried to add a non-numerical array");\r
+                               }\r
+                       });\r
+               }\r
+               throw new IllegalStateException();\r
+       }\r
+       \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new ElementwiseAddition(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp1 = exp1.rewrite(frame, copies);\r
+               exp2 = exp2.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
+       @Override\r
+       public void accept(ExpressionVisitor visitor) {\r
+               visitor.visit(this);\r
+               exp1.accept(visitor);\r
+               exp2.accept(visitor);\r
+       }\r
+       \r
+}\r
index 77362aa55ac60b302fdaef36d042ad86aecc58a3..ffb93df7ad7b2d1afd247310064e6592cd5affcb 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
-import java.util.Collection;\r
-import java.util.Iterator;\r
 import java.util.Map;\r
 \r
+import fi.semantum.sysdyn.solver.Array.Modifier;\r
+import fi.semantum.sysdyn.solver.Array.Modifier2;\r
+\r
 public class ElementwiseDivision implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -36,29 +37,41 @@ public class ElementwiseDivision implements IExpression {
                if(left instanceof Array && right instanceof Array) {\r
                        Array la = (Array)left;\r
                        Array ra = (Array)right;\r
-                       Collection<Object> lae = la.elements();\r
-                       Collection<Object> rae = ra.elements();\r
-                       if(lae.size() != rae.size()) throw new UnsupportedOperationException();\r
-                       Iterator<Object> li = lae.iterator();\r
-                       Iterator<Object> ri = rae.iterator();\r
-                       Array result = new Array();\r
-                       for(int i=0;i<lae.size();i++) {\r
-                               double ld = (Double)li.next();\r
-                               double rd = (Double)ri.next();\r
-                               result.addElement(ld/rd);\r
-                       }\r
-                       return result;\r
+                       return la.copy2(ra, new Modifier2() {\r
+                               \r
+                               @Override\r
+                               public Object modify(Object o1, Object o2) {\r
+                                       if(o1 instanceof Double && o2 instanceof Double) return ((Double)o1)/((Double)o2);\r
+                                       throw new IllegalStateException("Tried to divide a non-numerical array");\r
+                               }\r
+                               \r
+                       });\r
                } else if(left instanceof Array && right instanceof Double) {\r
                        Array la = (Array)left;\r
-                       double rd = (Double)right;\r
-                       Collection<Object> lae = la.elements();\r
-                       Iterator<Object> li = lae.iterator();\r
-                       Array result = new Array();\r
-                       for(int i=0;i<lae.size();i++) {\r
-                               double ld = (Double)li.next();\r
-                               result.addElement(ld/rd);\r
-                       }\r
-                       return result;\r
+                       final double rd = (Double)right;\r
+                       return la.copy(new Modifier() {\r
+\r
+                               @Override\r
+                               public Object modify(Object o) {\r
+                                       if(o instanceof Double) return ((Double)o)/rd;\r
+                                       else throw new IllegalStateException("Tried to divide a non-numerical array");\r
+                               }\r
+                               \r
+                       });\r
+               } else if(left instanceof Double && right instanceof Array) {\r
+                       Array la = (Array)right;\r
+                       final double rd = (Double)left;\r
+                       return la.copy(new Modifier() {\r
+\r
+                               @Override\r
+                               public Object modify(Object o) {\r
+                                       if(o instanceof Double) return rd / ((Double)o);\r
+                                       else throw new IllegalStateException("Tried to divide a non-numerical array");\r
+                               }\r
+                               \r
+                       });\r
+               } else if(left instanceof Double && right instanceof Double) {\r
+                       return ((Double)left)/((Double)right);\r
                } else {\r
                        throw new UnsupportedOperationException();\r
                }\r
index 6fac7280f2da4b7734e414ebfb97175671ee798d..15ac7bc56a116149c58bd159e53dc2a0961a15f1 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
-import java.util.Collection;\r
-import java.util.Iterator;\r
 import java.util.Map;\r
 \r
+import fi.semantum.sysdyn.solver.Array.Modifier;\r
+import fi.semantum.sysdyn.solver.Array.Modifier2;\r
+\r
 public class ElementwisePower implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -36,19 +37,41 @@ public class ElementwisePower implements IExpression {
                if(left instanceof Array && right instanceof Array) {\r
                        Array la = (Array)left;\r
                        Array ra = (Array)right;\r
-                       Collection<Object> lae = la.elements();\r
-                       Collection<Object> rae = ra.elements();\r
-                       if(lae.size() != rae.size()) throw new UnsupportedOperationException();\r
-                       Iterator<Object> li = lae.iterator();\r
-                       Iterator<Object> ri = rae.iterator();\r
-                       Array result = new Array();\r
-                       for(int i=0;i<lae.size();i++) {\r
-                               double ld = (Double)li.next();\r
-                               double rd = (Double)ri.next();\r
-                               result.addElement(Math.pow(ld,rd));\r
-                       }\r
-                       return result;\r
-               } else throw new UnsupportedOperationException();\r
+                       return la.copy2(ra, new Modifier2() {\r
+                               \r
+                               @Override\r
+                               public Object modify(Object o1, Object o2) {\r
+                                       if(o1 instanceof Double && o2 instanceof Double) return Math.pow((Double)o1,(Double)o2);\r
+                                       throw new IllegalStateException("Tried to pow a non-numerical array");\r
+                               }\r
+                       });\r
+               } else if (left instanceof Array && right instanceof Double) {\r
+                       Array la = (Array)left;\r
+                       final double rd = (Double)right;\r
+                       return la.copy(new Modifier() {\r
+\r
+                               @Override\r
+                               public Object modify(Object o) {\r
+                                       if(o instanceof Double) return Math.pow((Double)o,rd);\r
+                                       else throw new IllegalStateException("Tried to pow a non-numerical array");\r
+                               }\r
+                               \r
+                       });\r
+               } else if (left instanceof Double && right instanceof Array) {\r
+                       Array la = (Array)right;\r
+                       final double rd = (Double)left;\r
+                       return la.copy(new Modifier() {\r
+\r
+                               @Override\r
+                               public Object modify(Object o) {\r
+                                       if(o instanceof Double) return Math.pow(rd,(Double)o);\r
+                                       else throw new IllegalStateException("Tried to pow a non-numerical array");\r
+                               }\r
+                               \r
+                       });\r
+               } else {\r
+                       throw new UnsupportedOperationException();\r
+               }\r
        }\r
        \r
        @Override\r
index f87529c53fe4e52cb2d59ec303b05f27fa0347b1..b15f67819bb671cc2a66b2bfac1a335f1c4c7c3e 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
-import java.util.Collection;\r
-import java.util.Iterator;\r
-import java.util.List;\r
 import java.util.Map;\r
 \r
+import fi.semantum.sysdyn.solver.Array.Modifier;\r
+import fi.semantum.sysdyn.solver.Array.Modifier2;\r
+\r
 public class ElementwiseProduct implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -37,27 +37,38 @@ public class ElementwiseProduct implements IExpression {
                if(left instanceof Array && right instanceof Array) {\r
                        Array la = (Array)left;\r
                        Array ra = (Array)right;\r
-                       List<Object> lae = la.elements();\r
-                       List<Object> rae = ra.elements();\r
-                       if(lae.size() != rae.size()) throw new UnsupportedOperationException();\r
-                       Array result = new Array(lae.size());\r
-                       int index = 0;\r
-                       for(Object o : lae) {\r
-                               Double ld = (Double)o;\r
-                               Double rd = (Double)rae.get(index++);\r
-                               result.addElement(ld*rd);\r
-                       }\r
-                       return result;\r
+                       return la.copy2(ra, new Modifier2() {\r
+                               \r
+                               @Override\r
+                               public Object modify(Object o1, Object o2) {\r
+                                       if(o1 instanceof Double && o2 instanceof Double) return ((Double)o1)*((Double)o2);\r
+                                       throw new IllegalStateException("Tried to multiply a non-numerical array");\r
+                               }\r
+                       });\r
                } else if (left instanceof Array && right instanceof Double) {\r
                        Array la = (Array)left;\r
-                       Double rd = (Double)right;\r
-                       List<Object> lae = la.elements();\r
-                       Array result = new Array(lae.size());\r
-                       for(Object o : lae) {\r
-                               Double ld = (Double)o;\r
-                               result.addElement(ld*rd);\r
-                       }\r
-                       return result;\r
+                       final double rd = (Double)right;\r
+                       return la.copy(new Modifier() {\r
+\r
+                               @Override\r
+                               public Object modify(Object o) {\r
+                                       if(o instanceof Double) return ((Double)o)*rd;\r
+                                       else throw new IllegalStateException("Tried to multiply a non-numerical array");\r
+                               }\r
+                               \r
+                       });\r
+               } else if (left instanceof Double && right instanceof Array) {\r
+                       Array la = (Array)right;\r
+                       final double rd = (Double)left;\r
+                       return la.copy(new Modifier() {\r
+\r
+                               @Override\r
+                               public Object modify(Object o) {\r
+                                       if(o instanceof Double) return ((Double)o)*rd;\r
+                                       else throw new IllegalStateException("Tried to multiply a non-numerical array");\r
+                               }\r
+                               \r
+                       });\r
                } else {\r
                        throw new UnsupportedOperationException();\r
                }\r
diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseSubtraction.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseSubtraction.java
new file mode 100644 (file)
index 0000000..55a3662
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 Semantum Oy.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+import java.util.Map;\r
+\r
+import fi.semantum.sysdyn.solver.Array.Modifier2;\r
+\r
+public class ElementwiseSubtraction implements IExpression {\r
+       \r
+    public IExpression exp1;\r
+    public IExpression exp2;\r
+    \r
+    public ElementwiseSubtraction(IExpression exp1, IExpression exp2) {\r
+       if(exp1 == null) exp1 = new Constant("0");\r
+       this.exp1 = exp1;\r
+       this.exp2 = exp2;\r
+    }\r
+    \r
+    @Override\r
+    public String toString() {\r
+       return exp1 + " - " + exp2;\r
+    }\r
+    \r
+       @Override\r
+       public Object evaluate(IEnvironment environment) {\r
+               Object o1 = exp1.evaluate(environment);\r
+               Object o2 = exp2.evaluate(environment);\r
+               if(o1 == null || o2 == null) return null; \r
+               if(o1 instanceof Double && o2 instanceof Double) {\r
+                       return (Double)o1 - (Double)o2;\r
+               }\r
+               if(o1 instanceof Array && o2 instanceof Array) {\r
+                       Array la = (Array)o1;\r
+                       Array ra = (Array)o2;\r
+                       return la.copy2(ra, new Modifier2() {\r
+                               \r
+                               @Override\r
+                               public Object modify(Object o1, Object o2) {\r
+                                       if(o1 instanceof Double && o2 instanceof Double) return ((Double)o1)-((Double)o2);\r
+                                       throw new IllegalStateException("Tried to subtract a non-numerical array");\r
+                               }\r
+                       });\r
+               }\r
+               throw new IllegalStateException();\r
+       }\r
+       \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new ElementwiseSubtraction(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+    \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp1 = exp1.rewrite(frame, copies);\r
+               exp2 = exp2.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
+       @Override\r
+       public void accept(ExpressionVisitor visitor) {\r
+               visitor.visit(this);\r
+               exp1.accept(visitor);\r
+               exp2.accept(visitor);\r
+       }\r
+       \r
+}\r
index d3cfce2490c8b009ac9880d231619e39f3c29b91..135410d7283d6e4f1abd23901ffdc2232c0e5ab2 100644 (file)
@@ -11,6 +11,7 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import fi.semantum.sysdyn.solver.Array.Modifier;\r
 import gnu.trove.list.array.TIntArrayList;\r
 import gnu.trove.map.hash.TObjectIntHashMap;\r
 \r
@@ -28,7 +29,7 @@ interface Fn {
        public Object evaluateInput(IEnvironment environment, int argPosition);\r
        public void setLocals(IEnvironment environment);\r
        public int offset();\r
-       public Variable[] parameters();\r
+       public Variable[] parameters(int args);\r
 }\r
 \r
 abstract class Fn1 implements Fn {\r
@@ -36,17 +37,25 @@ abstract class Fn1 implements Fn {
        Variable[] parameters;\r
        \r
        public Fn1(int pCount) {\r
-               parameters = new Variable[pCount];\r
-               for(int i=0;i<pCount;i++)\r
-                       parameters[i] = new Variable(new VariableBase("", i));\r
+               if(pCount > 0) {\r
+                       parameters = new Variable[pCount];\r
+                       for(int i=0;i<pCount;i++)\r
+                               parameters[i] = new Variable(new VariableBase("", i));\r
+               }\r
        }\r
        \r
        public int offset() {\r
                return 0;\r
        }\r
        \r
-       public Variable[] parameters() {\r
-               return parameters;\r
+       public Variable[] parameters(int argc) {\r
+               if(parameters != null) return parameters;\r
+               else {\r
+                       Variable[] ret = new Variable[argc];\r
+                       for(int i=0;i<argc;i++)\r
+                               ret[i] = new Variable(new VariableBase("", i));\r
+                       return ret;\r
+               }\r
        }\r
        \r
        @Override\r
@@ -271,24 +280,164 @@ final public class Environment implements IEnvironment, ISystem {
                        @Override\r
                        public Object evaluate(IEnvironment environment, int argc) {\r
                                Object value = environment.getValue(0);\r
-                               Double result = (Double)value;\r
-                               double res = result.intValue(); \r
-                               return res;\r
+                               if(value instanceof Double) {\r
+                                       double d = ((Double)value).intValue(); \r
+                                       return d;\r
+                               } else if(value instanceof Array) {\r
+                                       return ((Array)value).copy(new Modifier() {\r
+\r
+                                               @Override\r
+                                               public Object modify(Object o) {\r
+                                                       if(o instanceof Double) {\r
+                                                               double d = ((Double)o).intValue(); \r
+                                                               return d;\r
+                                                       } else {\r
+                                                               throw new IllegalStateException();\r
+                                                       }\r
+                                               }\r
+                                               \r
+                                       });\r
+                               } else {\r
+                                       throw new IllegalStateException();\r
+                               }\r
                        }\r
                        \r
                });\r
-               model.functions.put("sum", new Fn1(1) {\r
+               model.functions.put("ceil", new Fn1(1) {\r
 \r
                        @Override\r
                        public Object evaluate(IEnvironment environment, int argc) {\r
                                Object value = environment.getValue(0);\r
-                               Array arr = (Array)value;\r
+                               if(value instanceof Double) {\r
+                                       return Math.ceil((Double)value);\r
+                               } else if(value instanceof Array) {\r
+                                       return ((Array)value).copy(new Modifier() {\r
+\r
+                                               @Override\r
+                                               public Object modify(Object o) {\r
+                                                       if(o instanceof Double) {\r
+                                                               return Math.ceil((Double)o);\r
+                                                       } else {\r
+                                                               throw new IllegalStateException();\r
+                                                       }\r
+                                               }\r
+                                               \r
+                                       });\r
+                               } else {\r
+                                       throw new IllegalStateException();\r
+                               }\r
+                       }\r
+                       \r
+               });\r
+               model.functions.put("floor", new Fn1(1) {\r
+\r
+                       @Override\r
+                       public Object evaluate(IEnvironment environment, int argc) {\r
+                               Object value = environment.getValue(0);\r
+                               if(value instanceof Double) {\r
+                                       return Math.floor((Double)value);\r
+                               } else if(value instanceof Array) {\r
+                                       return ((Array)value).copy(new Modifier() {\r
+\r
+                                               @Override\r
+                                               public Object modify(Object o) {\r
+                                                       if(o instanceof Double) {\r
+                                                               return Math.floor((Double)o);\r
+                                                       } else {\r
+                                                               throw new IllegalStateException();\r
+                                                       }\r
+                                               }\r
+                                               \r
+                                       });\r
+                               } else {\r
+                                       throw new IllegalStateException();\r
+                               }\r
+                       }\r
+                       \r
+               });\r
+               model.functions.put("sum", new Fn1(1) {\r
+\r
+                       public double sum(Array a) {\r
                                double res = 0;\r
-                               for(Object o : arr.elements())\r
-                                       res += (Double)o;\r
+                               for(Object element : a.elements()) {\r
+                                       if(element instanceof Array) {\r
+                                               res += sum((Array)element);\r
+                                       } else if(element instanceof Double) {\r
+                                               res += (Double)element;\r
+                                       } else {\r
+                                               throw new IllegalStateException("Tried to sum a non-numerical array");\r
+                                       }\r
+                               }\r
                                return res;\r
                        }\r
                        \r
+                       @Override\r
+                       public Object evaluate(IEnvironment environment, int argc) {\r
+                               Object value = environment.getValue(0);\r
+                               if(value instanceof Double) return (Double)value;\r
+                               Array arr = (Array)value;\r
+                               return sum(arr);\r
+                       }\r
+                       \r
+               });\r
+               model.functions.put("ones", new Fn1(-1) {\r
+\r
+                       private Array make(int[] dims, int pos) {\r
+                               Array result = new Array();\r
+                               int d = dims[pos];\r
+                               if(pos == dims.length - 1) {\r
+                                       for(int i=0;i<d;i++) result.addElement(1.0);\r
+                               } else {\r
+                                       for(int i=0;i<d;i++) result.addElement(make(dims, pos+1));\r
+                               }\r
+                               return result;\r
+                       }\r
+                       \r
+                       @Override\r
+                       public Object evaluate(IEnvironment environment, int argc) {\r
+                               int[] dims = new int[argc];\r
+                               for(int i=0;i<argc;i++) {\r
+                                       Double d = (Double)environment.getValue(i);\r
+                                       dims[i] = d.intValue();\r
+                               }\r
+                               return make(dims, 0);\r
+                       }\r
+                       \r
+               });\r
+               model.functions.put("zeros", new Fn1(-1) {\r
+\r
+                       private Array make(int[] dims, int pos) {\r
+                               Array result = new Array();\r
+                               int d = dims[pos];\r
+                               if(pos == dims.length - 1) {\r
+                                       for(int i=0;i<d;i++) result.addElement(0.0);\r
+                               } else {\r
+                                       for(int i=0;i<d;i++) result.addElement(make(dims, pos+1));\r
+                               }\r
+                               return result;\r
+                       }\r
+                       \r
+                       @Override\r
+                       public Object evaluate(IEnvironment environment, int argc) {\r
+                               int[] dims = new int[argc];\r
+                               for(int i=0;i<argc;i++) {\r
+                                       Double d = (Double)environment.getValue(i);\r
+                                       dims[i] = d.intValue();\r
+                               }\r
+                               return make(dims, 0);\r
+                       }\r
+                       \r
+               });\r
+               model.functions.put("transpose", new Fn1(1) {\r
+\r
+                       @Override\r
+                       public Object evaluate(IEnvironment environment, int argc) {\r
+                               \r
+                               Array array = (Array)environment.getValue(0);\r
+                               return array.transposed();\r
+                               \r
+                       }\r
+                       \r
                });\r
                model.functions.put("delay", new Fn1(4) {\r
                        \r
diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ExecutionException.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ExecutionException.java
new file mode 100644 (file)
index 0000000..ebea363
--- /dev/null
@@ -0,0 +1,18 @@
+package fi.semantum.sysdyn.solver;\r
+\r
+public class ExecutionException extends RuntimeException {\r
+\r
+       private static final long serialVersionUID = 8394963990462508948L;\r
+       \r
+       public int line = -1;\r
+       \r
+       public ExecutionException(String message) {\r
+               super(message);\r
+       }\r
+\r
+       public ExecutionException(String message, int line) {\r
+               super(message);\r
+               this.line = line;\r
+       }\r
+\r
+}\r
index 5dedd79ef39f9a3c23b868507cde8e83517cfa75..bd487b19449f3a9d9dbf08830604fea9fa9659b9 100644 (file)
@@ -27,23 +27,28 @@ public class ForStatement implements IStatement {
                return "for " + indices + " loop "+ statement + " end for";\r
        }\r
        \r
-       private void loop(IEnvironment environment, int i) {\r
+       private ReturnValue loop(IEnvironment environment, int i) {\r
                if(i == indices.size()) {\r
-                       statement.evaluate(environment);\r
-                       return;\r
+                       ReturnValue ret = statement.evaluate(environment);\r
+                       if(ReturnValue.BREAK.equals(ret)) return ReturnValue.CONTINUE;\r
+                       else if(ReturnValue.RETURN.equals(ret)) return ReturnValue.RETURN;\r
+                       else return ReturnValue.CONTINUE;\r
                } else {\r
                        ForIndex index = indices.get(i);\r
                        Array array = (Array)index.expression.evaluate(environment);\r
                        for(Object element : array.elements()) {\r
                                environment.put(index.base.index, element);\r
-                               loop(environment, i+1);\r
+                               ReturnValue ret = loop(environment, i+1);\r
+                               if(ReturnValue.BREAK.equals(ret)) return ReturnValue.CONTINUE;\r
+                               else if(ReturnValue.RETURN.equals(ret)) return ReturnValue.RETURN;\r
                        }\r
+                       return ReturnValue.CONTINUE;\r
                }\r
        }\r
        \r
        @Override\r
-       public void evaluate(IEnvironment environment) {\r
-               loop(environment, 0);\r
+       public ReturnValue evaluate(IEnvironment environment) {\r
+               return loop(environment, 0);\r
        }\r
        \r
 }\r
index 3c32e6e98901dd2f076cefd6813a419c6249dc83..f78c04a6b68634f5811fe1fd2a54203263b87d28 100644 (file)
@@ -28,10 +28,13 @@ final public class Function implements Fn, IFrame {
        public Variable[] parameters;\r
        \r
        public ArrayList<ForIndex> indices = new ArrayList<ForIndex>();\r
+       \r
+       public int line;\r
 \r
-       public Function(String name, IStatement statement) {\r
+       public Function(String name, IStatement statement, int line) {\r
                this.name = name;\r
                this.statement = statement;\r
+               this.line = line;\r
        }\r
        \r
        public Object evaluate(IEnvironment environment, int argc) {\r
@@ -48,7 +51,12 @@ final public class Function implements Fn, IFrame {
                }\r
                for(int i=0;i<internals.size();i++) {\r
                        VariableDeclaration decl = internals.get(i);\r
-                       decl.variable.assignPlain(environment, null);\r
+                       if(decl.modification.args.length == 1) {\r
+                               Object o = decl.modification.args[0].modification.evaluate(environment);\r
+                               decl.variable.assignPlain(environment, o);\r
+                       } else {\r
+                               decl.variable.assignPlain(environment, null);\r
+                       }\r
                }\r
        }\r
        \r
@@ -106,7 +114,7 @@ final public class Function implements Fn, IFrame {
        }\r
        \r
        @Override\r
-       public Variable[] parameters() {\r
+       public Variable[] parameters(int argc) {\r
                return parameters;\r
        }\r
        \r
index e91f0ffc6bcd5203bea79fe6f2ef29bd23830dce..5735e4b6c6a1618c0a628ff26c547dfa34cd21f0 100644 (file)
@@ -29,7 +29,9 @@ public class GreaterThan implements IExpression {
     \r
        @Override\r
        public Object evaluate(IEnvironment environment) {\r
-               return ((Double)exp1.evaluate(environment)) > ((Double)exp2.evaluate(environment));\r
+               Object left = exp1.evaluate(environment);\r
+               Object right = exp2.evaluate(environment);\r
+               return ((Double)left) > ((Double)right);\r
        }\r
 \r
        @Override\r
index e50a09bc6b77846d8f5cd0345d5ff4bec27e87b1..efb5472f95fb2efb3640d5cdde7c4ff3b8116bba 100644 (file)
@@ -12,6 +12,10 @@ package fi.semantum.sysdyn.solver;
 \r
 public interface IStatement {\r
 \r
-       public void evaluate(IEnvironment environment);\r
+       public enum ReturnValue {\r
+               CONTINUE,BREAK,RETURN;\r
+       }\r
+       \r
+       public ReturnValue evaluate(IEnvironment environment);\r
        \r
 }\r
index 37dc2af26714582c0d0e885d8e185d90e231d900..8fb020e7e5a37fecfed662e70604583208db5636 100644 (file)
@@ -28,11 +28,11 @@ public class IfStatement implements IStatement {
     }\r
     \r
        @Override\r
-       public void evaluate(IEnvironment environment) {\r
+       public ReturnValue evaluate(IEnvironment environment) {\r
                if((Boolean)exp.evaluate(environment)) {\r
-                       t.evaluate(environment);\r
+                       return t.evaluate(environment);\r
                } else {\r
-                       e.evaluate(environment);\r
+                       return e.evaluate(environment);\r
                }\r
        }\r
     \r
index e4b1337a5a10522972e4c36a193543caf976f0cd..ab861d89034a5da8b5726e88d7f5a42ba512508c 100644 (file)
@@ -13,6 +13,7 @@ package fi.semantum.sysdyn.solver;
 import java.util.ArrayList;\r
 import java.util.Arrays;\r
 import java.util.HashMap;\r
+import java.util.List;\r
 import java.util.Map;\r
 import java.util.TreeMap;\r
 \r
@@ -39,6 +40,7 @@ class Model implements IFrame {
        \r
        public final Globals globals;\r
        \r
+       public int line = -1;\r
        public String name;\r
        public boolean isEnumClass;\r
        \r
@@ -81,6 +83,16 @@ class Model implements IFrame {
                return base;\r
        }\r
        \r
+       private void reportException(Fn fn, ExecutionException e) throws ExecutionException {\r
+               \r
+               if(fn instanceof Function) {\r
+                       throw new ExecutionException("function " + name + ": " + (e.line - ((Function)fn).line) + ": " + e.getMessage());\r
+               } else {\r
+                       throw new ExecutionException("function " + name + ": " + (e.line - ((Function)fn).line) + ": " + e.getMessage());\r
+               }\r
+               \r
+       }\r
+       \r
        public Object evaluateFunction(IEnvironment environment, String name, ArgumentList args) {\r
                Fn fn = getFunction(name);\r
                if(fn == null) {\r
@@ -98,7 +110,7 @@ class Model implements IFrame {
                                argh.add(args.args[i].modification.evaluate(environment));\r
                        }\r
                        \r
-                       Variable[] parameters = fn.parameters();\r
+                       Variable[] parameters = fn.parameters(argh.size());\r
                        \r
                        for(int i=0;i<args.args.length+1;i++) {\r
                                Variable var = parameters[i];\r
@@ -108,7 +120,15 @@ class Model implements IFrame {
 \r
                        fn.setLocals(frame);\r
                        \r
-                       return fn.evaluate(frame, args.args.length+1);\r
+                       try {\r
+                       \r
+                               return fn.evaluate(frame, args.args.length+1);\r
+                               \r
+                       } catch (ExecutionException e) {\r
+                               \r
+                               reportException(fn, e);\r
+                               \r
+                       }\r
                        \r
                } else {\r
                        \r
@@ -121,24 +141,112 @@ class Model implements IFrame {
                                argh.add(arg);\r
                        }\r
                        \r
-                       Variable[] parameters = fn.parameters();\r
+                       Variable[] parameters = fn.parameters(args.args.length);\r
+                       Object[] ps = new Object[parameters.length];\r
+                       boolean vector[] = new boolean[parameters.length];\r
                        \r
+                       int vectorDimension = 0;\r
+                       ArrayList<Array> arrs = new ArrayList<Array>();\r
                        for(int i=0;i<parameters.length;i++) {\r
                                Variable var = parameters[i];\r
                                if(i < argh.size()) {\r
-                                       Object value = argh.get(i);\r
-                                       var.assignPlain(frame, value);\r
+                                       ps[i] = argh.get(i);\r
                                } else {\r
-                                       Object value = fn.evaluateInput(environment, i);\r
-                                       var.assignPlain(frame, value);\r
+                                       ps[i] = fn.evaluateInput(environment, i);\r
+                               }\r
+                               if(var.base.dimensions == null && ps[i] instanceof Array) {\r
+                                       int dim = ((Array)ps[i]).dimension();\r
+                                       if(vectorDimension > 0 && dim != vectorDimension) throw new IllegalStateException("Array dimensions do not agree");\r
+                                       vectorDimension = dim;\r
+                                       vector[i] = true;\r
+                                       arrs.add((Array)ps[i]);\r
+                               } else {\r
+                                       vector[i] = false;\r
                                }\r
                        }\r
                        \r
-                       fn.setLocals(frame);\r
-                       return fn.evaluate(frame, args.args.length);\r
+                       if(vectorDimension > 0) {\r
+                               \r
+                               return arrayEvaluate(frame, fn, parameters, ps, vector, arrs);\r
+                               \r
+                       } else {\r
+                       \r
+                               for(int i=0;i<parameters.length;i++) {\r
+                                       parameters[i].assignPlain(frame, ps[i]);\r
+                               }\r
+                               \r
+                               fn.setLocals(frame);\r
+                               \r
+                               try {\r
+\r
+                                       return fn.evaluate(frame, args.args.length); \r
+\r
+                               } catch (ExecutionException e) {\r
+\r
+                                       reportException(fn, e);\r
+\r
+                               }\r
+                               \r
+                       }\r
                        \r
                }\r
                        \r
+               // This cannot happen - reportException always throws\r
+               throw new IllegalStateException();\r
+               \r
+       }\r
+       \r
+       private Array arrayEvaluate(Frame frame, Fn fn, Variable[] parameters, Object[] ps, boolean[] vector, List<Array> arrs) {\r
+               \r
+               Array result = new Array();\r
+\r
+               Array first = arrs.get(0);\r
+               \r
+               int d = first.elements().size();\r
+               if(d == 0) return result;\r
+\r
+               Object firstElement = first.element(0);\r
+               boolean subArray = firstElement instanceof Array;\r
+               \r
+               for(int i=0;i<d;i++) {\r
+\r
+                       int vectorIndex = 0;\r
+\r
+                       if(subArray) {\r
+\r
+                               ArrayList<Array> subArrs = new ArrayList<Array>();\r
+                               for(int j=0;j<parameters.length;j++) {\r
+                                       if(vector[j]) {\r
+                                               Array a = arrs.get(vectorIndex++);\r
+                                               Array sub = (Array)a.element(i);\r
+                                               subArrs.add(sub);\r
+                                       }\r
+                               }\r
+                               \r
+                               result.addElement(arrayEvaluate(frame, fn, parameters, ps, vector, subArrs));\r
+\r
+                       } else {\r
+\r
+                               for(int j=0;j<parameters.length;j++) {\r
+                                       if(vector[j]) {\r
+                                               Array a = arrs.get(vectorIndex++);\r
+                                               Object sub = a.element(i);\r
+                                               parameters[j].assignPlain(frame, sub);\r
+                                       } else {\r
+                                               parameters[j].assignPlain(frame, ps[j]);\r
+                                       }\r
+                               }\r
+\r
+                               fn.setLocals(frame);\r
+                               Object ret = fn.evaluate(frame, parameters.length);\r
+                               result.addElement(ret);\r
+                               \r
+                       }\r
+                       \r
+               }                       \r
+               \r
+               return result;\r
+\r
        }\r
        \r
        private VariableBase resolveCopy(Map<String,VariableBase> work, VariableBase target) {\r
index ff330375b3f89752e99f7c4a80be10dc0fe9af01..f7c5083fb9cf484ca653d0b62dc63a808e08dd8c 100644 (file)
@@ -30,12 +30,13 @@ public class MultiStatement implements IStatement {
     }\r
     \r
     @Override\r
-    public void evaluate(IEnvironment environment) {\r
+    public ReturnValue evaluate(IEnvironment environment) {\r
        @SuppressWarnings("unchecked")\r
        ArrayList<Object> values = (ArrayList<Object>)environment.getSystem().evaluateFunction(environment, fn.base.name, args);\r
        for(int i=0;i<targets.size();i++) {\r
                targets.get(i).assignPlain(environment, values.get(i));\r
        }\r
+       return ReturnValue.CONTINUE;\r
     }\r
     \r
 }\r
index e4d29b2cd32b62b81d961dd61bbd9c22e866be8e..97791824bc142a658d0136f550db7dcd0b19317a 100644 (file)
@@ -38,7 +38,13 @@ public class Multiplication implements IExpression {
                else if(left instanceof Array && right instanceof Array) {\r
                        Array la = (Array)left;\r
                        Array ra = (Array)right;\r
-                       return la.mul(ra);\r
+                       if(la.isVector && ra.isVector) {\r
+                               return la.inner(ra);\r
+                       } else if(ra.isVector) {\r
+                               return la.matrixMulVector(ra);\r
+                       } else {\r
+                               return la.matrixMulMatrix(ra);\r
+                       }\r
                }\r
                else if (left instanceof Array && right instanceof Double) return ((Array)left).mul((Double)right);\r
                else if (left instanceof Double && right instanceof Array) return ((Array)right).mul((Double)left);\r
index 8cdad84e33600d9cc922fcd3cfde66aded68cb35..979594514bdc945c006f5d98cde70cc7e6c9035f 100644 (file)
@@ -12,6 +12,8 @@ package fi.semantum.sysdyn.solver;
 \r
 import java.util.Map;\r
 \r
+import fi.semantum.sysdyn.solver.Array.Modifier;\r
+\r
 public class Negation implements IExpression {\r
        \r
     public IExpression exp;\r
@@ -27,9 +29,26 @@ public class Negation implements IExpression {
     \r
        @Override\r
        public Object evaluate(IEnvironment environment) {\r
-               Double d = (Double)exp.evaluate(environment);\r
-               if(d == null) return null;\r
-               return -d;\r
+               Object value = exp.evaluate(environment);\r
+               if(value == null) return null;\r
+               if(value instanceof Double) {\r
+                       return -((Double)value); \r
+               } else if(value instanceof Array) {\r
+                       return ((Array)value).copy(new Modifier() {\r
+\r
+                               @Override\r
+                               public Object modify(Object o) {\r
+                                       if(o instanceof Double) {\r
+                                               return -((Double)o); \r
+                                       } else {\r
+                                               throw new IllegalStateException();\r
+                                       }\r
+                               }\r
+                               \r
+                       });\r
+               } else {\r
+                       throw new IllegalStateException();\r
+               }\r
        }\r
     \r
        @Override\r
index e2c722d75702dbc561d1da36c69f9842f7a6b062..32695d7417049f5454c02d48c93c459925b87dd5 100644 (file)
@@ -74,12 +74,12 @@ public class Parser {
                        IExpression exp = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
                        if(v instanceof Derivative) {\r
                                Derivative der = (Derivative)v;\r
-                               Assignment eq = new Assignment(der.variable, der.variable.subscripts, new Derivate(der.variable, der.variable.subscripts, exp));\r
+                               Assignment eq = new Assignment(model, der.variable, der.variable.subscripts, new Derivate(der.variable, der.variable.subscripts, exp));\r
                                model.derivatives.add(eq);\r
                                return eq;\r
                        } else {\r
                                Variable var = (Variable)v;\r
-                               Assignment eq = new Assignment(var, var.subscripts, exp);\r
+                               Assignment eq = new Assignment(model, var, var.subscripts, exp);\r
                                if(model.initial)\r
                                        model.initials.add(eq);\r
                                else\r
@@ -153,7 +153,15 @@ public class Parser {
 //                                     | when_statement() )\r
 //                             comment() \r
                        \r
-                       if(n.jjtGetNumChildren() == 1) {\r
+                       if(n.jjtGetNumChildren() == 0) {\r
+                               if("break".equals(n.op)) {\r
+                                       return new Break();\r
+                               } else if ("return".equals(n.op)) {\r
+                                       return new Return();\r
+                               } else {\r
+                                       throw new IllegalStateException();\r
+                               }\r
+                       } else if(n.jjtGetNumChildren() == 1) {\r
                                return (IStatement)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                        } else if (n.jjtGetNumChildren() == 2) {\r
                                SimpleNode n0 = (SimpleNode)n.jjtGetChild(1);\r
@@ -330,18 +338,18 @@ public class Parser {
                        return subs;\r
                case declaration:\r
                        if(n.jjtGetNumChildren() == 0) {\r
-                               return new Declaration(new Variable(frame, n.op, null), null);\r
+                               return new Declaration(new Variable(frame, n.op, null, n.line), null);\r
                        } else if(n.jjtGetNumChildren() == 1) {\r
                                Object o = walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                                if(o instanceof IExpression[]) {\r
-                                       return new Declaration(new Variable(frame, n.op, (IExpression[])o), null);\r
+                                       return new Declaration(new Variable(frame, n.op, (IExpression[])o, n.line), null);\r
                                } else {\r
-                                       return new Declaration(new Variable(frame, n.op, null), o);\r
+                                       return new Declaration(new Variable(frame, n.op, null, n.line), o);\r
                                }\r
                        } else if(n.jjtGetNumChildren() == 2) {\r
                                IExpression[] subscripts2 = (IExpression[])walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                                Object modification = walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
-                               return new Declaration(new Variable(frame, n.op,subscripts2), modification);\r
+                               return new Declaration(new Variable(frame, n.op,subscripts2, n.line), modification);\r
                        } else {\r
                                StringBuilder b = new StringBuilder();\r
                                b.append("declaration: ");\r
@@ -357,8 +365,9 @@ public class Parser {
                                SimpleNode child = (SimpleNode)n.jjtGetChild(0);\r
                                String packagePath = getPackagePath(child);\r
                                String functionName = packagePath + child.op;\r
+                               System.err.println("function " + functionName + " at line " + child.line);\r
                                ArrayList<IStatement> stms2 = new ArrayList<IStatement>();\r
-                               Function function = new Function(functionName, new StatementList(stms2));\r
+                               Function function = new Function(functionName, new StatementList(stms2), child.line);\r
                                ArrayList<Object> composition = (ArrayList<Object>)walk(child, indent+2, function);\r
                                for(int i=1;i<composition.size();i++) {\r
                                        Object comp = composition.get(i);\r
@@ -376,34 +385,41 @@ public class Parser {
                                                                ArrayList<Object> os = (ArrayList<Object>)os_;\r
                                                                for(Object o : os) {\r
                                                                        VariableDeclaration decl = (VariableDeclaration)o;\r
-                                                                       function.internals.add(decl);\r
+                                                                       if("input".equals(decl.direction)) function.inputs.add(decl);\r
+                                                                       else if ("output".equals(decl.direction)) function.outputs.add(decl);\r
+                                                                       else function.internals.add(decl);\r
                                                                }\r
                                                        }\r
                                                }\r
                                        }\r
                                }\r
-                               ArrayList<Object> declarations = (ArrayList<Object>)composition.get(0);\r
-                               for(Object os_ : declarations) {\r
-                                       if(os_ instanceof VariableDeclaration) {\r
-                                               VariableDeclaration decl = (VariableDeclaration)os_;\r
-                                               if("input".equals(decl.direction)) function.inputs.add(decl);\r
-                                               else if ("output".equals(decl.direction)) function.outputs.add(decl);\r
-                                               else throw new IllegalStateException();\r
-                                       } else {\r
-                                               ArrayList<Object> os = (ArrayList<Object>)os_;\r
-                                               for(Object o : os) {\r
-                                                       VariableDeclaration decl = (VariableDeclaration)o;\r
+                               if(!composition.isEmpty()) {\r
+                                       ArrayList<Object> declarations = (ArrayList<Object>)composition.get(0);\r
+                                       for(Object os_ : declarations) {\r
+                                               if(os_ instanceof VariableDeclaration) {\r
+                                                       VariableDeclaration decl = (VariableDeclaration)os_;\r
                                                        if("input".equals(decl.direction)) function.inputs.add(decl);\r
                                                        else if ("output".equals(decl.direction)) function.outputs.add(decl);\r
-                                                       else throw new IllegalStateException();\r
+                                                       else function.internals.add(decl);\r
+                                               } else {\r
+                                                       ArrayList<Object> os = (ArrayList<Object>)os_;\r
+                                                       for(Object o : os) {\r
+                                                               VariableDeclaration decl = (VariableDeclaration)o;\r
+                                                               if("input".equals(decl.direction)) function.inputs.add(decl);\r
+                                                               else if ("output".equals(decl.direction)) function.outputs.add(decl);\r
+                                                               else function.internals.add(decl);\r
+                                                       }\r
                                                }\r
                                        }\r
                                }\r
+                               \r
                                model.functions.put(functionName, function);\r
                                return function;\r
                                \r
                        } else if("model".equals(n.op)) {\r
 \r
+                               model.line = n.line;\r
+                               \r
                                if(n.jjtGetNumChildren() == 1) {\r
                                        return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                                } else {\r
@@ -419,8 +435,8 @@ public class Parser {
                                walk(specifier, indent+2, clazz);\r
                                \r
                                if(clazz.isEnumClass) {\r
-                                       Variable sizeVariable = new Variable(clazz, "size", null);\r
-                                       Variable elementsVariable = new Variable(clazz, "elements", new IExpression[] { new Constant(""+clazz.variables.size()) });\r
+                                       Variable sizeVariable = new Variable(clazz, "size", null, n.line);\r
+                                       Variable elementsVariable = new Variable(clazz, "elements", new IExpression[] { new Constant(""+clazz.variables.size()) }, n.line);\r
                                        clazz.parameters.add(new ParameterDeclaration(sizeVariable, sizeVariable.getPossibleConstant()));\r
                                        clazz.parameters.add(new ParameterDeclaration(elementsVariable, elementsVariable.getPossibleConstant()));\r
                                }\r
@@ -457,12 +473,12 @@ public class Parser {
                        }\r
                case component_reference:\r
                        if(n.jjtGetNumChildren() == 1) {\r
-                               return Variable.make(frame, n.op, (IExpression[])walk((SimpleNode)n.jjtGetChild(0), indent+2, frame));\r
+                               return Variable.make(frame, n.op, (IExpression[])walk((SimpleNode)n.jjtGetChild(0), indent+2, frame), n.line);\r
                        } else {\r
                                if ("time".equals(n.op)) {\r
                                        return new TimeVariable();\r
                                }\r
-                               return Variable.make(frame, n.op, null);\r
+                               return Variable.make(frame, n.op, null, n.line);\r
                        }\r
                case relation:\r
                        if(n.jjtGetNumChildren() == 3) {\r
@@ -536,7 +552,9 @@ public class Parser {
                                String op = ((String)walk((SimpleNode)n.jjtGetChild(i), indent+2, model)).trim();\r
                                IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(i+1), indent+2, frame);\r
                                if("+".equals(op)) left = new Addition(left, exp2);\r
+                               else if(".+".equals(op)) left = new ElementwiseAddition(left, exp2);\r
                                else if("-".equals(op)) left = new Subtraction(left, exp2);\r
+                               else if(".-".equals(op)) left = new ElementwiseSubtraction(left, exp2);\r
                        }\r
 \r
                        return left;\r
diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Return.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Return.java
new file mode 100644 (file)
index 0000000..023ae53
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 Semantum Oy.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+\r
+public class Return implements IStatement {\r
+       \r
+    public Return() {\r
+    }\r
+    \r
+    @Override\r
+    public String toString() {\r
+       return "return";\r
+    }\r
+    \r
+    @Override\r
+    public ReturnValue evaluate(IEnvironment environment) {\r
+       return ReturnValue.RETURN;\r
+    }\r
+    \r
+}\r
index 6ea46d57300767a0b6291b6d0974406f7a2b8757..80484a5608303380faa4de56761e03b812d1fe79 100644 (file)
@@ -28,18 +28,18 @@ import fi.semantum.sysdyn.solver.parser.SimpleNode;
 \r
 public class Solver {\r
 \r
+       private static final boolean VALIDATE = true;   \r
        private static final boolean PRINT_EXCEPTIONS = false;  \r
        private static final int STACK_SIZE = 1000;\r
+       private static final int MAX_LOOPS = 50;\r
 \r
        private Model model;\r
        private Environment env;\r
 \r
        private Object[] newValues;\r
-       private Object[] derivatives;\r
        \r
        private double defaultStep;\r
        private double start;\r
-       private NodeCache cache;\r
        private boolean ready;\r
        \r
        private boolean dirty;\r
@@ -49,7 +49,6 @@ public class Solver {
                defaultStep = 0.1;\r
                start = 0;\r
                // is it okay to store the cache with the solver instance?\r
-               cache = new NodeCache();\r
                ready = false;\r
        }\r
        \r
@@ -112,6 +111,24 @@ public class Solver {
        private SimpleNode n;\r
        private String codeCache = null;\r
        \r
+       private void validate(Variable var, Object value) {\r
+               if(VALIDATE) {\r
+                       if(value instanceof Double) {\r
+                               if(Double.isNaN((Double)value)) {\r
+                                       System.err.println("value is invalid (NaN): " + var.base.name);\r
+                                       throw new IllegalStateException("value is invalid (NaN)");\r
+                               }\r
+                               if(Double.isInfinite((Double)value)) {\r
+                                       System.err.println("value is invalid (Infinite): " + var.base.name);\r
+                                       throw new IllegalStateException("value is invalid (Infinite)");\r
+                               }\r
+                       }\r
+                       if(value instanceof Array) {\r
+                               for(Object o : ((Array)value).elements()) validate(var, o);\r
+                       }\r
+               }\r
+       }\r
+       \r
        public void prepare(String input) throws Exception {\r
                \r
                long startNanos = System.nanoTime();\r
@@ -148,13 +165,16 @@ public class Solver {
                model.parameterArray = model.parameters.toArray(new ParameterDeclaration[model.parameters.size()]);\r
                \r
                newValues = new Object[Math.max(model.assignments.size(),model.derivatives.size())];\r
-               derivatives = new Object[model.derivatives.size()];\r
                \r
                int condition = 1;\r
                int loops = 0;\r
                \r
-               while(condition > 0 && loops++ < 50) {\r
+               StringBuilder errors = null;\r
+               \r
+               while(condition > 0 && loops++ < MAX_LOOPS) {\r
 \r
+                       if(loops == MAX_LOOPS) errors = new StringBuilder();\r
+                       \r
                        if(PRINT_EXCEPTIONS) {\r
                                System.err.println("== LOOP " + loops + " ==");\r
                        }\r
@@ -164,14 +184,21 @@ public class Solver {
                        for(ParameterDeclaration pd : model.parameters) {\r
                                try {\r
                                        if(!pd.assigned) {\r
-                                               pd.variable.assign(env, null, pd.modification.evaluate(env));\r
+                                               Object value = pd.modification.evaluate(env);\r
+                                               validate(pd.variable, value);\r
+                                               pd.variable.assign(env, null, value);\r
                                                pd.assigned = true;\r
                                        }\r
                                } catch (Exception e) {\r
+                                       String error = "  -" + pd.variable.toString() + ": " + e.getMessage();\r
+                                       if(errors != null) {\r
+                                               errors.append(error);\r
+                                               errors.append("\n");\r
+                                       }\r
                                        condition++;\r
                                        if(PRINT_EXCEPTIONS) {\r
                                                e.printStackTrace();\r
-                                               System.err.println("failed to assign " + pd.variable.toString());\r
+                                               System.err.println(error);\r
                                        }\r
                                }\r
                        }\r
@@ -187,12 +214,16 @@ public class Solver {
                                                        if(arg.name.endsWith("start")) {\r
                                                                Object value = arg.modification.evaluate(env);\r
                                                                if(vd.variable.base.dimension() == 1) {\r
+                                                                       validate(vd.variable, value);\r
                                                                        vd.variable.assign(env, null, value);\r
                                                                } else {\r
+                                                                       validate(vd.variable, value);\r
                                                                        if(value instanceof Double) {\r
                                                                                Array array = new Array();\r
                                                                                for(int i=0;i<vd.variable.base.dimension();i++) array.addElement(value);\r
                                                                                vd.variable.assign(env, null, array);\r
+                                                                       } else if (value instanceof Array) {\r
+                                                                               vd.variable.assign(env, null, value);\r
                                                                        } else {\r
                                                                                throw new IllegalStateException();\r
                                                                        }\r
@@ -209,33 +240,41 @@ public class Solver {
                                                }\r
                                        }\r
                                } catch (Exception e) {\r
+                                       String error = "  -" + vd.variable.toString() + ": " + e.getMessage();\r
+                                       if(errors != null) {\r
+                                               errors.append(error);\r
+                                               errors.append("\n");\r
+                                       }\r
                                        condition++;\r
                                        if(PRINT_EXCEPTIONS) {\r
                                                e.printStackTrace();\r
-                                               System.err.println("failed to assign " + vd.variable.toString());\r
+                                               System.err.println(error);\r
                                        }\r
                                }\r
                        }\r
                        \r
                        for(Assignment ass : assignments) {\r
                                try {\r
-                                       if(!ass.assigned) {\r
-                                               Object value = ass.expression.evaluate(env);\r
-                                               if(value != null) {\r
-                                                       ass.target.assign(env, ass.subscripts, value);\r
-                                                       ass.assigned = true;\r
-                                               }\r
-                                       }\r
+                                       if(!ass.assigned)\r
+                                               ass.assign(env);\r
                                } catch (Exception e) {\r
+                                       String error = "  -" + ass.target.toString() + ": " + e.getMessage();\r
+                                       if(errors != null) {\r
+                                               errors.append(error);\r
+                                               errors.append("\n");\r
+                                       }\r
                                        condition++;\r
                                        if(PRINT_EXCEPTIONS) {\r
                                                e.printStackTrace();\r
-                                               System.err.println("failed to assign " + ass.target.toString());\r
+                                               System.err.println(error);\r
                                        }\r
                                }\r
                        }\r
                }\r
                \r
+               if(loops == (MAX_LOOPS+1))\r
+                       throw new IllegalStateException("Did not find initial state for model:\n" + errors.toString());\r
+               \r
                for(Assignment ass : model.assignments) {\r
                        if(ass.expression instanceof Constant)\r
                                ass.isConstant = true;\r
@@ -265,44 +304,53 @@ public class Solver {
 \r
                if(!started && dirty) {\r
                        \r
-                       // Solve all algebraic equations\r
-                       Assignment[] assignments = model.assignmentArray;\r
-                       for(int i=0;i<assignments.length;i++) {\r
-                               if(assignments[i].isConstant) continue;\r
-                               Object value = assignments[i].expression.evaluate(env);\r
-                               assignments[i].target.assign(env, assignments[i].subscripts, value);\r
-                       }\r
-                       for(Assignment ass : model.initials) {\r
-                               if(ass.isConstant) continue;\r
-                               Object value = ass.expression.evaluate(env);\r
-                               ass.target.assign(env, ass.subscripts, value);\r
-                       }\r
-\r
-                       // Solve initial values\r
-                       for(VariableDeclaration vd : model.variables) {\r
-                               try {\r
-                                       for(Argument arg : vd.modification.args) {\r
-                                               if(arg.name.endsWith("start")) {\r
-                                                       Object value = arg.modification.evaluate(env);\r
-                                                       if(vd.variable.base.dimension() == 1) {\r
-                                                               vd.variable.assign(env, null, value);\r
-                                                       } else {\r
-                                                               if(value instanceof Double) {\r
-                                                                       Array array = new Array();\r
-                                                                       for(int i=0;i<vd.variable.base.dimension();i++) array.addElement(value);\r
-                                                                       vd.variable.assign(env, null, array);\r
+                       for(int loop=0;loop<3;loop++) {\r
+                       \r
+                               // Solve all algebraic equations\r
+                               Assignment[] assignments = model.assignmentArray;\r
+                               for(int i=0;i<assignments.length;i++) {\r
+                                       if(assignments[i].isConstant) continue;\r
+                                       assignments[i].assign(env);\r
+//                                     Object value = assignments[i].expression.evaluate(env);\r
+//                                     assignments[i].target.assign(env, assignments[i].subscripts, value);\r
+                               }\r
+                               for(Assignment ass : model.initials) {\r
+                                       if(ass.isConstant) continue;\r
+                                       ass.assign(env);\r
+//                                     Object value = ass.expression.evaluate(env);\r
+//                                     ass.target.assign(env, ass.subscripts, value);\r
+                               }\r
+       \r
+                               for(VariableDeclaration vd : model.variables) {\r
+                                       try {\r
+                                               for(Argument arg : vd.modification.args) {\r
+                                                       if(arg.name.endsWith("start")) {\r
+                                                               Object value = arg.modification.evaluate(env);\r
+                                                               if(vd.variable.base.dimension() == 1) {\r
+                                                                       validate(vd.variable, value);\r
+                                                                       vd.variable.assign(env, null, value);\r
                                                                } else {\r
-                                                                       throw new IllegalStateException();\r
+                                                                       validate(vd.variable, value);\r
+                                                                       if(value instanceof Double) {\r
+                                                                               Array array = new Array();\r
+                                                                               for(int i=0;i<vd.variable.base.dimension();i++) array.addElement(value);\r
+                                                                               vd.variable.assign(env, null, array);\r
+                                                                       } else if (value instanceof Array) {\r
+                                                                               vd.variable.assign(env, null, value);\r
+                                                                       } else {\r
+                                                                               throw new IllegalStateException();\r
+                                                                       }\r
                                                                }\r
                                                        }\r
                                                }\r
-                                       }\r
-                               } catch (Exception e) {\r
-                                       if(PRINT_EXCEPTIONS) {\r
-                                               e.printStackTrace();\r
-                                               System.err.println("failed to assign " + vd.variable.toString());\r
+                                       } catch (Exception e) {\r
+                                               if(PRINT_EXCEPTIONS) {\r
+                                                       e.printStackTrace();\r
+                                                       System.err.println("failed to assign " + vd.variable.toString());\r
+                                               }\r
                                        }\r
                                }\r
+                               \r
                        }\r
                        \r
                        dirty = false;\r
@@ -345,8 +393,9 @@ public class Solver {
                // Next solve algebraic equations\r
                for(int i=0;i<assignments.length;i++) {\r
                        if(assignments[i].isConstant) continue;\r
-                       Object value = assignments[i].expression.evaluate(env);\r
-                       assignments[i].target.assign(env, assignments[i].subscripts, value);\r
+                       assignments[i].assign(env);\r
+//                     Object value = assignments[i].expression.evaluate(env);\r
+//                     assignments[i].target.assign(env, assignments[i].subscripts, value);\r
                }\r
 \r
        }\r
@@ -363,7 +412,11 @@ public class Solver {
        }\r
        \r
        public double getTime() {\r
-               return env.time;\r
+               if (env != null) {\r
+                       return env.time;\r
+               } else {\r
+                       return 0.0;\r
+               }\r
        }\r
        \r
        public void setValue(String key, double value) {\r
index a3dcd40f80c5c81174479238f4f0d58613e43fe4..381192f8e57b60d1f1e6ec5f64f5ae5b813c9eb2 100644 (file)
@@ -28,9 +28,10 @@ public class Statement implements IStatement {
     }\r
     \r
     @Override\r
-    public void evaluate(IEnvironment environment) {\r
+    public ReturnValue evaluate(IEnvironment environment) {\r
                Object value = expression.evaluate(environment);\r
                target.assign(environment, subscripts, value);\r
+               return ReturnValue.CONTINUE;\r
     }\r
     \r
 }\r
index b8c17f88b931c0d6116f3490b3edad96edd2632a..a7df2cd3ff5e16fa209e3c85da1e717a67b3b54b 100644 (file)
@@ -26,8 +26,12 @@ public class StatementList implements IStatement {
     }\r
     \r
     @Override\r
-    public void evaluate(IEnvironment environment) {\r
-       for(IStatement stm : statements) stm.evaluate(environment);\r
+    public ReturnValue evaluate(IEnvironment environment) {\r
+       for(IStatement stm : statements) {\r
+               ReturnValue ret = stm.evaluate(environment);\r
+               if(ReturnValue.RETURN.equals(ret)) return ReturnValue.RETURN;\r
+       }\r
+       return ReturnValue.CONTINUE;\r
     }\r
     \r
 }\r
index 7534d1fbbc0e471a57f15f1207b2ccfe03fa7510..e908d74d376c62abd99d4e0663460d5fa1fd1283 100644 (file)
@@ -12,6 +12,8 @@ package fi.semantum.sysdyn.solver;
 \r
 import java.util.Map;\r
 \r
+import fi.semantum.sysdyn.solver.Array.Modifier2;\r
+\r
 public class Subtraction implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -30,10 +32,25 @@ public class Subtraction implements IExpression {
     \r
        @Override\r
        public Object evaluate(IEnvironment environment) {\r
-               Double d1 = (Double)exp1.evaluate(environment);\r
-               Double d2 = (Double)exp2.evaluate(environment);\r
-               if(d1 == null || d2 == null) return null;\r
-               return d1-d2;\r
+               Object o1 = exp1.evaluate(environment);\r
+               Object o2 = exp2.evaluate(environment);\r
+               if(o1 == null || o2 == null) return null; \r
+               if(o1 instanceof Double && o2 instanceof Double) {\r
+                       return (Double)o1 - (Double)o2;\r
+               }\r
+               if(o1 instanceof Array && o2 instanceof Array) {\r
+                       Array la = (Array)o1;\r
+                       Array ra = (Array)o2;\r
+                       return la.copy2(ra, new Modifier2() {\r
+                               \r
+                               @Override\r
+                               public Object modify(Object o1, Object o2) {\r
+                                       if(o1 instanceof Double && o2 instanceof Double) return ((Double)o1)-((Double)o2);\r
+                                       throw new IllegalStateException("Tried to subtract a non-numerical array");\r
+                               }\r
+                       });\r
+               }\r
+               throw new IllegalStateException();\r
        }\r
        \r
        @Override\r
index 70508e471cfdff5804fd21a97757e88ee3ae2bb4..d4d4af1b60c14f3546ae0ca4191c2cf1509b5220 100644 (file)
@@ -17,6 +17,8 @@ public class Utils {
                        return ((Double)value).intValue()-1;\r
                } else if (value instanceof Constant) {\r
                        return getIndex(((Constant)value).value);\r
+               } else if (value instanceof Array) {\r
+                       return -3;\r
                } else {\r
                        throw new IllegalStateException();\r
                }\r
index 9335f68f77a6fcaa97490583747a0e50f60e3974..581ccecb8815a105be407b8ec3826b86330d6658 100644 (file)
@@ -19,18 +19,20 @@ public class Variable implements IExpression {
 \r
        public VariableBase base;\r
        public IExpression[] subscripts = null;\r
+       public int line = -1;\r
        \r
-       public Variable(IFrame frame, String name, IExpression[] subscripts) {\r
+       public Variable(IFrame frame, String name, IExpression[] subscripts, int line) {\r
                base = frame.getBase(name);\r
                this.subscripts = subscripts;\r
+               this.line = line;\r
        }\r
        \r
-       public static Object make(IFrame frame, String name, IExpression[] subscripts) {\r
+       public static Object make(IFrame frame, String name, IExpression[] subscripts, int line) {\r
 //             Array enumElements = enumerationElements(frame, name);\r
 //             if(enumElements != null) return enumElements;\r
 //             Constant enumSize = enumerationSize(frame, name);\r
 //             if(enumSize != null) return enumSize;\r
-               return new Variable(frame, name, subscripts);\r
+               return new Variable(frame, name, subscripts, line);\r
        }\r
        \r
        public Variable(VariableBase base) {\r
@@ -119,22 +121,28 @@ public class Variable implements IExpression {
                env.put(base.index, value);\r
        }\r
        \r
+       private int subscriptLength() {\r
+               if(this.subscripts == null) return 1;\r
+               return this.subscripts.length;\r
+       }\r
+       \r
        private void validateSize(IEnvironment env, IExpression[] subscripts, Object value) {\r
                \r
                if(value == null) return;\r
                \r
-               if(base.isStoredAsArray()) return;\r
+               if(base.isStoredAsArray(env)) return;\r
                \r
                int fullDimension = base.dimension();\r
                if(fullDimension == 1) {\r
                        if(!(value instanceof Double)) {\r
                                Array arr = (Array)value;\r
-                               if(arr.size(0) != 1)\r
-                                       throw new IllegalStateException();\r
+                               int arrSize = arr.dimension(); \r
+                               if(arrSize != 1)\r
+                                       throw new ExecutionException("Trying to assign an array into a scalar variable");\r
                        }\r
                } else {\r
                        if(subscripts == null) {\r
-                               if(base.dimensions.length == this.subscripts.length && value instanceof Double) \r
+                               if(base.dimensions.length == subscriptLength() && value instanceof Double) \r
                                        return;\r
                                if(!(value instanceof Array))\r
                                        throw new IllegalStateException();\r
@@ -164,13 +172,20 @@ public class Variable implements IExpression {
                validateSize(env, subscripts, value);\r
                \r
                if(value instanceof Array) {\r
-                       if(base.isStoredAsArray()) {\r
-                               env.put(base.index(env, subscripts), value);\r
+                       if(base.isStoredAsArray(env)) {\r
+                               if(SolverUtils.isFullSubscript(subscripts)) {\r
+                                       env.put(base.index(env, subscripts), value);\r
+                               } else {\r
+                                       Array[] indices = SolverUtils.parseSubscripts(env, subscripts);\r
+                                       Array current = (Array)env.getValue(base.index);\r
+                                       current.applyPartial(indices, (Array)value);\r
+                                       env.put(base.index, current);\r
+                               }\r
                        } else {\r
                                assignArray(env, base.index(env, subscripts), (Array)value, 0);\r
                        }\r
                } else {\r
-                       if(base.isStoredAsArray()) {\r
+                       if(base.isStoredAsArray(env)) {\r
                                Object _existing = env.getValue(base.index);\r
                                Array existing = (Array)_existing;\r
                                if(existing == null) {\r
@@ -191,9 +206,17 @@ public class Variable implements IExpression {
        @Override\r
        public Object evaluate(IEnvironment environment) {\r
                \r
-               if(constantIndex == -2) constantIndex = base.getConstantIndex(environment, subscripts);\r
+               try {\r
                \r
-               return base.evaluate(environment, subscripts, constantIndex);\r
+                       if(constantIndex == -2) constantIndex = base.getConstantIndex(environment, subscripts);\r
+                       \r
+                       return base.evaluate(environment, subscripts, constantIndex);\r
+                       \r
+               } catch (ExecutionException e) {\r
+                       \r
+                       throw new ExecutionException(base.name + ": " + e.getMessage(), line);\r
+                       \r
+               }\r
                \r
        }\r
 \r
index 842cb93a3332b7d6843726b55d6f38468e310eac..e18fc45d8055f07e7e3863aa492f2273b5bfb007 100644 (file)
@@ -80,10 +80,10 @@ public class VariableBase {
                for(int d : dimensions) result *= d;\r
                return result;\r
        }\r
-       public boolean isStoredAsArray() {\r
+       public boolean isStoredAsArray(IEnvironment env) {\r
                if(dimensions == null) return false;\r
                for(int d : dimensions) if(d == -1) return true;\r
-               return false;\r
+               return (env instanceof Frame);\r
        }\r
        \r
        VariableBase withBase(String prefix) {\r
@@ -130,10 +130,10 @@ public class VariableBase {
                return result;\r
        }\r
        \r
-       private boolean hasScalarSubscript(IExpression[] subscripts) {\r
-               if(subscripts == null) return false;\r
-               else return true;\r
-       }\r
+//     private boolean hasScalarSubscript(IExpression[] subscripts) {\r
+//             if(subscripts == null) return false;\r
+//             else return true;\r
+//     }\r
        \r
        public int intoArray(IEnvironment env, int index, int d, Array target) {\r
 \r
@@ -161,7 +161,7 @@ public class VariableBase {
        \r
        public int getConstantIndex(IEnvironment environment, IExpression[] subscripts) {\r
 \r
-               if(isStoredAsArray()) {\r
+               if(isStoredAsArray(environment)) {\r
                        return -1;\r
                } else {\r
                        \r
@@ -210,37 +210,42 @@ public class VariableBase {
                        }\r
                }\r
                \r
-               if(isStoredAsArray()) {\r
+               if(isStoredAsArray(environment)) {\r
                        \r
-                       Array array = (Array)environment.getValue(index);\r
-                       if(hasScalarSubscript(subscripts)) {\r
-                               Object o = getArrayIndex(environment, subscripts, array);\r
-                               if(o instanceof Variable) throw new IllegalStateException();\r
-                               if(o instanceof Array)\r
-                                       throw new IllegalStateException();\r
-                               return o;\r
+                       Object value = environment.getValue(index);\r
+                       if(value instanceof Array) {\r
+                               Array array = (Array)value;\r
+                               if(subscripts != null) {\r
+                                       return array.subscript(environment, subscripts);\r
+                               }\r
                        }\r
-                       else return array;\r
+                       return value;\r
                        \r
                } else {\r
-                       \r
+\r
                        if(dimension() > 1) {\r
+\r
+                               Array array = new Array();\r
+                               intoArray(environment, index, 0, array);\r
                                if(subscripts != null) {\r
-                                       \r
-                                       Array[] sub = SolverUtils.parseSubscripts(environment, subscripts);\r
-                                       if(SolverUtils.isSlice(sub)) {\r
-                                               Array arr = new Array();\r
-                                               intoArray(environment, index, 0, arr);\r
-                                               return arr.slice(sub);\r
-                                       } else { \r
-                                               return environment.getValue(index(environment, subscripts));\r
-                                       }\r
-                                       \r
-                               } else {\r
-                                       Array array = new Array();\r
-                                       intoArray(environment, index, 0, array);\r
-                                       return array;\r
+                                       return array.subscript(environment, subscripts);\r
                                }\r
+                               else return array;\r
+\r
+//                             if(subscripts != null) {\r
+//                                     \r
+//                                     Array[] sub = SolverUtils.parseSubscripts(environment, subscripts);\r
+//                                     if(SolverUtils.isSlice(sub)) {\r
+//                                             Array arr = new Array();\r
+//                                             intoArray(environment, index, 0, arr);\r
+//                                             return arr.slice(sub);\r
+//                                     } else { \r
+//                                             return environment.getValue(index(environment, subscripts));\r
+//                                     }\r
+//                                     \r
+//                             } else {\r
+//                                     return array;\r
+//                             }\r
                        }\r
                        \r
                        Object result = environment.getNamedValue(name);\r
index 47e94c86e6bd517644a5256bae0346dbe35ce2aa..61af2515bf18e35785892a56cecfda9234db9328 100644 (file)
@@ -26,9 +26,13 @@ public class While implements IStatement {
        }\r
        \r
        @Override\r
-       public void evaluate(IEnvironment environment) {\r
-               while ((Boolean)expression.evaluate(environment))\r
-                       statement.evaluate(environment);\r
+       public ReturnValue evaluate(IEnvironment environment) {\r
+               while ((Boolean)expression.evaluate(environment)) {\r
+                       ReturnValue ret = statement.evaluate(environment);\r
+                       if(ReturnValue.BREAK.equals(ret)) return ReturnValue.CONTINUE;\r
+                       else if(ReturnValue.RETURN.equals(ret)) return ReturnValue.RETURN;\r
+               }\r
+               return ReturnValue.CONTINUE;\r
        }\r
        \r
 }\r
index c50c60586559b38461a6834f24d3cba36ea9d273..b1101a81cba1fa497b44c1d7807555402b3d6bda 100644 (file)
@@ -166,9 +166,9 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
 /*** Class Definition **********************************************/\r
   final public void class_definition() throws ParseException {\r
                            /*@bgen(jjtree) class_definition */\r
-  SimpleNode jjtn000 = new SimpleNode(JJTCLASS_DEFINITION);\r
-  boolean jjtc000 = true;\r
-  jjtree.openNodeScope(jjtn000);\r
+                            SimpleNode jjtn000 = new SimpleNode(JJTCLASS_DEFINITION);\r
+                            boolean jjtc000 = true;\r
+                            jjtree.openNodeScope(jjtn000);Token t;\r
     try {\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
       case 30:\r
@@ -192,8 +192,8 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
                 jjtn000.op = "class";\r
         break;\r
       case 7:\r
-        jj_consume_token(7);\r
-                                                    jjtn000.op = "model";\r
+        t = jj_consume_token(7);\r
+                                                        jjtn000.op = "model"; jjtn000.line = t.beginLine;\r
         break;\r
       case 61:\r
         jj_consume_token(61);\r
@@ -268,7 +268,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     try {\r
       if (jj_2_1(2)) {\r
         t = jj_consume_token(IDENT);\r
-                             jjtn000.op = t.image;\r
+                             jjtn000.op = t.image; jjtn000.line = t.beginLine;\r
         string_comment();\r
         composition();\r
         jj_consume_token(35);\r
@@ -1403,7 +1403,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     Parameter ret = new Parameter();\r
     try {\r
       jj_consume_token(IDENT);\r
-                  ret.name = new String(token.image); jjtn000.op = token.image;\r
+                  ret.name = new String(token.image); jjtn000.op = token.image; jjtn000.line = token.beginLine;\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
       case 66:\r
         array_subscripts();\r
@@ -2193,9 +2193,11 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         break;\r
       case 29:\r
         jj_consume_token(29);\r
+                            jjtn000.op = "break";\r
         break;\r
       case 18:\r
         jj_consume_token(18);\r
+                             jjtn000.op = "return";\r
         break;\r
       case 31:\r
         if_statement();\r
@@ -3600,9 +3602,15 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         break;\r
       case 80:\r
         jj_consume_token(80);\r
+                                                                 jjtree.closeNodeScope(jjtn000, true);\r
+                                                                 jjtc000 = false;\r
+                                                                 jjtn000.op = ".+";\r
         break;\r
       case 81:\r
         jj_consume_token(81);\r
+                                                                                              jjtree.closeNodeScope(jjtn000, true);\r
+                                                                                              jjtc000 = false;\r
+                                                                                              jjtn000.op = ".-";\r
         break;\r
       default:\r
         jj_la1[103] = jj_gen;\r
@@ -3667,29 +3675,29 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
   jjtree.openNodeScope(jjtn000);\r
     try {\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
-      case 82:\r
-        jj_consume_token(82);\r
-          jjtree.closeNodeScope(jjtn000, true);\r
-          jjtc000 = false;\r
-          jjtn000.op = "*";\r
-        break;\r
-      case 83:\r
-        jj_consume_token(83);\r
-                                     jjtree.closeNodeScope(jjtn000, true);\r
-                                     jjtc000 = false;\r
-                                     jjtn000.op = "/";\r
-        break;\r
       case 84:\r
         jj_consume_token(84);\r
-                                                                 jjtree.closeNodeScope(jjtn000, true);\r
-                                                                 jjtc000 = false;\r
-                                                                 jjtn000.op = ".*";\r
+           jjtree.closeNodeScope(jjtn000, true);\r
+           jjtc000 = false;\r
+           jjtn000.op = ".*";\r
         break;\r
       case 85:\r
         jj_consume_token(85);\r
-                                                                                               jjtree.closeNodeScope(jjtn000, true);\r
-                                                                                               jjtc000 = false;\r
-                                                                                               jjtn000.op = "./";\r
+                                         jjtree.closeNodeScope(jjtn000, true);\r
+                                         jjtc000 = false;\r
+                                         jjtn000.op = "./";\r
+        break;\r
+      case 82:\r
+        jj_consume_token(82);\r
+                                                                     jjtree.closeNodeScope(jjtn000, true);\r
+                                                                     jjtc000 = false;\r
+                                                                     jjtn000.op = "*";\r
+        break;\r
+      case 83:\r
+        jj_consume_token(83);\r
+                                                                                                jjtree.closeNodeScope(jjtn000, true);\r
+                                                                                                jjtc000 = false;\r
+                                                                                                jjtn000.op = "/";\r
         break;\r
       default:\r
         jj_la1[105] = jj_gen;\r
@@ -4039,7 +4047,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         ;\r
       }\r
       t = jj_consume_token(IDENT);\r
-                             jjtn000.op = t.image;\r
+                             jjtn000.op = t.image; jjtn000.line = t.beginLine;\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
       case 66:\r
         array_subscripts();\r
@@ -4655,11 +4663,16 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     finally { jj_save(9, xla); }\r
   }\r
 \r
+  private boolean jj_3R_136() {\r
+    if (jj_scan_token(81)) return true;\r
+    return false;\r
+  }\r
+\r
   private boolean jj_3R_74() {\r
     if (jj_scan_token(62)) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_167()) jj_scanpos = xsp;\r
+    if (jj_3R_169()) jj_scanpos = xsp;\r
     if (jj_scan_token(63)) return true;\r
     return false;\r
   }\r
@@ -4674,16 +4687,16 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_154() {\r
+  private boolean jj_3R_156() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
     if (jj_scan_token(68)) jj_scanpos = xsp;\r
     if (jj_scan_token(IDENT)) return true;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_162()) jj_scanpos = xsp;\r
+    if (jj_3R_164()) jj_scanpos = xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_163()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_165()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
@@ -4694,18 +4707,18 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_160() {\r
-    if (jj_scan_token(58)) return true;\r
+  private boolean jj_3R_153() {\r
+    if (jj_scan_token(82)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_77() {\r
-    if (jj_scan_token(68)) return true;\r
+  private boolean jj_3R_162() {\r
+    if (jj_scan_token(58)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_151() {\r
-    if (jj_scan_token(84)) return true;\r
+  private boolean jj_3R_77() {\r
+    if (jj_scan_token(68)) return true;\r
     return false;\r
   }\r
 \r
@@ -4740,57 +4753,58 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
+  private boolean jj_3R_135() {\r
+    if (jj_scan_token(80)) return true;\r
+    return false;\r
+  }\r
+\r
   private boolean jj_3R_124() {\r
     if (jj_scan_token(74)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_147() {\r
-    if (jj_3R_156()) return true;\r
+  private boolean jj_3R_149() {\r
+    if (jj_3R_158()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_165() {\r
+  private boolean jj_3R_167() {\r
     if (jj_scan_token(70)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_146() {\r
+  private boolean jj_3R_148() {\r
     if (jj_scan_token(66)) return true;\r
-    if (jj_3R_155()) return true;\r
+    if (jj_3R_157()) return true;\r
     if (jj_scan_token(67)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_145() {\r
+  private boolean jj_3R_147() {\r
     if (jj_scan_token(62)) return true;\r
     if (jj_3R_47()) return true;\r
     if (jj_scan_token(63)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_143() {\r
-    if (jj_3R_153()) return true;\r
+  private boolean jj_3R_145() {\r
+    if (jj_3R_155()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_158() {\r
+  private boolean jj_3R_160() {\r
     if (jj_scan_token(87)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_144() {\r
-    if (jj_3R_154()) return true;\r
+  private boolean jj_3R_146() {\r
+    if (jj_3R_156()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_135() {\r
+  private boolean jj_3R_137() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_138()) {\r
-    jj_scanpos = xsp;\r
-    if (jj_3R_139()) {\r
-    jj_scanpos = xsp;\r
     if (jj_3R_140()) {\r
     jj_scanpos = xsp;\r
     if (jj_3R_141()) {\r
@@ -4807,6 +4821,10 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     jj_scanpos = xsp;\r
     if (jj_3R_147()) {\r
     jj_scanpos = xsp;\r
+    if (jj_3R_148()) {\r
+    jj_scanpos = xsp;\r
+    if (jj_3R_149()) {\r
+    jj_scanpos = xsp;\r
     if (jj_scan_token(35)) return true;\r
     }\r
     }\r
@@ -4821,33 +4839,33 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_138() {\r
+  private boolean jj_3R_140() {\r
     if (jj_scan_token(UNSIGNED_NUMBER)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_142() {\r
+  private boolean jj_3R_144() {\r
     if (jj_scan_token(33)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_141() {\r
+  private boolean jj_3R_143() {\r
     if (jj_scan_token(6)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_140() {\r
+  private boolean jj_3R_142() {\r
     if (jj_scan_token(STRING)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_139() {\r
+  private boolean jj_3R_141() {\r
     if (jj_scan_token(UNSIGNED_INTEGER)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_150() {\r
-    if (jj_scan_token(83)) return true;\r
+  private boolean jj_3R_152() {\r
+    if (jj_scan_token(85)) return true;\r
     return false;\r
   }\r
 \r
@@ -4856,30 +4874,30 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_156() {\r
+  private boolean jj_3R_158() {\r
     if (jj_scan_token(64)) return true;\r
-    if (jj_3R_166()) return true;\r
+    if (jj_3R_168()) return true;\r
     if (jj_scan_token(65)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_136() {\r
-    if (jj_3R_148()) return true;\r
-    if (jj_3R_135()) return true;\r
+  private boolean jj_3R_138() {\r
+    if (jj_3R_150()) return true;\r
+    if (jj_3R_137()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_155() {\r
-    if (jj_3R_164()) return true;\r
+  private boolean jj_3R_157() {\r
+    if (jj_3R_166()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_165()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_167()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_159() {\r
+  private boolean jj_3R_161() {\r
     if (jj_3R_60()) return true;\r
     return false;\r
   }\r
@@ -4889,14 +4907,14 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_153() {\r
+  private boolean jj_3R_155() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_159()) {\r
+    if (jj_3R_161()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_160()) {\r
+    if (jj_3R_162()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_161()) return true;\r
+    if (jj_3R_163()) return true;\r
     }\r
     }\r
     if (jj_3R_74()) return true;\r
@@ -4908,31 +4926,31 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_148() {\r
+  private boolean jj_3R_150() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_157()) {\r
+    if (jj_3R_159()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_158()) return true;\r
+    if (jj_3R_160()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_157() {\r
+  private boolean jj_3R_159() {\r
     if (jj_scan_token(86)) return true;\r
     return false;\r
   }\r
 \r
   private boolean jj_3R_120() {\r
-    if (jj_3R_135()) return true;\r
+    if (jj_3R_137()) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_136()) jj_scanpos = xsp;\r
+    if (jj_3R_138()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
   private boolean jj_3R_121() {\r
-    if (jj_3R_137()) return true;\r
+    if (jj_3R_139()) return true;\r
     if (jj_3R_120()) return true;\r
     return false;\r
   }\r
@@ -4949,24 +4967,24 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_137() {\r
+  private boolean jj_3R_139() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_149()) {\r
+    if (jj_3R_151()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_150()) {\r
+    if (jj_3R_152()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_151()) {\r
+    if (jj_3R_153()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_152()) return true;\r
+    if (jj_3R_154()) return true;\r
     }\r
     }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_149() {\r
-    if (jj_scan_token(82)) return true;\r
+  private boolean jj_3R_151() {\r
+    if (jj_scan_token(84)) return true;\r
     return false;\r
   }\r
 \r
@@ -4997,9 +5015,9 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     jj_scanpos = xsp;\r
     if (jj_3R_134()) {\r
     jj_scanpos = xsp;\r
-    if (jj_scan_token(80)) {\r
+    if (jj_3R_135()) {\r
     jj_scanpos = xsp;\r
-    if (jj_scan_token(81)) return true;\r
+    if (jj_3R_136()) return true;\r
     }\r
     }\r
     }\r
@@ -5186,6 +5204,14 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
+  private boolean jj_3R_107() {\r
+    Token xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_scan_token(50)) jj_scanpos = xsp;\r
+    if (jj_scan_token(44)) return true;\r
+    return false;\r
+  }\r
+\r
   private boolean jj_3R_66() {\r
     if (jj_3R_80()) return true;\r
     return false;\r
@@ -5275,14 +5301,6 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_107() {\r
-    Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_scan_token(50)) jj_scanpos = xsp;\r
-    if (jj_scan_token(44)) return true;\r
-    return false;\r
-  }\r
-\r
   private boolean jj_3R_84() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
@@ -5506,6 +5524,12 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
+  private boolean jj_3R_165() {\r
+    if (jj_scan_token(68)) return true;\r
+    if (jj_scan_token(IDENT)) return true;\r
+    return false;\r
+  }\r
+\r
   private boolean jj_3R_58() {\r
     if (jj_scan_token(IDENT)) return true;\r
     if (jj_3R_74()) return true;\r
@@ -5537,7 +5561,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_174() {\r
+  private boolean jj_3R_176() {\r
     if (jj_3R_47()) return true;\r
     return false;\r
   }\r
@@ -5569,9 +5593,8 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_163() {\r
-    if (jj_scan_token(68)) return true;\r
-    if (jj_scan_token(IDENT)) return true;\r
+  private boolean jj_3R_164() {\r
+    if (jj_3R_170()) return true;\r
     return false;\r
   }\r
 \r
@@ -5625,31 +5648,26 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_173() {\r
+  private boolean jj_3R_175() {\r
     if (jj_scan_token(69)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_169() {\r
+  private boolean jj_3R_171() {\r
     if (jj_scan_token(71)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_171() {\r
+  private boolean jj_3R_173() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_173()) {\r
+    if (jj_3R_175()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_174()) return true;\r
+    if (jj_3R_176()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_162() {\r
-    if (jj_3R_168()) return true;\r
-    return false;\r
-  }\r
-\r
   private boolean jj_3R_48() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
@@ -5665,9 +5683,9 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_168() {\r
+  private boolean jj_3R_170() {\r
     if (jj_scan_token(66)) return true;\r
-    if (jj_3R_171()) return true;\r
+    if (jj_3R_173()) return true;\r
     return false;\r
   }\r
 \r
@@ -5676,39 +5694,39 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_164() {\r
+  private boolean jj_3R_166() {\r
     if (jj_3R_47()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_169()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_171()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_175() {\r
+  private boolean jj_3R_177() {\r
     if (jj_scan_token(IDENT)) return true;\r
     if (jj_scan_token(88)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_161() {\r
+  private boolean jj_3R_163() {\r
     if (jj_scan_token(46)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_172() {\r
-    if (jj_3R_175()) return true;\r
+  private boolean jj_3R_154() {\r
+    if (jj_scan_token(83)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_152() {\r
-    if (jj_scan_token(85)) return true;\r
+  private boolean jj_3R_174() {\r
+    if (jj_3R_177()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_170() {\r
-    if (jj_3R_172()) return true;\r
+  private boolean jj_3R_172() {\r
+    if (jj_3R_174()) return true;\r
     return false;\r
   }\r
 \r
@@ -5720,18 +5738,18 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_166() {\r
+  private boolean jj_3R_168() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
     if (jj_3_10()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_170()) return true;\r
+    if (jj_3R_172()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_167() {\r
-    if (jj_3R_166()) return true;\r
+  private boolean jj_3R_169() {\r
+    if (jj_3R_168()) return true;\r
     return false;\r
   }\r
 \r
index dd08221904d8064d8f66c0487d4ddbc970b9e44e..1ce5ceba50724edf720ad37c6316f622d413cd93 100644 (file)
@@ -16,23 +16,21 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
    {\r
       case 0:\r
          if ((active1 & 0x80000L) != 0L)\r
-            return 22;\r
+            return 23;\r
          if ((active1 & 0xb30010L) != 0L)\r
-            return 10;\r
-         if ((active0 & 0x884210842108400L) != 0L)\r
+            return 11;\r
+         if ((active0 & 0x377bdef7bdef7bf0L) != 0L || (active1 & 0x180000000L) != 0L)\r
          {\r
             jjmatchedKind = 90;\r
-            return 48;\r
+            return 49;\r
          }\r
-         if ((active0 & 0x377bdef7bdef7bf0L) != 0L || (active1 & 0x180000000L) != 0L)\r
+         if ((active0 & 0x884210842108400L) != 0L)\r
          {\r
             jjmatchedKind = 90;\r
-            return 2;\r
+            return 50;\r
          }\r
          return -1;\r
       case 1:\r
-         if ((active0 & 0x108420080400000L) != 0L)\r
-            return 2;\r
          if ((active0 & 0x3ef7bdff7fbffff0L) != 0L || (active1 & 0x180000000L) != 0L)\r
          {\r
             if (jjmatchedPos != 1)\r
@@ -40,22 +38,24 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
                jjmatchedKind = 90;\r
                jjmatchedPos = 1;\r
             }\r
-            return 2;\r
+            return 49;\r
          }\r
+         if ((active0 & 0x108420080400000L) != 0L)\r
+            return 49;\r
          return -1;\r
       case 2:\r
          if ((active0 & 0x400000800201200L) != 0L)\r
-            return 2;\r
+            return 49;\r
          if ((active0 & 0x3bfffdf77f9fedf0L) != 0L || (active1 & 0x180000000L) != 0L)\r
          {\r
             jjmatchedKind = 90;\r
             jjmatchedPos = 2;\r
-            return 2;\r
+            return 49;\r
          }\r
          return -1;\r
       case 3:\r
          if ((active0 & 0x1000084212118400L) != 0L)\r
-            return 2;\r
+            return 49;\r
          if ((active0 & 0x2bfff5b56d8e69f0L) != 0L || (active1 & 0x180000000L) != 0L)\r
          {\r
             if (jjmatchedPos != 3)\r
@@ -63,32 +63,30 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
                jjmatchedKind = 90;\r
                jjmatchedPos = 3;\r
             }\r
-            return 2;\r
+            return 49;\r
          }\r
          return -1;\r
       case 4:\r
-         if ((active0 & 0x1090004290008c0L) != 0L)\r
-            return 2;\r
          if ((active0 & 0x2af6f5b1469e6130L) != 0L || (active1 & 0x180000000L) != 0L)\r
          {\r
             jjmatchedKind = 90;\r
             jjmatchedPos = 4;\r
-            return 2;\r
+            return 49;\r
          }\r
+         if ((active0 & 0x1090004290008c0L) != 0L)\r
+            return 49;\r
          return -1;\r
       case 5:\r
          if ((active0 & 0x22200011009c0000L) != 0L)\r
-            return 2;\r
+            return 49;\r
          if ((active0 & 0x8d6f5a046026130L) != 0L || (active1 & 0x180000000L) != 0L)\r
          {\r
             jjmatchedKind = 90;\r
             jjmatchedPos = 5;\r
-            return 2;\r
+            return 49;\r
          }\r
          return -1;\r
       case 6:\r
-         if ((active0 & 0x80d0a000000000L) != 0L)\r
-            return 2;\r
          if ((active0 & 0x856250046026130L) != 0L || (active1 & 0x180000000L) != 0L)\r
          {\r
             if (jjmatchedPos != 6)\r
@@ -96,10 +94,14 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
                jjmatchedKind = 90;\r
                jjmatchedPos = 6;\r
             }\r
-            return 2;\r
+            return 49;\r
          }\r
+         if ((active0 & 0x80d0a000000000L) != 0L)\r
+            return 49;\r
          return -1;\r
       case 7:\r
+         if ((active0 & 0x802200006020020L) != 0L || (active1 & 0x180000000L) != 0L)\r
+            return 49;\r
          if ((active0 & 0x54150040006110L) != 0L)\r
          {\r
             if (jjmatchedPos != 7)\r
@@ -107,19 +109,17 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
                jjmatchedKind = 90;\r
                jjmatchedPos = 7;\r
             }\r
-            return 2;\r
+            return 49;\r
          }\r
-         if ((active0 & 0x802200006020020L) != 0L || (active1 & 0x180000000L) != 0L)\r
-            return 2;\r
          return -1;\r
       case 8:\r
          if ((active0 & 0x10140000000110L) != 0L)\r
-            return 2;\r
+            return 49;\r
          if ((active0 & 0x44010040006000L) != 0L)\r
          {\r
             jjmatchedKind = 90;\r
             jjmatchedPos = 8;\r
-            return 2;\r
+            return 49;\r
          }\r
          return -1;\r
       case 9:\r
@@ -127,34 +127,34 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
          {\r
             jjmatchedKind = 90;\r
             jjmatchedPos = 9;\r
-            return 2;\r
+            return 49;\r
          }\r
          if ((active0 & 0x4000000004000L) != 0L)\r
-            return 2;\r
+            return 49;\r
          return -1;\r
       case 10:\r
-         if ((active0 & 0x10000002000L) != 0L)\r
-            return 2;\r
          if ((active0 & 0x40000040000000L) != 0L)\r
          {\r
             jjmatchedKind = 90;\r
             jjmatchedPos = 10;\r
-            return 2;\r
+            return 49;\r
          }\r
+         if ((active0 & 0x10000002000L) != 0L)\r
+            return 49;\r
          return -1;\r
       case 11:\r
          if ((active0 & 0x40000000L) != 0L)\r
-            return 2;\r
+            return 49;\r
          if ((active0 & 0x40000000000000L) != 0L)\r
          {\r
             jjmatchedKind = 90;\r
             jjmatchedPos = 11;\r
-            return 2;\r
+            return 49;\r
          }\r
          return -1;\r
       case 12:\r
          if ((active0 & 0x40000000000000L) != 0L)\r
-            return 2;\r
+            return 49;\r
          return -1;\r
       default :\r
          return -1;\r
@@ -190,7 +190,7 @@ private int jjMoveStringLiteralDfa0_0()
          jjmatchedKind = 68;\r
          return jjMoveStringLiteralDfa1_0(0x0L, 0xb30000L);\r
       case 47:\r
-         return jjStartNfaWithStates_0(0, 83, 22);\r
+         return jjStartNfaWithStates_0(0, 83, 23);\r
       case 58:\r
          jjmatchedKind = 69;\r
          return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000L);\r
@@ -300,7 +300,7 @@ private int jjMoveStringLiteralDfa1_0(long active0, long active1)
          return jjMoveStringLiteralDfa2_0(active0, 0x2400000000042100L, active1, 0L);\r
       case 102:\r
          if ((active0 & 0x80000000L) != 0L)\r
-            return jjStartNfaWithStates_0(1, 31, 2);\r
+            return jjStartNfaWithStates_0(1, 31, 49);\r
          break;\r
       case 104:\r
          return jjMoveStringLiteralDfa2_0(active0, 0x1080010000000L, active1, 0L);\r
@@ -325,7 +325,7 @@ private int jjMoveStringLiteralDfa1_0(long active0, long active1)
          return jjMoveStringLiteralDfa2_0(active0, 0x200000000000L, active1, 0L);\r
       case 114:\r
          if ((active0 & 0x400000L) != 0L)\r
-            return jjStartNfaWithStates_0(1, 22, 2);\r
+            return jjStartNfaWithStates_0(1, 22, 49);\r
          return jjMoveStringLiteralDfa2_0(active0, 0x10000220000000L, active1, 0L);\r
       case 115:\r
          return jjMoveStringLiteralDfa2_0(active0, 0x80000L, active1, 0L);\r
@@ -361,9 +361,9 @@ private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa3_0(active0, 0x2000002040000400L, active1, 0L);\r
       case 100:\r
          if ((active0 & 0x200L) != 0L)\r
-            return jjStartNfaWithStates_0(2, 9, 2);\r
+            return jjStartNfaWithStates_0(2, 9, 49);\r
          else if ((active0 & 0x800000000L) != 0L)\r
-            return jjStartNfaWithStates_0(2, 35, 2);\r
+            return jjStartNfaWithStates_0(2, 35, 49);\r
          return jjMoveStringLiteralDfa3_0(active0, 0x180L, active1, 0L);\r
       case 101:\r
          return jjMoveStringLiteralDfa3_0(active0, 0x80030020000L, active1, 0x180000000L);\r
@@ -381,15 +381,15 @@ private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa3_0(active0, 0x104005000002000L, active1, 0L);\r
       case 114:\r
          if ((active0 & 0x200000L) != 0L)\r
-            return jjStartNfaWithStates_0(2, 21, 2);\r
+            return jjStartNfaWithStates_0(2, 21, 49);\r
          else if ((active0 & 0x400000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(2, 58, 2);\r
+            return jjStartNfaWithStates_0(2, 58, 49);\r
          return jjMoveStringLiteralDfa3_0(active0, 0x840000800000L, active1, 0L);\r
       case 115:\r
          return jjMoveStringLiteralDfa3_0(active0, 0x2188020L, active1, 0L);\r
       case 116:\r
          if ((active0 & 0x1000L) != 0L)\r
-            return jjStartNfaWithStates_0(2, 12, 2);\r
+            return jjStartNfaWithStates_0(2, 12, 49);\r
          return jjMoveStringLiteralDfa3_0(active0, 0x8a0000108040000L, active1, 0L);\r
       case 117:\r
          return jjMoveStringLiteralDfa3_0(active0, 0x210200000000L, active1, 0L);\r
@@ -420,13 +420,13 @@ private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long a
             jjmatchedPos = 3;\r
          }\r
          else if ((active0 & 0x200000000L) != 0L)\r
-            return jjStartNfaWithStates_0(3, 33, 2);\r
+            return jjStartNfaWithStates_0(3, 33, 49);\r
          else if ((active0 & 0x4000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(3, 38, 2);\r
+            return jjStartNfaWithStates_0(3, 38, 49);\r
          return jjMoveStringLiteralDfa4_0(active0, 0x88800000a980180L, active1, 0L);\r
       case 104:\r
          if ((active0 & 0x400L) != 0L)\r
-            return jjStartNfaWithStates_0(3, 10, 2);\r
+            return jjStartNfaWithStates_0(3, 10, 49);\r
          return jjMoveStringLiteralDfa4_0(active0, 0x20000000000000L, active1, 0L);\r
       case 107:\r
          return jjMoveStringLiteralDfa4_0(active0, 0x2000000000L, active1, 0L);\r
@@ -436,15 +436,15 @@ private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa4_0(active0, 0x10000000000L, active1, 0L);\r
       case 110:\r
          if ((active0 & 0x10000000L) != 0L)\r
-            return jjStartNfaWithStates_0(3, 28, 2);\r
+            return jjStartNfaWithStates_0(3, 28, 49);\r
          else if ((active0 & 0x80000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(3, 43, 2);\r
+            return jjStartNfaWithStates_0(3, 43, 49);\r
          return jjMoveStringLiteralDfa4_0(active0, 0x108000000000L, active1, 0L);\r
       case 111:\r
          return jjMoveStringLiteralDfa4_0(active0, 0x2000001000004010L, active1, 0L);\r
       case 112:\r
          if ((active0 & 0x1000000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(3, 60, 2);\r
+            return jjStartNfaWithStates_0(3, 60, 49);\r
          return jjMoveStringLiteralDfa4_0(active0, 0x100000000L, active1, 0L);\r
       case 114:\r
          return jjMoveStringLiteralDfa4_0(active0, 0x20000L, active1, 0x180000000L);\r
@@ -456,7 +456,7 @@ private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa4_0(active0, 0x100000000040000L, active1, 0L);\r
       case 119:\r
          if ((active0 & 0x10000L) != 0L)\r
-            return jjStartNfaWithStates_0(3, 16, 2);\r
+            return jjStartNfaWithStates_0(3, 16, 49);\r
          break;\r
       default :\r
          break;\r
@@ -480,23 +480,23 @@ private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa5_0(active0, 0x100L, active1, 0L);\r
       case 101:\r
          if ((active0 & 0x40L) != 0L)\r
-            return jjStartNfaWithStates_0(4, 6, 2);\r
+            return jjStartNfaWithStates_0(4, 6, 49);\r
          else if ((active0 & 0x1000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(4, 48, 2);\r
+            return jjStartNfaWithStates_0(4, 48, 49);\r
          return jjMoveStringLiteralDfa5_0(active0, 0x10118000000000L, active1, 0L);\r
       case 105:\r
          return jjMoveStringLiteralDfa5_0(active0, 0x220c00000100000L, active1, 0L);\r
       case 107:\r
          if ((active0 & 0x1000000L) != 0L)\r
-            return jjStartNfaWithStates_0(4, 24, 2);\r
+            return jjStartNfaWithStates_0(4, 24, 49);\r
          else if ((active0 & 0x20000000L) != 0L)\r
-            return jjStartNfaWithStates_0(4, 29, 2);\r
+            return jjStartNfaWithStates_0(4, 29, 49);\r
          break;\r
       case 108:\r
          if ((active0 & 0x80L) != 0L)\r
-            return jjStartNfaWithStates_0(4, 7, 2);\r
+            return jjStartNfaWithStates_0(4, 7, 49);\r
          else if ((active0 & 0x800L) != 0L)\r
-            return jjStartNfaWithStates_0(4, 11, 2);\r
+            return jjStartNfaWithStates_0(4, 11, 49);\r
          break;\r
       case 109:\r
          return jjMoveStringLiteralDfa5_0(active0, 0x40000000000L, active1, 0L);\r
@@ -506,17 +506,17 @@ private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa5_0(active0, 0x40000000L, active1, 0L);\r
       case 114:\r
          if ((active0 & 0x8000000L) != 0L)\r
-            return jjStartNfaWithStates_0(4, 27, 2);\r
+            return jjStartNfaWithStates_0(4, 27, 49);\r
          else if ((active0 & 0x8000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(4, 51, 2);\r
+            return jjStartNfaWithStates_0(4, 51, 49);\r
          return jjMoveStringLiteralDfa5_0(active0, 0x28000010000c0030L, active1, 0L);\r
       case 115:\r
          if ((active0 & 0x400000000L) != 0L)\r
-            return jjStartNfaWithStates_0(4, 34, 2);\r
+            return jjStartNfaWithStates_0(4, 34, 49);\r
          break;\r
       case 116:\r
          if ((active0 & 0x100000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(4, 56, 2);\r
+            return jjStartNfaWithStates_0(4, 56, 49);\r
          return jjMoveStringLiteralDfa5_0(active0, 0x42200004004000L, active1, 0L);\r
       case 117:\r
          return jjMoveStringLiteralDfa5_0(active0, 0x100000000L, active1, 0L);\r
@@ -542,17 +542,17 @@ private int jjMoveStringLiteralDfa5_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa6_0(active0, 0x2c00000004000L, active1, 0L);\r
       case 99:\r
          if ((active0 & 0x200000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(5, 57, 2);\r
+            return jjStartNfaWithStates_0(5, 57, 49);\r
          return jjMoveStringLiteralDfa6_0(active0, 0x10108000002000L, active1, 0L);\r
       case 100:\r
          if ((active0 & 0x2000000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(5, 61, 2);\r
+            return jjStartNfaWithStates_0(5, 61, 49);\r
          return jjMoveStringLiteralDfa6_0(active0, 0x84000000000000L, active1, 0L);\r
       case 101:\r
          return jjMoveStringLiteralDfa6_0(active0, 0x40000000020L, active1, 0L);\r
       case 102:\r
          if ((active0 & 0x100000L) != 0L)\r
-            return jjStartNfaWithStates_0(5, 20, 2);\r
+            return jjStartNfaWithStates_0(5, 20, 49);\r
          break;\r
       case 103:\r
          return jjMoveStringLiteralDfa6_0(active0, 0x2000000000L, active1, 0L);\r
@@ -564,13 +564,13 @@ private int jjMoveStringLiteralDfa5_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa6_0(active0, 0x100L, active1, 0L);\r
       case 109:\r
          if ((active0 & 0x800000L) != 0L)\r
-            return jjStartNfaWithStates_0(5, 23, 2);\r
+            return jjStartNfaWithStates_0(5, 23, 49);\r
          break;\r
       case 110:\r
          if ((active0 & 0x40000L) != 0L)\r
-            return jjStartNfaWithStates_0(5, 18, 2);\r
+            return jjStartNfaWithStates_0(5, 18, 49);\r
          else if ((active0 & 0x20000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(5, 53, 2);\r
+            return jjStartNfaWithStates_0(5, 53, 49);\r
          return jjMoveStringLiteralDfa6_0(active0, 0x800000000000000L, active1, 0L);\r
       case 114:\r
          return jjMoveStringLiteralDfa6_0(active0, 0x40010000000000L, active1, 0L);\r
@@ -578,11 +578,11 @@ private int jjMoveStringLiteralDfa5_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa6_0(active0, 0x40000000L, active1, 0L);\r
       case 116:\r
          if ((active0 & 0x80000L) != 0L)\r
-            return jjStartNfaWithStates_0(5, 19, 2);\r
+            return jjStartNfaWithStates_0(5, 19, 49);\r
          else if ((active0 & 0x100000000L) != 0L)\r
-            return jjStartNfaWithStates_0(5, 32, 2);\r
+            return jjStartNfaWithStates_0(5, 32, 49);\r
          else if ((active0 & 0x1000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(5, 36, 2);\r
+            return jjStartNfaWithStates_0(5, 36, 49);\r
          return jjMoveStringLiteralDfa6_0(active0, 0x20000L, active1, 0x180000000L);\r
       default :\r
          break;\r
@@ -604,13 +604,13 @@ private int jjMoveStringLiteralDfa6_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa7_0(active0, 0x844010000000100L, active1, 0L);\r
       case 101:\r
          if ((active0 & 0x2000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(6, 37, 2);\r
+            return jjStartNfaWithStates_0(6, 37, 49);\r
          return jjMoveStringLiteralDfa7_0(active0, 0x2002000L, active1, 0L);\r
       case 108:\r
          if ((active0 & 0x400000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(6, 46, 2);\r
+            return jjStartNfaWithStates_0(6, 46, 49);\r
          else if ((active0 & 0x800000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(6, 47, 2);\r
+            return jjStartNfaWithStates_0(6, 47, 49);\r
          break;\r
       case 110:\r
          return jjMoveStringLiteralDfa7_0(active0, 0x2000000000000L, active1, 0L);\r
@@ -618,7 +618,7 @@ private int jjMoveStringLiteralDfa6_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa7_0(active0, 0x200004020000L, active1, 0x180000000L);\r
       case 115:\r
          if ((active0 & 0x80000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(6, 55, 2);\r
+            return jjStartNfaWithStates_0(6, 55, 49);\r
          break;\r
       case 116:\r
          if ((active0 & 0x8000000000L) != 0L)\r
@@ -651,7 +651,7 @@ private int jjMoveStringLiteralDfa7_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa8_0(active0, 0x4000000000000L, active1, 0L);\r
       case 101:\r
          if ((active0 & 0x20L) != 0L)\r
-            return jjStartNfaWithStates_0(7, 5, 2);\r
+            return jjStartNfaWithStates_0(7, 5, 49);\r
          return jjMoveStringLiteralDfa8_0(active0, 0x10040000000000L, active1, 0L);\r
       case 104:\r
          return jjMoveStringLiteralDfa8_0(active0, 0x10L, active1, 0L);\r
@@ -659,15 +659,15 @@ private int jjMoveStringLiteralDfa7_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa8_0(active0, 0x40000000004000L, active1, 0L);\r
       case 108:\r
          if ((active0 & 0x800000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(7, 59, 2);\r
+            return jjStartNfaWithStates_0(7, 59, 49);\r
          return jjMoveStringLiteralDfa8_0(active0, 0x40000000L, active1, 0L);\r
       case 110:\r
          if ((active0 & 0x2000000L) != 0L)\r
-            return jjStartNfaWithStates_0(7, 25, 2);\r
+            return jjStartNfaWithStates_0(7, 25, 49);\r
          else if ((active0 & 0x4000000L) != 0L)\r
-            return jjStartNfaWithStates_0(7, 26, 2);\r
+            return jjStartNfaWithStates_0(7, 26, 49);\r
          else if ((active0 & 0x200000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(7, 45, 2);\r
+            return jjStartNfaWithStates_0(7, 45, 49);\r
          break;\r
       case 111:\r
          return jjMoveStringLiteralDfa8_0(active0, 0x100000000000L, active1, 0L);\r
@@ -680,7 +680,7 @@ private int jjMoveStringLiteralDfa7_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa8_0(active0, 0x100L, active1, 0x180000000L);\r
       case 116:\r
          if ((active0 & 0x2000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(7, 49, 2);\r
+            return jjStartNfaWithStates_0(7, 49, 49);\r
          return jjMoveStringLiteralDfa8_0(active0, 0x10000000000L, active1, 0L);\r
       default :\r
          break;\r
@@ -706,11 +706,11 @@ private int jjMoveStringLiteralDfa8_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa9_0(active0, 0x2000L, active1, 0L);\r
       case 100:\r
          if ((active0 & 0x10000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(8, 52, 2);\r
+            return jjStartNfaWithStates_0(8, 52, 49);\r
          break;\r
       case 101:\r
          if ((active0 & 0x100L) != 0L)\r
-            return jjStartNfaWithStates_0(8, 8, 2);\r
+            return jjStartNfaWithStates_0(8, 8, 49);\r
          break;\r
       case 105:\r
          return jjMoveStringLiteralDfa9_0(active0, 0x10000000000L, active1, 0L);\r
@@ -718,7 +718,7 @@ private int jjMoveStringLiteralDfa8_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa9_0(active0, 0x4000000000000L, active1, 0L);\r
       case 109:\r
          if ((active0 & 0x10L) != 0L)\r
-            return jjStartNfaWithStates_0(8, 4, 2);\r
+            return jjStartNfaWithStates_0(8, 4, 49);\r
          break;\r
       case 110:\r
          return jjMoveStringLiteralDfa9_0(active0, 0x40000000000000L, active1, 0L);\r
@@ -726,9 +726,9 @@ private int jjMoveStringLiteralDfa8_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa9_0(active0, 0x4000L, active1, 0L);\r
       case 114:\r
          if ((active0 & 0x40000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(8, 42, 2);\r
+            return jjStartNfaWithStates_0(8, 42, 49);\r
          else if ((active0 & 0x100000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(8, 44, 2);\r
+            return jjStartNfaWithStates_0(8, 44, 49);\r
          break;\r
       default :\r
          break;\r
@@ -748,7 +748,7 @@ private int jjMoveStringLiteralDfa9_0(long old0, long active0, long old1, long a
    {\r
       case 101:\r
          if ((active0 & 0x4000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(9, 50, 2);\r
+            return jjStartNfaWithStates_0(9, 50, 49);\r
          return jjMoveStringLiteralDfa10_0(active0, 0x40000000000000L, active1, 0L);\r
       case 102:\r
          return jjMoveStringLiteralDfa10_0(active0, 0L, active1, 0x80000000L);\r
@@ -756,7 +756,7 @@ private int jjMoveStringLiteralDfa9_0(long old0, long active0, long old1, long a
          return jjMoveStringLiteralDfa10_0(active0, 0x2000L, active1, 0L);\r
       case 110:\r
          if ((active0 & 0x4000L) != 0L)\r
-            return jjStartNfaWithStates_0(9, 14, 2);\r
+            return jjStartNfaWithStates_0(9, 14, 49);\r
          break;\r
       case 111:\r
          return jjMoveStringLiteralDfa10_0(active0, 0x10000000000L, active1, 0L);\r
@@ -784,11 +784,11 @@ private int jjMoveStringLiteralDfa10_0(long old0, long active0, long old1, long
          return jjMoveStringLiteralDfa11_0(active0, 0x40000000000000L, active1, 0L);\r
       case 101:\r
          if ((active0 & 0x2000L) != 0L)\r
-            return jjStartNfaWithStates_0(10, 13, 2);\r
+            return jjStartNfaWithStates_0(10, 13, 49);\r
          return jjMoveStringLiteralDfa11_0(active0, 0x40000000L, active1, 0x100000000L);\r
       case 110:\r
          if ((active0 & 0x10000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(10, 40, 2);\r
+            return jjStartNfaWithStates_0(10, 40, 49);\r
          break;\r
       case 117:\r
          return jjMoveStringLiteralDfa11_0(active0, 0L, active1, 0x80000000L);\r
@@ -814,7 +814,7 @@ private int jjMoveStringLiteralDfa11_0(long old0, long active0, long old1, long
          return jjMoveStringLiteralDfa12_0(active0, 0L, active1, 0x100000000L);\r
       case 100:\r
          if ((active0 & 0x40000000L) != 0L)\r
-            return jjStartNfaWithStates_0(11, 30, 2);\r
+            return jjStartNfaWithStates_0(11, 30, 49);\r
          break;\r
       case 110:\r
          return jjMoveStringLiteralDfa12_0(active0, 0L, active1, 0x80000000L);\r
@@ -840,7 +840,7 @@ private int jjMoveStringLiteralDfa12_0(long old0, long active0, long old1, long
          return jjMoveStringLiteralDfa13_0(active0, 0L, active1, 0x100000000L);\r
       case 121:\r
          if ((active0 & 0x40000000000000L) != 0L)\r
-            return jjStartNfaWithStates_0(12, 54, 2);\r
+            return jjStartNfaWithStates_0(12, 54, 49);\r
          break;\r
       default :\r
          break;\r
@@ -941,7 +941,7 @@ static final long[] jjbitVec0 = {
 private int jjMoveNfa_0(int startState, int curPos)\r
 {\r
    int startsAt = 0;\r
-   jjnewStateCnt = 48;\r
+   jjnewStateCnt = 49;\r
    int i = 1;\r
    jjstateSet[0] = startState;\r
    int kind = 0x7fffffff;\r
@@ -956,12 +956,32 @@ private int jjMoveNfa_0(int startState, int curPos)
          {\r
             switch(jjstateSet[--i])\r
             {\r
+               case 23:\r
+                  if (curChar == 47)\r
+                  {\r
+                     if (kind > 3)\r
+                        kind = 3;\r
+                     jjCheckNAdd(30);\r
+                  }\r
+                  else if (curChar == 42)\r
+                     jjCheckNAddStates(0, 2);\r
+                  break;\r
+               case 49:\r
+                  if ((0x3ff000000000000L & l) != 0L)\r
+                  {\r
+                     if (kind > 90)\r
+                        kind = 90;\r
+                     jjCheckNAddTwoStates(2, 3);\r
+                  }\r
+                  else if (curChar == 46)\r
+                     jjCheckNAdd(2);\r
+                  break;\r
                case 0:\r
                   if ((0x3ff000000000000L & l) != 0L)\r
                   {\r
                      if (kind > 93)\r
                         kind = 93;\r
-                     jjCheckNAddStates(0, 6);\r
+                     jjCheckNAddStates(3, 9);\r
                   }\r
                   else if ((0x100002600L & l) != 0L)\r
                   {\r
@@ -969,18 +989,18 @@ private int jjMoveNfa_0(int startState, int curPos)
                         kind = 1;\r
                   }\r
                   else if (curChar == 47)\r
-                     jjAddStates(7, 8);\r
+                     jjAddStates(10, 11);\r
                   else if (curChar == 46)\r
-                     jjCheckNAdd(10);\r
+                     jjCheckNAdd(11);\r
                   else if (curChar == 34)\r
-                     jjCheckNAddStates(9, 11);\r
+                     jjCheckNAddStates(12, 14);\r
                   break;\r
-               case 48:\r
-                  if ((0x3ff400000000000L & l) != 0L)\r
+               case 50:\r
+                  if ((0x3ff000000000000L & l) != 0L)\r
                   {\r
                      if (kind > 90)\r
                         kind = 90;\r
-                     jjCheckNAdd(2);\r
+                     jjCheckNAddTwoStates(2, 3);\r
                   }\r
                   else if (curChar == 43)\r
                   {\r
@@ -992,177 +1012,173 @@ private int jjMoveNfa_0(int startState, int curPos)
                      if (kind > 92)\r
                         kind = 92;\r
                   }\r
-                  break;\r
-               case 22:\r
-                  if (curChar == 47)\r
-                  {\r
-                     if (kind > 3)\r
-                        kind = 3;\r
-                     jjCheckNAdd(29);\r
-                  }\r
-                  else if (curChar == 42)\r
-                     jjCheckNAddStates(12, 14);\r
+                  else if (curChar == 46)\r
+                     jjCheckNAdd(2);\r
                   break;\r
                case 2:\r
-                  if ((0x3ff400000000000L & l) == 0L)\r
+                  if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 90)\r
                      kind = 90;\r
-                  jjCheckNAdd(2);\r
+                  jjCheckNAddTwoStates(2, 3);\r
                   break;\r
                case 3:\r
-                  if (curChar == 34)\r
-                     jjCheckNAddStates(9, 11);\r
+                  if (curChar == 46)\r
+                     jjCheckNAdd(2);\r
                   break;\r
                case 4:\r
+                  if (curChar == 34)\r
+                     jjCheckNAddStates(12, 14);\r
+                  break;\r
+               case 5:\r
                   if ((0xfffffffbfffffbffL & l) != 0L)\r
-                     jjCheckNAddStates(9, 11);\r
+                     jjCheckNAddStates(12, 14);\r
                   break;\r
-               case 6:\r
+               case 7:\r
                   if ((0xfffffffffffffbffL & l) != 0L)\r
-                     jjCheckNAddStates(9, 11);\r
+                     jjCheckNAddStates(12, 14);\r
                   break;\r
-               case 7:\r
+               case 8:\r
                   if (curChar == 34 && kind > 91)\r
                      kind = 91;\r
                   break;\r
-               case 9:\r
+               case 10:\r
                   if (curChar == 46)\r
-                     jjCheckNAdd(10);\r
+                     jjCheckNAdd(11);\r
                   break;\r
-               case 10:\r
+               case 11:\r
                   if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 94)\r
                      kind = 94;\r
                   jjCheckNAddStates(15, 18);\r
                   break;\r
-               case 12:\r
+               case 13:\r
                   if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 94)\r
                      kind = 94;\r
-                  jjCheckNAdd(12);\r
+                  jjCheckNAdd(13);\r
                   break;\r
-               case 14:\r
+               case 15:\r
                   if (curChar == 45)\r
-                     jjCheckNAdd(12);\r
+                     jjCheckNAdd(13);\r
                   break;\r
-               case 15:\r
+               case 16:\r
                   if (curChar == 43)\r
-                     jjCheckNAdd(12);\r
+                     jjCheckNAdd(13);\r
                   break;\r
-               case 18:\r
+               case 19:\r
                   if (curChar == 45 && kind > 92)\r
                      kind = 92;\r
                   break;\r
-               case 19:\r
+               case 20:\r
                   if (curChar == 43 && kind > 92)\r
                      kind = 92;\r
                   break;\r
-               case 21:\r
+               case 22:\r
                   if (curChar == 47)\r
-                     jjAddStates(7, 8);\r
+                     jjAddStates(10, 11);\r
                   break;\r
-               case 23:\r
+               case 24:\r
                   if ((0xfffffbffffffffffL & l) != 0L)\r
-                     jjCheckNAddStates(12, 14);\r
+                     jjCheckNAddStates(0, 2);\r
                   break;\r
-               case 24:\r
+               case 25:\r
                   if (curChar == 42)\r
-                     jjstateSet[jjnewStateCnt++] = 25;\r
+                     jjstateSet[jjnewStateCnt++] = 26;\r
                   break;\r
-               case 25:\r
+               case 26:\r
                   if ((0xffff7fffffffffffL & l) != 0L)\r
-                     jjCheckNAddStates(12, 14);\r
+                     jjCheckNAddStates(0, 2);\r
                   break;\r
-               case 26:\r
+               case 27:\r
                   if (curChar == 47 && kind > 2)\r
                      kind = 2;\r
                   break;\r
-               case 27:\r
+               case 28:\r
                   if (curChar == 42)\r
-                     jjstateSet[jjnewStateCnt++] = 26;\r
+                     jjstateSet[jjnewStateCnt++] = 27;\r
                   break;\r
-               case 28:\r
+               case 29:\r
                   if (curChar != 47)\r
                      break;\r
                   if (kind > 3)\r
                      kind = 3;\r
-                  jjCheckNAdd(29);\r
+                  jjCheckNAdd(30);\r
                   break;\r
-               case 29:\r
+               case 30:\r
                   if ((0xfffffffffffffbffL & l) == 0L)\r
                      break;\r
                   if (kind > 3)\r
                      kind = 3;\r
-                  jjCheckNAdd(29);\r
+                  jjCheckNAdd(30);\r
                   break;\r
-               case 30:\r
+               case 31:\r
                   if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 93)\r
                      kind = 93;\r
-                  jjCheckNAddStates(0, 6);\r
+                  jjCheckNAddStates(3, 9);\r
                   break;\r
-               case 31:\r
+               case 32:\r
                   if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 93)\r
                      kind = 93;\r
-                  jjCheckNAdd(31);\r
+                  jjCheckNAdd(32);\r
                   break;\r
-               case 32:\r
+               case 33:\r
                   if ((0x3ff000000000000L & l) != 0L)\r
-                     jjCheckNAddTwoStates(32, 33);\r
+                     jjCheckNAddTwoStates(33, 34);\r
                   break;\r
-               case 33:\r
+               case 34:\r
                   if (curChar != 46)\r
                      break;\r
                   if (kind > 94)\r
                      kind = 94;\r
                   jjCheckNAddStates(19, 22);\r
                   break;\r
-               case 34:\r
+               case 35:\r
                   if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 94)\r
                      kind = 94;\r
                   jjCheckNAddStates(19, 22);\r
                   break;\r
-               case 36:\r
+               case 37:\r
                   if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 94)\r
                      kind = 94;\r
-                  jjCheckNAdd(36);\r
+                  jjCheckNAdd(37);\r
                   break;\r
-               case 38:\r
+               case 39:\r
                   if (curChar == 45)\r
-                     jjCheckNAdd(36);\r
+                     jjCheckNAdd(37);\r
                   break;\r
-               case 39:\r
+               case 40:\r
                   if (curChar == 43)\r
-                     jjCheckNAdd(36);\r
+                     jjCheckNAdd(37);\r
                   break;\r
-               case 41:\r
+               case 42:\r
                   if ((0x3ff000000000000L & l) != 0L)\r
                      jjCheckNAddStates(23, 26);\r
                   break;\r
-               case 43:\r
+               case 44:\r
                   if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 94)\r
                      kind = 94;\r
-                  jjCheckNAdd(43);\r
+                  jjCheckNAdd(44);\r
                   break;\r
-               case 45:\r
+               case 46:\r
                   if (curChar == 45)\r
-                     jjCheckNAdd(43);\r
+                     jjCheckNAdd(44);\r
                   break;\r
-               case 46:\r
+               case 47:\r
                   if (curChar == 43)\r
-                     jjCheckNAdd(43);\r
+                     jjCheckNAdd(44);\r
                   break;\r
                default : break;\r
             }\r
@@ -1175,12 +1191,20 @@ private int jjMoveNfa_0(int startState, int curPos)
          {\r
             switch(jjstateSet[--i])\r
             {\r
+               case 49:\r
+               case 2:\r
+                  if ((0x7fffffe87fffffeL & l) == 0L)\r
+                     break;\r
+                  if (kind > 90)\r
+                     kind = 90;\r
+                  jjCheckNAddTwoStates(2, 3);\r
+                  break;\r
                case 0:\r
                   if ((0x7fffffe87fffffeL & l) != 0L)\r
                   {\r
                      if (kind > 90)\r
                         kind = 90;\r
-                     jjCheckNAdd(2);\r
+                     jjCheckNAddTwoStates(2, 3);\r
                   }\r
                   if ((0x2000000020L & l) != 0L)\r
                   {\r
@@ -1188,92 +1212,91 @@ private int jjMoveNfa_0(int startState, int curPos)
                         kind = 92;\r
                   }\r
                   if (curChar == 69)\r
-                     jjCheckNAddTwoStates(18, 19);\r
+                     jjCheckNAddTwoStates(19, 20);\r
                   else if (curChar == 101)\r
-                     jjCheckNAddTwoStates(18, 19);\r
+                     jjCheckNAddTwoStates(19, 20);\r
                   break;\r
-               case 48:\r
-               case 2:\r
+               case 50:\r
                   if ((0x7fffffe87fffffeL & l) == 0L)\r
                      break;\r
                   if (kind > 90)\r
                      kind = 90;\r
-                  jjCheckNAdd(2);\r
+                  jjCheckNAddTwoStates(2, 3);\r
                   break;\r
                case 1:\r
                   if ((0x7fffffe87fffffeL & l) == 0L)\r
                      break;\r
                   if (kind > 90)\r
                      kind = 90;\r
-                  jjCheckNAdd(2);\r
+                  jjCheckNAddTwoStates(2, 3);\r
                   break;\r
-               case 4:\r
+               case 5:\r
                   if ((0xffffffffefffffffL & l) != 0L)\r
-                     jjCheckNAddStates(9, 11);\r
+                     jjCheckNAddStates(12, 14);\r
                   break;\r
-               case 5:\r
+               case 6:\r
                   if (curChar == 92)\r
-                     jjstateSet[jjnewStateCnt++] = 6;\r
+                     jjstateSet[jjnewStateCnt++] = 7;\r
                   break;\r
-               case 6:\r
-                  jjCheckNAddStates(9, 11);\r
+               case 7:\r
+                  jjCheckNAddStates(12, 14);\r
                   break;\r
-               case 8:\r
+               case 9:\r
                   if ((0x2000000020L & l) != 0L && kind > 92)\r
                      kind = 92;\r
                   break;\r
-               case 11:\r
+               case 12:\r
                   if ((0x2000000020L & l) != 0L)\r
-                     jjstateSet[jjnewStateCnt++] = 12;\r
+                     jjstateSet[jjnewStateCnt++] = 13;\r
                   break;\r
-               case 13:\r
+               case 14:\r
                   if (curChar == 101)\r
-                     jjCheckNAddTwoStates(14, 15);\r
+                     jjCheckNAddTwoStates(15, 16);\r
                   break;\r
-               case 16:\r
+               case 17:\r
                   if (curChar == 69)\r
-                     jjCheckNAddTwoStates(14, 15);\r
+                     jjCheckNAddTwoStates(15, 16);\r
                   break;\r
-               case 17:\r
+               case 18:\r
                   if (curChar == 101)\r
-                     jjCheckNAddTwoStates(18, 19);\r
+                     jjCheckNAddTwoStates(19, 20);\r
                   break;\r
-               case 20:\r
+               case 21:\r
                   if (curChar == 69)\r
-                     jjCheckNAddTwoStates(18, 19);\r
+                     jjCheckNAddTwoStates(19, 20);\r
                   break;\r
-               case 23:\r
-               case 25:\r
-                  jjCheckNAddStates(12, 14);\r
+               case 24:\r
+               case 26:\r
+                  jjCheckNAddStates(0, 2);\r
                   break;\r
-               case 29:\r
+               case 30:\r
                   if (kind > 3)\r
                      kind = 3;\r
-                  jjstateSet[jjnewStateCnt++] = 29;\r
+                  jjstateSet[jjnewStateCnt++] = 30;\r
                   break;\r
-               case 35:\r
+               case 36:\r
                   if ((0x2000000020L & l) != 0L)\r
-                     jjstateSet[jjnewStateCnt++] = 36;\r
+                     jjstateSet[jjnewStateCnt++] = 37;\r
                   break;\r
-               case 37:\r
+               case 38:\r
                   if (curChar == 101)\r
-                     jjCheckNAddTwoStates(38, 39);\r
+                     jjCheckNAddTwoStates(39, 40);\r
                   break;\r
-               case 40:\r
+               case 41:\r
                   if (curChar == 69)\r
-                     jjCheckNAddTwoStates(38, 39);\r
+                     jjCheckNAddTwoStates(39, 40);\r
                   break;\r
-               case 42:\r
+               case 43:\r
                   if ((0x2000000020L & l) != 0L)\r
-                     jjstateSet[jjnewStateCnt++] = 43;\r
+                     jjstateSet[jjnewStateCnt++] = 44;\r
                   break;\r
-               case 44:\r
+               case 45:\r
                   if (curChar == 101)\r
-                     jjCheckNAddTwoStates(45, 46);\r
+                     jjCheckNAddTwoStates(46, 47);\r
                   break;\r
-               case 47:\r
+               case 48:\r
                   if (curChar == 69)\r
-                     jjCheckNAddTwoStates(45, 46);\r
+                     jjCheckNAddTwoStates(46, 47);\r
                   break;\r
                default : break;\r
             }\r
@@ -1287,22 +1310,22 @@ private int jjMoveNfa_0(int startState, int curPos)
          {\r
             switch(jjstateSet[--i])\r
             {\r
-               case 4:\r
-               case 6:\r
+               case 5:\r
+               case 7:\r
                   if ((jjbitVec0[i2] & l2) != 0L)\r
-                     jjCheckNAddStates(9, 11);\r
+                     jjCheckNAddStates(12, 14);\r
                   break;\r
-               case 23:\r
-               case 25:\r
+               case 24:\r
+               case 26:\r
                   if ((jjbitVec0[i2] & l2) != 0L)\r
-                     jjCheckNAddStates(12, 14);\r
+                     jjCheckNAddStates(0, 2);\r
                   break;\r
-               case 29:\r
+               case 30:\r
                   if ((jjbitVec0[i2] & l2) == 0L)\r
                      break;\r
                   if (kind > 3)\r
                      kind = 3;\r
-                  jjstateSet[jjnewStateCnt++] = 29;\r
+                  jjstateSet[jjnewStateCnt++] = 30;\r
                   break;\r
                default : break;\r
             }\r
@@ -1315,15 +1338,15 @@ private int jjMoveNfa_0(int startState, int curPos)
          kind = 0x7fffffff;\r
       }\r
       ++curPos;\r
-      if ((i = jjnewStateCnt) == (startsAt = 48 - (jjnewStateCnt = startsAt)))\r
+      if ((i = jjnewStateCnt) == (startsAt = 49 - (jjnewStateCnt = startsAt)))\r
          return curPos;\r
       try { curChar = input_stream.readChar(); }\r
       catch(java.io.IOException e) { return curPos; }\r
    }\r
 }\r
 static final int[] jjnextStates = {
-   31, 32, 33, 41, 42, 44, 47, 22, 28, 4, 5, 7, 23, 24, 27, 10
-   11, 13, 16, 34, 35, 37, 40, 41, 42, 44, 47
+   24, 25, 28, 32, 33, 34, 42, 43, 45, 48, 23, 29, 5, 6, 8, 11
+   12, 14, 17, 35, 36, 38, 41, 42, 43, 45, 48
 };\r
 \r
 /** Token literal values. */\r
@@ -1362,8 +1385,8 @@ static final long[] jjtoSkip = {
    0xeL, 0x0L, 
 };\r
 protected SimpleCharStream input_stream;\r
-private final int[] jjrounds = new int[48];\r
-private final int[] jjstateSet = new int[96];\r
+private final int[] jjrounds = new int[49];\r
+private final int[] jjstateSet = new int[98];\r
 private final StringBuilder jjimage = new StringBuilder();\r
 private StringBuilder image = jjimage;\r
 private int jjimageLen;\r
@@ -1394,7 +1417,7 @@ private void ReInitRounds()
 {\r
    int i;\r
    jjround = 0x80000001;\r
-   for (i = 48; i-- > 0;)\r
+   for (i = 49; i-- > 0;)\r
       jjrounds[i] = 0x80000000;\r
 }\r
 \r
index 6c8fb79101ced0ee43ef8a08b1a344422cc4baee..d5f57adb877ac32bbe64832bbc07c51cb4e90207 100644 (file)
@@ -75,7 +75,7 @@ TOKEN:
 | "*" | "/" | ".*" | "./"\r
 | "^" | ".^"\r
 | "=" | ":=" \r
-| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_",".", "0"-"9"])* >\r
+| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_","0"-"9"] | "." ["a"-"z","A"-"Z","_","0"-"9"])* >\r
 | <STRING: "\"" (~["\"", "\\", "\n"] | "\\" ~["\n"])* "\"">\r
     { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); }\r
 | <EXP: "e" | "e-" | "E" | "E-" | "E+" | "e+" >\r
@@ -177,10 +177,10 @@ Node stored_definition()         : {/*@bgen(jjtree) STORED */
 /*** Class Definition **********************************************/\r
   \r
 void class_definition() : {/*@bgen(jjtree) class_definition */\r
-  SimpleNode jjtn000 = new SimpleNode(JJTCLASS_DEFINITION);\r
-  boolean jjtc000 = true;\r
-  jjtree.openNodeScope(jjtn000);\r
-/*@egen*/\r
+                            SimpleNode jjtn000 = new SimpleNode(JJTCLASS_DEFINITION);\r
+                            boolean jjtc000 = true;\r
+                            jjtree.openNodeScope(jjtn000);\r
+/*@egen*/ Token t;\r
 } {/*@bgen(jjtree) class_definition */\r
     try {\r
 /*@egen*/\r
@@ -192,7 +192,7 @@ void class_definition() : {/*@bgen(jjtree) class_definition */
 //  class_specifier\r
     ( "encapsulated" )?\r
     ( "partial" )?\r
-    ( "class" { jjtn000.op = "class"; } | "model" { jjtn000.op = "model"; } | "record" | "block" | ( "expandable" )? "connector" | "type" |\r
+    ( "class" { jjtn000.op = "class"; } | t = "model" { jjtn000.op = "model"; jjtn000.line = t.beginLine; } | "record" | "block" | ( "expandable" )? "connector" | "type" |\r
     "package" { jjtn000.op = "package"; } | "function" { jjtn000.op = "function"; } | "operator" | "operator function" | "operator record" )\r
     class_specifier()/*@bgen(jjtree)*/\r
     } catch (Throwable jjte000) {\r
@@ -234,7 +234,7 @@ void class_specifier() : {/*@bgen(jjtree) class_specifier */
 //  | IDENT "=" der "(" name "," IDENT { "," IDENT } ")" comment\r
 //  | extends IDENT [ class_modification ] string_comment composition\r
 //  end IDENT  \r
-    LOOKAHEAD(2) t=<IDENT> { jjtn000.op = t.image; } string_comment() composition() "end" <IDENT>\r
+    LOOKAHEAD(2) t=<IDENT> { jjtn000.op = t.image; jjtn000.line = t.beginLine; } string_comment() composition() "end" <IDENT>\r
     | LOOKAHEAD(2) <IDENT> "=" base_prefix() name() ( array_subscripts() )? ( class_modification() )? comment()\r
     | LOOKAHEAD(3)  <IDENT> "=" "der" "(" name() "," <IDENT> ( "," <IDENT> )* ")" comment()\r
     | LOOKAHEAD(3) <IDENT> "=" "enumeration" "(" ( ( enum_list() )? | ":" ) ")" comment()/*@bgen(jjtree)*/\r
@@ -924,7 +924,7 @@ Parameter declaration() : {/*@bgen(jjtree) declaration */
         try {\r
 /*@egen*/\r
 //     IDENT [ array_subscripts ] [ modification ]\r
-       <IDENT> { ret.name = new String(token.image); jjtn000.op = token.image; }\r
+       <IDENT> { ret.name = new String(token.image); jjtn000.op = token.image; jjtn000.line = token.beginLine; }\r
        ( array_subscripts() )?\r
        ( ret.optional = modification() )?/*@bgen(jjtree)*/\r
         {\r
@@ -1454,8 +1454,8 @@ void statement() : {/*@bgen(jjtree) statement */
 //     comment\r
        ( component_reference() ( ":=" expression() | function_call_args() )\r
                | "(" output_expression_list() ")" ":=" component_reference() function_call_args()\r
-               | "break"\r
-               | "return"\r
+               | "break" { jjtn000.op = "break";}\r
+               | "return" { jjtn000.op = "return";}\r
                | if_statement()\r
                | for_statement()\r
                | while_statement()\r
@@ -2300,7 +2300,17 @@ void add_op() : {/*@bgen(jjtree) add_op */
                                      jjtree.closeNodeScope(jjtn000, true);\r
                                      jjtc000 = false;\r
                                    }\r
-/*@egen*/ { jjtn000.op = "-";} | ".+" | ".-"/*@bgen(jjtree)*/\r
+/*@egen*/ { jjtn000.op = "-";} | ".+"/*@bgen(jjtree)*/\r
+                                                               {\r
+                                                                 jjtree.closeNodeScope(jjtn000, true);\r
+                                                                 jjtc000 = false;\r
+                                                               }\r
+/*@egen*/ { jjtn000.op = ".+";} | ".-"/*@bgen(jjtree)*/\r
+                                                                                            {\r
+                                                                                              jjtree.closeNodeScope(jjtn000, true);\r
+                                                                                              jjtc000 = false;\r
+                                                                                            }\r
+/*@egen*/ { jjtn000.op = ".-";}/*@bgen(jjtree)*/\r
     } finally {\r
       if (jjtc000) {\r
         jjtree.closeNodeScope(jjtn000, true);\r
@@ -2349,33 +2359,33 @@ void mul_op() : {/*@bgen(jjtree) mul_op */
 } {/*@bgen(jjtree) mul_op */\r
     try {\r
 /*@egen*/\r
-    "*"/*@bgen(jjtree)*/\r
-        {\r
-          jjtree.closeNodeScope(jjtn000, true);\r
-          jjtc000 = false;\r
-        }\r
-/*@egen*/ { jjtn000.op = "*";} | "/"/*@bgen(jjtree)*/\r
-                                   {\r
-                                     jjtree.closeNodeScope(jjtn000, true);\r
-                                     jjtc000 = false;\r
-                                   }\r
-/*@egen*/ { jjtn000.op = "/";} | ".*"/*@bgen(jjtree)*/\r
-                                                               {\r
-                                                                 jjtree.closeNodeScope(jjtn000, true);\r
-                                                                 jjtc000 = false;\r
-                                                               }\r
+    ".*"/*@bgen(jjtree)*/\r
+         {\r
+           jjtree.closeNodeScope(jjtn000, true);\r
+           jjtc000 = false;\r
+         }\r
 /*@egen*/ { jjtn000.op = ".*";} | "./"/*@bgen(jjtree)*/\r
-                                                                                             {\r
-                                                                                               jjtree.closeNodeScope(jjtn000, true);\r
-                                                                                               jjtc000 = false;\r
-                                                                                             }\r
-/*@egen*/  { jjtn000.op = "./";}/*@bgen(jjtree)*/\r
+                                       {\r
+                                         jjtree.closeNodeScope(jjtn000, true);\r
+                                         jjtc000 = false;\r
+                                       }\r
+/*@egen*/  { jjtn000.op = "./";} | "*"/*@bgen(jjtree)*/\r
+                                                                   {\r
+                                                                     jjtree.closeNodeScope(jjtn000, true);\r
+                                                                     jjtc000 = false;\r
+                                                                   }\r
+/*@egen*/ { jjtn000.op = "*";} | "/"/*@bgen(jjtree)*/\r
+                                                                                              {\r
+                                                                                                jjtree.closeNodeScope(jjtn000, true);\r
+                                                                                                jjtc000 = false;\r
+                                                                                              }\r
+/*@egen*/ { jjtn000.op = "/";}/*@bgen(jjtree)*/\r
     } finally {\r
       if (jjtc000) {\r
         jjtree.closeNodeScope(jjtn000, true);\r
       }\r
     }\r
-/*@egen*/\r
+/*@egen*/ \r
 }\r
 \r
 void factor() : {/*@bgen(jjtree) factor */\r
@@ -2633,7 +2643,7 @@ void component_reference() : {/*@bgen(jjtree) component_reference */
         try {\r
 /*@egen*/\r
 //     [ "." ] IDENT [ array_subscripts ] { "." IDENT [ array_subscripts ] }\r
-       ( "." )? t=<IDENT> { jjtn000.op = t.image; } ( array_subscripts() )? ( "." <IDENT> ( array_subscripts() )? )*/*@bgen(jjtree)*/\r
+       ( "." )? t=<IDENT> { jjtn000.op = t.image; jjtn000.line = t.beginLine; } ( array_subscripts() )? ( "." <IDENT> ( array_subscripts() )? )*/*@bgen(jjtree)*/\r
         } catch (Throwable jjte000) {\r
           if (jjtc000) {\r
             jjtree.clearNodeScope(jjtn000);\r
index 977d83d7ce37f61b67ec5204c1041c8ec5ac6628..87103388fce5d648059b3ae03f9cf3b052d80475 100644 (file)
@@ -71,7 +71,7 @@ TOKEN:
 | "*" | "/" | ".*" | "./"\r
 | "^" | ".^"\r
 | "=" | ":=" \r
-| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_",".", "0"-"9"])* >\r
+| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_","0"-"9"] | "." ["a"-"z","A"-"Z","_","0"-"9"])* >\r
 | <STRING: "\"" (~["\"", "\\", "\n"] | "\\" ~["\n"])* "\"">\r
     { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); }\r
 | <EXP: "e" | "e-" | "E" | "E-" | "E+" | "e+" >\r
@@ -110,7 +110,7 @@ Node stored_definition() #STORED : {
 \r
 /*** Class Definition **********************************************/\r
   \r
-void class_definition() : {\r
+void class_definition() : { Token t;\r
 } {\r
 //  class_definition :\r
 //  [ encapsulated ]\r
@@ -120,7 +120,7 @@ void class_definition() : {
 //  class_specifier\r
     ( "encapsulated" )?\r
     ( "partial" )?\r
-    ( "class" { jjtThis.op = "class"; } | "model" { jjtThis.op = "model"; } | "record" | "block" | ( "expandable" )? "connector" | "type" |\r
+    ( "class" { jjtThis.op = "class"; } | t = "model" { jjtThis.op = "model"; jjtThis.line = t.beginLine; } | "record" | "block" | ( "expandable" )? "connector" | "type" |\r
     "package" { jjtThis.op = "package"; } | "function" { jjtThis.op = "function"; } | "operator" | "operator function" | "operator record" )\r
     class_specifier()\r
 }\r
@@ -136,7 +136,7 @@ void class_specifier() : { Token t;
 //  | IDENT "=" der "(" name "," IDENT { "," IDENT } ")" comment\r
 //  | extends IDENT [ class_modification ] string_comment composition\r
 //  end IDENT  \r
-    LOOKAHEAD(2) t=<IDENT> { jjtThis.op = t.image; } string_comment() composition() "end" <IDENT>\r
+    LOOKAHEAD(2) t=<IDENT> { jjtThis.op = t.image; jjtThis.line = t.beginLine; } string_comment() composition() "end" <IDENT>\r
     | LOOKAHEAD(2) <IDENT> "=" base_prefix() name() ( array_subscripts() )? ( class_modification() )? comment()\r
     | LOOKAHEAD(3)  <IDENT> "=" "der" "(" name() "," <IDENT> ( "," <IDENT> )* ")" comment()\r
     | LOOKAHEAD(3) <IDENT> "=" "enumeration" "(" ( ( enum_list() )? | ":" ) ")" comment()\r
@@ -320,7 +320,7 @@ Parameter declaration() : { Token t;
     Parameter ret = new Parameter();\r
 } {\r
 //     IDENT [ array_subscripts ] [ modification ]\r
-       <IDENT> { ret.name = new String(token.image); jjtThis.op = token.image; }\r
+       <IDENT> { ret.name = new String(token.image); jjtThis.op = token.image; jjtThis.line = token.beginLine; }\r
        ( array_subscripts() )?\r
        ( ret.optional = modification() )?\r
        {\r              return ret;\r    }\r
@@ -445,8 +445,8 @@ void statement() : {
 //     comment\r
        ( component_reference() ( ":=" expression() | function_call_args() )\r
                | "(" output_expression_list() ")" ":=" component_reference() function_call_args()\r
-               | "break"\r
-               | "return"\r
+               | "break" { jjtThis.op = "break";}\r
+               | "return" { jjtThis.op = "return";}\r
                | if_statement()\r
                | for_statement()\r
                | while_statement()\r
@@ -641,7 +641,7 @@ void arithmetic_expression() : {
 \r
 void add_op() : {\r
 } {\r
-    "+" { jjtThis.op = "+";} | "-" { jjtThis.op = "-";} | ".+" | ".-"\r
+    "+" { jjtThis.op = "+";} | "-" { jjtThis.op = "-";} | ".+" { jjtThis.op = ".+";} | ".-" { jjtThis.op = ".-";}\r
 }\r
 \r
 \r
@@ -652,7 +652,7 @@ void term() : {
 \r
 void mul_op() : {\r
 } {\r
-    "*" { jjtThis.op = "*";} | "/" { jjtThis.op = "/";} | ".*" { jjtThis.op = ".*";} | "./"  { jjtThis.op = "./";}\r
+    ".*" { jjtThis.op = ".*";} | "./"  { jjtThis.op = "./";} | "*" { jjtThis.op = "*";} | "/" { jjtThis.op = "/";} \r
 }\r
 \r
 void factor() : {\r
@@ -710,7 +710,7 @@ void component_reference() : {
   Token t;\r
 } {\r
 //     [ "." ] IDENT [ array_subscripts ] { "." IDENT [ array_subscripts ] }\r
-       ( "." )? t=<IDENT> { jjtThis.op = t.image; } ( array_subscripts() )? ( "." <IDENT> ( array_subscripts() )? )*\r
+       ( "." )? t=<IDENT> { jjtThis.op = t.image; jjtThis.line = t.beginLine; } ( array_subscripts() )? ( "." <IDENT> ( array_subscripts() )? )*\r
 }\r
 \r
 void function_call_args() : {\r
index b399a88f63cd2742b635f088940c3db98e56d496..4a12bf77a95b09db01ea3b49d549bb9170dcf98f 100644 (file)
@@ -11,6 +11,7 @@ class SimpleNode implements Node {
   protected Object value;\r
   protected ModelParser parser;\r
   \r
+  public int line = -1;\r
   public String op;\r
 \r
   public SimpleNode(int i) {\r