本文整理汇总了Python中compiler.syntax.check方法的典型用法代码示例。如果您正苦于以下问题:Python syntax.check方法的具体用法?Python syntax.check怎么用?Python syntax.check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类compiler.syntax
的用法示例。
在下文中一共展示了syntax.check方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visitIf
# 需要导入模块: from compiler import syntax [as 别名]
# 或者: from compiler.syntax import check [as 别名]
def visitIf(self, node):
end = self.newBlock()
numtests = len(node.tests)
for i in range(numtests):
test, suite = node.tests[i]
if is_constant_false(test):
# XXX will need to check generator stuff here
continue
self.set_lineno(test)
self.visit(test)
nextTest = self.newBlock()
self.emit('POP_JUMP_IF_FALSE', nextTest)
self.nextBlock()
self.visit(suite)
self.emit('JUMP_FORWARD', end)
self.startBlock(nextTest)
if node.else_:
self.visit(node.else_)
self.nextBlock(end)
示例2: visitIf
# 需要导入模块: from compiler import syntax [as 别名]
# 或者: from compiler.syntax import check [as 别名]
def visitIf(self, node):
end = self.newBlock()
numtests = len(node.tests)
for i in range(numtests):
test, suite = node.tests[i]
if is_constant_false(test):
# XXX will need to check generator stuff here
continue
self.set_lineno(test)
self.visit(test)
nextTest = self.newBlock()
self.emit('JUMP_IF_FALSE', nextTest)
self.nextBlock()
self.emit('POP_TOP')
self.visit(suite)
self.emit('JUMP_FORWARD', end)
self.startBlock(nextTest)
self.emit('POP_TOP')
if node.else_:
self.visit(node.else_)
self.nextBlock(end)
示例3: _get_tree
# 需要导入模块: from compiler import syntax [as 别名]
# 或者: from compiler.syntax import check [as 别名]
def _get_tree(self):
tree = parse(self.source, self.mode)
misc.set_filename(self.filename, tree)
syntax.check(tree)
return tree