Class Variable

java.lang.Object
org.oristool.lello.ast.Expression
org.oristool.lello.ast.Variable

public class Variable extends Expression
Represents an expression consisting of a variable reference.
  • Constructor Details

    • Variable

      public Variable(String name)
      Initializes a new variable reference expression.
      Parameters:
      name - The name of the variable being referenced.
  • Method Details

    • getName

      public String getName()
      Retrieves the name of the variable being referenced.
      Returns:
      The name of the variable being referenced.
    • eval

      public Value eval(Bindings bindings)
      Description copied from class: Expression
      Evaluates this expression using the specified variable bindings. Calling this method does not alter this expression.

      It is important to note that this method will not attempt any kind of simplification on the expression, which means that all the variables appearing in it must be either bound or correspond to Java static fields defined somewhere; if this is not the case an exception will be thrown.

      Specified by:
      eval in class Expression
      Parameters:
      bindings - Variable bindings.
      Returns:
      The value of the expression.
    • simplify

      public Expression simplify(Bindings bindings, SymbolicVisitor visitor)
      Description copied from class: Expression
      Tries to simplify this expression. Calling this method does not alter this expression.

      This method will not throw an exception if some variables appearing in the expression are not bound. However it may still be able to cancel a variable, if an appropriate rule is found.

      Specified by:
      simplify in class Expression
      Parameters:
      bindings - Variable bindings.
      visitor - The visitor implementing the simplification rules.
      Returns:
      A simplified expression if an appropriate rule was found, the same expression otherwise.
    • isZero

      public Truth isZero()
      Description copied from class: Expression
      Checks whether this expression is equal to 0 (with respect to the EPSILON tolerance).

      To decrease the probability that this method will return DONTKNOW, simplify or eval should be preventively called on this expression.

      Specified by:
      isZero in class Expression
      Returns:
      YES if this expression is equal to 0, NO if it is not, DONTKNOW if it is not known.
    • isOne

      public Truth isOne()
      Description copied from class: Expression
      Checks whether this expression is equal to 1 (with respect to the EPSILON tolerance).

      To decrease the probability that this method will return DONTKNOW, simplify or eval should be preventively called on this expression.

      Specified by:
      isOne in class Expression
      Returns:
      YES if this expression is equal to 1, NO if it is not, DONTKNOW if it is not known.
    • variables

      public Set<String> variables()
      Description copied from class: Expression
      Retrieves the names of all the variables appearing in this expression.
      Specified by:
      variables in class Expression
      Returns:
      set of variables
    • copy

      public Variable copy()
      Creates a copy of this object.
      Specified by:
      copy in class Expression
      Returns:
      a copy
    • format

      public String format(FormatVisitor visitor)
      Description copied from class: Expression
      Formats this expression.
      Overrides:
      format in class Expression
      Parameters:
      visitor - The visitor implementing the formatting rules.
      Returns:
      The formatted string.
    • toString

      public String toString()
      Overrides:
      toString in class Expression