NodeStack

public final class NodeStack<NodeType> : CustomStringConvertible where NodeType : Node

A NodeStack can be used to manage AST construction state, as new rule evaluations begin new contexts can be pushed onto the node stack and then popped and discarded on failure, or popped and acted on for success.

  • Creates a new instance of the stack with an active context

    Declaration

    Swift

    public init()
  • Removes all current stack entries and adds a new initial context

    Declaration

    Swift

    public func reset()
  • Adds a new context to the top of the stack

    Declaration

    Swift

    public func push()
  • Removes the stack entry from the top of the stack

    Declaration

    Swift

    public func pop() -> NodeStackEntry<NodeType>

    Return Value

    The popped entry

  • top

    The entry currently on the top of the stack, if any

    Declaration

    Swift

    public var top: NodeStackEntry<NodeType>? { get }
  • The depth of the stack

    Declaration

    Swift

    public var depth: Int { get }
  • all

    An inverted (from deepest to shallowest) representation of the stack

    Declaration

    Swift

    public var all: [NodeStackEntry<NodeType>] { get }
  • A human readable description of the stack

    Declaration

    Swift

    public var description: String { get }