Class Translet.OptionParser<D>

java.lang.Object
eu.bandm.tscore.base.Translet.Parser<D>
eu.bandm.tscore.base.Translet.OptionParser<D>
Enclosing class:
Translet

public static class Translet.OptionParser<D> extends Translet.Parser<D>
Option parser, in greedy and non-deterministic variant, with or without default value.
  • Field Details

    • sub

      protected Translet.Parser<D> sub
      The sub-parser to parse or ski.
    • deflt

      @Opt protected D deflt
      Default value, returned when sub-parser did not match.
    • greedy

      protected boolean greedy
      Whether parser behaves greedily or non-deterministically. In the latter case it returns two results when the sub-parser matches: One with and one without this match.
  • Constructor Details

    • OptionParser

      public OptionParser(Translet.Parser<D> sub, @Opt D deflt, boolean greedy)
      Constructor called by the factory methods.
  • Method Details

    • stripOpt

      public Translet.Parser<D> stripOpt()
      Description copied from class: Translet.Parser
      Returns the first nested parser which is NOT an Translet.OptionParser.
      Overrides:
      stripOpt in class Translet.Parser<D>
    • 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<D>
    • parseOneState

      public Set<Translet.State<D>> parseOneState(Translet.State<?> inState, Set<Translet.Alternative> alternatives)
      Description copied from class: Translet.Parser
      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.
      Specified by:
      parseOneState in class Translet.Parser<D>
    • name

      public Format name(boolean full, Map<Translet.Recursive,String> names)
      Returns a user-readable text representation. for this class it is not the reverse of a constructor call, but a symbolic representation "[content]?" for the non-greedy and . "[content]?_" for the greedy variant. If sub-parser is CONST("") with no default and full==false, then dismiss completely.
      Specified by:
      name in class Translet.Parser<D>
      Parameters:
      full - whether storing operators do appear in the rendering.
      names - map to handle recursive loops in the parser structure.