class CLTK::Parser::State
- CLTK::Parser::State
- Reference
- Object
Overview
The State class is used to represent sets of items and actions to be used during parsing.
Defined in:
cltk/parser/state.crcltk/parser/msgpack.cr
Class Method Summary
- .new(id : Int32, actions : Hash(String, Array(CLTK::Parser::Action)), items : Array(CFG::Item))
-
.new(tokens : Array(String), items = [] of CFG::Item)
Instantiate a new State object.
- .new(__temp_54 : MessagePack::Unpacker)
Instance Method Summary
- #<<(item)
-
#==(other)
Compare one State to another.
- #actions : Hash(String, Array(CLTK::Parser::Action))
- #actions=(_actions : Hash(String, Array(CLTK::Parser::Action)))
-
#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(&block)
Iterate over the state's items.
- #id : Int32
-
#id=(id)
@return [Integer] State's ID.
- #id=(_id : Int32)
- #items : Array(CLTK::CFG::Item)
- #items=(_items : Array(CFG::Item))
-
#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.
- #to_msgpack(packer : MessagePack::Packer)
Instance methods inherited from class Object
in?(collection : Array | Set)
in?
Class Method Detail
Instantiate a new State object.
@param [Array<Symbol>] tokens Tokens that represent this state @param [Array<CFG::Item>] items Items that make up this state
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]
Add a Reduce action to the state.
@param [Production] production Production used to perform the reduction
@return [void]
Close this state using productions.
@param [Array<CFG::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<Action>] Actions that should be taken.