本文整理匯總了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