Class ExecutableExpression<T>

All Implemented Interfaces:
Expression<T>, SyntaxElement
Direct Known Subclasses:
ExecExprListOperators, ExecExprReplace

public abstract class ExecutableExpression<T> extends Effect implements Expression<T>
A base class for syntax that can be used as Expression or Effect. An example of this could be:
    replace all {x} in {y} with {z}
    print "%replace all {x} in {y} with {z}%
Both syntaxes are valid and this enables productive and better coding practices.
The behaviour is different based on how the syntax is used:
  • If the syntax is used like an expression, the result should not change any expressions (like variables) whatsoever.
  • Otherwise, if the syntax is used like an effect, the result should be used to perform actions according to the syntax.
To look at an example, like ExecExprListOperators:
    set {x} to pop {y::*} should set the variable x to the last element of the list y.
    pop {y::*} should remove the last element of the list y, because it is used as an effect now.
  • Constructor Details

    • ExecutableExpression

      public ExecutableExpression()
  • Method Details

    • execute

      protected void execute(TriggerContext ctx)
      Specified by:
      execute in class Effect
    • getValues

      public T[] getValues(TriggerContext ctx)
      Description copied from interface: Expression
      Retrieves all values of this Expression, accounting for possible modifiers. This means that if this is an or-list, it will choose a random value to return.
      Specified by:
      getValues in interface Expression<T>
      Parameters:
      ctx - the event
      Returns:
      an array of the values
      See Also:
    • getValues

      public abstract T[] getValues(TriggerContext ctx, boolean isEffect)
      Retrieves all values of this expression, if used as one. Otherwise, if used as an effect, performs side-effects with certain behaviour. Note that when this is not the case, this syntax, by convention, should not have any side-effects.
      Parameters:
      ctx - the context
      isEffect - whether this syntax is used as effect or as an expression
      Returns:
      an array of the values