本文整理汇总了Python中ply.yacc.NullLogger方法的典型用法代码示例。如果您正苦于以下问题:Python yacc.NullLogger方法的具体用法?Python yacc.NullLogger怎么用?Python yacc.NullLogger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ply.yacc
的用法示例。
在下文中一共展示了yacc.NullLogger方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from ply import yacc [as 别名]
# 或者: from ply.yacc import NullLogger [as 别名]
def __init__(self, **kwargs):
if 'tokens' in kwargs.keys(): # MANDATORY
self.tokens = kwargs['tokens']
kwargs.pop('tokens', None)
# debugging and logging http://www.dabeaz.com/ply/ply.html#ply_nn44
#self.parser = yacc.yacc(module=self, start='step', errorlog=yacc.NullLogger(), debug = True, debugfile='debug_file', **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:
示例2: __init__
# 需要导入模块: from ply import yacc [as 别名]
# 或者: from ply.yacc import NullLogger [as 别名]
def __init__(self, outputdir='', lexer=None):
Tokenizer.__init__(self, outputdir, lexer)
self.parser = yacc.yacc(module=self,
outputdir=outputdir,
tabmodule='webidlyacc',
errorlog=yacc.NullLogger(),
picklefile='WebIDLGrammar.pkl')
self._globalScope = IDLScope(BuiltinLocation("<Global Scope>"), None, None)
self._installBuiltins(self._globalScope)
self._productions = []
self._filename = "<builtin>"
self.lexer.input(Parser._builtins)
self._filename = None
self.parser.parse(lexer=self.lexer,tracking=True)
示例3: __init__
# 需要导入模块: from ply import yacc [as 别名]
# 或者: from ply.yacc import NullLogger [as 别名]
def __init__(self, debug=0, log=yacc.NullLogger()):
self.parser = yacc.yacc(module=self, tabmodule='pyoracc.atf.parsetab',
debug=debug, debuglog=log)
示例4: build
# 需要导入模块: from ply import yacc [as 别名]
# 或者: from ply.yacc import NullLogger [as 别名]
def build(self, **kwargs):
self.parser = yacc.yacc(
module=self, debug=False, write_tables=False, errorlog=yacc.NullLogger(), **kwargs)
self.lexer = HealthLexer().build()
return self.parser
示例5: __init__
# 需要导入模块: from ply import yacc [as 别名]
# 或者: from ply.yacc import NullLogger [as 别名]
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()
示例6: __init__
# 需要导入模块: from ply import yacc [as 别名]
# 或者: from ply.yacc import NullLogger [as 别名]
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)
示例7: _yacc
# 需要导入模块: from ply import yacc [as 别名]
# 或者: from ply.yacc import NullLogger [as 别名]
def _yacc(verbose=False, out_dir=None):
"""
Return YACC parser object for the MOF compiler.
Parameters:
verbose (bool): Print messages while creating the parser object.
out_dir (string): Path name of the directory in which the YACC table
module source file (_mofparsetab.py) for the MOF compiler will be
generated. If None, that file will not be generated.
Returns:
yacc.Parser: YACC parser object for the MOF compiler.
"""
# The write_tables argument controls whether the YACC parser writes
# the YACC table module file.
write_tables = (out_dir is not None)
# In yacc(), the 'debug' parameter controls the main error
# messages to the 'errorlog' in addition to the debug messages
# to the 'debuglog'. Because we want to see the error messages,
# we enable debug but set the debuglog to the NullLogger.
# To enable debug logging, set debuglog to some other logger
# (ex. PlyLogger(sys.stdout) to generate log output.
return yacc.yacc(optimize=_optimize,
tabmodule=_tabmodule,
outputdir=out_dir,
write_tables=write_tables,
debug=verbose,
debuglog=yacc.NullLogger(),
errorlog=yacc.PlyLogger(sys.stdout) if verbose
else yacc.NullLogger())
示例8: _lex
# 需要导入模块: from ply import yacc [as 别名]
# 或者: from ply.yacc import NullLogger [as 别名]
def _lex(verbose=False, out_dir=None):
"""
Return LEX analyzer object for the MOF Compiler.
Parameters:
verbose (bool): Print messages while creating the parser object.
out_dir (string): Path name of the directory in which the LEX table
module source file (_moflextab.py) for the MOF compiler will be
generated. If None, that file will not be generated.
Returns:
lex.Lexer: LEX analyzer object for the MOF compiler.
"""
# Unfortunately, lex() does not support a write_tables argument. It
# always tries to write the tables if optimize=True, so we supply a dummy
# output directory. Always setting optimize=False is also not a good
# solution because that causes the input table not to be used.
if out_dir is None:
out_dir = tempfile.gettempdir()
# To debug lex you may set debug=True and enable the debuglog statement.
# or other logger definition.
return lex.lex(optimize=_optimize,
lextab=_lextab,
outputdir=out_dir,
debug=False,
# debuglog = lex.PlyLogger(sys.stdout),
errorlog=yacc.PlyLogger(sys.stdout) if verbose
else yacc.NullLogger())