Example #1
0
def LoadSQLG():
    import kjParser
    print "unmarshalling"
    infile = open(MARSHALFILE, "r")
    SQLG = kjParser.UnMarshalGram(infile)
    infile.close()
    return SQLG
Example #2
0
def unMarshalLispG():
    import kjParser
    infile = open(MARSHALLEDFILENAME, "r")
    LispG = kjParser.UnMarshalGram(infile)
    infile.close()
    DeclareTerminals(LispG)
    BindRules(LispG)
    return LispG
Example #3
0
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
Example #4
0
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
Example #5
0
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
Example #6
0
    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()