Package lemon :: Package external :: Package gadfly :: Module kjParseBuild :: Class CGrammar
[show private | hide private]
[frames | no frames]

Class CGrammar

Grammar --+
          |
         CGrammar


a derived grammar class
this is a compilable grammar for automatic parser generation.

Method Summary
  comments(self, listOfCommentStrings)
register a list of regular expression strings...
  Compile(self, MetaGrammar)
The compilation function assumes NonTermDict RuleString LexD TermDict have all been set up properly (at least if the default MetaGrammar is used).
  Declarerules(self, StringWithRules)
initialize or add more rules to the RuleString...
  Keywords(self, Stringofkeys)
insert a white separated list of keywords into the LexD TODO: THIS SHOULD CHECK FOR KEYWORD/NONTERMINAL/PUNCT NAME COLLISIONS (BUT DOESN'T YET).
  MarshalDump(self, Tofile)
marshalling of a grammar to a file...
  Nonterms(self, StringofNonterms)
register a white separated list of nonterminal strings...
  punct(self, Stringofpuncts)
insert a string of punctuations into the LexD...
  Reconstruct(self, VarName, Tofile, FName, indent)
Write a reconstructable representation for this grammar to a file...
    Inherited from Grammar
  __init__(self, LexD, DFA, RuleL, RuleNameDict)
  AddNameDict(self, RuleNameDict)
this method associates rules to names using a RuleNameDict dictionary which maps names to rule indices.
  Addterm(self, termname, regexpstr, funct)
bind a terminal to a regular expression and interp function...
  Bind(self, Rulename, NewFunction)
if the Name dictionary has been initialized...
  CleanUp(self)
this may be silly, but to save some space in construction a token dictionary may be used that facilitates sharing of token representations.
  DoParse(self, String, Context, DoReductions)
parse a string using the grammar, return result and context...
  DoParse1(self, String, Context, DoReductions)
parse a string using the grammar, but only return...
  PrintDefaults(self)
look for default bindings...
  SetCaseSensitivity(self, Boolean)
setting case sensitivity: must happen before keyword installation in LexD.

Method Details

comments(self, listOfCommentStrings)

register a list of regular expression strings
to represent comments in LexD

Compile(self, MetaGrammar=<lemon.external.gadfly.kjParser.Grammar instance at 0x016...)

The compilation function assumes
  NonTermDict
  RuleString
  LexD
  TermDict
have all been set up properly
(at least if the default MetaGrammar is used).
On successful completion it will set up
  DFA
  RuleL
  RuleNameToIndex

the following should return a list of rules
with punctuations of self.LexD interpreted as trivial keywords
  keywords of seld.LexD interpreted as keywords
and nonterminals registered in NonTermDict interpreted as
nonterms.
 ParseResult should be of form ( (rootNT, RuleL), self )

Declarerules(self, StringWithRules)

initialize or add more rules to the RuleString

Keywords(self, Stringofkeys)

insert a white separated list of keywords into the LexD
TODO: THIS SHOULD CHECK FOR KEYWORD/NONTERMINAL/PUNCT NAME
COLLISIONS (BUT DOESN'T YET).

MarshalDump(self, Tofile)

marshalling of a grammar to a file

Nonterms(self, StringofNonterms)

register a white separated list of nonterminal strings

punct(self, Stringofpuncts)

insert a string of punctuations into the LexD

Reconstruct(self, VarName, Tofile, FName=None, indent='')

Write a reconstructable representation for this grammar to a file
EXCEPT:
  - rule associations to reduction functions
    will be lost (must be reset elsewhere)
  - terminals in the lexical dictionary
    will not be initialized

IND is used for indentation, should be whitespace (add check!)

FName if given will cause the reconstructed to be placed
inside a function `FName`+"()" returning the grammar object

NOTE: this function violates information hiding principles;
 in particular it "knows" the guts of the FSM and LexD classes

Generated by Epydoc 2.0 on Mon Nov 10 15:08:04 2003 http://epydoc.sf.net