本文整理汇总了Python中symbol.atom方法的典型用法代码示例。如果您正苦于以下问题:Python symbol.atom方法的具体用法?Python symbol.atom怎么用?Python symbol.atom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类symbol
的用法示例。
在下文中一共展示了symbol.atom方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_op
# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import atom [as 别名]
def get_op(cls, op):
ops = {
symbol.test: cls.test,
symbol.and_test: cls.and_test,
symbol.atom: cls.atom,
symbol.comparison: cls.comparison,
'not in': lambda x, y: x not in y,
'in': lambda x, y: x in y,
'==': operator.eq,
'!=': operator.ne,
'<': operator.lt,
'>': operator.gt,
'<=': operator.le,
'>=': operator.ge,
}
if hasattr(symbol, 'or_test'):
ops[symbol.or_test] = cls.test
return ops[op]
示例2: Annotate
# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import atom [as 别名]
def Annotate(cls, nodes):
if not nodes:
return None
if nodes[0].type != symbol.atom:
return None
if not nodes[0].children or nodes[0].children[0].type != token.NAME:
return None
for i in xrange(1, len(nodes)):
if not nodes:
break
if nodes[i].type != symbol.trailer:
break
if len(nodes[i].children) != 2:
break
if (nodes[i].children[0].type != token.DOT or
nodes[i].children[1].type != token.NAME):
break
else:
i = len(nodes)
return [cls(nodes[:i])] + nodes[i:]
示例3: atom
# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import atom [as 别名]
def atom(cls, nodelist):
t = nodelist[1][0]
if t == token.LPAR:
if nodelist[2][0] == token.RPAR:
raise SyntaxError("Empty parentheses")
return cls.interpret(nodelist[2])
msg = "Language feature not supported in environment markers"
raise SyntaxError(msg)
示例4: get_op
# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import atom [as 别名]
def get_op(cls, op):
ops = {
symbol.test: cls.test,
symbol.and_test: cls.and_test,
symbol.atom: cls.atom,
symbol.comparison: cls.comparison,
'not in': lambda x, y: x not in y,
'in': lambda x, y: x in y,
'==': operator.eq,
'!=': operator.ne,
}
if hasattr(symbol, 'or_test'):
ops[symbol.or_test] = cls.test
return ops[op]
示例5: power
# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import atom [as 别名]
def power(self, nodelist):
# power: atom trailer* ('**' factor)*
node = self.com_node(nodelist[0])
for i in range(1, len(nodelist)):
elt = nodelist[i]
if elt[0] == token.DOUBLESTAR:
return Power([node, self.com_node(nodelist[i+1])],
lineno=elt[2])
node = self.com_apply_trailer(node, elt)
return node
示例6: atom
# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import atom [as 别名]
def atom(self, nodelist):
return self._atom_dispatch[nodelist[0][0]](nodelist)
示例7: get_docstring
# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import atom [as 别名]
def get_docstring(self, node, n=None):
if n is None:
n = node[0]
node = node[1:]
if n == symbol.suite:
if len(node) == 1:
return self.get_docstring(node[0])
for sub in node:
if sub[0] == symbol.stmt:
return self.get_docstring(sub)
return None
if n == symbol.file_input:
for sub in node:
if sub[0] == symbol.stmt:
return self.get_docstring(sub)
return None
if n == symbol.atom:
if node[0][0] == token.STRING:
s = ''
for t in node:
s = s + eval(t[1])
return s
return None
if n == symbol.stmt or n == symbol.simple_stmt \
or n == symbol.small_stmt:
return self.get_docstring(node[0])
if n in _doc_nodes and len(node) == 1:
return self.get_docstring(node[0])
return None
示例8: atom
# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import atom [as 别名]
def atom(cls, nodelist):
t = nodelist[1][0]
if t == token.LPAR:
if nodelist[2][0] == token.RPAR:
raise SyntaxError("Empty parentheses")
return cls.interpret(nodelist[2])
raise SyntaxError("Language feature not supported in environment markers")