grammatica.grammar.DerivationRule#

class grammatica.grammar.DerivationRule(symbol, value)[source]#

Derivation rule that expands to a expression (grammar).

Non-terminal symbol and an expression separated by a metasymbol (e.g. ‘symbol ::= expression’).

Parameters:
  • symbol (str) – Symbol (non-terminal) for the derivation rule.

  • value (Grammar) – Grammar the symbol derives into.

Attributes

symbol

Symbol (non-terminal) for the derivation rule.

value

Grammar the symbol derives into.

separator

Separator metasymbol to use for the derivation rule.

Methods

as_string([indent])

Return a string representation of the grammar.

attrs_dict()

Return instance attributes of the grammar.

copy()

Create a copy of the grammar.

equals(other[, check_quantifier])

Check equality with another value.

render([full, wrap])

Render the grammar as a regular expression.

simplify()

Simplify the grammar.