本文整理汇总了Python中tree.Node.funcInfo方法的典型用法代码示例。如果您正苦于以下问题:Python Node.funcInfo方法的具体用法?Python Node.funcInfo怎么用?Python Node.funcInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree.Node
的用法示例。
在下文中一共展示了Node.funcInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: p_funDecl
# 需要导入模块: from tree import Node [as 别名]
# 或者: from tree.Node import funcInfo [as 别名]
def p_funDecl(p):
'''funDecl : typeSpecifier IDENTIFIER LPAREN formalDeclList RPAREN funBody'''
global local_scope
#print "Function %s left local scope. Local scope contains "
#print local_scope
all_local_scopes[p[2]] = local_scope
p[0] = Node("funDecl", p[1:])
p[0].funcInfo = {'return': getTerminals(p[1])[0], 'numparams':len(local_scope), 'params': local_scope, 'name': p[2]}
#add function info to tree, and also to the functions.
#check if the function has already been defined.
match = False
for function in functions:
if function['name'] == p[0].funcInfo['name']:
global syntaxerrs
print "Syntax Error: Function %s re-declared near line %s.\n" % (function['name'], p.lexer.lineno)
syntaxerrs += 1
match = True
if not match:
functions.append(p[0].funcInfo)
local_scope = []