class CLTK::CFG::Item

Overview

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

Defined in:

cltk/cfg/item.cr

Constructors

Instance Method Summary

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

==(other) ==, copy copy, id : Int32 id, last_terminal last_terminal, lhs : String lhs, rhs : Array(String) rhs, to_item to_item, to_s(padding = 0) to_s

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

new(id : Int32, lhs : String, rhs : Array(String)) new

Instance methods inherited from class Object

in?(collection : Array | Set) in?

Constructor Detail

def self.new(dot : Int32, *args) #

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] args (see {Production#initialize})


Instance Method Detail

def ==(other : Item) #

Compares two items.

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

@return [Boolean]


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]


def at_end? #

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

@return [Boolean]


def copy #

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


def dot : Int32 #

@return [Integer] Index of the next symbol in this item.


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).


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]