Class ParserState

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

public class ParserState extends Object
An object that stores data about the current parsing, on the scale of the entire trigger.
  • Constructor Details

    • ParserState

      public ParserState()
  • Method Details

    • getCurrentContexts

      public Set<Class<? extends TriggerContext>> getCurrentContexts()
      Returns:
      the TriggerContexts handled by the currently parsed event
    • setCurrentContexts

      public void setCurrentContexts(Set<Class<? extends TriggerContext>> currentContexts)
      Sets the TriggerContexts handled by the currently parsed event
      Parameters:
      currentContexts - the handled TriggerContexts
    • getCurrentSections

      public LinkedList<CodeSection> getCurrentSections()
      Returns:
      a list of all enclosing CodeSections, with the closest one first
    • addCurrentSection

      public void addCurrentSection(CodeSection section)
      Adds a new enclosing CodeSection to the hierarchy
      Parameters:
      section - the enclosing CodeSection
    • removeCurrentSection

      public void removeCurrentSection()
      Removes the current section from the hierarchy, after all parsing inside it has been completed.
    • getCurrentStatements

      public LinkedList<Statement> getCurrentStatements()
      Returns a list of all consecutive, successfully parsed Statements in the enclosing section. This is essentially a list with all previously parsed items of this section.
      Returns:
      a list of all Statements in the enclosing section.
    • addCurrentStatement

      public void addCurrentStatement(Statement statement)
      Adds a new Statement to the items of the enclosing section.
      Parameters:
      statement - the enclosing Statement
    • recurseCurrentStatements

      public void recurseCurrentStatements()
      Uses recursion to allow items of a new enclosing section to be added, preserving the current items to be used when the callback has been invoked.
    • callbackCurrentStatements

      public void callbackCurrentStatements()
      Clears all stored items of this enclosing section, after all parsing inside it has been completed.
    • setSyntaxRestrictions

      public void setSyntaxRestrictions(Set<Class<? extends SyntaxElement>> allowedSyntaxes, boolean restrictingExpressions)
      Define the syntax restrictions enforced by the current section
      Parameters:
      allowedSyntaxes - all allowed syntaxes
      restrictingExpressions - whether expressions are also restricted
    • clearSyntaxRestrictions

      public void clearSyntaxRestrictions()
      Clears the previously enforced syntax restrictions
    • forbidsSyntax

      public boolean forbidsSyntax(Class<? extends SyntaxElement> c)
      Parameters:
      c - the class of the syntax
      Returns:
      whether the current syntax restrictions forbid a given syntax or not
    • isRestrictingExpressions

      public boolean isRestrictingExpressions()
      Returns:
      whether the current syntax restrictions also apply to expressions