Package ch.njol.skript.lang.parser
Class ParsingStack
java.lang.Object
ch.njol.skript.lang.parser.ParsingStack
- All Implemented Interfaces:
Iterable<ParsingStack.Element>
A stack that keeps track of what Skript is currently parsing.
When accessing the stack from within
SyntaxElement.init(Expression[], int, Kleenean, SkriptParser.ParseResult)
,
the stack element corresponding to that SyntaxElement
is not
on the parsing stack.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
A stack element, containing details about the syntax element it is about. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty parsing stack.ParsingStack
(ParsingStack parsingStack) Creates a parsing stack containing all elements of another given parsing stack. -
Method Summary
Modifier and TypeMethodDescriptionboolean
isEmpty()
Check if this stack is empty.iterator()
Iterate over the stack, starting at the top.peek()
Returns the top element of the stack.peek
(int index) Returns the element at the given index in the stack, starting with the top element at index 0.pop()
Removes and returns the top element of this stack.void
print
(PrintStream printStream) Prints this stack to the givenPrintStream
.void
push
(ParsingStack.Element element) Adds the given element to the top of the stack.int
size()
Gets the size of the stack.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ParsingStack
public ParsingStack()Creates an empty parsing stack. -
ParsingStack
Creates a parsing stack containing all elements of another given parsing stack.
-
-
Method Details
-
pop
Removes and returns the top element of this stack.- Throws:
IllegalStateException
- if the stack is empty.
-
peek
Returns the element at the given index in the stack, starting with the top element at index 0.- Parameters:
index
- the index in stack.- Throws:
IndexOutOfBoundsException
- if the index is not appointed to an element in the stack.
-
peek
Returns the top element of the stack. Equivalent topeek(0)
.- Throws:
IllegalStateException
- if the stack is empty.
-
push
Adds the given element to the top of the stack. -
isEmpty
public boolean isEmpty()Check if this stack is empty. -
size
public int size()Gets the size of the stack. -
print
Prints this stack to the givenPrintStream
.- Parameters:
printStream
- aPrintStream
to print the stack to.
-
iterator
Iterate over the stack, starting at the top.- Specified by:
iterator
in interfaceIterable<ParsingStack.Element>
-