Class Translet.RepParser<D>

java.lang.Object
eu.bandm.tscore.base.Translet.Parser<List<D>>
eu.bandm.tscore.base.Translet.RepParser<D>
Direct Known Subclasses:
Translet.PlusParser, Translet.StarParser
Enclosing class:
Translet

public static class Translet.RepParser<D> extends Translet.Parser<List<D>>
Common superclass for Translet.StarParser and Translet.PlusParser.
  • Field Details

    • sub

      protected Translet.Parser<D> sub
      The repeated sub-parser.
    • sep

      @Opt protected @Opt Translet.Parser<?> sep
      An optional additional non-terminal parser, which must accept between the repetitions.
    • greedy

      protected boolean greedy
      Whether this constructor behaves greedy.
    • isStar

      protected boolean isStar
      Whether this constructor treats no match at all as an accept case.
  • Constructor Details

    • RepParser

      protected RepParser(Translet.Parser<D> sub, Translet.Parser<?> sep, boolean greedy, boolean isStar)
      Constructor only called by factory methods
  • Method Details

    • unparse

      public String unparse(Object key)
      Description copied from class: Translet.Parser
      Reverse the parsing process (as far as possible) and deliver a string representation which when parsed delivered the parse result.
      Specified by:
      unparse in class Translet.Parser<List<D>>
    • parseProlongation

      protected void parseProlongation(List<D> prefix, Translet.State<?> inState, Set<Translet.Alternative> alternatives, Set<Translet.State<List<D>>> allResults)
      Basic parser procedure for all four kinds of RepParsers. Parses new instances after a certain prefix has already been parsed. Adds a result for the incoming prefix if no prolongation is possible or (under the way) if parser is not greedy. Epsilon-productions may appear at most once.
      Parameters:
      prefix - already parsed instances of the content
      alternatives - output parameter for accepted partial prefices
      allResults - output accu for all result states
    • parseOneState

      public Set<Translet.State<List<D>>> 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.. Here it calls parseProlongation(List,Translet.State,Set,Set)
      Specified by:
      parseOneState in class Translet.Parser<List<D>>
    • name

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