当前位置: 首页>>代码示例>>Python>>正文


Python Analyzer.incrementLabel方法代码示例

本文整理汇总了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
开发者ID:agroves333,项目名称:compiler,代码行数:70,代码来源:Parser.py


注:本文中的Analyzer.Analyzer.incrementLabel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。