本文整理汇总了Python中Analyzer.Analyzer.endProcOrFunc方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.endProcOrFunc方法的具体用法?Python Analyzer.endProcOrFunc怎么用?Python Analyzer.endProcOrFunc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyzer.Analyzer
的用法示例。
在下文中一共展示了Analyzer.endProcOrFunc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Parser
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import endProcOrFunc [as 别名]
#.........这里部分代码省略.........
identList = []
identList = self.identifierList();
self.match('MP_COLON')
varType = self.type()
for name in identList:
self.symbolTableStack.getCurrentTable().insertEntry(name, 'dparam', varType, '', self.firstIdFlag)
self.firstIdFlag = False
else:
self.error("Identifier")
def variableParameterSection(self):
if self.lookahead is 'MP_VAR': # 24 VariableParameterSection -> "var" IdentifierList ":" Type
self.match('MP_VAR')
identList = []
identList = self.identifierList();
self.match('MP_COLON')
varType = self.type()
for name in identList:
self.symbolTableStack.getCurrentTable().insertEntry(name, 'iparam', varType, '', self.firstIdFlag)
self.firstIdFlag = False
else:
self.error("Var")
def statementPart(self):
if self.lookahead is 'MP_BEGIN': # 25 StatementPart -> CompoundStatement
label = self.symbolTableStack.getCurrentTable().label
self.analyzer.genLabel(label)
if label == 1:
self.analyzer.initMainAR()
self.compoundStatement()
self.symbolTableStack.getCurrentTable().printTable()
self.analyzer.endProcOrFunc(self.symbolTableStack.getCurrentTable())
self.symbolTableStack.popTable()
else:
self.error("Begin")
def compoundStatement(self):
if self.lookahead is 'MP_BEGIN': # 26 CompoundStatement -> "begin" StatementSequence "end"
self.match('MP_BEGIN')
self.analyzer.finishProcOrFuncAR()
self.statementSequence()
self.match('MP_END')
else:
self.error("begin")
def statementSequence(self):
if self.lookahead in ['MP_SCOLON', 'MP_IDENTIFIER', # 27 StatementSequence -> Statement StatementTail
'MP_BEGIN', 'MP_END', 'MP_READ',
'MP_WRITE', 'MP_IF', 'MP_ELSE',
'MP_REPEAT', 'MP_UNTIL', 'MP_WHILE',
'MP_FOR', 'MP_WRITELN']:
self.statement()
self.statementTail()
else:
self.error("'MP_SCOLON', 'MP_IDENTIFIER', 'MP_BEGIN', 'MP_END', 'MP_READ',\
'MP_WRITE', 'MP_IF', 'MP_ELSE', 'MP_REPEAT', 'MP_UNTIL', 'MP_WHILE',\
'MP_FOR', 'MP_WRITELN'")
def statementTail(self):
if self.lookahead is 'MP_SCOLON': # 28 StatementTail -> ";" Statement StatementTail
self.match('MP_SCOLON')