Class Choice<R,M,O>

java.lang.Object
eu.bandm.tools.ramus.runtime2.Action<R,M,O>
eu.bandm.tools.ramus.runtime2.Choice<R,M,O>

public final class Choice<R,M,O> extends Action<R,M,O>
Choice node class of the parsing search-tree monad.
  • Constructor Details

  • Method Details

    • either

      public static <R, M, O> Choice<R,M,O> either(Action<R,M,O> first, Action<R,M,O> second)
    • getAlts

      public List<Action<? extends R,M,O>> getAlts()
    • getLeafCount

      protected int getLeafCount()
      Specified by:
      getLeafCount in class Action<R,M,O>
    • bind

      public <S> Action<S,M,O> bind(Action.Continuation<? super R,S,M,O> cont)
      Description copied from class: Action
      Applies a monadic continuation to all leaves of this search tree (transition operation).
      Specified by:
      bind in class Action<R,M,O>
      Type Parameters:
      S - the output parsing result type of the continuation
      Parameters:
      cont - the continuation to apply
      Returns:
      an updated search tree
    • prune

      public <Q> Action<? extends R,M,Q> prune()
      Description copied from class: Action
      Simplifies this search tree by removing redundant choice nodes and all obstructions (transition operation).
      Specified by:
      prune in class Action<R,M,O>
      Type Parameters:
      Q - the new type of obstructions
      Returns:
      a simplified search tree without nested or unary choice nodes
    • pruneTo

      protected <Q> boolean pruneTo(List<? super Action<? extends R,M,Q>> alts)
      Description copied from class: Action
      Adds a pruned variant of this search subtree to a list of choice alternatives.
      Overrides:
      pruneTo in class Action<R,M,O>
      Type Parameters:
      Q - the new type of obstructions
      Parameters:
      alts - the list to add to
      Returns:
      true iff this subtree has been simplified by recursive pruning
    • isEmpty

      public boolean isEmpty()
      Description copied from class: Action
      Checks whether this search tree is empty.
      Specified by:
      isEmpty in class Action<R,M,O>
      Returns:
      true iff this tree has no leaves
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • host

      public void host(Action.Visitor<? super R,M,O> v)
      Description copied from class: Action
      Performs a double dispatch to the appropriate method of a visitor.
      Specified by:
      host in class Action<R,M,O>
      Parameters:
      v - the visitor