Class TokenParser<V>

java.lang.Object
io.jenetics.ext.internal.parser.Parser<Token<V>>
io.jenetics.ext.internal.parser.TokenParser<V>
Type Parameters:
V - the token value type

public class TokenParser<V> extends Parser<Token<V>>
Parser implementation for parsing explicit Token sequences.
Since:
7.1
Version:
7.1
  • Constructor Details

    • TokenParser

      public TokenParser(Tokenizer<Token<V>> tokenizer, int k)
      Create a new parser object with the given tokenizer and lookahead count k.
      Parameters:
      tokenizer - the token source this parser uses
      k - the lookahead count
  • Method Details

    • LA

      public int LA(int index)
      Return the token type code for the given lookahead index.
      Parameters:
      index - lookahead index
      Returns:
      the token type code for the given lookahead index
    • match

      public Token<V> match(Token.Type type)
      Try to match and consume the next token of the given type. If the current token is not from the given type, a ParsingException is thrown.
      Parameters:
      type - the token type to match
      Returns:
      the matched token
      Throws:
      NullPointerException - if the given token type is null
      ParsingException - if the current token doesn't match the desired token type