Package EasyExtend :: Package trail :: Module nfagen :: Class FlatRule
[hide private]
[frames] | no frames]

Class FlatRule

object --+
         |
        FlatRule

Class used to turn EBNF grammar rules into list description using numerical identifiers of symbols and tokens. :

  Example 1:

       single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE

                      =====>

       ['|', ['1', 4], ['1', 267], ['1', 291, 4]]

  Here '1' represents the multiplicty of the whole box. Other multiplicities
  are '*', '+' and '?' according to the EBNF notations.

  Example 2:

      test: and_test ('or' and_test)* | lambdef

                     =====>

      ['|', ['1', 299, ['*', 'or', 299]], ['1', 314]]
Instance Methods [hide private]
 
__init__(self, langlet, nid=-1)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
create(self, node)
 
from_alt(self, node)
 
left_factor(self, alt_rule)
 
flatten(self)
 
maybe_elimination(self, stream)

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Methods [hide private]
 
generate_all(cls, langlet, typ='Grammar')
function used to create simple rule table from EBNF grammar description.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, langlet, nid=-1)
(Constructor)

 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

generate_all(cls, langlet, typ='Grammar')
Class Method

 

function used to create simple rule table from EBNF grammar description.

Parameters:
  • langlet - optional langlet module. When available Grammar of langlet is parsed. Otherwise Pythons Grammar is used as a default.
Returns:
dictionary of rules.