本文整理汇总了Python中ast.Node.body方法的典型用法代码示例。如果您正苦于以下问题:Python Node.body方法的具体用法?Python Node.body怎么用?Python Node.body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ast.Node
的用法示例。
在下文中一共展示了Node.body方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: p_fDef
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_fDef(p):
"""fDef : DEF NAME defTuple ARROW EXCLAMATION NAME block"""
p[0] = Node("Fdef")
p[0].func = p[2]
p[0].args = p[3]
p[0].rettype = p[6]
p[0].body = p[7]
示例2: p_for3
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_for3(p):
"""for : FOR NAME EQ range block
"""
p[0] = Node("For")
p[0].iter = p[2]
p[0].range = p[4]
p[0].body = p[5]
示例3: p_for1
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_for1(p):
"""for : FOR NAME IN load block
"""
p[0] = Node("ForEach")
p[0].iter = p[2]
p[0].list = p[4]
p[0].body = p[5]
示例4: p_elif2
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_elif2(p):
'''elif : ELIF expr block elif
| ELIF expr block else
'''
p[0] =Node('IF')
p[0].cond = p[2]
p[0].body = p[3].body
p[0].orelse = p[4]
示例5: p_if2
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_if2(p):
'''if : IF expr block elif
| IF expr block else
'''
p[0] = Node('IF')
p[0].cond = p[1]
p[0].body=p[3].body
p[0].orelse = p[4]
示例6: p_foreach
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_foreach(p):
'''foreach : FOR IDENTIFIER IN expr block
| FOR vdef IN expr block
'''
p[0] = Node('Foreach')
p[0].iter = p[2]
p[0].target = p[4]
p[0].body = p[5].body
示例7: p_for2
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_for2(p):
"""for : FOR nameList IN load block
"""
x = Node("Tuple")
p[0] = Node("ForEach")
p[0].iter = x
p[0].list = p[4]
p[0].body = p[5]
p[0].iter.elems = p[2]
示例8: p_fdef
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_fdef(p):
'''fdef : DEF IDENTIFIER tuple block
'''
p[0] = Node('FuncDef')
p[0].name = p[2].value
p[0].args = Node('Arguments')
p[0].args.args = p[3].elems
p[0].body = p[4].body
示例9: p_for
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_for(p):
'''for : FOR IDENTIFIER EQ expr COMMA expr block
| FOR vdef EQ expr COMMA expr block
'''
p[0] = Node('FOR')
p[0].iter = p[2]
p[0].start = p[4]
p[0].step = 1
p[0].stop = p[6]
p[0].body = p[7].body
示例10: p_program
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_program(p):
"""program : statements EOF"""
p[0] = Node("Program")
p[0].body = p[1]
示例11: p_if1
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_if1(p):
'''if : IF expr block
'''
p[0]=Node('IF')
p[0].cond = p[2]
p[0].body = p[3].body
示例12: p_elif1
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_elif1(p):
'''elif : ELIF expr block
'''
p[0] =Node('IF')
p[0].cond = p[2]
p[0].body = p[3].body
示例13: p_program
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_program(p):
'''program : statements EOF
'''
p[0]=Node('program')
p[0].body = p[1].body
示例14: p_while
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_while(p):
"""while : WHILE LPAREN expr RPAREN block"""
p[0] = Node("While")
p[0].cond = p[3]
p[0].body = p[5]
示例15: p_while1
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import body [as 别名]
def p_while1(p):
'''while : WHILE expr block
'''
p[0] =Node('WHILE')
p[0].cond = p[2]
p[0].body=p[3].body