本文整理汇总了Python中ast.Node.var方法的典型用法代码示例。如果您正苦于以下问题:Python Node.var方法的具体用法?Python Node.var怎么用?Python Node.var使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ast.Node
的用法示例。
在下文中一共展示了Node.var方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: p_lookup
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import var [as 别名]
def p_lookup(p):
"""lookup : load DOT NAME
"""
p[0] = Node("Lookup")
p[0].var = p[1]
p[0].var.ctl = "store"
p[0].attr = p[3]
示例2: p_array
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import var [as 别名]
def p_array(p):
'''array : unary_expr list %prec LBRACKET
| tuple list %prec LBRACKET
'''
p[0]= Node('Subscript')
p[0].var = p[1]
p[0].slice = p[2]
示例3: p_array
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import var [as 别名]
def p_array(p):
'''array : unary_expr list %prec LBRACKET
| tuple list %prec LBRACKET
'''
p[0]= Node('ARRAY')
p[0].var = p[1]
p[0].elems = p[2].elems
示例4: p_arrayAccess1
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import var [as 别名]
def p_arrayAccess1(p):
"""arrayAccess : load LBRACKET expr RBRACKET
| load LBRACKET range RBRACKET
"""
p[0] = Node("ArrayAccess")
p[0].var = p[1]
p[0].var.ctl = "store"
p[0].args = p[3]
示例5: p_lookup
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import var [as 别名]
def p_lookup(p):
'''lookup : unary_expr DOT IDENTIFIER %prec DOT
| list DOT IDENTIFIER %prec DOT
| tuple DOT IDENTIFIER %prec DOT
'''
p[0] = Node('LOOKUP')
p[0].var = p[1]
p[0].attr = p[3]
示例6: p_ptr
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import var [as 别名]
def p_ptr(p):
'''ptr : AMP unary_expr
| AMP tuple
| AMP list
'''
p[0] =Node('PTR')
p[0].var = p[2]
示例7: p_vdef1
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import var [as 别名]
def p_vdef1(p):
'''vdef : IDENTIFIER unary_expr %prec DEF
| ptr unary_expr %prec DEF
| fptr unary_expr %prec DEF
| tuple unary_expr %prec DEF
'''
p[0] = Node('VDEF')
t = p[1]
p[0].datatype = t
p[0].var = p[2]
示例8: p_varDef
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import var [as 别名]
def p_varDef(p):
"""varDef : type NAME
| type NAME LBRACKET INT RBRACKET
"""
p[0] = Node("VarDef")
p[0].dtype = p[1]
p[0].var = p[2]
if len(p) > 4:
p[0].size = p[4].value
else:
p[0].size = None
示例9: p_ptr
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import var [as 别名]
def p_ptr(p):
"""ptr : AMP NAME"""
p[0] = Node("Ptr")
p[0].var = p[2]
示例10: p_atPtr
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import var [as 别名]
def p_atPtr(p):
"""atPtr : AT load"""
p[0] = Node("At")
p[0].var = p[2]
示例11: p_arrayAccess2
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import var [as 别名]
def p_arrayAccess2(p):
"""arrayAccess : load LBRACKET RBRACKET"""
p[0] = Node("ArrayAccess")
p[0].var = p[1]
p[0].var.ctl = "store"
p[0].args = []
示例12: p_expr3
# 需要导入模块: from ast import Node [as 别名]
# 或者: from ast.Node import var [as 别名]
def p_expr3(p):
"""expr : NOT expr"""
p[0] = Node("Not")
p[0].var = p[2]