本文整理汇总了Python中Analyzer.Analyzer.genCall方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.genCall方法的具体用法?Python Analyzer.genCall怎么用?Python Analyzer.genCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyzer.Analyzer
的用法示例。
在下文中一共展示了Analyzer.genCall方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Parser
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import genCall [as 别名]
#.........这里部分代码省略.........
self.error("(, identifier, +, -, any literal value, not")
def stepValue(self):
if self.lookahead is 'MP_TO': # 59 StepValue -> "to"
return self.match('MP_TO')
elif self.lookahead is 'MP_DOWNTO': # 60 StepValue -> "downto"
return self.match('MP_DOWNTO')
else:
self.error("to, downto")
def finalValue(self):
if self.lookahead in ['MP_LPAREN', 'MP_IDENTIFIER', # 61 FinalValue -> OrdinalExpression
'MP_PLUS', 'MP_MINUS',
'MP_FLOAT_LIT', 'MP_FIXED_LIT', 'MP_STRING_LIT',
'MP_NOT', 'MP_INTEGER_LIT',
'MP_TRUE', 'MP_FALSE']:
self.ordinalExpression()
else:
self.error("(, identifier, +, -, any literal value, not")
def procedureStatement(self):
if self.lookahead is 'MP_IDENTIFIER': # 62 ProcedureStatement -> ProcedureIdentifier OptionalActualParameterList
self.analyzer.incrementSP(4) # leave space for function/procedure
procedureName = self.procedureIdentifier()
self.optionalActualParameterList()
entry = self.symbolTableStack.getCurrentTable().find(procedureName)
if entry != None:
self.analyzer.genCall(entry['label'])
else:
print "Error: "+procedureName+" not found. It either doesn't exist or out of scope."
sys.exit()
else:
self.error("identifier")
def optionalActualParameterList(self):
if self.lookahead is 'MP_LPAREN': # 63 OptionalActualParameterList -> "(" ActualParameter ActualParameterTail ")"
self.match('MP_LPAREN')
self.actualParameter()
self.actualParameterTail()
self.match('MP_RPAREN')
elif self.lookahead in ['MP_SCOLON', 'MP_RPAREN', 'MP_END', 'MP_COMMA', # 64 OptionalActualParameterList -> lambda
'MP_THEN', 'MP_ELSE', 'MP_UNTIL', 'MP_TO',
'MP_DO', 'MP_DOWNTO', 'MP_EQUAL', 'MP_LTHAN',
'MP_GTHAN', 'MP_LEQUAL', 'MP_GEQUAL', 'MP_NEQUAL',
'MP_PLUS', 'MP_MINUS', 'MP_OR', 'MP_TIMES',
'MP_DIV', 'MP_MOD', 'MP_AND', 'MP_SLASH']:
return
else:
self.error(";, ), end, comma, then, else, until, to do, downto, an equality operator, an arithmetic operator, and, mod")
def actualParameterTail(self):
if self.lookahead is 'MP_COMMA': # 65 ActualParameterTail -> "," ActualParameter ActualParameterTail
self.match('MP_COMMA')
self.actualParameter()
self.actualParameterTail()
elif self.lookahead is 'MP_RPAREN': # 66 ActualParameterTail -> lambda