com.evelopers.unimod.analysis
Class ASTTermSimplifier

java.lang.Object
  extended bycom.evelopers.unimod.analysis.TermSimplifier
      extended bycom.evelopers.unimod.analysis.ASTTermSimplifier

class ASTTermSimplifier
extends TermSimplifier


Nested Class Summary
protected  class TermSimplifier.BooleanLiteral
           
protected  class TermSimplifier.IntervalLiteral
           
 
Field Summary
(package private)  antlr.ASTFactory astFactory
           
 
Constructor Summary
ASTTermSimplifier(antlr.collections.AST inputTerm, antlr.ASTFactory astFactory)
           
ASTTermSimplifier(antlr.ASTFactory astFactory)
           
ASTTermSimplifier(TermSimplifier that, antlr.ASTFactory astFactory)
           
 
Method Summary
protected  void addASTIntervalChildren(Range.Interval interval, IdentNode templateIdentNode, antlr.collections.AST term)
           
protected  void addASTRangeChildren(Range range, IdentNode templateIdentNode, antlr.collections.AST term)
           
protected  void addBooleanChildren(antlr.collections.AST term)
           
protected  void addIntervalChildren(antlr.collections.AST term)
           
 java.util.Iterator booleanVariablesIterator()
           
protected  void checkIdenticalFalse(boolean identicalFalse)
           
protected  antlr.collections.AST createEQ_AST(IdentNode templateIdentNode, int rightConst)
           
protected  IdentNode createIdentNode(Action action)
           
protected  antlr.collections.AST createLE_AST(IdentNode templateIdentNode, int rightConst)
           
protected  antlr.collections.AST createLE_AST(int leftConst, IdentNode templateIdentNode)
           
protected  antlr.collections.AST createNEQ_AST(IdentNode templateIdentNode, int rightConst)
           
 boolean dependsOn(Action action)
           
 Range getRange(Action var)
          Gets the array of intervals for variable action.
 antlr.collections.AST getSimplifiedTerm()
           
 java.util.Iterator intervalVariablesIterator()
           
 boolean isIdenticalFalse()
           
 boolean isIdenticalTrue()
           
 boolean isNegated(Action var)
          Checks if variable action is in the term with negation
 boolean put(Action var, boolean isNegated)
          Puts variable action or it's nigation
 boolean put(Action var, int relation, int value)
          Intersects interval of action with it's current interval.
protected  void put(antlr.collections.AST literal)
           
 boolean put(int booleanConst)
          Tests if booleanConst is true or false.
 boolean put(int value, int relation, Action var)
          Reverse version of TermSimplifier.put(Action, boolean)
 boolean put(int leftConst, int relation, int rightConst)
          Tests relation between two consts.
 void setTerm(antlr.collections.AST inputTerm)
           
 java.lang.String toString()
           
 java.util.Iterator variablesIterator()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

astFactory

antlr.ASTFactory astFactory
Constructor Detail

ASTTermSimplifier

public ASTTermSimplifier(TermSimplifier that,
                         antlr.ASTFactory astFactory)

ASTTermSimplifier

public ASTTermSimplifier(antlr.ASTFactory astFactory)

ASTTermSimplifier

public ASTTermSimplifier(antlr.collections.AST inputTerm,
                         antlr.ASTFactory astFactory)
                  throws InterpreterException,
                         antlr.RecognitionException
Method Detail

setTerm

public void setTerm(antlr.collections.AST inputTerm)
             throws InterpreterException,
                    antlr.RecognitionException
Throws:
InterpreterException
antlr.RecognitionException

getSimplifiedTerm

public antlr.collections.AST getSimplifiedTerm()

put

protected void put(antlr.collections.AST literal)
            throws antlr.RecognitionException,
                   InterpreterException
Throws:
antlr.RecognitionException
InterpreterException

addIntervalChildren

protected void addIntervalChildren(antlr.collections.AST term)

addBooleanChildren

protected void addBooleanChildren(antlr.collections.AST term)

createIdentNode

protected IdentNode createIdentNode(Action action)

addASTRangeChildren

protected void addASTRangeChildren(Range range,
                                   IdentNode templateIdentNode,
                                   antlr.collections.AST term)

addASTIntervalChildren

protected void addASTIntervalChildren(Range.Interval interval,
                                      IdentNode templateIdentNode,
                                      antlr.collections.AST term)

createLE_AST

protected antlr.collections.AST createLE_AST(int leftConst,
                                             IdentNode templateIdentNode)

createLE_AST

protected antlr.collections.AST createLE_AST(IdentNode templateIdentNode,
                                             int rightConst)

createEQ_AST

protected antlr.collections.AST createEQ_AST(IdentNode templateIdentNode,
                                             int rightConst)

createNEQ_AST

protected antlr.collections.AST createNEQ_AST(IdentNode templateIdentNode,
                                              int rightConst)

put

public boolean put(Action var,
                   boolean isNegated)
            throws InterpreterException
Puts variable action or it's nigation

Parameters:
var - variable to put
isNegated - if it is true then negation of action will be putted
Returns:
true if this term is identical false
Throws:
InterpreterException

put

public boolean put(Action var,
                   int relation,
                   int value)
            throws InterpreterException
Intersects interval of action with it's current interval. By default an interval of each variable is [Interval.MIN, Interval.MAX].

Parameters:
var - name of interval variable
relation - type of relation of action with value. Should be one of:
  • ExprTokenTypes.GT
  • ExprTokenTypes.LT
  • ExprTokenTypes.GE
  • ExprTokenTypes.LE
  • ExprTokenTypes.EQUAL
  • ExprTokenTypes.NEQUAL
value - limit of interval for action
Returns:
true if this term is identical false
Throws:
InterpreterException

put

public boolean put(int value,
                   int relation,
                   Action var)
            throws InterpreterException
Reverse version of TermSimplifier.put(Action, boolean)

Throws:
InterpreterException

put

public boolean put(int booleanConst)
Tests if booleanConst is true or false. If it is true it is skipped. If it is false then whole term should be false.

Parameters:
booleanConst - boolean constant to test
Returns:
true if this term is identical false

put

public boolean put(int leftConst,
                   int relation,
                   int rightConst)
            throws InterpreterException
Tests relation between two consts. If it is identical true it is skipped. If it is identical false

Parameters:
leftConst - constant on the left side of the relation
relation - relation to test
rightConst - constant on the right side of the relation
Returns:
true if this term is identical false
Throws:
InterpreterException

booleanVariablesIterator

public java.util.Iterator booleanVariablesIterator()
Returns:
Boolean variables list iterator
See Also:
TermSimplifier.isNegated(com.evelopers.unimod.core.stateworks.Action)

intervalVariablesIterator

public java.util.Iterator intervalVariablesIterator()
Returns:
Interval variables list iterator
See Also:
TermSimplifier.getRange(com.evelopers.unimod.core.stateworks.Action action)

variablesIterator

public java.util.Iterator variablesIterator()
Returns:
Any variables list iterator
See Also:
TermSimplifier.getRange(com.evelopers.unimod.core.stateworks.Action action)

dependsOn

public boolean dependsOn(Action action)

isIdenticalFalse

public boolean isIdenticalFalse()

isIdenticalTrue

public boolean isIdenticalTrue()

isNegated

public boolean isNegated(Action var)
                  throws java.lang.IndexOutOfBoundsException,
                         InterpreterException
Checks if variable action is in the term with negation

Returns:
true if variable action is in the term with negation
Throws:
java.lang.IndexOutOfBoundsException - if action is not in the term
InterpreterException - if action is not boolean variable
See Also:
TermSimplifier.booleanVariablesIterator()

getRange

public Range getRange(Action var)
               throws java.lang.IndexOutOfBoundsException,
                      InterpreterException
Gets the array of intervals for variable action. This interval represent range for variable var.

Returns:
An array of intervals
Throws:
java.lang.IndexOutOfBoundsException - if there is no variable action in this term
InterpreterException - if action is not interval variable
See Also:
TermSimplifier.intervalVariablesIterator()

toString

public java.lang.String toString()

checkIdenticalFalse

protected void checkIdenticalFalse(boolean identicalFalse)