All Implemented Interfaces:
ErrorContainer<Error.ParseError>, Resettable

public final class Parser extends ParsingStateBase<Error.ParseError>
Parses the tokens that have been tokenized from the CLI input.

This class is responsible for parsing the tokens and delegating the parsing of the values to the ArgumentTypes of the arguments that are being parsed.

When finished parsing, this class will contain a map of the arguments to their parsed values. This map can be accessed by calling getParsedArgsMap().
  • Constructor Details

    • Parser

      public Parser(@NotNull @NotNull Command command)
  • Method Details

    • getCurrentTokenIndex

      public int getCurrentTokenIndex()
      Returns the index of the current token that is being parsed.
    • getForwardValue

      @Nullable public @Nullable String getForwardValue()
      Returns the forward value if one was found.
      Returns:
      The forward value, or null if there is no forward value.
    • setTokens

      public void setTokens(@NotNull @NotNull List<@NotNull Token> tokens)
      Sets the tokens that this parser will parse.
    • parseTokens

      public void parseTokens(@Nullable @Nullable Parser previousParser)
      Parses the tokens that have been set. Delegates parsing of argument values to the ArgumentType of the argument that is being parsed.
    • getParsedArgsMap

      @NotNull public @NotNull HashMap<@NotNull Argument<?,?>,@Nullable Object> getParsedArgsMap()
      Returns a hashmap of Arguments and their corresponding parsed values. This function invokes the Argument.finishParsing() method on each argument the first time it is called. After that, it will return the same hashmap.