Package schlachtfeld :: Package namegen :: Package pycfnamegen :: Module cfnamegen :: Class CFNameGen
[hide private]
[frames] | no frames]

Class CFNameGen

source code

object --+
         |
        CFNameGen

Instance Methods [hide private]
  __init__(self, nameGrammar)
Create a namegen object.
  checkTypes(self, nameGrammar)
Check given grammar object for correct datatypes.
  checkUndefinedNonTerminals(self, nameGrammar)
Check given grammar for undefined non-terminals.
  checkUnproductiveNonTerminals(self, nameGrammar)
Check grammar for possibly unproductive non-terminals.
  checkUnusedNonTerminals(self, nameGrammar)
Check grammar for non-terminals that can never be reached.
  verifyGrammar(self)
  getName(self)

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


Class Variables [hide private]
  stringUndefinedNonTerminal = 'Undefined non-terminal "%(undefinedNonTerminal)s" i...
  reNonTerminal = <_sre.SRE_Pattern object at 0xa6dc90>

Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, nameGrammar)
(Constructor)

source code 

Create a namegen object.

We take a grammar dict, as before the Great Refactoring.
Overrides: object.__init__

checkTypes(self, nameGrammar)

source code 

Check given grammar object for correct datatypes.

This function is only really necessary while the grammar's still being specified in here. It will likely disappear when we parse the grammar from a data file.

checkUndefinedNonTerminals(self, nameGrammar)

source code 

Check given grammar for undefined non-terminals.

An undefined non-terminal is a non-terminal symbol used in a symbol definition that has no definition of its own and cannot therefore be expanded. Undefined non-terminals can lead to ugly error messages instead of beautifully generated names.

checkUnproductiveNonTerminals(self, nameGrammar)

source code 

Check grammar for possibly unproductive non-terminals.

An unproductive non-terminal is a non-terminal symbol that cannot be converted to a terminal symbol in the given grammar. A good example of this is a non-terminal symbol that includes itself in its definition.

This function is currently very basic and should be extended (rewritten?) to allow warnings for _possible_ unproductive non-terminals and errors for _definite_ unproductive non-terminals. Volunteers?

XXX: INCOMPLETE

checkUnusedNonTerminals(self, nameGrammar)

source code 

Check grammar for non-terminals that can never be reached.

While unused non-terminals are irrelevant in the generation of sentences, their presence usually implies an error in the grammar.

XXX: INCOMPLETE

verifyGrammar(self)

source code 
None

getName(self)

source code 
None

Class Variable Details [hide private]

stringUndefinedNonTerminal

None
Value:
'Undefined non-terminal "%(undefinedNonTerminal)s" in rule "%(rule)s".
'                                                                      
      

reNonTerminal

None
Value:
<(\w+)>