From: jsimomaa Date: Thu, 16 Oct 2014 06:55:20 +0000 (+0000) Subject: Merged trunk@30111, @30195, @30274, @30356, @30385 to branches/sysdyn-1.8 on 2014... X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=3a592db49830306d15dab9edf649dfd79af0fb1e;p=simantics%2Fsysdyn.git Merged trunk@30111, @30195, @30274, @30356, @30385 to branches/sysdyn-1.8 on 2014-10-16 for 1.8.2 release. refs #5198 refs #5224 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches/1.8@30413 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Addition.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Addition.java index 8c09ab6f..6c531d41 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Addition.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Addition.java @@ -12,6 +12,8 @@ package fi.semantum.sysdyn.solver; import java.util.Map; +import fi.semantum.sysdyn.solver.Array.Modifier2; + public class Addition implements IExpression { public IExpression exp1; @@ -38,7 +40,14 @@ public class Addition implements IExpression { if(o1 instanceof Array && o2 instanceof Array) { Array la = (Array)o1; Array ra = (Array)o2; - return la.add(ra); + return la.copy2(ra, new Modifier2() { + + @Override + public Object modify(Object o1, Object o2) { + if(o1 instanceof Double && o2 instanceof Double) return ((Double)o1)+((Double)o2); + throw new IllegalStateException("Tried to add a non-numerical array"); + } + }); } throw new IllegalStateException(); } diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Array.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Array.java index 68a0504b..cb16d4b9 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Array.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Array.java @@ -16,11 +16,16 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +/* + * For matrices first dimension is rows and second is columns i.e. top level elements are rows + */ public class Array implements IExpression { public static final Array FULL = new Array(); final private ArrayList elements; + + boolean isVector = true; public Array() { elements = new ArrayList(); @@ -32,7 +37,15 @@ public class Array implements IExpression { public Array addElement(Object element) { if(element instanceof Constant) addElement(((Constant)element).value); - else elements.add(element); + else { + +// if(element instanceof Double) +// if(Double.isNaN((Double)element)) +// throw new IllegalStateException(); + + if(element instanceof Array) isVector = false; + elements.add(element); + } return this; } @@ -68,7 +81,15 @@ public class Array implements IExpression { } public int size(int col) { - return elements.size(); + + if(col == 1) return elements.size(); + + if(elements.isEmpty()) throw new IllegalStateException(); + Object elem = element(0); + if(!(elem instanceof Array)) throw new IllegalStateException(); + + return ((Array)elem).size(col-1); + } public Object element(int index) { @@ -283,23 +304,22 @@ public class Array implements IExpression { throw new IllegalStateException(); } - - public Array add(Array other) { - Array result = new Array(); + + /* + * Both arrays are vectors + */ + public double inner(Array other) { + double result = 0; Collection lae = elements(); Collection rae = other.elements(); - if(lae.size() != rae.size()) throw new IllegalStateException(); + if(lae.size() != rae.size()) throw new IllegalStateException("inner product: vector sizes do not match: " + this + " vs. " + other); Iterator li = lae.iterator(); Iterator ri = rae.iterator(); for(int i=0;i lae = elements(); - Collection rae = other.elements(); - if(lae.size() != rae.size()) throw new IllegalStateException(); - Iterator li = lae.iterator(); - Iterator ri = rae.iterator(); - for(int i=0;i lae = elements(); @@ -378,5 +406,193 @@ public class Array implements IExpression { } return result; } + + interface Modifier { + Object modify(Object o); + } + + interface Modifier2 { + Object modify(Object o1, Object o2); + } + + public Array copy(Modifier modifier) { + Array result = new Array(); + for(Object element : elements) { + if(element instanceof Array) { + Array sub = (Array)element; + result.addElement(sub.copy(modifier)); + } else { + result.addElement(modifier.modify(element)); + } + } + return result; + } + + public Array copy2(Array other, Modifier2 modifier) { + Array result = new Array(); + Collection es = elements(); + Collection oes = other.elements(); + if(es.size() != oes.size()) throw new IllegalStateException("Array dimensions do not match"); + Iterator e = es.iterator(); + Iterator oe = oes.iterator(); + for(int i=0;i elements = elements(); + if(elements.isEmpty()) return this; + + Array first = (Array)elements.get(0); + + Array[] arrs = new Array[first.elements().size()]; + for(int i=0;i copies) { + exp1 = exp1.rewrite(frame, copies); + exp2 = exp2.rewrite(frame, copies); + return this; + } + + @Override + public void accept(ExpressionVisitor visitor) { + visitor.visit(this); + exp1.accept(visitor); + exp2.accept(visitor); + } + +} diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseDivision.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseDivision.java index 77362aa5..ffb93df7 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseDivision.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseDivision.java @@ -10,10 +10,11 @@ *******************************************************************************/ package fi.semantum.sysdyn.solver; -import java.util.Collection; -import java.util.Iterator; import java.util.Map; +import fi.semantum.sysdyn.solver.Array.Modifier; +import fi.semantum.sysdyn.solver.Array.Modifier2; + public class ElementwiseDivision implements IExpression { public IExpression exp1; @@ -36,29 +37,41 @@ public class ElementwiseDivision implements IExpression { if(left instanceof Array && right instanceof Array) { Array la = (Array)left; Array ra = (Array)right; - Collection lae = la.elements(); - Collection rae = ra.elements(); - if(lae.size() != rae.size()) throw new UnsupportedOperationException(); - Iterator li = lae.iterator(); - Iterator ri = rae.iterator(); - Array result = new Array(); - for(int i=0;i lae = la.elements(); - Iterator li = lae.iterator(); - Array result = new Array(); - for(int i=0;i lae = la.elements(); - Collection rae = ra.elements(); - if(lae.size() != rae.size()) throw new UnsupportedOperationException(); - Iterator li = lae.iterator(); - Iterator ri = rae.iterator(); - Array result = new Array(); - for(int i=0;i lae = la.elements(); - List rae = ra.elements(); - if(lae.size() != rae.size()) throw new UnsupportedOperationException(); - Array result = new Array(lae.size()); - int index = 0; - for(Object o : lae) { - Double ld = (Double)o; - Double rd = (Double)rae.get(index++); - result.addElement(ld*rd); - } - return result; + return la.copy2(ra, new Modifier2() { + + @Override + public Object modify(Object o1, Object o2) { + if(o1 instanceof Double && o2 instanceof Double) return ((Double)o1)*((Double)o2); + throw new IllegalStateException("Tried to multiply a non-numerical array"); + } + }); } else if (left instanceof Array && right instanceof Double) { Array la = (Array)left; - Double rd = (Double)right; - List lae = la.elements(); - Array result = new Array(lae.size()); - for(Object o : lae) { - Double ld = (Double)o; - result.addElement(ld*rd); - } - return result; + final double rd = (Double)right; + return la.copy(new Modifier() { + + @Override + public Object modify(Object o) { + if(o instanceof Double) return ((Double)o)*rd; + else throw new IllegalStateException("Tried to multiply a non-numerical array"); + } + + }); + } else if (left instanceof Double && right instanceof Array) { + Array la = (Array)right; + final double rd = (Double)left; + return la.copy(new Modifier() { + + @Override + public Object modify(Object o) { + if(o instanceof Double) return ((Double)o)*rd; + else throw new IllegalStateException("Tried to multiply a non-numerical array"); + } + + }); } else { throw new UnsupportedOperationException(); } 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 index 00000000..55a36627 --- /dev/null +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseSubtraction.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2013 Semantum Oy. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package fi.semantum.sysdyn.solver; + +import java.util.Map; + +import fi.semantum.sysdyn.solver.Array.Modifier2; + +public class ElementwiseSubtraction implements IExpression { + + public IExpression exp1; + public IExpression exp2; + + public ElementwiseSubtraction(IExpression exp1, IExpression exp2) { + if(exp1 == null) exp1 = new Constant("0"); + this.exp1 = exp1; + this.exp2 = exp2; + } + + @Override + public String toString() { + return exp1 + " - " + exp2; + } + + @Override + public Object evaluate(IEnvironment environment) { + Object o1 = exp1.evaluate(environment); + Object o2 = exp2.evaluate(environment); + if(o1 == null || o2 == null) return null; + if(o1 instanceof Double && o2 instanceof Double) { + return (Double)o1 - (Double)o2; + } + if(o1 instanceof Array && o2 instanceof Array) { + Array la = (Array)o1; + Array ra = (Array)o2; + return la.copy2(ra, new Modifier2() { + + @Override + public Object modify(Object o1, Object o2) { + if(o1 instanceof Double && o2 instanceof Double) return ((Double)o1)-((Double)o2); + throw new IllegalStateException("Tried to subtract a non-numerical array"); + } + }); + } + throw new IllegalStateException(); + } + + @Override + public IExpression withBase(IFrame frame, String prefix) { + return new ElementwiseSubtraction(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix)); + } + + @Override + public Object getPossibleConstant() { + return null; + } + + @Override + public IExpression rewrite(IFrame frame, Map copies) { + exp1 = exp1.rewrite(frame, copies); + exp2 = exp2.rewrite(frame, copies); + return this; + } + + @Override + public void accept(ExpressionVisitor visitor) { + visitor.visit(this); + exp1.accept(visitor); + exp2.accept(visitor); + } + +} diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Environment.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Environment.java index d3cfce24..135410d7 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Environment.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Environment.java @@ -11,6 +11,7 @@ *******************************************************************************/ package fi.semantum.sysdyn.solver; +import fi.semantum.sysdyn.solver.Array.Modifier; import gnu.trove.list.array.TIntArrayList; import gnu.trove.map.hash.TObjectIntHashMap; @@ -28,7 +29,7 @@ interface Fn { public Object evaluateInput(IEnvironment environment, int argPosition); public void setLocals(IEnvironment environment); public int offset(); - public Variable[] parameters(); + public Variable[] parameters(int args); } abstract class Fn1 implements Fn { @@ -36,17 +37,25 @@ abstract class Fn1 implements Fn { Variable[] parameters; public Fn1(int pCount) { - parameters = new Variable[pCount]; - for(int i=0;i 0) { + parameters = new Variable[pCount]; + for(int i=0;i indices = new ArrayList(); + + public int line; - public Function(String name, IStatement statement) { + public Function(String name, IStatement statement, int line) { this.name = name; this.statement = statement; + this.line = line; } public Object evaluate(IEnvironment environment, int argc) { @@ -48,7 +51,12 @@ final public class Function implements Fn, IFrame { } for(int i=0;i ((Double)exp2.evaluate(environment)); + Object left = exp1.evaluate(environment); + Object right = exp2.evaluate(environment); + return ((Double)left) > ((Double)right); } @Override diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IStatement.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IStatement.java index e50a09bc..efb5472f 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IStatement.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IStatement.java @@ -12,6 +12,10 @@ package fi.semantum.sysdyn.solver; public interface IStatement { - public void evaluate(IEnvironment environment); + public enum ReturnValue { + CONTINUE,BREAK,RETURN; + } + + public ReturnValue evaluate(IEnvironment environment); } diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IfStatement.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IfStatement.java index 37dc2af2..8fb020e7 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IfStatement.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IfStatement.java @@ -28,11 +28,11 @@ public class IfStatement implements IStatement { } @Override - public void evaluate(IEnvironment environment) { + public ReturnValue evaluate(IEnvironment environment) { if((Boolean)exp.evaluate(environment)) { - t.evaluate(environment); + return t.evaluate(environment); } else { - e.evaluate(environment); + return e.evaluate(environment); } } diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Model.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Model.java index e4b1337a..ab861d89 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Model.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Model.java @@ -13,6 +13,7 @@ package fi.semantum.sysdyn.solver; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -39,6 +40,7 @@ class Model implements IFrame { public final Globals globals; + public int line = -1; public String name; public boolean isEnumClass; @@ -81,6 +83,16 @@ class Model implements IFrame { return base; } + private void reportException(Fn fn, ExecutionException e) throws ExecutionException { + + if(fn instanceof Function) { + throw new ExecutionException("function " + name + ": " + (e.line - ((Function)fn).line) + ": " + e.getMessage()); + } else { + throw new ExecutionException("function " + name + ": " + (e.line - ((Function)fn).line) + ": " + e.getMessage()); + } + + } + public Object evaluateFunction(IEnvironment environment, String name, ArgumentList args) { Fn fn = getFunction(name); if(fn == null) { @@ -98,7 +110,7 @@ class Model implements IFrame { argh.add(args.args[i].modification.evaluate(environment)); } - Variable[] parameters = fn.parameters(); + Variable[] parameters = fn.parameters(argh.size()); for(int i=0;i arrs = new ArrayList(); for(int i=0;i 0 && dim != vectorDimension) throw new IllegalStateException("Array dimensions do not agree"); + vectorDimension = dim; + vector[i] = true; + arrs.add((Array)ps[i]); + } else { + vector[i] = false; } } - fn.setLocals(frame); - return fn.evaluate(frame, args.args.length); + if(vectorDimension > 0) { + + return arrayEvaluate(frame, fn, parameters, ps, vector, arrs); + + } else { + + for(int i=0;i arrs) { + + Array result = new Array(); + + Array first = arrs.get(0); + + int d = first.elements().size(); + if(d == 0) return result; + + Object firstElement = first.element(0); + boolean subArray = firstElement instanceof Array; + + for(int i=0;i subArrs = new ArrayList(); + for(int j=0;j work, VariableBase target) { diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/MultiStatement.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/MultiStatement.java index ff330375..f7c5083f 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/MultiStatement.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/MultiStatement.java @@ -30,12 +30,13 @@ public class MultiStatement implements IStatement { } @Override - public void evaluate(IEnvironment environment) { + public ReturnValue evaluate(IEnvironment environment) { @SuppressWarnings("unchecked") ArrayList values = (ArrayList)environment.getSystem().evaluateFunction(environment, fn.base.name, args); for(int i=0;i stms2 = new ArrayList(); - Function function = new Function(functionName, new StatementList(stms2)); + Function function = new Function(functionName, new StatementList(stms2), child.line); ArrayList composition = (ArrayList)walk(child, indent+2, function); for(int i=1;i os = (ArrayList)os_; for(Object o : os) { VariableDeclaration decl = (VariableDeclaration)o; - function.internals.add(decl); + if("input".equals(decl.direction)) function.inputs.add(decl); + else if ("output".equals(decl.direction)) function.outputs.add(decl); + else function.internals.add(decl); } } } } } - ArrayList declarations = (ArrayList)composition.get(0); - for(Object os_ : declarations) { - if(os_ instanceof VariableDeclaration) { - VariableDeclaration decl = (VariableDeclaration)os_; - if("input".equals(decl.direction)) function.inputs.add(decl); - else if ("output".equals(decl.direction)) function.outputs.add(decl); - else throw new IllegalStateException(); - } else { - ArrayList os = (ArrayList)os_; - for(Object o : os) { - VariableDeclaration decl = (VariableDeclaration)o; + if(!composition.isEmpty()) { + ArrayList declarations = (ArrayList)composition.get(0); + for(Object os_ : declarations) { + if(os_ instanceof VariableDeclaration) { + VariableDeclaration decl = (VariableDeclaration)os_; if("input".equals(decl.direction)) function.inputs.add(decl); else if ("output".equals(decl.direction)) function.outputs.add(decl); - else throw new IllegalStateException(); + else function.internals.add(decl); + } else { + ArrayList os = (ArrayList)os_; + for(Object o : os) { + VariableDeclaration decl = (VariableDeclaration)o; + if("input".equals(decl.direction)) function.inputs.add(decl); + else if ("output".equals(decl.direction)) function.outputs.add(decl); + else function.internals.add(decl); + } } } } + model.functions.put(functionName, function); return function; } else if("model".equals(n.op)) { + model.line = n.line; + if(n.jjtGetNumChildren() == 1) { return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame); } else { @@ -419,8 +435,8 @@ public class Parser { walk(specifier, indent+2, clazz); if(clazz.isEnumClass) { - Variable sizeVariable = new Variable(clazz, "size", null); - Variable elementsVariable = new Variable(clazz, "elements", new IExpression[] { new Constant(""+clazz.variables.size()) }); + Variable sizeVariable = new Variable(clazz, "size", null, n.line); + Variable elementsVariable = new Variable(clazz, "elements", new IExpression[] { new Constant(""+clazz.variables.size()) }, n.line); clazz.parameters.add(new ParameterDeclaration(sizeVariable, sizeVariable.getPossibleConstant())); clazz.parameters.add(new ParameterDeclaration(elementsVariable, elementsVariable.getPossibleConstant())); } @@ -457,12 +473,12 @@ public class Parser { } case component_reference: if(n.jjtGetNumChildren() == 1) { - return Variable.make(frame, n.op, (IExpression[])walk((SimpleNode)n.jjtGetChild(0), indent+2, frame)); + return Variable.make(frame, n.op, (IExpression[])walk((SimpleNode)n.jjtGetChild(0), indent+2, frame), n.line); } else { if ("time".equals(n.op)) { return new TimeVariable(); } - return Variable.make(frame, n.op, null); + return Variable.make(frame, n.op, null, n.line); } case relation: if(n.jjtGetNumChildren() == 3) { @@ -536,7 +552,9 @@ public class Parser { String op = ((String)walk((SimpleNode)n.jjtGetChild(i), indent+2, model)).trim(); IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(i+1), indent+2, frame); if("+".equals(op)) left = new Addition(left, exp2); + else if(".+".equals(op)) left = new ElementwiseAddition(left, exp2); else if("-".equals(op)) left = new Subtraction(left, exp2); + else if(".-".equals(op)) left = new ElementwiseSubtraction(left, exp2); } return left; 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 index 00000000..023ae534 --- /dev/null +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Return.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2013 Semantum Oy. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package fi.semantum.sysdyn.solver; + + +public class Return implements IStatement { + + public Return() { + } + + @Override + public String toString() { + return "return"; + } + + @Override + public ReturnValue evaluate(IEnvironment environment) { + return ReturnValue.RETURN; + } + +} diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java index 6ea46d57..80484a56 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java @@ -28,18 +28,18 @@ import fi.semantum.sysdyn.solver.parser.SimpleNode; public class Solver { + private static final boolean VALIDATE = true; private static final boolean PRINT_EXCEPTIONS = false; private static final int STACK_SIZE = 1000; + private static final int MAX_LOOPS = 50; private Model model; private Environment env; private Object[] newValues; - private Object[] derivatives; private double defaultStep; private double start; - private NodeCache cache; private boolean ready; private boolean dirty; @@ -49,7 +49,6 @@ public class Solver { defaultStep = 0.1; start = 0; // is it okay to store the cache with the solver instance? - cache = new NodeCache(); ready = false; } @@ -112,6 +111,24 @@ public class Solver { private SimpleNode n; private String codeCache = null; + private void validate(Variable var, Object value) { + if(VALIDATE) { + if(value instanceof Double) { + if(Double.isNaN((Double)value)) { + System.err.println("value is invalid (NaN): " + var.base.name); + throw new IllegalStateException("value is invalid (NaN)"); + } + if(Double.isInfinite((Double)value)) { + System.err.println("value is invalid (Infinite): " + var.base.name); + throw new IllegalStateException("value is invalid (Infinite)"); + } + } + if(value instanceof Array) { + for(Object o : ((Array)value).elements()) validate(var, o); + } + } + } + public void prepare(String input) throws Exception { long startNanos = System.nanoTime(); @@ -148,13 +165,16 @@ public class Solver { model.parameterArray = model.parameters.toArray(new ParameterDeclaration[model.parameters.size()]); newValues = new Object[Math.max(model.assignments.size(),model.derivatives.size())]; - derivatives = new Object[model.derivatives.size()]; int condition = 1; int loops = 0; - while(condition > 0 && loops++ < 50) { + StringBuilder errors = null; + + while(condition > 0 && loops++ < MAX_LOOPS) { + if(loops == MAX_LOOPS) errors = new StringBuilder(); + if(PRINT_EXCEPTIONS) { System.err.println("== LOOP " + loops + " =="); } @@ -164,14 +184,21 @@ public class Solver { for(ParameterDeclaration pd : model.parameters) { try { if(!pd.assigned) { - pd.variable.assign(env, null, pd.modification.evaluate(env)); + Object value = pd.modification.evaluate(env); + validate(pd.variable, value); + pd.variable.assign(env, null, value); pd.assigned = true; } } catch (Exception e) { + String error = " -" + pd.variable.toString() + ": " + e.getMessage(); + if(errors != null) { + errors.append(error); + errors.append("\n"); + } condition++; if(PRINT_EXCEPTIONS) { e.printStackTrace(); - System.err.println("failed to assign " + pd.variable.toString()); + System.err.println(error); } } } @@ -187,12 +214,16 @@ public class Solver { if(arg.name.endsWith("start")) { Object value = arg.modification.evaluate(env); if(vd.variable.base.dimension() == 1) { + validate(vd.variable, value); vd.variable.assign(env, null, value); } else { + validate(vd.variable, value); if(value instanceof Double) { Array array = new Array(); for(int i=0;i 1) { + + Array array = new Array(); + intoArray(environment, index, 0, array); if(subscripts != null) { - - Array[] sub = SolverUtils.parseSubscripts(environment, subscripts); - if(SolverUtils.isSlice(sub)) { - Array arr = new Array(); - intoArray(environment, index, 0, arr); - return arr.slice(sub); - } else { - return environment.getValue(index(environment, subscripts)); - } - - } else { - Array array = new Array(); - intoArray(environment, index, 0, array); - return array; + return array.subscript(environment, subscripts); } + else return array; + +// if(subscripts != null) { +// +// Array[] sub = SolverUtils.parseSubscripts(environment, subscripts); +// if(SolverUtils.isSlice(sub)) { +// Array arr = new Array(); +// intoArray(environment, index, 0, arr); +// return arr.slice(sub); +// } else { +// return environment.getValue(index(environment, subscripts)); +// } +// +// } else { +// return array; +// } } Object result = environment.getNamedValue(name); diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/While.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/While.java index 47e94c86..61af2515 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/While.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/While.java @@ -26,9 +26,13 @@ public class While implements IStatement { } @Override - public void evaluate(IEnvironment environment) { - while ((Boolean)expression.evaluate(environment)) - statement.evaluate(environment); + public ReturnValue evaluate(IEnvironment environment) { + while ((Boolean)expression.evaluate(environment)) { + ReturnValue ret = statement.evaluate(environment); + if(ReturnValue.BREAK.equals(ret)) return ReturnValue.CONTINUE; + else if(ReturnValue.RETURN.equals(ret)) return ReturnValue.RETURN; + } + return ReturnValue.CONTINUE; } } diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParser.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParser.java index c50c6058..b1101a81 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParser.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParser.java @@ -166,9 +166,9 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo /*** Class Definition **********************************************/ final public void class_definition() throws ParseException { /*@bgen(jjtree) class_definition */ - SimpleNode jjtn000 = new SimpleNode(JJTCLASS_DEFINITION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); + SimpleNode jjtn000 = new SimpleNode(JJTCLASS_DEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000);Token t; try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 30: @@ -192,8 +192,8 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo jjtn000.op = "class"; break; case 7: - jj_consume_token(7); - jjtn000.op = "model"; + t = jj_consume_token(7); + jjtn000.op = "model"; jjtn000.line = t.beginLine; break; case 61: jj_consume_token(61); @@ -268,7 +268,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo try { if (jj_2_1(2)) { t = jj_consume_token(IDENT); - jjtn000.op = t.image; + jjtn000.op = t.image; jjtn000.line = t.beginLine; string_comment(); composition(); jj_consume_token(35); @@ -1403,7 +1403,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo Parameter ret = new Parameter(); try { jj_consume_token(IDENT); - ret.name = new String(token.image); jjtn000.op = token.image; + ret.name = new String(token.image); jjtn000.op = token.image; jjtn000.line = token.beginLine; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 66: array_subscripts(); @@ -2193,9 +2193,11 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo break; case 29: jj_consume_token(29); + jjtn000.op = "break"; break; case 18: jj_consume_token(18); + jjtn000.op = "return"; break; case 31: if_statement(); @@ -3600,9 +3602,15 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo break; case 80: jj_consume_token(80); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.op = ".+"; break; case 81: jj_consume_token(81); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.op = ".-"; break; default: jj_la1[103] = jj_gen; @@ -3667,29 +3675,29 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo jjtree.openNodeScope(jjtn000); try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 82: - jj_consume_token(82); - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtn000.op = "*"; - break; - case 83: - jj_consume_token(83); - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtn000.op = "/"; - break; case 84: jj_consume_token(84); - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtn000.op = ".*"; + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.op = ".*"; break; case 85: jj_consume_token(85); - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - jjtn000.op = "./"; + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.op = "./"; + break; + case 82: + jj_consume_token(82); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.op = "*"; + break; + case 83: + jj_consume_token(83); + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + jjtn000.op = "/"; break; default: jj_la1[105] = jj_gen; @@ -4039,7 +4047,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo ; } t = jj_consume_token(IDENT); - jjtn000.op = t.image; + jjtn000.op = t.image; jjtn000.line = t.beginLine; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 66: array_subscripts(); @@ -4655,11 +4663,16 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo finally { jj_save(9, xla); } } + private boolean jj_3R_136() { + if (jj_scan_token(81)) return true; + return false; + } + private boolean jj_3R_74() { if (jj_scan_token(62)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_167()) jj_scanpos = xsp; + if (jj_3R_169()) jj_scanpos = xsp; if (jj_scan_token(63)) return true; return false; } @@ -4674,16 +4687,16 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_154() { + private boolean jj_3R_156() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(68)) jj_scanpos = xsp; if (jj_scan_token(IDENT)) return true; xsp = jj_scanpos; - if (jj_3R_162()) jj_scanpos = xsp; + if (jj_3R_164()) jj_scanpos = xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_163()) { jj_scanpos = xsp; break; } + if (jj_3R_165()) { jj_scanpos = xsp; break; } } return false; } @@ -4694,18 +4707,18 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_160() { - if (jj_scan_token(58)) return true; + private boolean jj_3R_153() { + if (jj_scan_token(82)) return true; return false; } - private boolean jj_3R_77() { - if (jj_scan_token(68)) return true; + private boolean jj_3R_162() { + if (jj_scan_token(58)) return true; return false; } - private boolean jj_3R_151() { - if (jj_scan_token(84)) return true; + private boolean jj_3R_77() { + if (jj_scan_token(68)) return true; return false; } @@ -4740,57 +4753,58 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } + private boolean jj_3R_135() { + if (jj_scan_token(80)) return true; + return false; + } + private boolean jj_3R_124() { if (jj_scan_token(74)) return true; return false; } - private boolean jj_3R_147() { - if (jj_3R_156()) return true; + private boolean jj_3R_149() { + if (jj_3R_158()) return true; return false; } - private boolean jj_3R_165() { + private boolean jj_3R_167() { if (jj_scan_token(70)) return true; return false; } - private boolean jj_3R_146() { + private boolean jj_3R_148() { if (jj_scan_token(66)) return true; - if (jj_3R_155()) return true; + if (jj_3R_157()) return true; if (jj_scan_token(67)) return true; return false; } - private boolean jj_3R_145() { + private boolean jj_3R_147() { if (jj_scan_token(62)) return true; if (jj_3R_47()) return true; if (jj_scan_token(63)) return true; return false; } - private boolean jj_3R_143() { - if (jj_3R_153()) return true; + private boolean jj_3R_145() { + if (jj_3R_155()) return true; return false; } - private boolean jj_3R_158() { + private boolean jj_3R_160() { if (jj_scan_token(87)) return true; return false; } - private boolean jj_3R_144() { - if (jj_3R_154()) return true; + private boolean jj_3R_146() { + if (jj_3R_156()) return true; return false; } - private boolean jj_3R_135() { + private boolean jj_3R_137() { Token xsp; xsp = jj_scanpos; - if (jj_3R_138()) { - jj_scanpos = xsp; - if (jj_3R_139()) { - jj_scanpos = xsp; if (jj_3R_140()) { jj_scanpos = xsp; if (jj_3R_141()) { @@ -4807,6 +4821,10 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo jj_scanpos = xsp; if (jj_3R_147()) { jj_scanpos = xsp; + if (jj_3R_148()) { + jj_scanpos = xsp; + if (jj_3R_149()) { + jj_scanpos = xsp; if (jj_scan_token(35)) return true; } } @@ -4821,33 +4839,33 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_138() { + private boolean jj_3R_140() { if (jj_scan_token(UNSIGNED_NUMBER)) return true; return false; } - private boolean jj_3R_142() { + private boolean jj_3R_144() { if (jj_scan_token(33)) return true; return false; } - private boolean jj_3R_141() { + private boolean jj_3R_143() { if (jj_scan_token(6)) return true; return false; } - private boolean jj_3R_140() { + private boolean jj_3R_142() { if (jj_scan_token(STRING)) return true; return false; } - private boolean jj_3R_139() { + private boolean jj_3R_141() { if (jj_scan_token(UNSIGNED_INTEGER)) return true; return false; } - private boolean jj_3R_150() { - if (jj_scan_token(83)) return true; + private boolean jj_3R_152() { + if (jj_scan_token(85)) return true; return false; } @@ -4856,30 +4874,30 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_156() { + private boolean jj_3R_158() { if (jj_scan_token(64)) return true; - if (jj_3R_166()) return true; + if (jj_3R_168()) return true; if (jj_scan_token(65)) return true; return false; } - private boolean jj_3R_136() { - if (jj_3R_148()) return true; - if (jj_3R_135()) return true; + private boolean jj_3R_138() { + if (jj_3R_150()) return true; + if (jj_3R_137()) return true; return false; } - private boolean jj_3R_155() { - if (jj_3R_164()) return true; + private boolean jj_3R_157() { + if (jj_3R_166()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_165()) { jj_scanpos = xsp; break; } + if (jj_3R_167()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_159() { + private boolean jj_3R_161() { if (jj_3R_60()) return true; return false; } @@ -4889,14 +4907,14 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_153() { + private boolean jj_3R_155() { Token xsp; xsp = jj_scanpos; - if (jj_3R_159()) { + if (jj_3R_161()) { jj_scanpos = xsp; - if (jj_3R_160()) { + if (jj_3R_162()) { jj_scanpos = xsp; - if (jj_3R_161()) return true; + if (jj_3R_163()) return true; } } if (jj_3R_74()) return true; @@ -4908,31 +4926,31 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_148() { + private boolean jj_3R_150() { Token xsp; xsp = jj_scanpos; - if (jj_3R_157()) { + if (jj_3R_159()) { jj_scanpos = xsp; - if (jj_3R_158()) return true; + if (jj_3R_160()) return true; } return false; } - private boolean jj_3R_157() { + private boolean jj_3R_159() { if (jj_scan_token(86)) return true; return false; } private boolean jj_3R_120() { - if (jj_3R_135()) return true; + if (jj_3R_137()) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_136()) jj_scanpos = xsp; + if (jj_3R_138()) jj_scanpos = xsp; return false; } private boolean jj_3R_121() { - if (jj_3R_137()) return true; + if (jj_3R_139()) return true; if (jj_3R_120()) return true; return false; } @@ -4949,24 +4967,24 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_137() { + private boolean jj_3R_139() { Token xsp; xsp = jj_scanpos; - if (jj_3R_149()) { + if (jj_3R_151()) { jj_scanpos = xsp; - if (jj_3R_150()) { + if (jj_3R_152()) { jj_scanpos = xsp; - if (jj_3R_151()) { + if (jj_3R_153()) { jj_scanpos = xsp; - if (jj_3R_152()) return true; + if (jj_3R_154()) return true; } } } return false; } - private boolean jj_3R_149() { - if (jj_scan_token(82)) return true; + private boolean jj_3R_151() { + if (jj_scan_token(84)) return true; return false; } @@ -4997,9 +5015,9 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo jj_scanpos = xsp; if (jj_3R_134()) { jj_scanpos = xsp; - if (jj_scan_token(80)) { + if (jj_3R_135()) { jj_scanpos = xsp; - if (jj_scan_token(81)) return true; + if (jj_3R_136()) return true; } } } @@ -5186,6 +5204,14 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } + private boolean jj_3R_107() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(50)) jj_scanpos = xsp; + if (jj_scan_token(44)) return true; + return false; + } + private boolean jj_3R_66() { if (jj_3R_80()) return true; return false; @@ -5275,14 +5301,6 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_107() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(50)) jj_scanpos = xsp; - if (jj_scan_token(44)) return true; - return false; - } - private boolean jj_3R_84() { Token xsp; xsp = jj_scanpos; @@ -5506,6 +5524,12 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } + private boolean jj_3R_165() { + if (jj_scan_token(68)) return true; + if (jj_scan_token(IDENT)) return true; + return false; + } + private boolean jj_3R_58() { if (jj_scan_token(IDENT)) return true; if (jj_3R_74()) return true; @@ -5537,7 +5561,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_174() { + private boolean jj_3R_176() { if (jj_3R_47()) return true; return false; } @@ -5569,9 +5593,8 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_163() { - if (jj_scan_token(68)) return true; - if (jj_scan_token(IDENT)) return true; + private boolean jj_3R_164() { + if (jj_3R_170()) return true; return false; } @@ -5625,31 +5648,26 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_173() { + private boolean jj_3R_175() { if (jj_scan_token(69)) return true; return false; } - private boolean jj_3R_169() { + private boolean jj_3R_171() { if (jj_scan_token(71)) return true; return false; } - private boolean jj_3R_171() { + private boolean jj_3R_173() { Token xsp; xsp = jj_scanpos; - if (jj_3R_173()) { + if (jj_3R_175()) { jj_scanpos = xsp; - if (jj_3R_174()) return true; + if (jj_3R_176()) return true; } return false; } - private boolean jj_3R_162() { - if (jj_3R_168()) return true; - return false; - } - private boolean jj_3R_48() { Token xsp; xsp = jj_scanpos; @@ -5665,9 +5683,9 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_168() { + private boolean jj_3R_170() { if (jj_scan_token(66)) return true; - if (jj_3R_171()) return true; + if (jj_3R_173()) return true; return false; } @@ -5676,39 +5694,39 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_164() { + private boolean jj_3R_166() { if (jj_3R_47()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_169()) { jj_scanpos = xsp; break; } + if (jj_3R_171()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_175() { + private boolean jj_3R_177() { if (jj_scan_token(IDENT)) return true; if (jj_scan_token(88)) return true; return false; } - private boolean jj_3R_161() { + private boolean jj_3R_163() { if (jj_scan_token(46)) return true; return false; } - private boolean jj_3R_172() { - if (jj_3R_175()) return true; + private boolean jj_3R_154() { + if (jj_scan_token(83)) return true; return false; } - private boolean jj_3R_152() { - if (jj_scan_token(85)) return true; + private boolean jj_3R_174() { + if (jj_3R_177()) return true; return false; } - private boolean jj_3R_170() { - if (jj_3R_172()) return true; + private boolean jj_3R_172() { + if (jj_3R_174()) return true; return false; } @@ -5720,18 +5738,18 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo return false; } - private boolean jj_3R_166() { + private boolean jj_3R_168() { Token xsp; xsp = jj_scanpos; if (jj_3_10()) { jj_scanpos = xsp; - if (jj_3R_170()) return true; + if (jj_3R_172()) return true; } return false; } - private boolean jj_3R_167() { - if (jj_3R_166()) return true; + private boolean jj_3R_169() { + if (jj_3R_168()) return true; return false; } diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParserTokenManager.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParserTokenManager.java index dd082219..1ce5ceba 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParserTokenManager.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParserTokenManager.java @@ -16,23 +16,21 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) { case 0: if ((active1 & 0x80000L) != 0L) - return 22; + return 23; if ((active1 & 0xb30010L) != 0L) - return 10; - if ((active0 & 0x884210842108400L) != 0L) + return 11; + if ((active0 & 0x377bdef7bdef7bf0L) != 0L || (active1 & 0x180000000L) != 0L) { jjmatchedKind = 90; - return 48; + return 49; } - if ((active0 & 0x377bdef7bdef7bf0L) != 0L || (active1 & 0x180000000L) != 0L) + if ((active0 & 0x884210842108400L) != 0L) { jjmatchedKind = 90; - return 2; + return 50; } return -1; case 1: - if ((active0 & 0x108420080400000L) != 0L) - return 2; if ((active0 & 0x3ef7bdff7fbffff0L) != 0L || (active1 & 0x180000000L) != 0L) { if (jjmatchedPos != 1) @@ -40,22 +38,24 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) jjmatchedKind = 90; jjmatchedPos = 1; } - return 2; + return 49; } + if ((active0 & 0x108420080400000L) != 0L) + return 49; return -1; case 2: if ((active0 & 0x400000800201200L) != 0L) - return 2; + return 49; if ((active0 & 0x3bfffdf77f9fedf0L) != 0L || (active1 & 0x180000000L) != 0L) { jjmatchedKind = 90; jjmatchedPos = 2; - return 2; + return 49; } return -1; case 3: if ((active0 & 0x1000084212118400L) != 0L) - return 2; + return 49; if ((active0 & 0x2bfff5b56d8e69f0L) != 0L || (active1 & 0x180000000L) != 0L) { if (jjmatchedPos != 3) @@ -63,32 +63,30 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) jjmatchedKind = 90; jjmatchedPos = 3; } - return 2; + return 49; } return -1; case 4: - if ((active0 & 0x1090004290008c0L) != 0L) - return 2; if ((active0 & 0x2af6f5b1469e6130L) != 0L || (active1 & 0x180000000L) != 0L) { jjmatchedKind = 90; jjmatchedPos = 4; - return 2; + return 49; } + if ((active0 & 0x1090004290008c0L) != 0L) + return 49; return -1; case 5: if ((active0 & 0x22200011009c0000L) != 0L) - return 2; + return 49; if ((active0 & 0x8d6f5a046026130L) != 0L || (active1 & 0x180000000L) != 0L) { jjmatchedKind = 90; jjmatchedPos = 5; - return 2; + return 49; } return -1; case 6: - if ((active0 & 0x80d0a000000000L) != 0L) - return 2; if ((active0 & 0x856250046026130L) != 0L || (active1 & 0x180000000L) != 0L) { if (jjmatchedPos != 6) @@ -96,10 +94,14 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) jjmatchedKind = 90; jjmatchedPos = 6; } - return 2; + return 49; } + if ((active0 & 0x80d0a000000000L) != 0L) + return 49; return -1; case 7: + if ((active0 & 0x802200006020020L) != 0L || (active1 & 0x180000000L) != 0L) + return 49; if ((active0 & 0x54150040006110L) != 0L) { if (jjmatchedPos != 7) @@ -107,19 +109,17 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) jjmatchedKind = 90; jjmatchedPos = 7; } - return 2; + return 49; } - if ((active0 & 0x802200006020020L) != 0L || (active1 & 0x180000000L) != 0L) - return 2; return -1; case 8: if ((active0 & 0x10140000000110L) != 0L) - return 2; + return 49; if ((active0 & 0x44010040006000L) != 0L) { jjmatchedKind = 90; jjmatchedPos = 8; - return 2; + return 49; } return -1; case 9: @@ -127,34 +127,34 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) { jjmatchedKind = 90; jjmatchedPos = 9; - return 2; + return 49; } if ((active0 & 0x4000000004000L) != 0L) - return 2; + return 49; return -1; case 10: - if ((active0 & 0x10000002000L) != 0L) - return 2; if ((active0 & 0x40000040000000L) != 0L) { jjmatchedKind = 90; jjmatchedPos = 10; - return 2; + return 49; } + if ((active0 & 0x10000002000L) != 0L) + return 49; return -1; case 11: if ((active0 & 0x40000000L) != 0L) - return 2; + return 49; if ((active0 & 0x40000000000000L) != 0L) { jjmatchedKind = 90; jjmatchedPos = 11; - return 2; + return 49; } return -1; case 12: if ((active0 & 0x40000000000000L) != 0L) - return 2; + return 49; return -1; default : return -1; @@ -190,7 +190,7 @@ private int jjMoveStringLiteralDfa0_0() jjmatchedKind = 68; return jjMoveStringLiteralDfa1_0(0x0L, 0xb30000L); case 47: - return jjStartNfaWithStates_0(0, 83, 22); + return jjStartNfaWithStates_0(0, 83, 23); case 58: jjmatchedKind = 69; return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000L); @@ -300,7 +300,7 @@ private int jjMoveStringLiteralDfa1_0(long active0, long active1) return jjMoveStringLiteralDfa2_0(active0, 0x2400000000042100L, active1, 0L); case 102: if ((active0 & 0x80000000L) != 0L) - return jjStartNfaWithStates_0(1, 31, 2); + return jjStartNfaWithStates_0(1, 31, 49); break; case 104: return jjMoveStringLiteralDfa2_0(active0, 0x1080010000000L, active1, 0L); @@ -325,7 +325,7 @@ private int jjMoveStringLiteralDfa1_0(long active0, long active1) return jjMoveStringLiteralDfa2_0(active0, 0x200000000000L, active1, 0L); case 114: if ((active0 & 0x400000L) != 0L) - return jjStartNfaWithStates_0(1, 22, 2); + return jjStartNfaWithStates_0(1, 22, 49); return jjMoveStringLiteralDfa2_0(active0, 0x10000220000000L, active1, 0L); case 115: return jjMoveStringLiteralDfa2_0(active0, 0x80000L, active1, 0L); @@ -361,9 +361,9 @@ private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa3_0(active0, 0x2000002040000400L, active1, 0L); case 100: if ((active0 & 0x200L) != 0L) - return jjStartNfaWithStates_0(2, 9, 2); + return jjStartNfaWithStates_0(2, 9, 49); else if ((active0 & 0x800000000L) != 0L) - return jjStartNfaWithStates_0(2, 35, 2); + return jjStartNfaWithStates_0(2, 35, 49); return jjMoveStringLiteralDfa3_0(active0, 0x180L, active1, 0L); case 101: return jjMoveStringLiteralDfa3_0(active0, 0x80030020000L, active1, 0x180000000L); @@ -381,15 +381,15 @@ private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa3_0(active0, 0x104005000002000L, active1, 0L); case 114: if ((active0 & 0x200000L) != 0L) - return jjStartNfaWithStates_0(2, 21, 2); + return jjStartNfaWithStates_0(2, 21, 49); else if ((active0 & 0x400000000000000L) != 0L) - return jjStartNfaWithStates_0(2, 58, 2); + return jjStartNfaWithStates_0(2, 58, 49); return jjMoveStringLiteralDfa3_0(active0, 0x840000800000L, active1, 0L); case 115: return jjMoveStringLiteralDfa3_0(active0, 0x2188020L, active1, 0L); case 116: if ((active0 & 0x1000L) != 0L) - return jjStartNfaWithStates_0(2, 12, 2); + return jjStartNfaWithStates_0(2, 12, 49); return jjMoveStringLiteralDfa3_0(active0, 0x8a0000108040000L, active1, 0L); case 117: return jjMoveStringLiteralDfa3_0(active0, 0x210200000000L, active1, 0L); @@ -420,13 +420,13 @@ private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long a jjmatchedPos = 3; } else if ((active0 & 0x200000000L) != 0L) - return jjStartNfaWithStates_0(3, 33, 2); + return jjStartNfaWithStates_0(3, 33, 49); else if ((active0 & 0x4000000000L) != 0L) - return jjStartNfaWithStates_0(3, 38, 2); + return jjStartNfaWithStates_0(3, 38, 49); return jjMoveStringLiteralDfa4_0(active0, 0x88800000a980180L, active1, 0L); case 104: if ((active0 & 0x400L) != 0L) - return jjStartNfaWithStates_0(3, 10, 2); + return jjStartNfaWithStates_0(3, 10, 49); return jjMoveStringLiteralDfa4_0(active0, 0x20000000000000L, active1, 0L); case 107: return jjMoveStringLiteralDfa4_0(active0, 0x2000000000L, active1, 0L); @@ -436,15 +436,15 @@ private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa4_0(active0, 0x10000000000L, active1, 0L); case 110: if ((active0 & 0x10000000L) != 0L) - return jjStartNfaWithStates_0(3, 28, 2); + return jjStartNfaWithStates_0(3, 28, 49); else if ((active0 & 0x80000000000L) != 0L) - return jjStartNfaWithStates_0(3, 43, 2); + return jjStartNfaWithStates_0(3, 43, 49); return jjMoveStringLiteralDfa4_0(active0, 0x108000000000L, active1, 0L); case 111: return jjMoveStringLiteralDfa4_0(active0, 0x2000001000004010L, active1, 0L); case 112: if ((active0 & 0x1000000000000000L) != 0L) - return jjStartNfaWithStates_0(3, 60, 2); + return jjStartNfaWithStates_0(3, 60, 49); return jjMoveStringLiteralDfa4_0(active0, 0x100000000L, active1, 0L); case 114: return jjMoveStringLiteralDfa4_0(active0, 0x20000L, active1, 0x180000000L); @@ -456,7 +456,7 @@ private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa4_0(active0, 0x100000000040000L, active1, 0L); case 119: if ((active0 & 0x10000L) != 0L) - return jjStartNfaWithStates_0(3, 16, 2); + return jjStartNfaWithStates_0(3, 16, 49); break; default : break; @@ -480,23 +480,23 @@ private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa5_0(active0, 0x100L, active1, 0L); case 101: if ((active0 & 0x40L) != 0L) - return jjStartNfaWithStates_0(4, 6, 2); + return jjStartNfaWithStates_0(4, 6, 49); else if ((active0 & 0x1000000000000L) != 0L) - return jjStartNfaWithStates_0(4, 48, 2); + return jjStartNfaWithStates_0(4, 48, 49); return jjMoveStringLiteralDfa5_0(active0, 0x10118000000000L, active1, 0L); case 105: return jjMoveStringLiteralDfa5_0(active0, 0x220c00000100000L, active1, 0L); case 107: if ((active0 & 0x1000000L) != 0L) - return jjStartNfaWithStates_0(4, 24, 2); + return jjStartNfaWithStates_0(4, 24, 49); else if ((active0 & 0x20000000L) != 0L) - return jjStartNfaWithStates_0(4, 29, 2); + return jjStartNfaWithStates_0(4, 29, 49); break; case 108: if ((active0 & 0x80L) != 0L) - return jjStartNfaWithStates_0(4, 7, 2); + return jjStartNfaWithStates_0(4, 7, 49); else if ((active0 & 0x800L) != 0L) - return jjStartNfaWithStates_0(4, 11, 2); + return jjStartNfaWithStates_0(4, 11, 49); break; case 109: return jjMoveStringLiteralDfa5_0(active0, 0x40000000000L, active1, 0L); @@ -506,17 +506,17 @@ private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa5_0(active0, 0x40000000L, active1, 0L); case 114: if ((active0 & 0x8000000L) != 0L) - return jjStartNfaWithStates_0(4, 27, 2); + return jjStartNfaWithStates_0(4, 27, 49); else if ((active0 & 0x8000000000000L) != 0L) - return jjStartNfaWithStates_0(4, 51, 2); + return jjStartNfaWithStates_0(4, 51, 49); return jjMoveStringLiteralDfa5_0(active0, 0x28000010000c0030L, active1, 0L); case 115: if ((active0 & 0x400000000L) != 0L) - return jjStartNfaWithStates_0(4, 34, 2); + return jjStartNfaWithStates_0(4, 34, 49); break; case 116: if ((active0 & 0x100000000000000L) != 0L) - return jjStartNfaWithStates_0(4, 56, 2); + return jjStartNfaWithStates_0(4, 56, 49); return jjMoveStringLiteralDfa5_0(active0, 0x42200004004000L, active1, 0L); case 117: return jjMoveStringLiteralDfa5_0(active0, 0x100000000L, active1, 0L); @@ -542,17 +542,17 @@ private int jjMoveStringLiteralDfa5_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa6_0(active0, 0x2c00000004000L, active1, 0L); case 99: if ((active0 & 0x200000000000000L) != 0L) - return jjStartNfaWithStates_0(5, 57, 2); + return jjStartNfaWithStates_0(5, 57, 49); return jjMoveStringLiteralDfa6_0(active0, 0x10108000002000L, active1, 0L); case 100: if ((active0 & 0x2000000000000000L) != 0L) - return jjStartNfaWithStates_0(5, 61, 2); + return jjStartNfaWithStates_0(5, 61, 49); return jjMoveStringLiteralDfa6_0(active0, 0x84000000000000L, active1, 0L); case 101: return jjMoveStringLiteralDfa6_0(active0, 0x40000000020L, active1, 0L); case 102: if ((active0 & 0x100000L) != 0L) - return jjStartNfaWithStates_0(5, 20, 2); + return jjStartNfaWithStates_0(5, 20, 49); break; case 103: return jjMoveStringLiteralDfa6_0(active0, 0x2000000000L, active1, 0L); @@ -564,13 +564,13 @@ private int jjMoveStringLiteralDfa5_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa6_0(active0, 0x100L, active1, 0L); case 109: if ((active0 & 0x800000L) != 0L) - return jjStartNfaWithStates_0(5, 23, 2); + return jjStartNfaWithStates_0(5, 23, 49); break; case 110: if ((active0 & 0x40000L) != 0L) - return jjStartNfaWithStates_0(5, 18, 2); + return jjStartNfaWithStates_0(5, 18, 49); else if ((active0 & 0x20000000000000L) != 0L) - return jjStartNfaWithStates_0(5, 53, 2); + return jjStartNfaWithStates_0(5, 53, 49); return jjMoveStringLiteralDfa6_0(active0, 0x800000000000000L, active1, 0L); case 114: return jjMoveStringLiteralDfa6_0(active0, 0x40010000000000L, active1, 0L); @@ -578,11 +578,11 @@ private int jjMoveStringLiteralDfa5_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa6_0(active0, 0x40000000L, active1, 0L); case 116: if ((active0 & 0x80000L) != 0L) - return jjStartNfaWithStates_0(5, 19, 2); + return jjStartNfaWithStates_0(5, 19, 49); else if ((active0 & 0x100000000L) != 0L) - return jjStartNfaWithStates_0(5, 32, 2); + return jjStartNfaWithStates_0(5, 32, 49); else if ((active0 & 0x1000000000L) != 0L) - return jjStartNfaWithStates_0(5, 36, 2); + return jjStartNfaWithStates_0(5, 36, 49); return jjMoveStringLiteralDfa6_0(active0, 0x20000L, active1, 0x180000000L); default : break; @@ -604,13 +604,13 @@ private int jjMoveStringLiteralDfa6_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa7_0(active0, 0x844010000000100L, active1, 0L); case 101: if ((active0 & 0x2000000000L) != 0L) - return jjStartNfaWithStates_0(6, 37, 2); + return jjStartNfaWithStates_0(6, 37, 49); return jjMoveStringLiteralDfa7_0(active0, 0x2002000L, active1, 0L); case 108: if ((active0 & 0x400000000000L) != 0L) - return jjStartNfaWithStates_0(6, 46, 2); + return jjStartNfaWithStates_0(6, 46, 49); else if ((active0 & 0x800000000000L) != 0L) - return jjStartNfaWithStates_0(6, 47, 2); + return jjStartNfaWithStates_0(6, 47, 49); break; case 110: return jjMoveStringLiteralDfa7_0(active0, 0x2000000000000L, active1, 0L); @@ -618,7 +618,7 @@ private int jjMoveStringLiteralDfa6_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa7_0(active0, 0x200004020000L, active1, 0x180000000L); case 115: if ((active0 & 0x80000000000000L) != 0L) - return jjStartNfaWithStates_0(6, 55, 2); + return jjStartNfaWithStates_0(6, 55, 49); break; case 116: if ((active0 & 0x8000000000L) != 0L) @@ -651,7 +651,7 @@ private int jjMoveStringLiteralDfa7_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa8_0(active0, 0x4000000000000L, active1, 0L); case 101: if ((active0 & 0x20L) != 0L) - return jjStartNfaWithStates_0(7, 5, 2); + return jjStartNfaWithStates_0(7, 5, 49); return jjMoveStringLiteralDfa8_0(active0, 0x10040000000000L, active1, 0L); case 104: return jjMoveStringLiteralDfa8_0(active0, 0x10L, active1, 0L); @@ -659,15 +659,15 @@ private int jjMoveStringLiteralDfa7_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa8_0(active0, 0x40000000004000L, active1, 0L); case 108: if ((active0 & 0x800000000000000L) != 0L) - return jjStartNfaWithStates_0(7, 59, 2); + return jjStartNfaWithStates_0(7, 59, 49); return jjMoveStringLiteralDfa8_0(active0, 0x40000000L, active1, 0L); case 110: if ((active0 & 0x2000000L) != 0L) - return jjStartNfaWithStates_0(7, 25, 2); + return jjStartNfaWithStates_0(7, 25, 49); else if ((active0 & 0x4000000L) != 0L) - return jjStartNfaWithStates_0(7, 26, 2); + return jjStartNfaWithStates_0(7, 26, 49); else if ((active0 & 0x200000000000L) != 0L) - return jjStartNfaWithStates_0(7, 45, 2); + return jjStartNfaWithStates_0(7, 45, 49); break; case 111: return jjMoveStringLiteralDfa8_0(active0, 0x100000000000L, active1, 0L); @@ -680,7 +680,7 @@ private int jjMoveStringLiteralDfa7_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa8_0(active0, 0x100L, active1, 0x180000000L); case 116: if ((active0 & 0x2000000000000L) != 0L) - return jjStartNfaWithStates_0(7, 49, 2); + return jjStartNfaWithStates_0(7, 49, 49); return jjMoveStringLiteralDfa8_0(active0, 0x10000000000L, active1, 0L); default : break; @@ -706,11 +706,11 @@ private int jjMoveStringLiteralDfa8_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa9_0(active0, 0x2000L, active1, 0L); case 100: if ((active0 & 0x10000000000000L) != 0L) - return jjStartNfaWithStates_0(8, 52, 2); + return jjStartNfaWithStates_0(8, 52, 49); break; case 101: if ((active0 & 0x100L) != 0L) - return jjStartNfaWithStates_0(8, 8, 2); + return jjStartNfaWithStates_0(8, 8, 49); break; case 105: return jjMoveStringLiteralDfa9_0(active0, 0x10000000000L, active1, 0L); @@ -718,7 +718,7 @@ private int jjMoveStringLiteralDfa8_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa9_0(active0, 0x4000000000000L, active1, 0L); case 109: if ((active0 & 0x10L) != 0L) - return jjStartNfaWithStates_0(8, 4, 2); + return jjStartNfaWithStates_0(8, 4, 49); break; case 110: return jjMoveStringLiteralDfa9_0(active0, 0x40000000000000L, active1, 0L); @@ -726,9 +726,9 @@ private int jjMoveStringLiteralDfa8_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa9_0(active0, 0x4000L, active1, 0L); case 114: if ((active0 & 0x40000000000L) != 0L) - return jjStartNfaWithStates_0(8, 42, 2); + return jjStartNfaWithStates_0(8, 42, 49); else if ((active0 & 0x100000000000L) != 0L) - return jjStartNfaWithStates_0(8, 44, 2); + return jjStartNfaWithStates_0(8, 44, 49); break; default : break; @@ -748,7 +748,7 @@ private int jjMoveStringLiteralDfa9_0(long old0, long active0, long old1, long a { case 101: if ((active0 & 0x4000000000000L) != 0L) - return jjStartNfaWithStates_0(9, 50, 2); + return jjStartNfaWithStates_0(9, 50, 49); return jjMoveStringLiteralDfa10_0(active0, 0x40000000000000L, active1, 0L); case 102: return jjMoveStringLiteralDfa10_0(active0, 0L, active1, 0x80000000L); @@ -756,7 +756,7 @@ private int jjMoveStringLiteralDfa9_0(long old0, long active0, long old1, long a return jjMoveStringLiteralDfa10_0(active0, 0x2000L, active1, 0L); case 110: if ((active0 & 0x4000L) != 0L) - return jjStartNfaWithStates_0(9, 14, 2); + return jjStartNfaWithStates_0(9, 14, 49); break; case 111: return jjMoveStringLiteralDfa10_0(active0, 0x10000000000L, active1, 0L); @@ -784,11 +784,11 @@ private int jjMoveStringLiteralDfa10_0(long old0, long active0, long old1, long return jjMoveStringLiteralDfa11_0(active0, 0x40000000000000L, active1, 0L); case 101: if ((active0 & 0x2000L) != 0L) - return jjStartNfaWithStates_0(10, 13, 2); + return jjStartNfaWithStates_0(10, 13, 49); return jjMoveStringLiteralDfa11_0(active0, 0x40000000L, active1, 0x100000000L); case 110: if ((active0 & 0x10000000000L) != 0L) - return jjStartNfaWithStates_0(10, 40, 2); + return jjStartNfaWithStates_0(10, 40, 49); break; case 117: return jjMoveStringLiteralDfa11_0(active0, 0L, active1, 0x80000000L); @@ -814,7 +814,7 @@ private int jjMoveStringLiteralDfa11_0(long old0, long active0, long old1, long return jjMoveStringLiteralDfa12_0(active0, 0L, active1, 0x100000000L); case 100: if ((active0 & 0x40000000L) != 0L) - return jjStartNfaWithStates_0(11, 30, 2); + return jjStartNfaWithStates_0(11, 30, 49); break; case 110: return jjMoveStringLiteralDfa12_0(active0, 0L, active1, 0x80000000L); @@ -840,7 +840,7 @@ private int jjMoveStringLiteralDfa12_0(long old0, long active0, long old1, long return jjMoveStringLiteralDfa13_0(active0, 0L, active1, 0x100000000L); case 121: if ((active0 & 0x40000000000000L) != 0L) - return jjStartNfaWithStates_0(12, 54, 2); + return jjStartNfaWithStates_0(12, 54, 49); break; default : break; @@ -941,7 +941,7 @@ static final long[] jjbitVec0 = { private int jjMoveNfa_0(int startState, int curPos) { int startsAt = 0; - jjnewStateCnt = 48; + jjnewStateCnt = 49; int i = 1; jjstateSet[0] = startState; int kind = 0x7fffffff; @@ -956,12 +956,32 @@ private int jjMoveNfa_0(int startState, int curPos) { switch(jjstateSet[--i]) { + case 23: + if (curChar == 47) + { + if (kind > 3) + kind = 3; + jjCheckNAdd(30); + } + else if (curChar == 42) + jjCheckNAddStates(0, 2); + break; + case 49: + if ((0x3ff000000000000L & l) != 0L) + { + if (kind > 90) + kind = 90; + jjCheckNAddTwoStates(2, 3); + } + else if (curChar == 46) + jjCheckNAdd(2); + break; case 0: if ((0x3ff000000000000L & l) != 0L) { if (kind > 93) kind = 93; - jjCheckNAddStates(0, 6); + jjCheckNAddStates(3, 9); } else if ((0x100002600L & l) != 0L) { @@ -969,18 +989,18 @@ private int jjMoveNfa_0(int startState, int curPos) kind = 1; } else if (curChar == 47) - jjAddStates(7, 8); + jjAddStates(10, 11); else if (curChar == 46) - jjCheckNAdd(10); + jjCheckNAdd(11); else if (curChar == 34) - jjCheckNAddStates(9, 11); + jjCheckNAddStates(12, 14); break; - case 48: - if ((0x3ff400000000000L & l) != 0L) + case 50: + if ((0x3ff000000000000L & l) != 0L) { if (kind > 90) kind = 90; - jjCheckNAdd(2); + jjCheckNAddTwoStates(2, 3); } else if (curChar == 43) { @@ -992,177 +1012,173 @@ private int jjMoveNfa_0(int startState, int curPos) if (kind > 92) kind = 92; } - break; - case 22: - if (curChar == 47) - { - if (kind > 3) - kind = 3; - jjCheckNAdd(29); - } - else if (curChar == 42) - jjCheckNAddStates(12, 14); + else if (curChar == 46) + jjCheckNAdd(2); break; case 2: - if ((0x3ff400000000000L & l) == 0L) + if ((0x3ff000000000000L & l) == 0L) break; if (kind > 90) kind = 90; - jjCheckNAdd(2); + jjCheckNAddTwoStates(2, 3); break; case 3: - if (curChar == 34) - jjCheckNAddStates(9, 11); + if (curChar == 46) + jjCheckNAdd(2); break; case 4: + if (curChar == 34) + jjCheckNAddStates(12, 14); + break; + case 5: if ((0xfffffffbfffffbffL & l) != 0L) - jjCheckNAddStates(9, 11); + jjCheckNAddStates(12, 14); break; - case 6: + case 7: if ((0xfffffffffffffbffL & l) != 0L) - jjCheckNAddStates(9, 11); + jjCheckNAddStates(12, 14); break; - case 7: + case 8: if (curChar == 34 && kind > 91) kind = 91; break; - case 9: + case 10: if (curChar == 46) - jjCheckNAdd(10); + jjCheckNAdd(11); break; - case 10: + case 11: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; jjCheckNAddStates(15, 18); break; - case 12: + case 13: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; - jjCheckNAdd(12); + jjCheckNAdd(13); break; - case 14: + case 15: if (curChar == 45) - jjCheckNAdd(12); + jjCheckNAdd(13); break; - case 15: + case 16: if (curChar == 43) - jjCheckNAdd(12); + jjCheckNAdd(13); break; - case 18: + case 19: if (curChar == 45 && kind > 92) kind = 92; break; - case 19: + case 20: if (curChar == 43 && kind > 92) kind = 92; break; - case 21: + case 22: if (curChar == 47) - jjAddStates(7, 8); + jjAddStates(10, 11); break; - case 23: + case 24: if ((0xfffffbffffffffffL & l) != 0L) - jjCheckNAddStates(12, 14); + jjCheckNAddStates(0, 2); break; - case 24: + case 25: if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 25; + jjstateSet[jjnewStateCnt++] = 26; break; - case 25: + case 26: if ((0xffff7fffffffffffL & l) != 0L) - jjCheckNAddStates(12, 14); + jjCheckNAddStates(0, 2); break; - case 26: + case 27: if (curChar == 47 && kind > 2) kind = 2; break; - case 27: + case 28: if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 26; + jjstateSet[jjnewStateCnt++] = 27; break; - case 28: + case 29: if (curChar != 47) break; if (kind > 3) kind = 3; - jjCheckNAdd(29); + jjCheckNAdd(30); break; - case 29: + case 30: if ((0xfffffffffffffbffL & l) == 0L) break; if (kind > 3) kind = 3; - jjCheckNAdd(29); + jjCheckNAdd(30); break; - case 30: + case 31: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 93) kind = 93; - jjCheckNAddStates(0, 6); + jjCheckNAddStates(3, 9); break; - case 31: + case 32: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 93) kind = 93; - jjCheckNAdd(31); + jjCheckNAdd(32); break; - case 32: + case 33: if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(32, 33); + jjCheckNAddTwoStates(33, 34); break; - case 33: + case 34: if (curChar != 46) break; if (kind > 94) kind = 94; jjCheckNAddStates(19, 22); break; - case 34: + case 35: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; jjCheckNAddStates(19, 22); break; - case 36: + case 37: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; - jjCheckNAdd(36); + jjCheckNAdd(37); break; - case 38: + case 39: if (curChar == 45) - jjCheckNAdd(36); + jjCheckNAdd(37); break; - case 39: + case 40: if (curChar == 43) - jjCheckNAdd(36); + jjCheckNAdd(37); break; - case 41: + case 42: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddStates(23, 26); break; - case 43: + case 44: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; - jjCheckNAdd(43); + jjCheckNAdd(44); break; - case 45: + case 46: if (curChar == 45) - jjCheckNAdd(43); + jjCheckNAdd(44); break; - case 46: + case 47: if (curChar == 43) - jjCheckNAdd(43); + jjCheckNAdd(44); break; default : break; } @@ -1175,12 +1191,20 @@ private int jjMoveNfa_0(int startState, int curPos) { switch(jjstateSet[--i]) { + case 49: + case 2: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 90) + kind = 90; + jjCheckNAddTwoStates(2, 3); + break; case 0: if ((0x7fffffe87fffffeL & l) != 0L) { if (kind > 90) kind = 90; - jjCheckNAdd(2); + jjCheckNAddTwoStates(2, 3); } if ((0x2000000020L & l) != 0L) { @@ -1188,92 +1212,91 @@ private int jjMoveNfa_0(int startState, int curPos) kind = 92; } if (curChar == 69) - jjCheckNAddTwoStates(18, 19); + jjCheckNAddTwoStates(19, 20); else if (curChar == 101) - jjCheckNAddTwoStates(18, 19); + jjCheckNAddTwoStates(19, 20); break; - case 48: - case 2: + case 50: if ((0x7fffffe87fffffeL & l) == 0L) break; if (kind > 90) kind = 90; - jjCheckNAdd(2); + jjCheckNAddTwoStates(2, 3); break; case 1: if ((0x7fffffe87fffffeL & l) == 0L) break; if (kind > 90) kind = 90; - jjCheckNAdd(2); + jjCheckNAddTwoStates(2, 3); break; - case 4: + case 5: if ((0xffffffffefffffffL & l) != 0L) - jjCheckNAddStates(9, 11); + jjCheckNAddStates(12, 14); break; - case 5: + case 6: if (curChar == 92) - jjstateSet[jjnewStateCnt++] = 6; + jjstateSet[jjnewStateCnt++] = 7; break; - case 6: - jjCheckNAddStates(9, 11); + case 7: + jjCheckNAddStates(12, 14); break; - case 8: + case 9: if ((0x2000000020L & l) != 0L && kind > 92) kind = 92; break; - case 11: + case 12: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 12; + jjstateSet[jjnewStateCnt++] = 13; break; - case 13: + case 14: if (curChar == 101) - jjCheckNAddTwoStates(14, 15); + jjCheckNAddTwoStates(15, 16); break; - case 16: + case 17: if (curChar == 69) - jjCheckNAddTwoStates(14, 15); + jjCheckNAddTwoStates(15, 16); break; - case 17: + case 18: if (curChar == 101) - jjCheckNAddTwoStates(18, 19); + jjCheckNAddTwoStates(19, 20); break; - case 20: + case 21: if (curChar == 69) - jjCheckNAddTwoStates(18, 19); + jjCheckNAddTwoStates(19, 20); break; - case 23: - case 25: - jjCheckNAddStates(12, 14); + case 24: + case 26: + jjCheckNAddStates(0, 2); break; - case 29: + case 30: if (kind > 3) kind = 3; - jjstateSet[jjnewStateCnt++] = 29; + jjstateSet[jjnewStateCnt++] = 30; break; - case 35: + case 36: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 36; + jjstateSet[jjnewStateCnt++] = 37; break; - case 37: + case 38: if (curChar == 101) - jjCheckNAddTwoStates(38, 39); + jjCheckNAddTwoStates(39, 40); break; - case 40: + case 41: if (curChar == 69) - jjCheckNAddTwoStates(38, 39); + jjCheckNAddTwoStates(39, 40); break; - case 42: + case 43: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 43; + jjstateSet[jjnewStateCnt++] = 44; break; - case 44: + case 45: if (curChar == 101) - jjCheckNAddTwoStates(45, 46); + jjCheckNAddTwoStates(46, 47); break; - case 47: + case 48: if (curChar == 69) - jjCheckNAddTwoStates(45, 46); + jjCheckNAddTwoStates(46, 47); break; default : break; } @@ -1287,22 +1310,22 @@ private int jjMoveNfa_0(int startState, int curPos) { switch(jjstateSet[--i]) { - case 4: - case 6: + case 5: + case 7: if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(9, 11); + jjCheckNAddStates(12, 14); break; - case 23: - case 25: + case 24: + case 26: if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(12, 14); + jjCheckNAddStates(0, 2); break; - case 29: + case 30: if ((jjbitVec0[i2] & l2) == 0L) break; if (kind > 3) kind = 3; - jjstateSet[jjnewStateCnt++] = 29; + jjstateSet[jjnewStateCnt++] = 30; break; default : break; } @@ -1315,15 +1338,15 @@ private int jjMoveNfa_0(int startState, int curPos) kind = 0x7fffffff; } ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 48 - (jjnewStateCnt = startsAt))) + if ((i = jjnewStateCnt) == (startsAt = 49 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } 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, }; /** Token literal values. */ @@ -1362,8 +1385,8 @@ static final long[] jjtoSkip = { 0xeL, 0x0L, }; protected SimpleCharStream input_stream; -private final int[] jjrounds = new int[48]; -private final int[] jjstateSet = new int[96]; +private final int[] jjrounds = new int[49]; +private final int[] jjstateSet = new int[98]; private final StringBuilder jjimage = new StringBuilder(); private StringBuilder image = jjimage; private int jjimageLen; @@ -1394,7 +1417,7 @@ private void ReInitRounds() { int i; jjround = 0x80000001; - for (i = 48; i-- > 0;) + for (i = 49; i-- > 0;) jjrounds[i] = 0x80000000; } diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jj b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jj index 6c8fb791..d5f57adb 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jj +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jj @@ -75,7 +75,7 @@ TOKEN: | "*" | "/" | ".*" | "./" | "^" | ".^" | "=" | ":=" -| +| | { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); } | @@ -177,10 +177,10 @@ Node stored_definition() : {/*@bgen(jjtree) STORED */ /*** Class Definition **********************************************/ void class_definition() : {/*@bgen(jjtree) class_definition */ - SimpleNode jjtn000 = new SimpleNode(JJTCLASS_DEFINITION); - boolean jjtc000 = true; - jjtree.openNodeScope(jjtn000); -/*@egen*/ + SimpleNode jjtn000 = new SimpleNode(JJTCLASS_DEFINITION); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); +/*@egen*/ Token t; } {/*@bgen(jjtree) class_definition */ try { /*@egen*/ @@ -192,7 +192,7 @@ void class_definition() : {/*@bgen(jjtree) class_definition */ // class_specifier ( "encapsulated" )? ( "partial" )? - ( "class" { jjtn000.op = "class"; } | "model" { jjtn000.op = "model"; } | "record" | "block" | ( "expandable" )? "connector" | "type" | + ( "class" { jjtn000.op = "class"; } | t = "model" { jjtn000.op = "model"; jjtn000.line = t.beginLine; } | "record" | "block" | ( "expandable" )? "connector" | "type" | "package" { jjtn000.op = "package"; } | "function" { jjtn000.op = "function"; } | "operator" | "operator function" | "operator record" ) class_specifier()/*@bgen(jjtree)*/ } catch (Throwable jjte000) { @@ -234,7 +234,7 @@ void class_specifier() : {/*@bgen(jjtree) class_specifier */ // | IDENT "=" der "(" name "," IDENT { "," IDENT } ")" comment // | extends IDENT [ class_modification ] string_comment composition // end IDENT - LOOKAHEAD(2) t= { jjtn000.op = t.image; } string_comment() composition() "end" + LOOKAHEAD(2) t= { jjtn000.op = t.image; jjtn000.line = t.beginLine; } string_comment() composition() "end" | LOOKAHEAD(2) "=" base_prefix() name() ( array_subscripts() )? ( class_modification() )? comment() | LOOKAHEAD(3) "=" "der" "(" name() "," ( "," )* ")" comment() | LOOKAHEAD(3) "=" "enumeration" "(" ( ( enum_list() )? | ":" ) ")" comment()/*@bgen(jjtree)*/ @@ -924,7 +924,7 @@ Parameter declaration() : {/*@bgen(jjtree) declaration */ try { /*@egen*/ // IDENT [ array_subscripts ] [ modification ] - { ret.name = new String(token.image); jjtn000.op = token.image; } + { ret.name = new String(token.image); jjtn000.op = token.image; jjtn000.line = token.beginLine; } ( array_subscripts() )? ( ret.optional = modification() )?/*@bgen(jjtree)*/ { @@ -1454,8 +1454,8 @@ void statement() : {/*@bgen(jjtree) statement */ // comment ( component_reference() ( ":=" expression() | function_call_args() ) | "(" output_expression_list() ")" ":=" component_reference() function_call_args() - | "break" - | "return" + | "break" { jjtn000.op = "break";} + | "return" { jjtn000.op = "return";} | if_statement() | for_statement() | while_statement() @@ -2300,7 +2300,17 @@ void add_op() : {/*@bgen(jjtree) add_op */ jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } -/*@egen*/ { jjtn000.op = "-";} | ".+" | ".-"/*@bgen(jjtree)*/ +/*@egen*/ { jjtn000.op = "-";} | ".+"/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + } +/*@egen*/ { jjtn000.op = ".+";} | ".-"/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + } +/*@egen*/ { jjtn000.op = ".-";}/*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); @@ -2349,33 +2359,33 @@ void mul_op() : {/*@bgen(jjtree) mul_op */ } {/*@bgen(jjtree) mul_op */ try { /*@egen*/ - "*"/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - } -/*@egen*/ { jjtn000.op = "*";} | "/"/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - } -/*@egen*/ { jjtn000.op = "/";} | ".*"/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - } + ".*"/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + } /*@egen*/ { jjtn000.op = ".*";} | "./"/*@bgen(jjtree)*/ - { - jjtree.closeNodeScope(jjtn000, true); - jjtc000 = false; - } -/*@egen*/ { jjtn000.op = "./";}/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + } +/*@egen*/ { jjtn000.op = "./";} | "*"/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + } +/*@egen*/ { jjtn000.op = "*";} | "/"/*@bgen(jjtree)*/ + { + jjtree.closeNodeScope(jjtn000, true); + jjtc000 = false; + } +/*@egen*/ { jjtn000.op = "/";}/*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } -/*@egen*/ +/*@egen*/ } void factor() : {/*@bgen(jjtree) factor */ @@ -2633,7 +2643,7 @@ void component_reference() : {/*@bgen(jjtree) component_reference */ try { /*@egen*/ // [ "." ] IDENT [ array_subscripts ] { "." IDENT [ array_subscripts ] } - ( "." )? t= { jjtn000.op = t.image; } ( array_subscripts() )? ( "." ( array_subscripts() )? )*/*@bgen(jjtree)*/ + ( "." )? t= { jjtn000.op = t.image; jjtn000.line = t.beginLine; } ( array_subscripts() )? ( "." ( array_subscripts() )? )*/*@bgen(jjtree)*/ } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jjt b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jjt index 977d83d7..87103388 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jjt +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jjt @@ -71,7 +71,7 @@ TOKEN: | "*" | "/" | ".*" | "./" | "^" | ".^" | "=" | ":=" -| +| | { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); } | @@ -110,7 +110,7 @@ Node stored_definition() #STORED : { /*** Class Definition **********************************************/ -void class_definition() : { +void class_definition() : { Token t; } { // class_definition : // [ encapsulated ] @@ -120,7 +120,7 @@ void class_definition() : { // class_specifier ( "encapsulated" )? ( "partial" )? - ( "class" { jjtThis.op = "class"; } | "model" { jjtThis.op = "model"; } | "record" | "block" | ( "expandable" )? "connector" | "type" | + ( "class" { jjtThis.op = "class"; } | t = "model" { jjtThis.op = "model"; jjtThis.line = t.beginLine; } | "record" | "block" | ( "expandable" )? "connector" | "type" | "package" { jjtThis.op = "package"; } | "function" { jjtThis.op = "function"; } | "operator" | "operator function" | "operator record" ) class_specifier() } @@ -136,7 +136,7 @@ void class_specifier() : { Token t; // | IDENT "=" der "(" name "," IDENT { "," IDENT } ")" comment // | extends IDENT [ class_modification ] string_comment composition // end IDENT - LOOKAHEAD(2) t= { jjtThis.op = t.image; } string_comment() composition() "end" + LOOKAHEAD(2) t= { jjtThis.op = t.image; jjtThis.line = t.beginLine; } string_comment() composition() "end" | LOOKAHEAD(2) "=" base_prefix() name() ( array_subscripts() )? ( class_modification() )? comment() | LOOKAHEAD(3) "=" "der" "(" name() "," ( "," )* ")" comment() | LOOKAHEAD(3) "=" "enumeration" "(" ( ( enum_list() )? | ":" ) ")" comment() @@ -320,7 +320,7 @@ Parameter declaration() : { Token t; Parameter ret = new Parameter(); } { // IDENT [ array_subscripts ] [ modification ] - { ret.name = new String(token.image); jjtThis.op = token.image; } + { ret.name = new String(token.image); jjtThis.op = token.image; jjtThis.line = token.beginLine; } ( array_subscripts() )? ( ret.optional = modification() )? { return ret; } @@ -445,8 +445,8 @@ void statement() : { // comment ( component_reference() ( ":=" expression() | function_call_args() ) | "(" output_expression_list() ")" ":=" component_reference() function_call_args() - | "break" - | "return" + | "break" { jjtThis.op = "break";} + | "return" { jjtThis.op = "return";} | if_statement() | for_statement() | while_statement() @@ -641,7 +641,7 @@ void arithmetic_expression() : { void add_op() : { } { - "+" { jjtThis.op = "+";} | "-" { jjtThis.op = "-";} | ".+" | ".-" + "+" { jjtThis.op = "+";} | "-" { jjtThis.op = "-";} | ".+" { jjtThis.op = ".+";} | ".-" { jjtThis.op = ".-";} } @@ -652,7 +652,7 @@ void term() : { void mul_op() : { } { - "*" { jjtThis.op = "*";} | "/" { jjtThis.op = "/";} | ".*" { jjtThis.op = ".*";} | "./" { jjtThis.op = "./";} + ".*" { jjtThis.op = ".*";} | "./" { jjtThis.op = "./";} | "*" { jjtThis.op = "*";} | "/" { jjtThis.op = "/";} } void factor() : { @@ -710,7 +710,7 @@ void component_reference() : { Token t; } { // [ "." ] IDENT [ array_subscripts ] { "." IDENT [ array_subscripts ] } - ( "." )? t= { jjtThis.op = t.image; } ( array_subscripts() )? ( "." ( array_subscripts() )? )* + ( "." )? t= { jjtThis.op = t.image; jjtThis.line = t.beginLine; } ( array_subscripts() )? ( "." ( array_subscripts() )? )* } void function_call_args() : { diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/SimpleNode.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/SimpleNode.java index b399a88f..4a12bf77 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/SimpleNode.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/SimpleNode.java @@ -11,6 +11,7 @@ class SimpleNode implements Node { protected Object value; protected ModelParser parser; + public int line = -1; public String op; public SimpleNode(int i) {