本文整理匯總了Python中compiler.ast.Add方法的典型用法代碼示例。如果您正苦於以下問題:Python ast.Add方法的具體用法?Python ast.Add怎麽用?Python ast.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類compiler.ast
的用法示例。
在下文中一共展示了ast.Add方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _Getattr
# 需要導入模塊: from compiler import ast [as 別名]
# 或者: from compiler.ast import Add [as 別名]
def _Getattr(self, t):
""" Handle getting an attribute of an object
"""
if isinstance(t.expr, (Div, Mul, Sub, Add)):
self._write('(')
self._dispatch(t.expr)
self._write(')')
else:
self._dispatch(t.expr)
self._write('.'+t.attrname)
示例2: expr
# 需要導入模塊: from compiler import ast [as 別名]
# 或者: from compiler.ast import Add [as 別名]
def expr(self, node, current_klass):
if isinstance(node, ast.Const):
return self._const(node)
# @@@ not sure if the parentheses should be here or in individual operator functions - JKT
elif isinstance(node, ast.Mul):
return " ( " + self._mul(node, current_klass) + " ) "
elif isinstance(node, ast.Add):
return " ( " + self._add(node, current_klass) + " ) "
elif isinstance(node, ast.Sub):
return " ( " + self._sub(node, current_klass) + " ) "
elif isinstance(node, ast.Div):
return " ( " + self._div(node, current_klass) + " ) "
elif isinstance(node, ast.Mod):
return self._mod(node, current_klass)
elif isinstance(node, ast.UnaryAdd):
return self._unaryadd(node, current_klass)
elif isinstance(node, ast.UnarySub):
return self._unarysub(node, current_klass)
elif isinstance(node, ast.Not):
return self._not(node, current_klass)
elif isinstance(node, ast.Or):
return self._or(node, current_klass)
elif isinstance(node, ast.And):
return self._and(node, current_klass)
elif isinstance(node, ast.Invert):
return self._invert(node, current_klass)
elif isinstance(node, ast.Bitand):
return "("+self._bitand(node, current_klass)+")"
elif isinstance(node, ast.LeftShift):
return self._bitshiftleft(node, current_klass)
elif isinstance(node, ast.RightShift):
return self._bitshiftright(node, current_klass)
elif isinstance(node, ast.Bitxor):
return "("+self._bitxor(node, current_klass)+")"
elif isinstance(node, ast.Bitor):
return "("+self._bitor(node, current_klass)+")"
elif isinstance(node, ast.Compare):
return self._compare(node, current_klass)
elif isinstance(node, ast.CallFunc):
return self._callfunc(node, current_klass)
elif isinstance(node, ast.Name):
return self._name(node, current_klass)
elif isinstance(node, ast.Subscript):
return self._subscript(node, current_klass)
elif isinstance(node, ast.Getattr):
return self._getattr(node, current_klass)
elif isinstance(node, ast.List):
return self._list(node, current_klass)
elif isinstance(node, ast.Dict):
return self._dict(node, current_klass)
elif isinstance(node, ast.Tuple):
return self._tuple(node, current_klass)
elif isinstance(node, ast.Slice):
return self._slice(node, current_klass)
elif isinstance(node, ast.Lambda):
return self._lambda(node, current_klass)
else:
raise TranslationError("unsupported type (in expr)", node)