Class MatchContext

java.lang.Object
io.github.syst3ms.skriptparser.parsing.MatchContext

public class MatchContext extends Object
An object that provides contextual information during syntax matching.
  • Constructor Details

  • Method Details

    • getOriginalElement

      public PatternElement getOriginalElement()
      Returns:
      the PatternElement that is currently being matched
    • getOriginalPattern

      public String 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 a CompoundElement).
    • advanceInPattern

      public void advanceInPattern()
      Indicates that the next element inside the original pattern element (which must be a CompoundElement) is now being matched.
    • getParsedExpressions

      public List<Expression<?>> getParsedExpressions()
      Returns:
      a list of all successfully parsed expressions so far.
    • addExpression

      public void addExpression(Expression<?> expression)
      Adds a new successfully parsed expression to the list.
      Parameters:
      expression - a parsed expression
    • addRegexMatch

      public void addRegexMatch(MatchResult match)
      Adds a new successful regex match to the list.
      Parameters:
      match - a regex match
    • getMarks

      public List<String> getMarks()
      Returns:
      the parse marks so far
    • addMark

      public void addMark(String mark)
      Adds the just matched parse marks to the list of all parse marks matched so far
      Parameters:
      mark - the just matched parse mark
    • getSource

      public Optional<MatchContext> getSource()
      When the original element must be updated (inside of an OptionalGroup or a ChoiceGroup), the source tracks what the original MatchContext was. This is non-null only after branch(PatternElement) is called.
      Returns:
      the source of this MatchContext
    • branch

      public MatchContext branch(PatternElement e)
      Creates a new MatchContext based on the given PatternElement
      Parameters:
      e - the new original pattern element
      Returns:
      the branched MatchContext
    • merge

      public void merge(MatchContext branch)
      Merges a branched MatchContext back into the current one
      Parameters:
      branch - the branched MatchContext
    • toParseResult

      public ParseContext toParseResult()
      Turns this MatchContext into a ParseContext used in SyntaxElements
      Returns:
      a ParseContext based on this MatchContext
    • getParserState

      public ParserState getParserState()
    • getLogger

      public SkriptLogger getLogger()