Exemple #1
0
    def build(self, **kwargs):
        debug = kwargs.get('debug', verbose())
        start = kwargs.get('start', self.__class__.start)
        parserspath = kwargs.get('outputdir', tempfile.gettempdir())
        if debug:
            print("nameparse parsers path", parserspath)
        method = kwargs.get('method', 'LALR')
        if debug:
            print("Build for", self.__class__.__name__)
            print("tokens:")
            for t in self.__class__.tokens:
                # t is not always in tokensDict, not sure if this is bad or not...
                # print "\t%s = %r" % (t, self.__class__.tokensDict[t])
                print("\t%s" % (t))
            print("rules:")
            for t in self.__class__.rules:
                # t is not always in rulesDict, not sure if this is bad or not...
                # print "\t%s = %r" % (t, self.__class__.rulesDict[t].__doc__)
                print("\t%s" % (t))
            print("start: %s" % start)

        if self.lexer is None:
            lextab = self.__class__.__name__ + "_lex"
            lkwargs = {'debug': debug, 'lextab': lextab}
            self.lexer = lex.lex(object=self, **lkwargs)
        if self.parser is None:
            tabmodule = self.__class__.__name__ + "_yacc_" + start
            pkwargs = {
                'outputdir': parserspath,
                'debug': debug,
                'tabmodule': tabmodule,
                'start': start,
                'method': method
            }
            self.parser = yacc.yacc(module=self, **pkwargs)
Exemple #2
0
 def build(self, **kwargs):
     self.lexer = lex.lex(object=self, **kwargs)
Exemple #3
0
 def build(self, **kwargs):
     self.lexer = lex.lex(object=self, **kwargs)