Module io.github.darvil.lanat
Package io.github.darvil.lanat.parsing
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
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final @NotNull CommandThe command that is being parsed.protected booleanWhether the parsing/tokenizing has finished.protected intThe offset position of the input values from the previous parser. -
Constructor Summary
ConstructorsConstructorDescriptionParsingStateBase(@NotNull Command command) Instantiates a new parsing state. -
Method Summary
Modifier and TypeMethodDescriptionprotected @Nullable Argument<?,?> getMatchingArgument(char argName) Returns the argument found by the single character name specified.protected @Nullable Argument<?,?> getMatchingArgument(@NotNull String argName) Returns the argument found by the name specified.intReturns the offset position of the input values from the previous parser.booleanReturnstrueif the parsing of the input has finished,falseotherwise.voidResets the object to its default/initial state.protected booleanrunForMatchingArgument(char argName, @NotNull Consumer<@NotNull Argument<?, ?>> f) Executes a callback for the argument found by the single character name specified.protected booleanrunForMatchingArgument(@NotNull String argName, @NotNull Consumer<@NotNull Argument<?, ?>> f) Executes a callback for the argument found by the name specified.Methods inherited from class io.github.darvil.lanat.utils.errors.ErrorContainerImpl
addError, getErrorDisplayThreshold, getErrorExitThreshold, getErrorsUnderDisplayThreshold, getErrorsUnderExitThreshold, getErrorsUnderThreshold, hasDisplayErrors, hasExitErrors, setErrorDisplayThreshold, setErrorExitThreshold
-
Field Details
-
command
The command that is being parsed. -
hasFinished
protected boolean hasFinishedWhether the parsing/tokenizing has finished. -
nestingOffset
protected int nestingOffsetThe offset position of the input values from the previous parser.
-
-
Constructor Details
-
ParsingStateBase
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:
trueif 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:
trueif an argument was found
-
getMatchingArgument
Returns the argument found by the single character name specified.- Parameters:
argName- the name of the argument to find- Returns:
- the argument found, or
nullif no argument was found
-
getMatchingArgument
Returns the argument found by the name specified.- Parameters:
argName- the name of the argument to find- Returns:
- the argument found, or
nullif no argument was found
-
hasFinished
public boolean hasFinished()Returnstrueif the parsing of the input has finished,falseotherwise.- Returns:
trueif the parsing of the input has finished,falseotherwise.
-
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:ResettableResets the object to its default/initial state.- Specified by:
resetStatein interfaceResettable- Overrides:
resetStatein classErrorContainerImpl<T extends ErrorLevelProvider>
-