Class Translet.Parser<R>

java.lang.Object
eu.bandm.tscore.base.Translet.Parser<R>
Direct Known Subclasses:
Translet._CAT, Translet._CONST, Translet._REGEX, Translet.DisjunctionParser, Translet.FramedParser, Translet.HeadParser, Translet.OptionParser, Translet.ProductParser, Translet.Recursive, Translet.RepParser, Translet.StorageWrapper, TransletLib._TEST
Enclosing class:
Translet

public abstract static class Translet.Parser<R> extends Object
Base class for all parser classes, contains most of the working methods.
  • Constructor Details

    • Parser

      public Parser()
  • Method Details

    • isTerminal

      public boolean isTerminal()
      Whether the parser does directly consume character data. (is true for Translet._CONST, Translet._CAT and Translet._REGEX).
      Returns:
      false
    • unparse

      public abstract String unparse(Object key)
      Reverse the parsing process (as far as possible) and deliver a string representation which when parsed delivered the parse result.
    • stripOpt

      public Translet.Parser<R> stripOpt()
      Returns the first nested parser which is NOT an Translet.OptionParser.
    • name

      public Format name(boolean full)
      Returns a user-readable text representation. This is in most cases, but not always, source text to construct the parser.
      Parameters:
      full - whether storing operators do appear in the rendering.
    • name

      public abstract Format name(boolean full, Map<Translet.Recursive,String> names)
      Returns a user-readable text representation. This is in most cases, but not always, source text to construct the parser.
      Parameters:
      full - whether storage constructs do appear in the rendering.
      names - a map for managing the renderings of recursive calls
    • toString

      public String toString(boolean includeStoring)
      Returns a user-readable text representation. This corresponds to the source text to construct the parser.
      Parameters:
      includeStoring - whether storage constructs do appear in the rendering.
    • toString

      public String toString()
      Returns a user-readable text representation. It calls toString(boolean) with the argument set to true.
      Overrides:
      toString in class Object
    • executeStoring

      public void executeStoring(Translet.State<R> s, Event e, eu.bandm.tools.location.Location<eu.bandm.tools.util.xml.XMLDocumentIdentifier> loc, MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg)
      Execute the store operation represented by "this" parser.
    • mparse

      public final Set<Translet.State<R>> mparse(Set<? extends Translet.State<?>> inStates, Set<Translet.Alternative> alternatives)
      "*M*ultiple Parse" means to apply the parser to a set of incoming Translet.States, which represent the parsing situations reached so far. Executes parseOneState(Translet.State,Set) for each incoming state. Finally delivers one single set, the set union of all States resulting from these calls.
      "alternatives" is an IN AND OUT parameter, and alternatives are collected in parallel with the parsing:
      1. The parser as a whole is simply appended to all incoming alternatives, not considering its internal structure.
      2. In case there is no single result nor alternative returned in a particular parsing situation, this and the parser are turned into a new Alternative and added to this set.
      3. All Alternatives returned by sub-parser calls represent partly parsed sequences (i.e. matching of prefices) and are added to the returned set of alternatives.
    • parseEpsilon

      @Opt protected @Opt Translet.State<?> parseEpsilon(Translet.State<?> inState)
      Find one parse result which consumes no characters. (Alternatives are not accumulated)
      Parameters:
      inState - the start state of parsing
      Returns:
      a state after successful parsing zero charachters, if any
    • parseOneState

      protected abstract Set<Translet.State<R>> parseOneState(Translet.State<?> inState, Set<Translet.Alternative> alternatives)
      Calculate a set of possible successor states by applying this parser to the incoming state and append all altenatives found underways to the parameter "alternatives". This method is specific to and overridden by the subclasses of Parser.