def LoadSQLG(): import kjParser print "unmarshalling" infile = open(MARSHALFILE, "r") SQLG = kjParser.UnMarshalGram(infile) infile.close() return SQLG
def unMarshalLispG(): import kjParser infile = open(MARSHALLEDFILENAME, "r") LispG = kjParser.UnMarshalGram(infile) infile.close() DeclareTerminals(LispG) BindRules(LispG) return LispG
def reloadSQLG(filename=MARSHALFILE): """does not bind any interpretation functions.""" import kjParser infile = open(filename, "rb") SQLG = kjParser.UnMarshalGram(infile) infile.close() DeclareTerminals(SQLG) return SQLG
def reloadrelalg(filename=MARSHALFILE): import kjParser filename = INSTALLDIR + "/" + filename infile = open(filename, "rb") SQLG = kjParser.UnMarshalGram(infile) infile.close() DeclareTerminals(SQLG) BindRules(SQLG) return SQLG
def unMarshalpygram(): global pyg import kjParser print "loading" try: infile = open(marshalfilename, "rb") except IOError: print marshalfilename, "not found, attempting creation" pyg = GrammarBuild() else: pyg = kjParser.UnMarshalGram(infile) infile.close() pyg.DoParse = hackDoParse # lexical override pyg.LexD = pylexdict() DeclareTerminals(pyg) # BindRules(pyg) if dotest: print "self testing the grammar" test(pyg) return pyg
def GrammarBuild(self, load=1): if load and os.path.exists(MARSHALLEDFILENAME): import kjParser infile = open(MARSHALLEDFILENAME, 'r') self._grammar = kjParser.UnMarshalGram(infile) infile.close() self.DeclareTerminals() else: import kjParseBuild self._grammar = kjParseBuild.NullCGrammar() self._grammar.SetCaseSensitivity(0) self._grammar.punct('=<>+*') self._grammar.Nonterms("Equation Expression Operator ") self._grammar.Nonterms("Term Variable Plus Times Constant ") self.DeclareTerminals() self._grammar.Declarerules(GRAMMARSTRING) self._grammar.Compile() outfile = open(MARSHALLEDFILENAME, "w") self._grammar.MarshalDump(outfile) outfile.close() self.BindRules()