class CLTK::Parser::ParseStack

Overview

The ParseStack class is used by a Parser to keep track of state during parsing.

Defined in:

cltk/parser/parse_stack.cr

Class Method Summary

Instance Method Summary

Instance methods inherited from class Object

in?(collection : Array | Set) in?

Class Method Detail

def self.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.


[View source]

Instance Method Detail

def branch(new_id) #

Branch this stack, effectively creating a new copy of its internal state.

@param [Integer] new_id ID for the new ParseStack.

@return [ParseStack]


[View source]
def id : Int32 #

@return [Integer] ID of this parse stack.


[View source]
def output_stack : Array(CLTK::Parser::StackType) #

@return [Array<Object>] Array of objects produced by {Reduce} actions.


[View source]
def pop(n = 1) #

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.


[View source]
def position #

@return [StreamPosition] Position data for the last symbol on the stack.


[View source]
def push(state, o, node0, position) #

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]


[View source]
def resolve(env, procs) #

[View source]
def result #

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.


[View source]
def state #

@return [Integer] Current state of this ParseStack.


[View source]
def state_stack : Array(Int32) #

@return [Array<Integer>] Array of states used when performing {Reduce} actions.


[View source]
def tree #

@return [String] Representation of the parse tree in the DOT langauge.


[View source]