本文整理汇总了Python中Analyzer.Analyzer.incrementLabel方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.incrementLabel方法的具体用法?Python Analyzer.incrementLabel怎么用?Python Analyzer.incrementLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyzer.Analyzer
的用法示例。
在下文中一共展示了Analyzer.incrementLabel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Parser
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import incrementLabel [as 别名]
#.........这里部分代码省略.........
elif self.lookahead is "MP_FUNCTION": # 11 ProcedureAndFunctionDeclarationPart -> FunctionDeclaration ProcedureAndFunctionDeclarationPart
self.functionDeclaration()
self.procedureAndFunctionDeclarationPart()
elif self.lookahead is "MP_BEGIN": # 12 ProcedureAndFunctionDeclarationPart -> lambda
return
else:
self.error("Procedure, Function, Begin")
def procedureDeclaration(self):
if self.lookahead is "MP_PROCEDURE": # 13 ProcedureDeclaration -> ProcedureHeading ";" Block ";"
self.procedureHeading();
self.match('MP_SCOLON')
self.block()
self.match('MP_SCOLON')
else:
self.error("Procedure")
def functionDeclaration(self):
if self.lookahead is "MP_FUNCTION": # 14 FunctionDeclaration -> FunctionHeading ";" Block ";"
self.functionHeading()
self.match("MP_SCOLON")
self.block()
self.match("MP_SCOLON")
else:
self.error("Function")
def procedureHeading(self):
if self.lookahead is "MP_PROCEDURE": # 15 ProcedureHeading -> "procedure" procedureIdentifier OptionalFormalParameterList
self.match("MP_PROCEDURE")
name = self.procedureIdentifier()
self.analyzer.incrementLabel()
self.symbolTableStack.getCurrentTable().insertEntry(name, 'procedure', label=self.analyzer.getLabel())
self.symbolTableStack.addTable(name, self.analyzer.getLabel())
self.optionalFormalParameterList()
else:
self.error("Procedure")
def functionHeading(self):
if self.lookahead is "MP_FUNCTION": # 16 FunctionHeading -> "function" functionIdentifier OptionalFormalParameterList ":" Type
self.match("MP_FUNCTION")
name = self.functionIdentifier()
self.analyzer.incrementLabel()
self.symbolTableStack.getCurrentTable().insertEntry(name, 'function', label=self.analyzer.getLabel())
self.symbolTableStack.addTable(name, self.analyzer.getLabel())
self.optionalFormalParameterList()
self.match("MP_COLON")
type = self.type()
self.symbolTableStack.updateType(name, type)
else:
self.error("Function")
def optionalFormalParameterList(self):
if self.lookahead is 'MP_LPAREN': # 17 OptionalFormalParameterList -> "(" FormalParameterSection FormalParameterSectionTail ")"
self.match('MP_LPAREN')
self.firstIdFlag = True
self.formalParameterSection()
self.formalParameterSectionTail()
self.match('MP_RPAREN')
elif self.lookahead in ['MP_COLON', 'MP_SCOLON', 'MP_INTEGER', 'MP_FLOAT', 'MP_BOOLEAN', 'MP_STRING']: # 18 OptionalFormalParameterList -> lambda