Class MatchContext
java.lang.Object
io.github.syst3ms.skriptparser.parsing.MatchContext
An object that provides contextual information during syntax matching.
-
Constructor Summary
ConstructorsConstructorDescriptionMatchContext(PatternElement e, ParserState parserState, SkriptLogger logger) MatchContext(PatternElement e, ParserState parserState, SkriptLogger logger, @Nullable MatchContext source) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExpression(Expression<?> expression) Adds a new successfully parsed expression to the list.voidAdds the just matched parse marks to the list of all parse marks matched so farvoidaddRegexMatch(MatchResult match) Adds a new successful regex match to the list.voidIndicates that the next element inside the original pattern element (which must be aCompoundElement) is now being matched.Creates a new MatchContext based on the givenPatternElementgetMarks()List<Expression<?>> intWhen the original element must be updated (inside of anOptionalGroupor aChoiceGroup), the source tracks what the original MatchContext was.voidmerge(MatchContext branch) Merges a branched MatchContext back into the current one
-
Constructor Details
-
MatchContext
-
MatchContext
public MatchContext(PatternElement e, ParserState parserState, SkriptLogger logger, @Nullable @Nullable MatchContext source)
-
-
Method Details
-
getOriginalElement
- Returns:
- the
PatternElementthat is currently being matched
-
getOriginalPattern
- Returns:
- the string version of
getOriginalElement()
-
getPatternIndex
public int getPatternIndex()- Returns:
- an index indicating where the matching is currently at inside of the original
PatternElement(almost always when it is aCompoundElement).
-
advanceInPattern
public void advanceInPattern()Indicates that the next element inside the original pattern element (which must be aCompoundElement) is now being matched. -
getParsedExpressions
- Returns:
- a list of all successfully parsed expressions so far.
-
addExpression
Adds a new successfully parsed expression to the list.- Parameters:
expression- a parsed expression
-
addRegexMatch
Adds a new successful regex match to the list.- Parameters:
match- a regex match
-
getMarks
-
addMark
Adds the just matched parse marks to the list of all parse marks matched so far- Parameters:
mark- the just matched parse mark
-
getSource
When the original element must be updated (inside of anOptionalGroupor aChoiceGroup), the source tracks what the original MatchContext was. This is non-null only afterbranch(PatternElement)is called.- Returns:
- the source of this MatchContext
-
branch
Creates a new MatchContext based on the givenPatternElement- Parameters:
e- the new original pattern element- Returns:
- the branched MatchContext
-
merge
Merges a branched MatchContext back into the current one- Parameters:
branch- the branched MatchContext
-
toParseResult
- Returns:
- a
ParseContextbased on thisMatchContext
-
getParserState
-
getLogger
-