Class Lexer.RuleMatchValueGenerator<U>

  • Type Parameters:
    U - The type of token identifier to use.
    Enclosing class:
    Lexer<T>

    class Lexer.RuleMatchValueGenerator<U>
    extends Object
    Generates token identifiers for a rule from either a constant value, or a generator function processing a MatchResult.
    • Constructor Detail

      • RuleMatchValueGenerator

        public RuleMatchValueGenerator​(U id)
        Constructs a new RuleMatchValueGenerator with a token identifier.
        Parameters:
        id - The token identifier to use.
      • RuleMatchValueGenerator

        public RuleMatchValueGenerator​(Function<MatchResult,​U> generator)
        Constructs a new RuleMatchValueGenerator with a function that generates token identifiers.
        Parameters:
        generator - The generator function to use.
    • Method Detail

      • getId

        public U getId​(MatchResult m)
        Returns the token identifier.
        Parameters:
        m - The regex match result to apply the generator to.
        Returns:
        The token identifier, or the result of the function against the supplied MatchResult if there is no constant value.