Class ParsingStateBase<T extends ErrorLevelProvider>

java.lang.Object
io.github.darvil.lanat.utils.errors.ErrorContainerImpl<T>
io.github.darvil.lanat.parsing.ParsingStateBase<T>
Type Parameters:
T - The type of the errors to store.
All Implemented Interfaces:
ErrorContainer<T>, Resettable
Direct Known Subclasses:
Parser, Tokenizer

public abstract sealed class ParsingStateBase<T extends ErrorLevelProvider> extends ErrorContainerImpl<T> permits Tokenizer, Parser
Base class for parsing states. Provides a context for parsing and tokenizing, and some utility methods that are shared by both.
  • Field Details

    • command

      @NotNull protected final @NotNull Command command
      The command that is being parsed.
    • hasFinished

      protected boolean hasFinished
      Whether the parsing/tokenizing has finished.
    • nestingOffset

      protected int nestingOffset
      The offset position of the input values from the previous parser.
  • Constructor Details

    • ParsingStateBase

      public ParsingStateBase(@NotNull @NotNull Command command)
      Instantiates a new parsing state.
      Parameters:
      command - the command that is being parsed
  • Method Details

    • runForMatchingArgument

      protected boolean runForMatchingArgument(@NotNull @NotNull String argName, @NotNull @NotNull Consumer<@NotNull Argument<?,?>> f)
      Executes a callback for the argument found by the name specified.
      Returns:
      true if an argument was found
    • runForMatchingArgument

      protected boolean runForMatchingArgument(char argName, @NotNull @NotNull Consumer<@NotNull Argument<?,?>> f)
      Executes a callback for the argument found by the single character name specified.
      Returns:
      true if an argument was found
    • getMatchingArgument

      @Nullable protected @Nullable Argument<?,?> getMatchingArgument(char argName)
      Returns the argument found by the single character name specified.
      Parameters:
      argName - the name of the argument to find
      Returns:
      the argument found, or null if no argument was found
    • getMatchingArgument

      @Nullable protected @Nullable Argument<?,?> getMatchingArgument(@NotNull @NotNull String argName)
      Returns the argument found by the name specified.
      Parameters:
      argName - the name of the argument to find
      Returns:
      the argument found, or null if no argument was found
    • hasFinished

      public boolean hasFinished()
      Returns true if the parsing of the input has finished, false otherwise.
      Returns:
      true if the parsing of the input has finished, false otherwise.
    • getNestingOffset

      public int getNestingOffset()
      Returns the offset position of the input values from the previous parser.
      Returns:
      the offset position of the input values from the previous parser
    • resetState

      public void resetState()
      Description copied from interface: Resettable
      Resets the object to its default/initial state.
      Specified by:
      resetState in interface Resettable
      Overrides:
      resetState in class ErrorContainerImpl<T extends ErrorLevelProvider>