class documentation

A grammar production. Each production maps a single symbol on the "left-hand side" to a sequence of symbols on the "right-hand side". (In the case of context-free productions, the left-hand side must be a Nonterminal, and the right-hand side is a sequence of terminals and Nonterminals.) "terminals" can be any immutable hashable object that is not a Nonterminal. Typically, terminals are strings representing words, such as "dog" or "under".

See Also
CFG
DependencyGrammar
Nonterminal
Method __eq__ Return True if this Production is equal to other.
Method __hash__ Return a hash value for the Production.
Method __init__ Construct a new Production.
Method __len__ Return the length of the right-hand side.
Method __lt__ Undocumented
Method __ne__ Undocumented
Method __repr__ Return a concise string representation of the Production.
Method __str__ Return a verbose string representation of the Production.
Method is_lexical Return True if the right-hand contain at least one terminal token.
Method is_nonlexical Return True if the right-hand side only contains Nonterminals
Method lhs Return the left-hand side of this Production.
Method rhs Return the right-hand side of this Production.
Instance Variable _lhs The left-hand side of the production.
Instance Variable _rhs The right-hand side of the production.
def __eq__(self, other): (source)

Return True if this Production is equal to other.

Returns
boolUndocumented
def __hash__(self): (source)

Return a hash value for the Production.

Returns
intUndocumented
def __init__(self, lhs, rhs): (source)

Construct a new Production.

Parameters
lhs:NonterminalThe left-hand side of the new Production.
rhs:sequence(Nonterminal and terminal)The right-hand side of the new Production.
def __len__(self): (source)

Return the length of the right-hand side.

Returns
intUndocumented
def __lt__(self, other): (source)

Undocumented

def __ne__(self, other): (source)

Undocumented

def __repr__(self): (source)

Return a concise string representation of the Production.

Returns
strUndocumented
def __str__(self): (source)

Return a verbose string representation of the Production.

Returns
strUndocumented
def is_lexical(self): (source)

Return True if the right-hand contain at least one terminal token.

Returns
boolUndocumented
def is_nonlexical(self): (source)

Return True if the right-hand side only contains Nonterminals

Returns
boolUndocumented
def lhs(self): (source)

Return the left-hand side of this Production.

Returns
NonterminalUndocumented
def rhs(self): (source)

Return the right-hand side of this Production.

Returns
sequence(Nonterminal and terminal)Undocumented
_lhs: Nonterminal = (source)

The left-hand side of the production.

_rhs: tuple(Nonterminal, terminal) = (source)

The right-hand side of the production.