class CLTK::Parser::ParseStack
- CLTK::Parser::ParseStack
- Reference
- Object
Overview
The ParseStack class is used by a Parser to keep track of state during parsing.
Defined in:
cltk/parser/parse_stack.crClass Method Summary
-
.new(id : Int32, output_stack = [] of CLTK::Parser::StackType, state_stack = [0] of Int32, node_stack = [] of Int32, connections = [] of ::Tuple(Int32, Int32), labels = [] of String, positions = [] of StreamPosition)
Instantiate a new ParserStack object.
Instance Method Summary
-
#branch(new_id)
Branch this stack, effectively creating a new copy of its internal state.
-
#id : Int32
@return [Integer] ID of this parse stack.
-
#output_stack : Array(CLTK::Parser::StackType)
@return [Array<Object>] Array of objects produced by {Reduce} actions.
-
#pop(n = 1)
Pop some number of objects off of the inside stacks.
-
#position
@return [StreamPosition] Position data for the last symbol on the stack.
-
#push(state, o, node0, position)
Push new state and other information onto the stack.
- #resolve(env, procs)
-
#result
Fetch the result stored in this ParseStack.
-
#state
@return [Integer] Current state of this ParseStack.
-
#state_stack : Array(Int32)
@return [Array<Integer>] Array of states used when performing {Reduce} actions.
-
#tree
@return [String] Representation of the parse tree in the DOT langauge.
Instance methods inherited from class Object
in?(collection : Array | Set)
in?
Class Method Detail
Instantiate a new ParserStack object.
Instance Method Detail
Branch this stack, effectively creating a new copy of its internal state.
@param [Integer] new_id ID for the new ParseStack.
@return [ParseStack]
@return [Array<Object>] Array of objects produced by {Reduce} actions.
Pop some number of objects off of the inside stacks.
@param [Integer] n Number of object to pop off the stack.
@return [Array(Object, StreamPosition)] Values popped from the output and positions stacks.
Push new state and other information onto the stack.
@param [Integer] state ID of the shifted state. @param [Object] o Value of Token that caused the shift. @param [Symbol] node0 Label for node in parse tree. @param [StreamPosition] position Position token that got shifted.
@return [void]
Fetch the result stored in this ParseStack. If there is more than one object left on the output stack there is an error.
@return [Object] The end result of this parse stack.
@return [Array<Integer>] Array of states used when performing {Reduce} actions.