struct CLTK::Parser::State
- CLTK::Parser::State
- Struct
- Value
- Object
Overview
The State class is used to represent sets of items and actions to be used during parsing.
Defined in:
cltk/parser/state.crConstructors
- .new(id : Int32, actions : Hash(String, Array(CLTK::Parser::Action)), items : Array(CFG::Item))
-
.new(tokens : Array(String), items : Array(CLTK::CFG::Item) = [] of CFG::Item)
Instantiate a new State object.
Instance Method Summary
- #<<(item)
-
#==(other)
Compare one State to another.
-
#actions : Hash(String, Array(CLTK::Parser::Action))
@return [Hash{Symbol => Array
}] Maps lookahead symbols to actions -
#add_reduction(production)
Add a Reduce action to the state.
-
#append(item)
@param [CFG::Item] item Item to add to this state.
-
#clean
Clean this State by removing the list of {CFG::Item} objects.
-
#close(productions)
Close this state using productions.
-
#conflict_on?(sym)
Checks to see if there is a conflict in this state, given a input of sym.
-
#each(&)
Iterate over the state's items.
-
#id : Int32
@return [Integer] State's ID.
-
#id=(id : Int32)
@return [Integer] State's ID.
-
#items : Array(CLTK::CFG::Item)
@return [ArrayCFG::Item] Item objects that comprise this state
-
#on(symbol, action : Action)
Specify an Action to perform when the input token is symbol.
-
#on?(symbol)
Returns that actions that should be taken when the input token is symbol.
Instance methods inherited from class Object
in?(collection : Array | Set)
in?
Constructor Detail
Instantiate a new State object.
@param [Array
Instance Method Detail
Compare one State to another. Two States are equal if they have the same items or, if the items have been cleaned, if the States have the same ID.
@param [State] other Another State to compare to
@return [Boolean]
@return [Hash{Symbol => Array
Add a Reduce action to the state.
@param [Production] production Production used to perform the reduction
@return [void]
Close this state using productions.
@param [ArrayCFG::Production] productions Productions used to close this state.
@return [vod]
Checks to see if there is a conflict in this state, given a input of sym. Returns :SR if a shift/reduce conflict is detected and :RR if a reduce/reduce conflict is detected. If no conflict is detected nil is returned.
@param [Symbol] sym Symbol to check for conflicts on.
@return [:SR, :RR, nil]
Specify an Action to perform when the input token is symbol.
@param [Symbol] symbol Symbol to add action for. @param [Action] action Action for symbol.
@return [void]
Returns that actions that should be taken when the input token is symbol.
@param [Symbol] symbol Symbol we want the actions for.
@return [Array