Python ply.yacc 模块,NullLogger() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用ply.yacc.NullLogger()

项目:PyRATA    作者:nicolashernandez    | 项目源码 | 文件源码
def build(self, **kwargs):
    """ the start attribute is mandatory !
        When calling the method with a start distinct from expression you may get the following message
        WARNING: Symbol 'expression' is unreachable
        Nothing to be aware of
    """

    # keep track of 

    # # start the parser
    # start = 'expression'
    # if 'start' in kwargs.keys(): # MANDATORY
    #   start = kwargs['start'] 
    # kwargs.pop('start', None)      
    # debugging and logging http://www.dabeaz.com/ply/ply.html#ply_nn44 
    #self.parser = yacc.yacc(module=self, start=start, errorlog=yacc.NullLogger(), debug = False, **kwargs) 
    self.parser = yacc.yacc(module=self, start='step', errorlog=yacc.NullLogger(), debug = False, **kwargs) 

    # https://github.com/dabeaz/ply/blob/master/ply/yacc.py
    # debug yaccdebug   = True        # Debugging mode.  If set, yacc generates a
                               # a 'parser.out' file in the current directory

# """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
#  MAIN
# """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


# example use:
项目:fastweb    作者:BSlience    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        if kwargs.pop('silent', False):
            kwargs['errorlog'] = yacc.NullLogger()

        kwargs.setdefault('debug', False)
        kwargs.setdefault('write_tables', False)
        self._parser = yacc.yacc(module=self, **kwargs)
        self._lexer = Lexer()
项目:SpaghettIDE    作者:Bleu-royal    | 项目源码 | 文件源码
def test_recurse_expansion(self):
        """Verify that stack depth doesn't get exceeded on recursive rules marked for expansion."""
        g = Grammar(r"""@start: a | start a ; a : A ; A : 'a' ;""")

        # Force PLY to write to the debug log, but prevent writing it to the terminal (uses repr() on the half-built
        # STree data structures, which uses recursion).
        g._grammar.debug = yacc.NullLogger()

        g.parse("a" * (sys.getrecursionlimit() // 4))
项目:SpaghettIDE    作者:Bleu-royal    | 项目源码 | 文件源码
def test_recurse_flatten(self):
        """Verify that stack depth doesn't get exceeded on recursive rules marked for flattening."""
        g = Grammar(r"""#start: a | start a ; a : A ; A : 'a' ;""")

        # Force PLY to write to the debug log, but prevent writing it to the terminal (uses repr() on the half-built
        # STree data structures, which uses recursion).
        g._grammar.debug = yacc.NullLogger()

        g.parse("a" * (sys.getrecursionlimit() // 4))
项目:PyQYT    作者:collinsctk    | 项目源码 | 文件源码
def __init__(self, startSym='mibFile', tempdir=''):
        if tempdir:
            tempdir = os.path.join(tempdir, startSym)
            try:
                os.makedirs(tempdir)
            except OSError:
                if sys.exc_info()[1].errno != 17:
                    raise error.PySmiError('Failed to create cache directory %s: %s' % (tempdir, sys.exc_info()[1]))

        self.lexer = self.defaultLexer(tempdir=tempdir)

        # tokens are required for parser
        self.tokens = self.lexer.tokens

        if debug.logger & debug.flagParser:
            logger = debug.logger.getCurrentLogger()
        else:
            logger = yacc.NullLogger()

        if debug.logger & debug.flagGrammar:
            debuglogger = debug.logger.getCurrentLogger()
        else:
            debuglogger = None

        self.parser = yacc.yacc(module=self,
                                start=startSym,
                                write_tables=bool(tempdir),
                                debug=False,
                                outputdir=tempdir,
                                debuglog=debuglogger,
                                errorlog=logger)