class CLTK::CFG::Production

Overview

Oddly enough, the Production class represents a production in a context-free grammar.

Direct Known Subclasses

Defined in:

cltk/cfg/production.cr

Constructors

Instance Method Summary

Instance methods inherited from class Object

in?(collection : Array | Set) in?

Constructor Detail

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

Instantiates a new Production object with the specified ID, and left- and right-hand sides.

@param [Integer] id ID number of this production. @param [Symbol] lhs Left-hand side of the production. @param [Array] rhs Right-hand side of the production.


[View source]

Instance Method Detail

def ==(other) #

Comparese on production to another. Returns true only if the left- and right- hand sides match.

@param [Production] other Another production to compare to.

@return [Boolean]


[View source]
def copy #

@return [Production] A new copy of this production.


[View source]
def id : Int32 #

@return [Integer] ID of this production.


[View source]
def last_terminal #

@return [Symbol] The last terminal in the right-hand side of the production.


[View source]
def lhs : String #

@return [Symbol] Left-hand side of this production.


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

@return [Array] Right-hand side of this production.


[View source]
def to_item #

@return [Item] An Item based on this production.


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

Returns a string representation of this production.

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

@return [String]


[View source]