class CLTK::CFG::Item

Overview

The Item class represents a CFG production with dot in it.

Defined in:

cltk/cfg/item.cr
cltk/parser/msgpack.cr

Class Method Summary

Instance Method Summary

Instance methods inherited from class CLTK::CFG::Production

==(other) ==, copy copy, id : Int32 id, id=(_id : Int32) id=, last_terminal last_terminal, lhs : String lhs, lhs=(_lhs : String) lhs=, rhs : Array(String) rhs, rhs=(_rhs : Array(String)) rhs=, to_item to_item, to_msgpack(packer : MessagePack::Packer) to_msgpack, to_s(padding = 0) to_s

Class methods inherited from class CLTK::CFG::Production

new(id : Int32, lhs : String, rhs : Array(String))
new(__temp_80 : MessagePack::Unpacker)
new

Instance methods inherited from class Object

in?(collection : Array | Set) in?

Class Method Detail

def self.new(dot : Int32, id : Int32, lhs : String, rhs : Array(String)) #

Instantiates a new Item object with a dot located before the symbol at index dot of the right-hand side. The remaining arguments (args) should be as specified by {Production#initialize}.

@param [Integer] dot Location of the dot in this Item. @param [Array<Object>] args (see {Production#initialize})


[View source]
def self.new(__temp_88 : MessagePack::Unpacker) #

[View source]

Instance Method Detail

def ==(other : Item) #

Compares two items.

@param [Item] other Another item to compare to.

@return [Boolean]


[View source]
def advance #

Moves the items dot forward by one if the end of the right-hand side hasn't already been reached.

@return [Integer, nil]


[View source]
def at_end? #

Tests to see if the dot is at the end of the right-hand side.

@return [Boolean]


[View source]
def copy #

@return [Item] A new copy of this item.


[View source]
def dot : Int32 #

[View source]
def dot=(_dot : Int32) #

[View source]
def id : Int32 #

[View source]
def id=(_id : Int32) #

[View source]
def lhs : String #

[View source]
def lhs=(_lhs : String) #

[View source]
def next_symbol #

Returns the symbol located after the dot.

@return [Symbol] Symbol located after the dot (at the index indicated by the {#dot} attribute).


[View source]
def rhs : Array(String) #

[View source]
def rhs=(_rhs : Array(String)) #

[View source]
def to_msgpack(packer : MessagePack::Packer) #

[View source]
def to_s(padding = 0) #

Returns a string representation of this item.

@param [Integer] padding The ammount of padding spaces to add to the beginning of the string.

@return [String]


[View source]