Package org.jparsec

Class Lexicon

java.lang.Object
org.jparsec.Lexicon
Direct Known Subclasses:
Terminals

class Lexicon extends Object
A Lexicon is a group of lexical words that can be tokenized by a single tokenizer.
  • Field Details

    • words

      final Function<String,Object> words
      Maps lexical word name to token value.
    • tokenizer

      final Parser<?> tokenizer
      The scanner that recognizes any of the lexical word.
  • Constructor Details

  • Method Details

    • tokenizer

      public Parser<?> tokenizer()
      Returns the tokenizer that tokenizes all terminals (operators, keywords, identifiers etc.) managed in this instance.
    • phrase

      public Parser<?> phrase(String... tokenNames)
      A Parser that recognizes a sequence of tokens identified by tokenNames, as an atomic step.
    • token

      public Parser<Token> token(String... tokenNames)
      A Parser that recognizes a token identified by any of tokenNames.
    • token

      public Parser<Token> token(String tokenName)
      A Parser that recognizes the token identified by tokenName.
    • word

      Object word(String name)
      Gets the token value identified by the token text. This text is the operator or the keyword.
      Parameters:
      name - the token text.
      Returns:
      the token object.
      Throws:
      IllegalArgumentException - if the token object does not exist.
    • union

      Lexicon union(Lexicon that)
      Returns a Lexicon instance that's a union of this and that.
    • fallback

      static <F, T> Function<F,T> fallback(Function<F,T> function, Function<? super F,? extends T> defaultFunction)
      Returns a Function that delegates to function and falls back to defaultFunction for null return values.