From 7bad78be2fcb96f6fd4e3fefde18418e25bd2360 Mon Sep 17 00:00:00 2001 From: Sophie Coudert <sophie.coudert@telecom-paris.fr> Date: Tue, 23 May 2023 17:13:49 +0200 Subject: [PATCH] sauvegarde --- .../intboolsolver/IBSAttributeClass.java | 14 +- .../intboolsolver/IBSExpressionClass.java | 63 +++- .../myutil/intboolsolver/IBSParserAPI.java | 26 +- .../intboolsolver/IBSStdAttributeClass.java | 2 + .../intboolsolver/IBSStdExpressionClass.java | 345 ++++++++++++++++-- .../myutil/intboolsolver/IBSStdLexer.java | 141 +++---- .../myutil/intboolsolver/IBSStdParser.java | 276 ++++++++------ .../myutil/intboolsolver/IBSStdSymbols.java | 6 +- .../intboolsolver/javacup/IBSOptParser.jcup | 31 +- .../intboolsolver/javacup/IBSStdLexer.jflex | 1 + .../intboolsolver/javacup/IBSStdParser.jcup | 31 +- .../myutil/intboolsolver/package-info.java | 66 ++-- 12 files changed, 733 insertions(+), 269 deletions(-) diff --git a/src/main/java/myutil/intboolsolver/IBSAttributeClass.java b/src/main/java/myutil/intboolsolver/IBSAttributeClass.java index e4ef515d8e..6f695153dc 100644 --- a/src/main/java/myutil/intboolsolver/IBSAttributeClass.java +++ b/src/main/java/myutil/intboolsolver/IBSAttributeClass.java @@ -145,11 +145,17 @@ public class IBSAttributeClass< attrVal = a; if (isbool) type=BoolAttr; else type=IntAttr; } - /** As its name suggests... */ + /** As its name suggests... + * @return the attribute type + */ public int getType() { return type; } - /** As its name suggests... relevant only for constant types (unchecked) */ + /** As its name suggests... relevant only for constant types (unchecked) + * @return the constant value of the attribute + */ public int getConstant() { return constVal; } - /** As its name suggests... relevant only for variable types (unchecked) */ + /** As its name suggests... relevant only for variable types (unchecked) + * @return the attribute that characterizes the variable + */ public Attribute getAttribute() { return attrVal; } public boolean isAttribute() { return (type >= BoolAttr); } } @@ -205,6 +211,8 @@ public class IBSAttributeClass< * links components of attributes to their environment (spec). * If possible... (attributes must have internal information about * their components). Too specific, to enhance in the future... + * @param _spec the specification in which the components are + * comprised */ public void linkComp(Spec _spec) {} public String toString() { return ""; } diff --git a/src/main/java/myutil/intboolsolver/IBSExpressionClass.java b/src/main/java/myutil/intboolsolver/IBSExpressionClass.java index b51fc0f4e1..219190b1e1 100644 --- a/src/main/java/myutil/intboolsolver/IBSExpressionClass.java +++ b/src/main/java/myutil/intboolsolver/IBSExpressionClass.java @@ -106,103 +106,160 @@ public class IBSExpressionClass< public boolean isIconstant(int i){ return false; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. - * Parameters are indexes of previously build expressions + * Parameters are indexes of previously build expressions. + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_iiiPlus(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_iiiMinus(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_iiiMult(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_iiiDiv(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_iiiMod(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_bbbAnd(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_bbbOr(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_biiEq(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_bbbEq(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_biiDif(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_bbbDif(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_biiLt(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_biiGt(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_biiLeq(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. * Parameters are indexes of previously build expressions + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of build expression, or -1 (if error) */ public int make_biiGeq(int _left, int _right) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. + * @param _v attribute from which the expression is build + * @return index of build expression, or -1 (if error) */ public int make_iVar(IBSAttributeClass<Spec,Comp,State,SpecState,CompState>.Attribute _v) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. + * @param _v attribute from which the expression is build + * @return index of build expression, or -1 (if error) */ public int make_bVar(IBSAttributeClass<Spec,Comp,State,SpecState,CompState>.Attribute _v) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. + * @param _i integer value from which the constant expression is build + * @return index of build expression, or -1 (if error) */ public int make_iConst(int _i) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. + * @param _b boolean value from which the constant expression is build + * @return index of build expression, or -1 (if error) */ public int make_bConst(boolean _b) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. - * The Parameter is the index of a previously build expression. + * The Parameter is the index of an expression build previously. + * @param _expr expression from which the negative version is requested + * @return index of build expression, or -1 (if error) */ public int make_iNeg(int _expr) { return -1; } /** method for building an expression. Such a method find * a free index to memorize the build expression and return it. - * The Parameter is the index of a previously build expression. + * The Parameter is the index of an expression build previously. + * @param _expr expression from which the negated version is requested + * @return index of build expression, or -1 (if error) */ public int make_bNot(int _expr) { return -1; } diff --git a/src/main/java/myutil/intboolsolver/IBSParserAPI.java b/src/main/java/myutil/intboolsolver/IBSParserAPI.java index 488ba33fbd..0f725940e5 100644 --- a/src/main/java/myutil/intboolsolver/IBSParserAPI.java +++ b/src/main/java/myutil/intboolsolver/IBSParserAPI.java @@ -56,7 +56,9 @@ import java.util.HashSet; * IBSExpressionClass<Spec,Comp,State,SpecState,CompState> _e); * </PRE> * <p> When using the default constructor, attribute and expression classes - * can be set <i>a posteriori</i>.</p> + * can be set <i>a posteriori</i>. In some implementation, additional + * components must be provided: for example, when using the provided javacup + * generated parser, a lexer must be provided.</p> * * <p>The parser offers several parsing methods depending on the structure * in which open leaves are interpreted.</p> @@ -69,6 +71,11 @@ import java.util.HashSet; * exhaustive. * </p> * + * <p> Parsing is provided for integer expressions, boolean expressions, + * and guards. The only difference between guards and boolean expressions + * is that guards can be empty strings (or only spaces), which are + * evaluated as {@code true}. </p> + * * @author Sophie Coudert (rewrite from Alessandro TEMPIA CALVINO) * @version 1.0 11/04/2023 */ @@ -124,6 +131,12 @@ public interface IBSParserAPI< * @return an expression if no error has been detected. Otherwise, null. */ public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseBool(Spec _spec, String _s); + /** parse a guard + * @param _spec the specification in which open leaves are interpreted + * @param _s the string to parse + * @return an expression if no error has been detected. Otherwise, null. + */ + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseGuard(Spec _spec, String _s); /** parse an integer expression * @param _comp the component in which open leaves are interpreted * @param _s the string to parse @@ -136,6 +149,12 @@ public interface IBSParserAPI< * @return an expression if no error has been detected. Otherwise, null. */ public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseBool(Comp _comp, String _s); + /** parse a guard + * @param _comp the component in which open leaves are interpreted + * @param _s the string to parse + * @return an expression if no error has been detected. Otherwise, null. + */ + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseGuard(Comp _comp, String _s); /** parse a closed integer expression * @param _s the string to parse * @return an expression if no error has been detected. Otherwise, null. @@ -146,6 +165,11 @@ public interface IBSParserAPI< * @return an expression if no error has been detected. Otherwise, null. */ public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseBool(String _s); + /** parse a closed guard + * @param _s the string to parse + * @return an expression if no error has been detected. Otherwise, null. + */ + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseGuard(String _s); /** builds an integer expression from an attribute * @param _attr the source attribute * @return an expression if no error has been detected. Otherwise, null. diff --git a/src/main/java/myutil/intboolsolver/IBSStdAttributeClass.java b/src/main/java/myutil/intboolsolver/IBSStdAttributeClass.java index bc1c8d7a7d..df3a1d16bf 100644 --- a/src/main/java/myutil/intboolsolver/IBSStdAttributeClass.java +++ b/src/main/java/myutil/intboolsolver/IBSStdAttributeClass.java @@ -369,6 +369,8 @@ public class IBSStdAttributeClass< * just before.</p> * <p> Returned type should be BoolAttr, or NullAttr if the attribute is not * a state attribute (error case).</p> + * @param _comp the component that associates structures to attribute + * @return the type of the identified attribute, i.e. BoolAttr or NullAttr */ protected int initStateAttribute(Comp _comp) { return IBSAttributeClass.NullAttr; } diff --git a/src/main/java/myutil/intboolsolver/IBSStdExpressionClass.java b/src/main/java/myutil/intboolsolver/IBSStdExpressionClass.java index c94566cebe..4cda649786 100644 --- a/src/main/java/myutil/intboolsolver/IBSStdExpressionClass.java +++ b/src/main/java/myutil/intboolsolver/IBSStdExpressionClass.java @@ -43,23 +43,46 @@ import java.util.ArrayList; * * <p> Methods are provided to build and evaluate integer and boolean * expressions.</p> + * <p> W.r.t. {@link myutil.intboolsolver.IBSExpressionClass IBSExpressionClass}, + * some additional methods are provided (to identify expression types, to access + * subexpressions, and to put expression in internal memory in order to be able + * to build new expressions).</p> * <p>Integer that are used as parameter or return value by building * methods are indexes in some internal memory where build expressions * are saved (technical choice that allow inheritance)</p> * <p> There are two memories: one for integer expressions and one * for boolean expressions.</p> + * <p> Expressions are instances of subclasses depending on their kind (plus, + * minus, greater than,...). Names are prefixed by letters which denote types. For example, + * {@code BII} or {@code bii} is used for binary operators that provide a boolean + * expression from two binary expression (i.e. integer comparisons).</p> + * <p> When building expressions, the index where the result is memorized is returned. + * A returned index equal to -1 denotes an error.</p> + * <p> Notice that, due to implementation choices, primitives that build expressions + * do not fully preserve original expression structure, especially when using negation + * ({@code !true} becomes {@code false}, {@code !(a<b)} becomes {@code a>=b},...). The expressions + * that preserve negation (or negativity) are integer/boolean binary operations and variables.</p> * <hr> - * <p> About the encoding of expression types: considering bits from less significant bit (0) to most significant bit (15)</p> + * <p> Due to some Java implementation choices around generic classes, the use of {@code instanceof} + * to recover the precise subclass of an expression is not allowed (casts are allowed). Thus we + * provide expression types to allow the user to recover this information. As explained above, + * prefixes of type names denote the input/output type of expressions. Moreover, a {@code _n} + * suffix denotes a negated (or negative) expression. The types are encoded by numbers in a way + * that allow to easy recover information about them.</p> + * <p> Encoding of expression types: considering bits from less significant bit (0) to most significant bit (15)</p> * <ul><li> Bit 0 is 1 iff expression type is boolean </li> - * <li> Bit 1 is 1 iff expression is unary, i.e. negated (not or unary minus) </li> - * <li> Bit 2 is 1 iff expression is binary (negated or not...) </li> + * <li> Bit 1 is 1 iff expression is unary, i.e. negated or negative. </li> + * <li> Bit 2 is 1 iff expression is binary (may be negated/negative or not...) </li> * <li> if expression is binary, then bit 3 is 1 iff arguments are booleans (otherwise they are integers)</li> * <li> if expression is not binary, then bit 3 is 1 iff expression is constant (otherwise it is variable)</li> * <li> if relevant, other bits provide the index of the associated symbol in the symbol table: - * <code> symbol = opString[expression.getType()>>>4] </code></li> + * <code> symbol = opString[expression.getType()>>>4] </code></li> * </ul> + * <p> Some methods are provided based on this encoding that allow to recover type information without having to + * do this manually (which of course remains possible)</p> * <p><code>iNeg</code> and <code>bNeg</code> are not types but simple symbol indexes (thus they do not contain - * the 4-bit encoding and do not require the right shift 4.</p> + * the 4-bit encoding and do not require the right shift 4).</p> + * <p> Finally, note that expressions are immutable.</p> * * @version 1.0 11/04/2023 * @author Sophie Coudert @@ -72,56 +95,151 @@ public class IBSStdExpressionClass< SpecState extends IBSParamSpecState, CompState extends IBSParamCompState > extends IBSExpressionClass<Spec,Comp,State,SpecState,CompState> { - private final String[] opString = {"+","-","*","/","%","&&","||","==","==","!=","!=","<",">","<=",">=","-","!","true","false"}; - public final short iiiPlus = 0<<4 | 0b0100; - public final short iiiPlus_n = 0<<4 | 0b0110; - public final short iiiMinus = 1<<4 | 0b0100; - public final short iiiMinus_n = 1<<4 | 0b0110; - public final short iiiMult = 2<<4 | 0b0100; - public final short iiiMult_n = 2<<4 | 0b0110; - public final short iiiDiv = 3<<4 | 0b0100; - public final short iiiDiv_n = 3<<4 | 0b0110; - public final short iiiMod = 4<<4 | 0b0100; - public final short iiiMod_n = 4<<4 | 0b0110; - public final short bbbAnd = 5<<4 | 0b1101; - public final short bbbAnd_n = 5<<4 | 0b1111; - public final short bbbOr = 6<<4 | 0b1101; - public final short bbbOr_n = 6<<4 | 0b1111; - public final short biiEq = 7<<4 | 0b0101 ; - public final short bbbEq = 8<<4 | 0b1101; - public final short biiDif = 9<<4 | 0b0101; + /** table of symbols associated to operators and boolean constants */ + private final String[] opString = {"-","!","+","-","*","/","%","&&","||","==","!=","<",">","<=",">=","true","false"}; + /** index of the unary minus symbol in {@link myutil.intboolsolver.IBSStdExpressionClass#opString opString} */ + public final short iNeg = 0; // simple symbol index + /** index of the unary not symbol in {@link myutil.intboolsolver.IBSStdExpressionClass#opString opString} */ + public final short bNot = 1; // simple symbol index + /** type of expression. Clear from name... */ + public final short iiiPlus = 2<<4 | 0b0100; + /** type of expression. Clear from name... */ + public final short iiiPlus_n = 2<<4 | 0b0110; + /** type of expression. Clear from name... */ + public final short iiiMinus = 3<<4 | 0b0100; + /** type of expression. Clear from name... */ + public final short iiiMinus_n = 3<<4 | 0b0110; + /** type of expression. Clear from name... */ + public final short iiiMult = 4<<4 | 0b0100; + /** type of expression. Clear from name... */ + public final short iiiMult_n = 4<<4 | 0b0110; + /** type of expression. Clear from name... */ + public final short iiiDiv = 5<<4 | 0b0100; + /** type of expression. Clear from name... */ + public final short iiiDiv_n = 5<<4 | 0b0110; + /** type of expression. Clear from name... */ + public final short iiiMod = 6<<4 | 0b0100; + /** type of expression. Clear from name... */ + public final short iiiMod_n = 6<<4 | 0b0110; + /** type of expression. Clear from name... */ + public final short bbbAnd = 7<<4 | 0b1101; + /** type of expression. Clear from name... */ + public final short bbbAnd_n = 7<<4 | 0b1111; + /** type of expression. Clear from name... */ + public final short bbbOr = 8<<4 | 0b1101; + /** type of expression. Clear from name... */ + public final short bbbOr_n = 8<<4 | 0b1111; + /** type of expression. Clear from name... */ + public final short biiEq = 9<<4 | 0b0101 ; + /** type of expression. Clear from name... */ + public final short bbbEq = 9<<4 | 0b1101; + /** type of expression. Clear from name... */ + public final short biiDif = 10<<4 | 0b0101; + /** type of expression. Clear from name... */ public final short bbbDif = 10<<4 | 0b1101; + /** type of expression. Clear from name... */ public final short biiLt = 11<<4 | 0b0101; + /** type of expression. Clear from name... */ public final short biiGt = 12<<4 | 0b0101; + /** type of expression. Clear from name... */ public final short biiLeq = 13<<4 | 0b0101; + /** type of expression. Clear from name... */ public final short biiGeq = 14<<4 | 0b0101; - public final short iNeg = 15; // simple symbol index - public final short bNot = 16; // simple symbol index - public final short btrue = 17<<4 | 0b1001; - public final short bfalse = 18<<4 | 0b1001; + /** type of expression. Clear from name... */ + public final short btrue = 15<<4 | 0b1001; + /** type of expression. Clear from name... */ + public final short bfalse = 16<<4 | 0b1001; + /** type of expression. Clear from name... */ public final short iVar = 64<<4 | 0b0000; // no associated symbol + /** type of expression. Clear from name... */ public final short iVar_n = 64<<4 | 0b0010; // no associated symbol + /** type of expression. Clear from name... */ public final short bVar = 65<<4 | 0b0001; // no associated symbol + /** type of expression. Clear from name... */ public final short bVar_n = 65<<4 | 0b0011; // no associated symbol + /** type of expression. Clear from name... */ public final short iConst = 67<<4 | 0b1000 ; // no associated symbol + /** type of expression. Clear from name... */ public final short bConst = 68<<4 | 0b1001 ; // no associated symbol + /** default (and single) constructor */ + public IBSStdExpressionClass(){} + /** + * test if an expression is boolean + * @param e the expression to test + * @return true iff e is boolean (otherwise, integer) + */ public final boolean isBool(Expr e) { return (e.getType() & 0b1) == 0b1; } + /** + * test if expression is build on a unary operator (not or minus) + * @param e the expression to test + * @return true iff e is build on a unary operator + */ public final boolean isUnary(Expr e) { return (e.getType() & 0b10) == 0b10; } + /** + * test if expression is build on a binary operator (not or minus) + * @param e the expression to test + * @return true iff e is build on a binary operator + */ public final boolean isBinary(Expr e) { return ((e.getType() & 0b110) == 0b100); } + /** + * test if expression is a constant + * @param e the expression to test + * @return true iff e is a constant expression + */ public final boolean isConstant(Expr e) { return ((e.getType() & 0b1110) == 0b1000); } + /** + * test if expression is a variable + * @param e the expression to test + * @return true iff e is a variable + */ public final boolean isVar(Expr e) { return ((e.getType() & 0b1110) == 0b0000); } + /** get the unique subexpression of an unary integer expression. + * @param e the expression + * @return its subexpression, or null if e is not unary + */ public final IExpr getArg(IExpr e){ return ( isUnary(e)?e.negate():null); } + /** get the unique subexpression of an unary boolean expression. + * @param e the expression + * @return its subexpression, or null if e is not unary + */ public final BExpr getArg(BExpr e){ return ( isUnary(e)?e.negate():null); } + /** get the left subexpression of an integer binary operator expression. + * @param e the expression + * @return its left subexpression, or null if e is not binary + */ public final IExpr getLeftArg(IIIBinOp e){ return ( isBinary(e)?e.left:null); } + /** get the right subexpression of an integer binary operator expression. + * @param e the expression + * @return its right subexpression, or null if e is not binary + */ public final IExpr getRightArg(IIIBinOp e){ return ( isBinary(e)?e.right:null); } + /** get the left subexpression of an integer comparison expression. + * @param e the expression + * @return its left subexpression, or null if e is not binary + */ public final IExpr getLeftArg(BIIBinOp e){ return ( isBinary(e)?e.left:null); } + /** get the right subexpression of an integer comparison expression. + * @param e the expression + * @return its left subexpression, or null if e is not binary + */ public final IExpr getRightArg(BIIBinOp e){ return ( isBinary(e)?e.right:null); } + /** get the right subexpression of a boolean binary operator expression. + * @param e the expression + * @return its left subexpression, or null if e is not binary + */ public final BExpr getLeftArg(BBBBinOp e){ return ( isBinary(e)?e.left:null); } + /** get the right subexpression of a boolean binary operator expression. + * @param e the expression + * @return its right subexpression, or null if e is not binary + */ public final BExpr getRightArg(BBBBinOp e){ return ( isBinary(e)?e.right:null); } private final ArrayList<IExpr> iExpressions = new ArrayList<IExpr>(16); private final ArrayList<BExpr> bExpressions = new ArrayList<BExpr>(16); - public IBSStdExpressionClass(){} + + /** + * clear the internal memories containing build integer and boolean expressions + */ public void clear(){ iExpressions.clear(); bExpressions.clear(); @@ -142,26 +260,56 @@ public class IBSStdExpressionClass< } return i; } + + /** deletes a memorized integer expression, making its index free + * @param _toFree the index to free + */ public void freeInt(int _toFree) { iExpressions.set(_toFree,null); } + /** deletes a memorized boolean expression, making its index free + * @param _toFree the index to free + */ public void freeBool(int _toFree) { bExpressions.set(_toFree,null); } - public IExpr getIExpr(int _expr) { - if (_expr >= iExpressions.size() || _expr < 0) - throw new Error("IBSStdExpressionClass.getIExpr: out of bounds"); + + /** get the integer expression memorized at some index + * @param _i the index + * @return the requested expression (may be null) + */ + public IExpr getIExpr(int _i) { + if (_i >= iExpressions.size() || _i < 0) + return null; else - return iExpressions.get(_expr); + return iExpressions.get(_i); } - public BExpr getBExpr(int _expr) { - if (_expr >= bExpressions.size() || _expr < 0) - throw new Error("IBSStdExpressionClass.getBExpr: out of bounds"); + /** get the boolean expression memorized at some index + * @param _i the index + * @return the requested expression (may be null) + */ + public BExpr getBExpr(int _i) { + if (_i >= bExpressions.size() || _i < 0) + return null; else - return bExpressions.get(_expr); + return bExpressions.get(_i); } - public boolean isBconstant(int i){ return bExpressions.get(i).getType()==bConst; } - public boolean isIconstant(int i){ return iExpressions.get(i).getType()==iConst; } + + /** test if a memorized boolean expression is constant + * @param _i index of a (not null) boolean expression + * @return true iff boolean expression at index _i is constant + */ + public boolean isBconstant(int _i){ return bExpressions.get(_i).getType()==bConst; } + /** test if a memorized integer expression is constant + * @param _i index of a (not null) boolean expression + * @return true iff boolean expression at index _i is constant + */ + public boolean isIconstant(int _i){ return iExpressions.get(_i).getType()==iConst; } + /** binary Plus expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_iiiPlus(int _left, int _right) { int tgt = findIfree(); if (iExpressions.size()<= _left || iExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -170,6 +318,11 @@ public class IBSStdExpressionClass< iExpressions.set(tgt, new IIIPlus(iExpressions.get(_left), iExpressions.get(_right))); return tgt; } + /** binary Minus expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_iiiMinus(int _left, int _right) { int tgt = findIfree(); if (iExpressions.size()<= _left || iExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -178,6 +331,11 @@ public class IBSStdExpressionClass< iExpressions.set(tgt, new IIIMinus(iExpressions.get(_left), iExpressions.get(_right))); return tgt; } + /** binary Mult expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_iiiMult(int _left, int _right) { int tgt = findIfree(); if (iExpressions.size()<= _left || iExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -186,6 +344,11 @@ public class IBSStdExpressionClass< iExpressions.set(tgt, new IIIMult(iExpressions.get(_left), iExpressions.get(_right))); return tgt; } + /** binary Div expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_iiiDiv(int _left, int _right) { int tgt = findIfree(); if (iExpressions.size()<= _left || iExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -194,6 +357,11 @@ public class IBSStdExpressionClass< iExpressions.set(tgt, new IIIDiv(iExpressions.get(_left), iExpressions.get(_right))); return tgt; } + /** binary Modulus expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_iiiMod(int _left, int _right) { int tgt = findIfree(); if (iExpressions.size()<= _left || iExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -202,6 +370,11 @@ public class IBSStdExpressionClass< iExpressions.set(tgt, new IIIMod(iExpressions.get(_left), iExpressions.get(_right))); return tgt; } + /** binary And expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_bbbAnd(int _left, int _right) { int tgt = findBfree(); if (bExpressions.size()<= _left || bExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -210,6 +383,11 @@ public class IBSStdExpressionClass< bExpressions.set(tgt, new BBBAnd(bExpressions.get(_left), bExpressions.get(_right))); return tgt; } + /** binary Or expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_bbbOr(int _left, int _right) { int tgt = findBfree(); if (bExpressions.size()<= _left || bExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -218,6 +396,11 @@ public class IBSStdExpressionClass< bExpressions.set(tgt, new BBBOr(bExpressions.get(_left), bExpressions.get(_right))); return tgt; } + /** integer equality expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_biiEq(int _left, int _right) { int tgt = findBfree(); if (iExpressions.size()<= _left || iExpressions.size() <= _right || iExpressions.get(_left) == null || iExpressions.get(_right) == null) @@ -227,6 +410,11 @@ public class IBSStdExpressionClass< bExpressions.set(tgt, new BIIEq(iExpressions.get(_left), iExpressions.get(_right))); return tgt; } + /** boolean equality expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_bbbEq(int _left, int _right) { int tgt = findBfree(); if (bExpressions.size()<= _left || bExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -235,6 +423,11 @@ public class IBSStdExpressionClass< bExpressions.set(tgt, new BBBEq(bExpressions.get(_left), bExpressions.get(_right))); return tgt; } + /** integer difference expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_biiDif(int _left, int _right) { int tgt = findBfree(); if (iExpressions.size()<= _left || iExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -243,6 +436,11 @@ public class IBSStdExpressionClass< bExpressions.set(tgt, new BIIDif(iExpressions.get(_left), iExpressions.get(_right))); return tgt; } + /** boolean difference expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_bbbDif(int _left, int _right) { int tgt = findBfree(); if (bExpressions.size()<= _left || bExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -251,6 +449,11 @@ public class IBSStdExpressionClass< bExpressions.set(tgt, new BBBDif(bExpressions.get(_left), bExpressions.get(_right))); return tgt; } + /** integer "lower than" expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_biiLt(int _left, int _right) { int tgt = findBfree(); if (iExpressions.size()<= _left || iExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -259,6 +462,11 @@ public class IBSStdExpressionClass< bExpressions.set(tgt, new BIILt(iExpressions.get(_left), iExpressions.get(_right))); return tgt; } + /** integer "greater than" expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_biiGt(int _left, int _right) { int tgt = findBfree(); if (iExpressions.size()<= _left || iExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -267,6 +475,11 @@ public class IBSStdExpressionClass< bExpressions.set(tgt, new BIIGt(iExpressions.get(_left), iExpressions.get(_right))); return tgt; } + /** integer "lower than or equal" expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_biiLeq(int _left, int _right) { int tgt = findBfree(); if (iExpressions.size()<= _left || iExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -275,6 +488,11 @@ public class IBSStdExpressionClass< bExpressions.set(tgt, new BIILeq(iExpressions.get(_left), iExpressions.get(_right))); return tgt; } + /** integer "greater than or equal" expression constructor + * @param _left index of left subexpression + * @param _right index of right subexpression + * @return index of the build expression + */ public int make_biiGeq(int _left, int _right) { int tgt = findBfree(); if (iExpressions.size()<= _left || iExpressions.size() <= _right || 0 > _left || 0 > _right || @@ -283,6 +501,10 @@ public class IBSStdExpressionClass< bExpressions.set(tgt, new BIIGeq(iExpressions.get(_left), iExpressions.get(_right))); return tgt; } + /** integer variable expression constructor + * @param _v attribute defining the variable + * @return index of the build expression + */ public int make_iVar(IBSAttributeClass<Spec,Comp,State,SpecState,CompState>.Attribute _v) { int tgt = findIfree(); if (_v == null) @@ -292,6 +514,10 @@ public class IBSStdExpressionClass< iExpressions.set(tgt, new IVar(_v)); return tgt; } + /** boolean variable expression constructor + * @param _v attribute defining the variable + * @return index of the build expression + */ public int make_bVar(IBSAttributeClass<Spec,Comp,State,SpecState,CompState>.Attribute _v) { int tgt = findBfree(); if (_v == null) @@ -301,16 +527,28 @@ public class IBSStdExpressionClass< bExpressions.set(tgt, new BVar(_v)); return tgt; } + /** integer constant expression constructor + * @param _i the value of the constant + * @return index of the build expression + */ public int make_iConst(int _i) { int tgt = findIfree(); iExpressions.set(tgt, new IConst(_i)); return tgt; } + /** boolean constant expression constructor + * @param _b the value of the constant + * @return index of the build expression + */ public int make_bConst(boolean _b) { int tgt = findBfree(); bExpressions.set(tgt, new BConst(_b)); return tgt; } + /** build an expression denoting the opposite of the provided integer expression + * @param _expr the expression from which the opposite is requested + * @return index of the build expression + */ public int make_iNeg(int _expr) { int tgt = findIfree(); if (iExpressions.size()<=_expr || _expr < 0 ||iExpressions.get(_expr) == null) @@ -318,6 +556,10 @@ public class IBSStdExpressionClass< iExpressions.set(tgt, iExpressions.get(_expr).negate()); return tgt; } + /** build an expression denoting the negation of the provided boolean expression + * @param _expr the expression from which the negation is requested + * @return index of the build expression + */ public int make_bNot(int _expr) { int tgt = findBfree(); if (bExpressions.size()<=_expr || _expr < 0 || bExpressions.get(_expr) == null) @@ -325,13 +567,15 @@ public class IBSStdExpressionClass< bExpressions.set(tgt, bExpressions.get(_expr).negate()); return tgt; } + /** Integer expressions */ public abstract class IExpr extends IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.IExpr { public abstract IExpr negate(); } + /** Boolean expressions */ public abstract class BExpr extends IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr { - public final short getType() { return type; } public abstract BExpr negate(); } + /** Integer binary expressions */ public abstract class IIIBinOp extends IExpr{ protected final IExpr left; protected final IExpr right; @@ -351,6 +595,7 @@ public class IBSStdExpressionClass< right.linkComps(_spec); } } + /** Integer comparison expressions */ public abstract class BIIBinOp extends BExpr{ protected final IExpr left; protected final IExpr right; @@ -370,6 +615,7 @@ public class IBSStdExpressionClass< right.linkComps(_spec); } } + /** Boolean binary expressions */ public abstract class BBBBinOp extends BExpr{ protected final BExpr left; protected final BExpr right; @@ -388,7 +634,8 @@ public class IBSStdExpressionClass< left.linkComps(_spec); right.linkComps(_spec); } - } + } + /** Integer constant expressions */ public final class IConst extends IExpr { private final int constant; private IConst(int _i){ constant = _i; type = iConst;} @@ -409,6 +656,7 @@ public class IBSStdExpressionClass< public final void linkStates() {} public final void linkComps(Spec _spec) {} } + /** Boolean constant expressions */ public final class BConst extends BExpr { private final boolean constant; public BConst(boolean _b){ constant = _b; type = bConst;} @@ -429,6 +677,7 @@ public class IBSStdExpressionClass< public final void linkStates() {} public final void linkComps(Spec _spec) {} } + /** integer variable expressions */ public final class IVar extends IExpr { private final boolean isNeg; private final IBSAttributeClass<Spec,Comp,State,SpecState,CompState>.Attribute var; @@ -459,6 +708,7 @@ public class IBSStdExpressionClass< public final void linkStates() {var.linkState();} public final void linkComps(Spec _spec) {var.linkComp(_spec);} } + /** Boolean variable expressions */ public final class BVar extends BExpr { private final boolean isNot; private final IBSAttributeClass<Spec,Comp,State,SpecState,CompState>.Attribute var; @@ -495,6 +745,7 @@ public class IBSStdExpressionClass< public final void linkStates() {var.linkState();} public final void linkComps(Spec _spec) {var.linkComp(_spec);} } + /** Integer binary Plus expressions */ public final class IIIPlus extends IIIBinOp { private final boolean isNeg; public IIIPlus(IExpr _l, IExpr _r) { @@ -524,6 +775,7 @@ public class IBSStdExpressionClass< return (isNeg? opString[iNeg] + "(" + s + ")" : s); } } + /** Integer binary Minus expressions */ public final class IIIMinus extends IIIBinOp { private final boolean isNeg; public IIIMinus(IExpr _l, IExpr _r) { @@ -555,6 +807,7 @@ public class IBSStdExpressionClass< return (isNeg? opString[iNeg] + "(" + s + ")" : s); } } + /** Integer binary Mult expressions */ public final class IIIMult extends IIIBinOp { private final boolean isNeg; public IIIMult(IExpr _l, IExpr _r) { @@ -586,6 +839,7 @@ public class IBSStdExpressionClass< return (isNeg? opString[iNeg] + "(" + s + ")" : s); } } + /** Integer binary Div expressions */ public final class IIIDiv extends IIIBinOp { private final boolean isNeg; public IIIDiv(IExpr _l, IExpr _r) { @@ -617,6 +871,7 @@ public class IBSStdExpressionClass< return (isNeg? opString[iNeg] + "(" + s + ")" : s); } } + /** Integer binary Modulus expressions */ public final class IIIMod extends IIIBinOp { private final boolean isNeg; public IIIMod(IExpr _l, IExpr _r) { @@ -648,6 +903,7 @@ public class IBSStdExpressionClass< return (isNeg? opString[iNeg] + "(" + s + ")" : s); } } + /** Boolean binary And expressions */ public final class BBBAnd extends BBBBinOp { private final boolean isNot; public BBBAnd(BExpr _l, BExpr _r) { super(_l, _r); isNot=false; type = bbbAnd;} @@ -682,6 +938,7 @@ public class IBSStdExpressionClass< return (isNot? opString[bNot] + "(" + s + ")" : s); } } + /** Boolean binary Or expressions */ public final class BBBOr extends BBBBinOp { private final boolean isNot; public BBBOr(BExpr _l, BExpr _r){ super(_l, _r); isNot=false; type = bbbOr;} @@ -716,6 +973,7 @@ public class IBSStdExpressionClass< return (isNot? opString[bNot] + "(" + s + ")" : s); } } + /** Integer Equality expressions */ public final class BIIEq extends BIIBinOp { public BIIEq(IExpr _l, IExpr _r){ super(_l, _r); type = biiEq;} public BIIEq(BIIDif _p){ @@ -732,6 +990,7 @@ public class IBSStdExpressionClass< return "(" + left.toString() + ")" + opString[biiEq>>>4] + " (" + right.toString() + ")"; } } + /** Boolean Equality expressions */ public final class BBBEq extends BBBBinOp { public BBBEq(BExpr _l, BExpr _r){ super(_l, _r); type = bbbEq; } public BBBEq(BBBDif _p){ super(_p.left, _p.right); type = bbbEq; } @@ -745,6 +1004,7 @@ public class IBSStdExpressionClass< return "(" + left.toString() + ")" + opString[bbbEq>>>4] + " (" + right.toString() + ")"; } } + /** Integer Difference expressions */ public final class BIIDif extends BIIBinOp { public BIIDif(IExpr _l, IExpr _r){ super(_l, _r); type = biiDif; } public BIIDif(BIIEq _p){ @@ -761,6 +1021,7 @@ public class IBSStdExpressionClass< return "(" + left.toString() + ")" + opString[biiDif>>>4] + " (" + right.toString() + ")"; } } + /** Boolean Difference expressions */ public final class BBBDif extends BBBBinOp { public BBBDif(BExpr _l, BExpr _r){ super(_l, _r); type = bbbDif; } public BBBDif(BBBEq _p){ super(_p.left, _p.right); type = bbbDif; } @@ -776,6 +1037,7 @@ public class IBSStdExpressionClass< return "(" + left.toString() + ")" + opString[bbbDif>>>4] + " (" + right.toString() + ")"; } } + /** Integer "Lower Than" expressions */ public final class BIILt extends BIIBinOp { public BIILt(IExpr _l, IExpr _r) { super(_l, _r); type = biiLt; } public BIILt(BIIGeq _p){ super(_p.left, _p.right); type = biiLt; } @@ -793,6 +1055,7 @@ public class IBSStdExpressionClass< return "(" +l + ")" + opString[biiLt>>>4] + "(" + r + ")"; } } + /** Integer "Greater Than" expressions */ public final class BIIGt extends BIIBinOp { public BIIGt(IExpr _l, IExpr _r) { super(_l, _r); type = biiGt; } public BIIGt(BIILeq _p){ super(_p.left, _p.right); type = biiGt; } @@ -808,6 +1071,7 @@ public class IBSStdExpressionClass< return "(" +l + ")" + opString[biiGt>>>4] + "(" + r + ")"; } } + /** Integer "Lower Than or Equal" expressions */ public final class BIILeq extends BIIBinOp { public BIILeq(IExpr _l, IExpr _r){ super(_l, _r); type = biiLeq; } public BIILeq(BIIGt _p){ super(_p.left, _p.right); type = biiLeq; } @@ -823,6 +1087,7 @@ public class IBSStdExpressionClass< return "(" +l + ")" + opString[biiLeq>>>4] + "(" + r + ")"; } } + /** Integer "Greater Than or Equal" expressions */ public final class BIIGeq extends BIIBinOp { public BIIGeq(IExpr _l, IExpr _r) { super(_l, _r); type = biiGeq; } public BIIGeq(BIILt _p){ super(_p.left, _p.right); type = biiGeq; } diff --git a/src/main/java/myutil/intboolsolver/IBSStdLexer.java b/src/main/java/myutil/intboolsolver/IBSStdLexer.java index b7f8129c60..89def62e3f 100644 --- a/src/main/java/myutil/intboolsolver/IBSStdLexer.java +++ b/src/main/java/myutil/intboolsolver/IBSStdLexer.java @@ -1,4 +1,4 @@ -/* The following code was generated by JFlex 1.4.3 on 22/05/2023 11:19 */ +/* The following code was generated by JFlex 1.4.3 on 23/05/2023 14:37 */ /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille * @@ -46,7 +46,7 @@ import java.util.HashSet; /** * This class is a scanner generated by * <a href="http://www.jflex.de/">JFlex</a> 1.4.3 - * on 22/05/2023 11:19 from the specification file + * on 23/05/2023 14:37 from the specification file * <code>__IBSStdLexer__.jflex</code> */ public class IBSStdLexer< Spec extends IBSParamSpec, Comp extends IBSParamComp, State extends IBSParamState, SpecState extends IBSParamSpecState, CompState extends IBSParamCompState > implements IBSScanner<Spec, Comp, State, SpecState, CompState>, java_cup.runtime.Scanner { @@ -75,11 +75,11 @@ public class IBSStdLexer< Spec extends IBSParamSpec, Comp extends IBSParamComp, * Translates characters to character classes */ private static final String ZZ_CMAP_PACKED = - "\11\0\2\1\1\0\2\1\22\0\1\1\1\33\3\0\1\27\1\30"+ - "\1\0\1\37\1\40\1\25\1\23\1\0\1\24\1\5\1\26\1\2"+ + "\11\0\2\1\1\0\2\1\22\0\1\1\1\33\3\0\1\30\1\31"+ + "\1\0\1\37\1\40\1\26\1\24\1\0\1\25\1\5\1\27\1\2"+ "\11\3\2\0\1\35\1\34\1\36\2\0\32\4\4\0\1\4\1\0"+ - "\1\12\1\6\1\4\1\31\1\11\1\21\1\16\1\4\1\14\2\4"+ - "\1\10\1\4\1\13\1\7\2\4\1\17\1\22\1\15\1\20\5\4"+ + "\1\12\1\6\1\4\1\17\1\11\1\22\1\14\1\4\1\20\2\4"+ + "\1\10\1\4\1\13\1\7\2\4\1\16\1\23\1\21\1\15\5\4"+ "\1\0\1\32\uff83\0"; /** @@ -93,14 +93,14 @@ public class IBSStdLexer< Spec extends IBSParamSpec, Comp extends IBSParamComp, private static final int [] ZZ_ACTION = zzUnpackAction(); private static final String ZZ_ACTION_PACKED_0 = - "\2\0\1\1\2\0\2\2\6\3\1\4\1\5\1\6"+ + "\2\0\1\1\3\0\2\2\6\3\1\4\1\5\1\6"+ "\1\7\1\10\2\0\1\11\1\0\1\12\1\13\1\14"+ - "\1\15\2\0\1\16\4\3\1\17\1\16\1\20\1\21"+ - "\1\22\1\23\2\0\1\17\1\11\2\3\2\0\1\24"+ - "\1\3\2\0\1\25\2\0\1\26\1\27"; + "\1\15\3\0\1\16\4\3\1\17\1\16\1\20\1\21"+ + "\1\22\1\23\3\0\1\17\1\11\2\3\3\0\1\24"+ + "\1\3\1\0\1\25\1\0\1\26\2\0\1\27\1\30"; private static int [] zzUnpackAction() { - int [] result = new int[56]; + int [] result = new int[61]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -125,16 +125,17 @@ public class IBSStdLexer< Spec extends IBSParamSpec, Comp extends IBSParamComp, private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\41\0\102\0\143\0\204\0\102\0\245\0\306"+ - "\0\347\0\u0108\0\u0129\0\u014a\0\u016b\0\102\0\102\0\102"+ - "\0\102\0\102\0\u018c\0\u01ad\0\u01ce\0\u01ef\0\u0210\0\u0231"+ - "\0\102\0\102\0\u0252\0\u0273\0\306\0\u0294\0\u02b5\0\u02d6"+ - "\0\u02f7\0\102\0\102\0\102\0\102\0\102\0\102\0\u0318"+ - "\0\u0339\0\306\0\306\0\u035a\0\u037b\0\u039c\0\u03bd\0\306"+ - "\0\u03de\0\u03ff\0\u0420\0\306\0\u0441\0\u0462\0\102\0\102"; + "\0\0\0\41\0\102\0\143\0\204\0\245\0\102\0\306"+ + "\0\347\0\u0108\0\u0129\0\u014a\0\u016b\0\u018c\0\102\0\102"+ + "\0\102\0\102\0\102\0\u01ad\0\u01ce\0\u01ef\0\u0210\0\u0231"+ + "\0\u0252\0\102\0\102\0\u0273\0\u0294\0\u02b5\0\347\0\u02d6"+ + "\0\u02f7\0\u0318\0\u0339\0\102\0\102\0\102\0\102\0\102"+ + "\0\102\0\u035a\0\u037b\0\u039c\0\347\0\347\0\u03bd\0\u03de"+ + "\0\u03ff\0\u0420\0\u0441\0\347\0\u0462\0\u0483\0\102\0\u04a4"+ + "\0\347\0\u04c5\0\u04e6\0\102\0\102"; private static int [] zzUnpackRowMap() { - int [] result = new int[56]; + int [] result = new int[61]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -157,28 +158,26 @@ public class IBSStdLexer< Spec extends IBSParamSpec, Comp extends IBSParamComp, private static final int [] ZZ_TRANS = zzUnpackTrans(); private static final String ZZ_TRANS_PACKED_0 = - "\1\0\1\3\4\0\1\4\5\0\1\5\25\0\1\3"+ - "\1\6\1\7\1\10\1\0\1\10\1\11\2\10\1\12"+ - "\1\13\1\10\1\14\3\10\1\15\1\10\1\16\1\17"+ - "\1\20\1\21\1\22\1\23\1\10\1\24\1\25\1\26"+ - "\1\27\1\30\1\31\1\32\50\0\1\33\44\0\1\34"+ - "\27\0\2\7\37\0\21\10\6\0\1\10\11\0\15\10"+ - "\1\35\3\10\6\0\1\10\11\0\11\10\1\36\7\10"+ - "\6\0\1\10\11\0\5\10\1\37\13\10\6\0\1\10"+ - "\11\0\15\10\1\40\3\10\6\0\1\10\11\0\10\10"+ - "\1\41\10\10\6\0\1\10\37\0\1\42\42\0\1\43"+ - "\42\0\1\44\40\0\1\45\40\0\1\46\40\0\1\47"+ - "\13\0\1\50\46\0\1\51\25\0\21\10\6\0\1\52"+ - "\11\0\13\10\1\53\5\10\6\0\1\10\11\0\16\10"+ - "\1\54\2\10\6\0\1\10\11\0\6\10\1\55\12\10"+ - "\6\0\1\10\17\0\1\56\41\0\1\57\31\0\7\10"+ - "\1\60\11\10\6\0\1\10\11\0\20\10\1\61\6\0"+ - "\1\10\20\0\1\62\45\0\1\63\24\0\7\10\1\64"+ - "\11\10\6\0\1\10\21\0\1\65\37\0\1\66\42\0"+ - "\1\67\44\0\1\70\21\0"; + "\1\0\1\3\4\0\1\4\5\0\1\5\3\0\1\6"+ + "\21\0\1\3\1\7\1\10\1\11\1\0\1\11\1\12"+ + "\2\11\1\13\1\14\5\11\1\15\1\16\1\11\1\17"+ + "\1\20\1\21\1\22\1\23\1\24\1\25\1\26\1\27"+ + "\1\30\1\31\1\32\1\33\50\0\1\34\46\0\1\35"+ + "\36\0\1\36\27\0\2\10\37\0\22\11\17\0\14\11"+ + "\1\37\5\11\17\0\11\11\1\40\10\11\17\0\5\11"+ + "\1\41\14\11\17\0\14\11\1\42\5\11\17\0\10\11"+ + "\1\43\11\11\46\0\1\44\41\0\1\45\42\0\1\46"+ + "\40\0\1\47\40\0\1\50\40\0\1\51\13\0\1\52"+ + "\43\0\1\53\47\0\1\54\21\0\15\11\1\55\4\11"+ + "\17\0\17\11\1\56\2\11\17\0\13\11\1\57\6\11"+ + "\17\0\6\11\1\60\13\11\25\0\1\61\46\0\1\62"+ + "\33\0\1\63\31\0\7\11\1\64\12\11\17\0\21\11"+ + "\1\65\26\0\1\66\46\0\1\67\35\0\1\70\26\0"+ + "\7\11\1\71\12\11\27\0\1\72\37\0\1\73\42\0"+ + "\1\74\43\0\1\75\22\0"; private static int [] zzUnpackTrans() { - int [] result = new int[1155]; + int [] result = new int[1287]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -216,12 +215,12 @@ public class IBSStdLexer< Spec extends IBSParamSpec, Comp extends IBSParamComp, private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\2\0\1\11\2\0\1\11\7\1\5\11\2\0\1\1"+ - "\1\0\2\1\2\11\2\0\5\1\6\11\2\0\4\1"+ - "\2\0\2\1\2\0\1\1\2\0\2\11"; + "\2\0\1\11\3\0\1\11\7\1\5\11\2\0\1\1"+ + "\1\0\2\1\2\11\3\0\5\1\6\11\3\0\4\1"+ + "\3\0\2\1\1\0\1\11\1\0\1\1\2\0\2\11"; private static int [] zzUnpackAttribute() { - int [] result = new int[56]; + int [] result = new int[61]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -643,52 +642,52 @@ public void init(Comp _comp, String _s) throws java.io.IOException { attrHandler case 15: { return new Symbol(IBSStdSymbols.AND); } - case 24: break; + case 25: break; case 9: { return new Symbol(IBSStdSymbols.NOT); } - case 25: break; + case 26: break; case 4: { return new Symbol(IBSStdSymbols.PLUS); } - case 26: break; + case 27: break; case 2: { try { return new Symbol(IBSStdSymbols.INT, Integer.valueOf(exprC.make_iConst(Integer.parseInt(yytext()))));} catch (NumberFormatException nfe) { throw new Exception ("Lexer : Integer Format : " + yytext()); } } - case 27: break; + case 28: break; case 7: { return new Symbol(IBSStdSymbols.DIV); } - case 28: break; + case 29: break; case 11: { return new Symbol(IBSStdSymbols.GT); } - case 29: break; + case 30: break; case 20: { return new Symbol(IBSStdSymbols.BOOL, Integer.valueOf(exprC.make_bConst(true))); } - case 30: break; + case 31: break; case 17: { return new Symbol(IBSStdSymbols.EQ); } - case 31: break; + case 32: break; case 14: { return new Symbol(IBSStdSymbols.OR); } - case 32: break; - case 23: + case 33: break; + case 24: { yybegin(INTBOOL); return new Symbol(IBSStdSymbols.PARSE_INT); } - case 33: break; + case 34: break; case 16: { return new Symbol(IBSStdSymbols.DIF); } - case 34: break; + case 35: break; case 13: { return new Symbol(IBSStdSymbols.RPAR); } - case 35: break; + case 36: break; case 3: { IBSAttributeClass<Spec,Comp,State,SpecState,CompState>.TypedAttribute attr = attrHandler.getTypedAttribute(yytext()); @@ -701,47 +700,51 @@ public void init(Comp _comp, String _s) throws java.io.IOException { attrHandler default : throw new Error ("Lexer, BUG : bad attribute type"); } } - case 36: break; + case 37: break; case 5: { return new Symbol(IBSStdSymbols.MINUS); } - case 37: break; - case 22: + case 38: break; + case 23: { yybegin(INTBOOL); return new Symbol(IBSStdSymbols.PARSE_BOOL); } - case 38: break; + case 39: break; case 6: { return new Symbol(IBSStdSymbols.MULT); } - case 39: break; + case 40: break; case 12: { return new Symbol(IBSStdSymbols.LPAR); } - case 40: break; + case 41: break; case 19: { return new Symbol(IBSStdSymbols.GEQ); } - case 41: break; + case 42: break; case 8: { return new Symbol(IBSStdSymbols.MOD); } - case 42: break; - case 21: + case 43: break; + case 22: { return new Symbol(IBSStdSymbols.BOOL, Integer.valueOf(exprC.make_bConst(false))); } - case 43: break; + case 44: break; case 18: { return new Symbol(IBSStdSymbols.LEQ); } - case 44: break; + case 45: break; + case 21: + { yybegin(INTBOOL); return new Symbol(IBSStdSymbols.PARSE_GUARD); + } + case 46: break; case 10: { return new Symbol(IBSStdSymbols.LT); } - case 45: break; + case 47: break; case 1: { } - case 46: break; + case 48: break; default: if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { zzAtEOF = true; diff --git a/src/main/java/myutil/intboolsolver/IBSStdParser.java b/src/main/java/myutil/intboolsolver/IBSStdParser.java index d1e0595ba3..6c0681946f 100644 --- a/src/main/java/myutil/intboolsolver/IBSStdParser.java +++ b/src/main/java/myutil/intboolsolver/IBSStdParser.java @@ -33,14 +33,15 @@ public class IBSStdParser< Spec extends IBSParamSpec, Comp extends IBSParamComp, /** Production table. */ protected static final short _production_table[][] = unpackFromStrings(new String[] { - "\000\030\000\002\002\004\000\002\002\004\000\002\002" + - "\004\000\002\003\005\000\002\003\005\000\002\003\005" + + "\000\032\000\002\002\004\000\002\002\004\000\002\002" + + "\004\000\002\002\004\000\002\002\003\000\002\003\005" + "\000\002\003\005\000\002\003\005\000\002\003\005\000" + - "\002\003\004\000\002\003\003\000\002\004\005\000\002" + - "\004\005\000\002\004\003\000\002\004\005\000\002\004" + - "\004\000\002\004\005\000\002\004\005\000\002\004\005" + + "\002\003\005\000\002\003\005\000\002\003\004\000\002" + + "\003\003\000\002\004\005\000\002\004\005\000\002\004" + + "\003\000\002\004\005\000\002\004\004\000\002\004\005" + "\000\002\004\005\000\002\004\005\000\002\004\005\000" + - "\002\004\005\000\002\004\005" }); + "\002\004\005\000\002\004\005\000\002\004\005\000\002" + + "\004\005" }); /** Access to production table. */ @Override @@ -49,77 +50,79 @@ public class IBSStdParser< Spec extends IBSParamSpec, Comp extends IBSParamComp, /** Parse-action table. */ protected static final short[][] _action_table = unpackFromStrings(new String[] { - "\000\063\000\006\025\004\026\005\001\002\000\010\005" + - "\014\022\020\027\016\001\002\000\014\005\014\021\012" + - "\022\013\027\016\030\015\001\002\000\004\002\007\001" + - "\002\000\004\002\000\001\002\000\030\004\024\005\025" + - "\006\023\007\026\010\022\013\051\014\050\015\054\016" + - "\052\017\055\020\053\001\002\000\014\002\001\011\041" + - "\012\042\013\037\014\040\001\002\000\014\005\014\021" + - "\012\022\013\027\016\030\015\001\002\000\014\005\014" + - "\021\012\022\013\027\016\030\015\001\002\000\010\005" + - "\014\022\020\027\016\001\002\000\016\002\ufff4\011\ufff4" + - "\012\ufff4\013\ufff4\014\ufff4\023\ufff4\001\002\000\040\002" + + "\000\065\000\010\025\004\026\005\027\007\001\002\000" + + "\010\005\014\022\020\030\016\001\002\000\014\005\014" + + "\021\012\022\013\030\016\031\015\001\002\000\004\002" + + "\065\001\002\000\016\002\ufffd\005\014\021\012\022\013" + + "\030\016\031\015\001\002\000\030\004\024\005\025\006" + + "\023\007\026\010\022\013\051\014\050\015\054\016\052" + + "\017\055\020\053\001\002\000\014\002\ufffe\011\041\012" + + "\043\013\040\014\037\001\002\000\014\005\014\021\012" + + "\022\013\030\016\031\015\001\002\000\014\005\014\021" + + "\012\022\013\030\016\031\015\001\002\000\010\005\014" + + "\022\020\030\016\001\002\000\016\002\ufff2\011\ufff2\012" + + "\ufff2\013\ufff2\014\ufff2\023\ufff2\001\002\000\040\002\ufff5" + + "\004\ufff5\005\ufff5\006\ufff5\007\ufff5\010\ufff5\011\ufff5\012" + + "\ufff5\013\ufff5\014\ufff5\015\ufff5\016\ufff5\017\ufff5\020\ufff5" + + "\023\ufff5\001\002\000\040\002\ufff6\004\ufff6\005\ufff6\006" + + "\ufff6\007\ufff6\010\ufff6\011\ufff6\012\ufff6\013\ufff6\014\ufff6" + + "\015\ufff6\016\ufff6\017\ufff6\020\ufff6\023\ufff6\001\002\000" + + "\010\005\014\022\020\030\016\001\002\000\016\004\024" + + "\005\025\006\023\007\026\010\022\023\027\001\002\000" + + "\010\005\014\022\020\030\016\001\002\000\010\005\014" + + "\022\020\030\016\001\002\000\010\005\014\022\020\030" + + "\016\001\002\000\010\005\014\022\020\030\016\001\002" + + "\000\010\005\014\022\020\030\016\001\002\000\040\002" + "\ufff7\004\ufff7\005\ufff7\006\ufff7\007\ufff7\010\ufff7\011\ufff7" + "\012\ufff7\013\ufff7\014\ufff7\015\ufff7\016\ufff7\017\ufff7\020" + - "\ufff7\023\ufff7\001\002\000\040\002\ufff8\004\ufff8\005\ufff8" + - "\006\ufff8\007\ufff8\010\ufff8\011\ufff8\012\ufff8\013\ufff8\014" + - "\ufff8\015\ufff8\016\ufff8\017\ufff8\020\ufff8\023\ufff8\001\002" + - "\000\010\005\014\022\020\027\016\001\002\000\016\004" + - "\024\005\025\006\023\007\026\010\022\023\027\001\002" + - "\000\010\005\014\022\020\027\016\001\002\000\010\005" + - "\014\022\020\027\016\001\002\000\010\005\014\022\020" + - "\027\016\001\002\000\010\005\014\022\020\027\016\001" + - "\002\000\010\005\014\022\020\027\016\001\002\000\040" + - "\002\ufff9\004\ufff9\005\ufff9\006\ufff9\007\ufff9\010\ufff9\011" + - "\ufff9\012\ufff9\013\ufff9\014\ufff9\015\ufff9\016\ufff9\017\ufff9" + - "\020\ufff9\023\ufff9\001\002\000\040\002\ufffb\004\ufffb\005" + - "\ufffb\006\ufffb\007\ufffb\010\ufffb\011\ufffb\012\ufffb\013\ufffb" + - "\014\ufffb\015\ufffb\016\ufffb\017\ufffb\020\ufffb\023\ufffb\001" + - "\002\000\040\002\ufffd\004\ufffd\005\ufffd\006\023\007\026" + - "\010\022\011\ufffd\012\ufffd\013\ufffd\014\ufffd\015\ufffd\016" + - "\ufffd\017\ufffd\020\ufffd\023\ufffd\001\002\000\040\002\ufffe" + - "\004\ufffe\005\ufffe\006\023\007\026\010\022\011\ufffe\012" + - "\ufffe\013\ufffe\014\ufffe\015\ufffe\016\ufffe\017\ufffe\020\ufffe" + - "\023\ufffe\001\002\000\040\002\ufffc\004\ufffc\005\ufffc\006" + - "\ufffc\007\ufffc\010\ufffc\011\ufffc\012\ufffc\013\ufffc\014\ufffc" + - "\015\ufffc\016\ufffc\017\ufffc\020\ufffc\023\ufffc\001\002\000" + - "\040\002\ufffa\004\ufffa\005\ufffa\006\ufffa\007\ufffa\010\ufffa" + - "\011\ufffa\012\ufffa\013\ufffa\014\ufffa\015\ufffa\016\ufffa\017" + - "\ufffa\020\ufffa\023\ufffa\001\002\000\032\004\024\005\025" + - "\006\023\007\026\010\022\013\051\014\050\015\054\016" + - "\052\017\055\020\053\023\027\001\002\000\014\011\041" + - "\012\042\013\037\014\040\023\043\001\002\000\014\005" + - "\014\021\012\022\013\027\016\030\015\001\002\000\014" + - "\005\014\021\012\022\013\027\016\030\015\001\002\000" + - "\014\005\014\021\012\022\013\027\016\030\015\001\002" + - "\000\014\005\014\021\012\022\013\027\016\030\015\001" + - "\002\000\016\002\ufff3\011\ufff3\012\ufff3\013\ufff3\014\ufff3" + - "\023\ufff3\001\002\000\016\002\ufff6\011\041\012\ufff6\013" + - "\037\014\040\023\ufff6\001\002\000\016\002\ufff5\011\ufff5" + - "\012\ufff5\013\037\014\040\023\ufff5\001\002\000\016\002" + - "\uffea\011\uffea\012\uffea\013\uffea\014\uffea\023\uffea\001\002" + - "\000\016\002\uffeb\011\uffeb\012\uffeb\013\uffeb\014\uffeb\023" + - "\uffeb\001\002\000\010\005\014\022\020\027\016\001\002" + - "\000\010\005\014\022\020\027\016\001\002\000\010\005" + - "\014\022\020\027\016\001\002\000\010\005\014\022\020" + - "\027\016\001\002\000\010\005\014\022\020\027\016\001" + - "\002\000\010\005\014\022\020\027\016\001\002\000\030" + - "\002\uffef\004\024\005\025\006\023\007\026\010\022\011" + - "\uffef\012\uffef\013\uffef\014\uffef\023\uffef\001\002\000\030" + - "\002\ufff1\004\024\005\025\006\023\007\026\010\022\011" + - "\ufff1\012\ufff1\013\ufff1\014\ufff1\023\ufff1\001\002\000\030" + - "\002\uffee\004\024\005\025\006\023\007\026\010\022\011" + - "\uffee\012\uffee\013\uffee\014\uffee\023\uffee\001\002\000\030" + - "\002\ufff0\004\024\005\025\006\023\007\026\010\022\011" + - "\ufff0\012\ufff0\013\ufff0\014\ufff0\023\ufff0\001\002\000\030" + - "\002\uffed\004\024\005\025\006\023\007\026\010\022\011" + - "\uffed\012\uffed\013\uffed\014\uffed\023\uffed\001\002\000\030" + - "\002\uffec\004\024\005\025\006\023\007\026\010\022\011" + - "\uffec\012\uffec\013\uffec\014\uffec\023\uffec\001\002\000\016" + - "\002\ufff2\011\ufff2\012\ufff2\013\037\014\040\023\ufff2\001" + - "\002\000\016\002\uffff\004\024\005\025\006\023\007\026" + - "\010\022\001\002" }); + "\ufff7\023\ufff7\001\002\000\040\002\ufff9\004\ufff9\005\ufff9" + + "\006\ufff9\007\ufff9\010\ufff9\011\ufff9\012\ufff9\013\ufff9\014" + + "\ufff9\015\ufff9\016\ufff9\017\ufff9\020\ufff9\023\ufff9\001\002" + + "\000\040\002\ufffb\004\ufffb\005\ufffb\006\023\007\026\010" + + "\022\011\ufffb\012\ufffb\013\ufffb\014\ufffb\015\ufffb\016\ufffb" + + "\017\ufffb\020\ufffb\023\ufffb\001\002\000\040\002\ufffc\004" + + "\ufffc\005\ufffc\006\023\007\026\010\022\011\ufffc\012\ufffc" + + "\013\ufffc\014\ufffc\015\ufffc\016\ufffc\017\ufffc\020\ufffc\023" + + "\ufffc\001\002\000\040\002\ufffa\004\ufffa\005\ufffa\006\ufffa" + + "\007\ufffa\010\ufffa\011\ufffa\012\ufffa\013\ufffa\014\ufffa\015" + + "\ufffa\016\ufffa\017\ufffa\020\ufffa\023\ufffa\001\002\000\040" + + "\002\ufff8\004\ufff8\005\ufff8\006\ufff8\007\ufff8\010\ufff8\011" + + "\ufff8\012\ufff8\013\ufff8\014\ufff8\015\ufff8\016\ufff8\017\ufff8" + + "\020\ufff8\023\ufff8\001\002\000\032\004\024\005\025\006" + + "\023\007\026\010\022\013\051\014\050\015\054\016\052" + + "\017\055\020\053\023\027\001\002\000\014\011\041\012" + + "\043\013\040\014\037\023\042\001\002\000\014\005\014" + + "\021\012\022\013\030\016\031\015\001\002\000\014\005" + + "\014\021\012\022\013\030\016\031\015\001\002\000\014" + + "\005\014\021\012\022\013\030\016\031\015\001\002\000" + + "\016\002\ufff1\011\ufff1\012\ufff1\013\ufff1\014\ufff1\023\ufff1" + + "\001\002\000\014\005\014\021\012\022\013\030\016\031" + + "\015\001\002\000\016\002\ufff4\011\041\012\ufff4\013\040" + + "\014\037\023\ufff4\001\002\000\016\002\ufff3\011\ufff3\012" + + "\ufff3\013\040\014\037\023\ufff3\001\002\000\016\002\uffe9" + + "\011\uffe9\012\uffe9\013\uffe9\014\uffe9\023\uffe9\001\002\000" + + "\016\002\uffe8\011\uffe8\012\uffe8\013\uffe8\014\uffe8\023\uffe8" + + "\001\002\000\010\005\014\022\020\030\016\001\002\000" + + "\010\005\014\022\020\030\016\001\002\000\010\005\014" + + "\022\020\030\016\001\002\000\010\005\014\022\020\030" + + "\016\001\002\000\010\005\014\022\020\030\016\001\002" + + "\000\010\005\014\022\020\030\016\001\002\000\030\002" + + "\uffed\004\024\005\025\006\023\007\026\010\022\011\uffed" + + "\012\uffed\013\uffed\014\uffed\023\uffed\001\002\000\030\002" + + "\uffef\004\024\005\025\006\023\007\026\010\022\011\uffef" + + "\012\uffef\013\uffef\014\uffef\023\uffef\001\002\000\030\002" + + "\uffec\004\024\005\025\006\023\007\026\010\022\011\uffec" + + "\012\uffec\013\uffec\014\uffec\023\uffec\001\002\000\030\002" + + "\uffee\004\024\005\025\006\023\007\026\010\022\011\uffee" + + "\012\uffee\013\uffee\014\uffee\023\uffee\001\002\000\030\002" + + "\uffeb\004\024\005\025\006\023\007\026\010\022\011\uffeb" + + "\012\uffeb\013\uffeb\014\uffeb\023\uffeb\001\002\000\030\002" + + "\uffea\004\024\005\025\006\023\007\026\010\022\011\uffea" + + "\012\uffea\013\uffea\014\uffea\023\uffea\001\002\000\016\002" + + "\ufff0\011\ufff0\012\ufff0\013\040\014\037\023\ufff0\001\002" + + "\000\004\002\000\001\002\000\014\002\001\011\041\012" + + "\043\013\040\014\037\001\002\000\016\002\uffff\004\024" + + "\005\025\006\023\007\026\010\022\001\002" }); /** Access to parse-action table. */ @Override @@ -128,27 +131,28 @@ public class IBSStdParser< Spec extends IBSParamSpec, Comp extends IBSParamComp, /** <code>reduce_goto</code> table. */ protected static final short[][] _reduce_table = unpackFromStrings(new String[] { - "\000\063\000\004\002\005\001\001\000\004\003\064\001" + - "\001\000\006\003\007\004\010\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\006\003\007\004\063\001\001\000\006\003\034\004\035" + - "\001\001\000\004\003\016\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\004\003\020\001\001" + - "\000\002\001\001\000\004\003\033\001\001\000\004\003" + - "\032\001\001\000\004\003\031\001\001\000\004\003\030" + - "\001\001\000\004\003\027\001\001\000\002\001\001\000" + + "\000\065\000\004\002\005\001\001\000\004\003\066\001" + + "\001\000\006\003\007\004\065\001\001\000\002\001\001" + + "\000\006\003\007\004\010\001\001\000\002\001\001\000" + + "\002\001\001\000\006\003\007\004\063\001\001\000\006" + + "\003\034\004\035\001\001\000\004\003\016\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\004" + + "\003\020\001\001\000\002\001\001\000\004\003\033\001" + + "\001\000\004\003\032\001\001\000\004\003\031\001\001" + + "\000\004\003\030\001\001\000\004\003\027\001\001\000" + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\006\003\007\004\046\001\001\000\006\003\007" + - "\004\045\001\001\000\006\003\007\004\044\001\001\000" + - "\006\003\007\004\043\001\001\000\002\001\001\000\002" + + "\001\000\002\001\001\000\006\003\007\004\046\001\001" + + "\000\006\003\007\004\045\001\001\000\006\003\007\004" + + "\044\001\001\000\002\001\001\000\006\003\007\004\043" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\004\003\062\001\001\000\004\003\061\001\001" + - "\000\004\003\060\001\001\000\004\003\057\001\001\000" + - "\004\003\056\001\001\000\004\003\055\001\001\000\002" + + "\001\000\002\001\001\000\004\003\062\001\001\000\004" + + "\003\061\001\001\000\004\003\060\001\001\000\004\003" + + "\057\001\001\000\004\003\056\001\001\000\004\003\055" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001" }); + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001" }); /** Access to <code>reduce_goto</code> table. */ @Override @@ -225,6 +229,13 @@ public class IBSStdParser< Spec extends IBSParamSpec, Comp extends IBSParamComp, catch (Exception e) { lexer.getExpressionClass().clear(); return null; } } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseGuard(Spec _spec, String _s){ + try { lexer.init(_spec,"guard " + _s); } + catch (java.io.IOException e) { return null; } + try { return (IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr) parse().value; } + catch (Exception e) { lexer.getExpressionClass().clear(); return null; } + } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.IExpr parseInt(Comp _comp, String _s){ try { lexer.init(_comp,"integer " + _s); } catch (java.io.IOException e) { return null; } @@ -239,6 +250,13 @@ public class IBSStdParser< Spec extends IBSParamSpec, Comp extends IBSParamComp, catch (Exception e) { lexer.getExpressionClass().clear(); return null; } } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseGuard(Comp _comp, String _s){ + try { lexer.init(_comp,"guard " + _s); } + catch (java.io.IOException e) { return null; } + try { return (IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr) parse().value; } + catch (Exception e) { lexer.getExpressionClass().clear(); return null; } + } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.IExpr parseInt(String _s){ try { lexer.init("integer " + _s); } catch (java.io.IOException e) { return null; } @@ -253,6 +271,13 @@ public class IBSStdParser< Spec extends IBSParamSpec, Comp extends IBSParamComp, catch (Exception e) { lexer.getExpressionClass().clear(); return null; } } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseGuard(String _s){ + try { lexer.init("guard " + _s); } + catch (java.io.IOException e) { return null; } + try { return (IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr) parse().value; } + catch (Exception e) { lexer.getExpressionClass().clear(); return null; } + } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.IExpr makeInt(IBSAttributeClass<Spec,Comp,State,SpecState,CompState>.Attribute _attr){ int index = lexer.getExpressionClass().make_iVar(_attr); @@ -413,7 +438,34 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 3: // iexpr ::= iexpr PLUS iexpr + case 3: // expr ::= PARSE_GUARD bexpr + { + IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.Expr RESULT =null; + int eleft = (CUP$IBSStdParser$stack.peek()).left; + int eright = (CUP$IBSStdParser$stack.peek()).right; + Integer e = CUP$IBSStdParser$stack.peek().<Integer>value(); + RESULT = lexer.getExpressionClass().getBExpr(e.intValue()); + lexer.getExpressionClass().freeBool(e.intValue()); + CUP$IBSStdParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-1), CUP$IBSStdParser$stack.peek(), RESULT); + } + return CUP$IBSStdParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 4: // expr ::= PARSE_GUARD + { + IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.Expr RESULT =null; + int index = lexer.getExpressionClass().make_bConst(true); + if(index >=0){ + RESULT = lexer.getExpressionClass().getBExpr(index); + lexer.getExpressionClass().freeBool(index); + } + else RESULT = null; + CUP$IBSStdParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$IBSStdParser$stack.peek(), CUP$IBSStdParser$stack.peek(), RESULT); + } + return CUP$IBSStdParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 5: // iexpr ::= iexpr PLUS iexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -459,7 +511,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 4: // iexpr ::= iexpr MINUS iexpr + case 6: // iexpr ::= iexpr MINUS iexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -506,7 +558,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 5: // iexpr ::= iexpr MULT iexpr + case 7: // iexpr ::= iexpr MULT iexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -551,7 +603,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 6: // iexpr ::= iexpr DIV iexpr + case 8: // iexpr ::= iexpr DIV iexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -587,7 +639,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 7: // iexpr ::= iexpr MOD iexpr + case 9: // iexpr ::= iexpr MOD iexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -620,7 +672,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 8: // iexpr ::= LPAR iexpr RPAR + case 10: // iexpr ::= LPAR iexpr RPAR { Integer RESULT =null; int eleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-1)).left; @@ -632,7 +684,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 9: // iexpr ::= MINUS iexpr + case 11: // iexpr ::= MINUS iexpr { Integer RESULT =null; int eleft = (CUP$IBSStdParser$stack.peek()).left; @@ -644,7 +696,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 10: // iexpr ::= INT + case 12: // iexpr ::= INT { Integer RESULT =null; int eleft = (CUP$IBSStdParser$stack.peek()).left; @@ -656,7 +708,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 11: // bexpr ::= bexpr OR bexpr + case 13: // bexpr ::= bexpr OR bexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -694,7 +746,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 12: // bexpr ::= bexpr AND bexpr + case 14: // bexpr ::= bexpr AND bexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -732,7 +784,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 13: // bexpr ::= BOOL + case 15: // bexpr ::= BOOL { Integer RESULT =null; int eleft = (CUP$IBSStdParser$stack.peek()).left; @@ -744,7 +796,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 14: // bexpr ::= LPAR bexpr RPAR + case 16: // bexpr ::= LPAR bexpr RPAR { Integer RESULT =null; int eleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-1)).left; @@ -756,7 +808,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 15: // bexpr ::= NOT bexpr + case 17: // bexpr ::= NOT bexpr { Integer RESULT =null; int eleft = (CUP$IBSStdParser$stack.peek()).left; @@ -781,7 +833,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 16: // bexpr ::= iexpr LT iexpr + case 18: // bexpr ::= iexpr LT iexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -805,7 +857,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 17: // bexpr ::= iexpr GT iexpr + case 19: // bexpr ::= iexpr GT iexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -829,7 +881,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 18: // bexpr ::= iexpr LEQ iexpr + case 20: // bexpr ::= iexpr LEQ iexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -853,7 +905,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 19: // bexpr ::= iexpr GEQ iexpr + case 21: // bexpr ::= iexpr GEQ iexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -877,7 +929,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 20: // bexpr ::= iexpr EQ iexpr + case 22: // bexpr ::= iexpr EQ iexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -901,7 +953,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 21: // bexpr ::= iexpr DIF iexpr + case 23: // bexpr ::= iexpr DIF iexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -925,7 +977,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 22: // bexpr ::= bexpr EQ bexpr + case 24: // bexpr ::= bexpr EQ bexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; @@ -965,7 +1017,7 @@ class CUP$IBSStdParser$actions { return CUP$IBSStdParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 23: // bexpr ::= bexpr DIF bexpr + case 25: // bexpr ::= bexpr DIF bexpr { Integer RESULT =null; int lleft = (CUP$IBSStdParser$stack.elementAt(CUP$IBSStdParser$top-2)).left; diff --git a/src/main/java/myutil/intboolsolver/IBSStdSymbols.java b/src/main/java/myutil/intboolsolver/IBSStdSymbols.java index caaf1ecc87..5ed90128b9 100644 --- a/src/main/java/myutil/intboolsolver/IBSStdSymbols.java +++ b/src/main/java/myutil/intboolsolver/IBSStdSymbols.java @@ -13,18 +13,19 @@ public class IBSStdSymbols { public static final int AND = 7; public static final int LT = 11; public static final int PLUS = 2; - public static final int INT = 21; + public static final int INT = 22; public static final int OR = 8; public static final int NOT = 15; public static final int GT = 12; public static final int PARSE_INT = 19; public static final int EOF = 0; public static final int MULT = 4; + public static final int PARSE_GUARD = 21; public static final int DIV = 5; public static final int MINUS = 3; public static final int error = 1; public static final int EQ = 9; - public static final int BOOL = 22; + public static final int BOOL = 23; public static final int PARSE_BOOL = 20; public static final int LEQ = 13; public static final int RPAR = 17; @@ -53,6 +54,7 @@ public class IBSStdSymbols { "UMINUS", "PARSE_INT", "PARSE_BOOL", + "PARSE_GUARD", "INT", "BOOL" }; diff --git a/src/main/java/myutil/intboolsolver/javacup/IBSOptParser.jcup b/src/main/java/myutil/intboolsolver/javacup/IBSOptParser.jcup index a33b409669..4fbc0733f2 100644 --- a/src/main/java/myutil/intboolsolver/javacup/IBSOptParser.jcup +++ b/src/main/java/myutil/intboolsolver/javacup/IBSOptParser.jcup @@ -78,6 +78,13 @@ parser code {: catch (Exception e) { lexer.getExpressionClass().clear(); return null; } } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseGuard(Spec _spec, String _s){ + try { lexer.init(_spec,"guard " + _s); } + catch (java.io.IOException e) { return null; } + try { return (IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr) parse().value; } + catch (Exception e) { lexer.getExpressionClass().clear(); return null; } + } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.IExpr parseInt(Comp _comp, String _s){ try { lexer.init(_comp,"integer " + _s); } catch (java.io.IOException e) { return null; } @@ -92,6 +99,13 @@ parser code {: catch (Exception e) { lexer.getExpressionClass().clear(); return null; } } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseGuard(Comp _comp, String _s){ + try { lexer.init(_comp,"guard " + _s); } + catch (java.io.IOException e) { return null; } + try { return (IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr) parse().value; } + catch (Exception e) { lexer.getExpressionClass().clear(); return null; } + } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.IExpr parseInt(String _s){ try { lexer.init("integer " + _s); } catch (java.io.IOException e) { return null; } @@ -106,6 +120,13 @@ parser code {: catch (Exception e) { lexer.getExpressionClass().clear(); return null; } } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseGuard(String _s){ + try { lexer.init("guard " + _s); } + catch (java.io.IOException e) { return null; } + try { return (IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr) parse().value; } + catch (Exception e) { lexer.getExpressionClass().clear(); return null; } + } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.IExpr makeInt(IBSAttributeClass<Spec,Comp,State,SpecState,CompState>.Attribute _attr){ int index = lexer.getExpressionClass().make_iVar(_attr); @@ -206,7 +227,7 @@ parser code {: /* Terminals (tokens returned by the scanner). */ terminal PLUS, MINUS, MULT, DIV, MOD, AND, OR, EQ, DIF, LT, GT, LEQ, GEQ; terminal NOT, LPAR, RPAR, UMINUS; -terminal PARSE_INT, PARSE_BOOL; +terminal PARSE_INT, PARSE_BOOL, PARSE_GUARD; terminal Integer INT, BOOL; @@ -231,6 +252,14 @@ expr ::= lexer.getExpressionClass().freeBool(e.intValue()); :} | PARSE_INT iexpr:e {: RESULT = lexer.getExpressionClass().getIExpr(e.intValue()); lexer.getExpressionClass().freeInt(e.intValue()); :} + | PARSE_GUARD bexpr:e {: RESULT = lexer.getExpressionClass().getBExpr(e.intValue()); + lexer.getExpressionClass().freeBool(e.intValue()); :} + | PARSE_GUARD {: int index = lexer.getExpressionClass().make_bConst(true); + if(index >=0){ + RESULT = lexer.getExpressionClass().getBExpr(index); + lexer.getExpressionClass().freeBool(index); + } + else RESULT = null; :} ; iexpr ::= diff --git a/src/main/java/myutil/intboolsolver/javacup/IBSStdLexer.jflex b/src/main/java/myutil/intboolsolver/javacup/IBSStdLexer.jflex index 34a59bab30..cb764edd50 100644 --- a/src/main/java/myutil/intboolsolver/javacup/IBSStdLexer.jflex +++ b/src/main/java/myutil/intboolsolver/javacup/IBSStdLexer.jflex @@ -105,6 +105,7 @@ Identifier = [a-zA-Z_][a-zA-Z0-9_\.]* %% <YYINITIAL> "boolean" { yybegin(INTBOOL); return new Symbol(IBSFlex#Symb.PARSE_BOOL); } +<YYINITIAL> "guard" { yybegin(INTBOOL); return new Symbol(IBSFlex#Symb.PARSE_GUARD); } <YYINITIAL> "integer" { yybegin(INTBOOL); return new Symbol(IBSFlex#Symb.PARSE_INT); } <YYINITIAL> {Space} {} diff --git a/src/main/java/myutil/intboolsolver/javacup/IBSStdParser.jcup b/src/main/java/myutil/intboolsolver/javacup/IBSStdParser.jcup index 70e0b7b041..67a7f937a1 100644 --- a/src/main/java/myutil/intboolsolver/javacup/IBSStdParser.jcup +++ b/src/main/java/myutil/intboolsolver/javacup/IBSStdParser.jcup @@ -78,6 +78,13 @@ parser code {: catch (Exception e) { lexer.getExpressionClass().clear(); return null; } } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseGuard(Spec _spec, String _s){ + try { lexer.init(_spec,"guard " + _s); } + catch (java.io.IOException e) { return null; } + try { return (IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr) parse().value; } + catch (Exception e) { lexer.getExpressionClass().clear(); return null; } + } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.IExpr parseInt(Comp _comp, String _s){ try { lexer.init(_comp,"integer " + _s); } catch (java.io.IOException e) { return null; } @@ -92,6 +99,13 @@ parser code {: catch (Exception e) { lexer.getExpressionClass().clear(); return null; } } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseGuard(Comp _comp, String _s){ + try { lexer.init(_comp,"guard " + _s); } + catch (java.io.IOException e) { return null; } + try { return (IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr) parse().value; } + catch (Exception e) { lexer.getExpressionClass().clear(); return null; } + } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.IExpr parseInt(String _s){ try { lexer.init("integer " + _s); } catch (java.io.IOException e) { return null; } @@ -106,6 +120,13 @@ parser code {: catch (Exception e) { lexer.getExpressionClass().clear(); return null; } } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr parseGuard(String _s){ + try { lexer.init("guard " + _s); } + catch (java.io.IOException e) { return null; } + try { return (IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.BExpr) parse().value; } + catch (Exception e) { lexer.getExpressionClass().clear(); return null; } + } + public IBSExpressionClass<Spec,Comp,State,SpecState,CompState>.IExpr makeInt(IBSAttributeClass<Spec,Comp,State,SpecState,CompState>.Attribute _attr){ int index = lexer.getExpressionClass().make_iVar(_attr); @@ -206,7 +227,7 @@ parser code {: /* Terminals (tokens returned by the scanner). */ terminal PLUS, MINUS, MULT, DIV, MOD, AND, OR, EQ, DIF, LT, GT, LEQ, GEQ; terminal NOT, LPAR, RPAR, UMINUS; -terminal PARSE_INT, PARSE_BOOL; +terminal PARSE_INT, PARSE_BOOL, PARSE_GUARD; terminal Integer INT, BOOL; @@ -231,6 +252,14 @@ expr ::= lexer.getExpressionClass().freeBool(e.intValue()); :} | PARSE_INT iexpr:e {: RESULT = lexer.getExpressionClass().getIExpr(e.intValue()); lexer.getExpressionClass().freeInt(e.intValue()); :} + | PARSE_GUARD bexpr:e {: RESULT = lexer.getExpressionClass().getBExpr(e.intValue()); + lexer.getExpressionClass().freeBool(e.intValue()); :} + | PARSE_GUARD {: int index = lexer.getExpressionClass().make_bConst(true); + if(index >=0){ + RESULT = lexer.getExpressionClass().getBExpr(index); + lexer.getExpressionClass().freeBool(index); + } + else RESULT = null; :} ; iexpr ::= diff --git a/src/main/java/myutil/intboolsolver/package-info.java b/src/main/java/myutil/intboolsolver/package-info.java index e1e4eadace..abf4959439 100644 --- a/src/main/java/myutil/intboolsolver/package-info.java +++ b/src/main/java/myutil/intboolsolver/package-info.java @@ -42,10 +42,10 @@ * Creation: 11/04/2023. * * <p> This package provide a way to parse and evaluate boolean/integer - * expressions. The handling of open leaves is parametrized (thus can be - * instantiated in different contexts). The package is modular in the - * sense that expression structure or parsing algorithm can be changed - * without having to modify other components. </p> + * expressions. The handling of open leaves (i.e. variables) is parametrized + * (thus it can be instantiated in different contexts). The package is + * modular in the sense that expression structure or parsing algorithm can + * be changed without having to modify other components. </p> * * <p> The solver may be instantiated by usual expressions with variables * and their usual evaluation, but it is more generally dedicated to @@ -70,49 +70,39 @@ * <p> The parser also relies on an "<b>expression class</b>" which * implements the structure of the expressions build by the parser (full * implementations are provided)</p> - * <ul><li> {@link myutil.intboolsolver.history.IBSOriginParser IBSOriginParser} - * is an implementation of {@link myutil.intboolsolver.IBSParserAPI - * IBSParserAPI} based on the original implementation of the Avatar - * solver (here for historical reasons... another implementation is - * planned). - * </li> - * <li> {@link myutil.intboolsolver.IBSStdParser IBSStdParser}, + * <p> {@link myutil.intboolsolver.IBSStdParser IBSStdParser}, * {@link myutil.intboolsolver.IBSStdLexer IBSStdLexer} and * {@link myutil.intboolsolver.IBSStdSymbols IBSStdSymbol} are classes * generated by a <a href="#javacup">java-cup/jflex parser </a> (sources - * in the "javacup" subdirectory). + * in the "javacup" subdirectory) that implement + * {@link myutil.intboolsolver.IBSParserAPI IBSParserAPI}. * The additional interface {@link myutil.intboolsolver.IBSScanner * IBSScanner} abstracts the lexer, which can then be a parameter of * the parser. - * </li></ul><p></p> + * </p> * </li> * <li> <p>{@link myutil.intboolsolver.IBSExpressionClass IBSExpressionClass} * describes the interface expected for expression handling. It contains two * kind of methods: methods for building expressions (required by parsing) * and methods for evaluating expressions (useful for final user, but also * available for parser implementations).</p> - * <ul><li> <p>{@link myutil.intboolsolver.history.IBSOriginExpressionClass - * IBSOriginExpressionClass} is a full implementation of {@link - * myutil.intboolsolver.IBSExpressionClass IBSExpressionClass} based - * on the original implementation of the Avatar solver (here for - * historical reasons)</p> - * </li> - * <li> <p>{@link myutil.intboolsolver.IBSStdExpressionClass + * <p>{@link myutil.intboolsolver.IBSStdExpressionClass * IBSStdExpressionClass} is a full implementation of {@link * myutil.intboolsolver.IBSExpressionClass IBSExpressionClass}. - * Its classical structure is easy to extend.</p> - * </li></ul> + * Its classical structure is easy to extend (for example by adding + * operators). W.r.t. {@link myutil.intboolsolver.IBSExpressionClass + * IBSExpressionClass}, it provides additional features such as tools + * to identify expression kinds and to access sub-expressions.</p> * <li> <p>{@link myutil.intboolsolver.IBSAttributeClass IBSAttributeClass} * describes the interface required from the attribute class that must be * provided for instantiation. It also provides some data shared by all * instances (some constants and a technical classes). Roughly speaking, * this class provides an interpretation for open leaves.</p> - * <ul><li><p>{@link myutil.intboolsolver.IBSStdAttributeClass - * IBSStdAttributeClass} extends {@link - * myutil.intboolsolver.IBSAttributeClass IBSAttributeClass}. It - * provides a partial implementation so that instances just have - * to provide low level methods.</p> - * </li></ul> + * <p>{@link myutil.intboolsolver.IBSStdAttributeClass + * IBSStdAttributeClass} extends {@link + * myutil.intboolsolver.IBSAttributeClass IBSAttributeClass}. It + * provides a partial implementation so that instances just have + * to provide low level methods.</p> * <li><p>{@link myutil.intboolsolver.IBSParamSpec IBSParamSpec}, * {@link myutil.intboolsolver.IBSParamComp IBSParamComp}, * {@link myutil.intboolsolver.IBSParamState IBSParamState}, @@ -176,9 +166,8 @@ * <li> <p> provide an implementation {@code AttribClass} of * {@link myutil.intboolsolver.IBSAttributeClass IBSAttributeClass} or * {@link myutil.intboolsolver.IBSStdAttributeClass - * IBSStdAttributeClass} the instances of - * for {@code Spec}, {@code Comp}, {@code SpecState}, - * {@code CompState} and {@code State}.</p> + * IBSStdAttributeClass}, and instanciate it with the chosen {@code Spec}, + * {@code Comp}, {@code SpecState}, {@code CompState} and {@code State}.</p> <PRE> known from context (package, imports): intboolsolver, Spec, Comp, SpecState, CompState, State @@ -192,8 +181,7 @@ * </li> * <li> <p>build expression class <code>ExprClass</code> for your instance, ie. * for example instantiate {@link myutil.intboolsolver.IBSStdExpressionClass - * IBSStdExpressionClass} or {@link myutil.intboolsolver.history.IBSOriginExpressionClass - * IBSOriginExpressionClass}:</p> + * IBSStdExpressionClass}:</p> <PRE> known from context (package, imports): intboolsolver, Spec, Comp, SpecState, CompState, State @@ -211,15 +199,13 @@ * IBSStdExpressionClass}.</p> * </li> * <li> <p>build the parser <code>Parser</code> for your instance, ie. - * instantiate an implementation of the generic parser (for example - * {@link myutil.intboolsolver.history.IBSOriginParser - * IBSSOriginParser}) :</p> + * instantiate an implementation of the generic parser:</p> * <PRE> * known from context (package, imports): intboolsolver, * Spec, Comp, SpecState, CompState, State * * public class Parser - * extends IBSOriginParser <Spec,Comp, SpecState, CompState, State> { + * extends IBSParserImpl <Spec,Comp, SpecState, CompState, State> { * * public Parser() { super(new AttrClass(),new ExprClass()); } * public Parser(AttrClass _a, ExprClass _e) { super(_c,_e); } @@ -264,6 +250,12 @@ * genericity). Moreover by setting the variables at the beginning of the script, * several different parsers and lexers can be produced (obviously, a lexer can only * be coupled with a parser that defines all the symbols it uses)</p> + * <p> In fact, two javacup parsers are provided (IBSStdParser.jcup and + * IBSOptParser.jcup). They both recognise the same set of usual boolean and integer + * expressions. The difference is that IBSOptParser implements constant propagation + * while parsing, which may simplify expression, while IBSStdParser does not and thus + * globally preserves original structure (provided that expression building primitives + * do)</p> * * <i>Script variables : </i> * <ul><li><code>JFLEX_FILE</code>: the lexer jflex source file -- GitLab