Ejemplo n.º 1
0
    def enterVar_decl(self, ctx:LittleExprParser.Param_decl_listContext):
        varType = ctx.getChild(0).getText()
        idListTree = ctx.getChild(1)
        identifier = idListTree.getChild(0).getText()

        self.addSymbolToTable(identifier, varType, declType=self.declType)
        self.printSymbolTable.append("name {0} type {1}\r".format(identifier,varType))

        idTailTree = idListTree.getChild(1)        
        while(idTailTree.getChildCount() != 0):
            identifier = idTailTree.getChild(1).getText()
            self.addSymbolToTable(identifier, varType, declType=self.declType)
            self.printSymbolTable.append("name {0} type {1}\r".format(identifier,varType))
            idTailTree = idTailTree.getChild(2)
        pass
Ejemplo n.º 2
0
 def enterParam_decl(self, ctx:LittleExprParser.Param_decl_listContext):
     varType = ctx.getChild(0).getText()
     identifier = ctx.getChild(1).getChild(0).getText()
     self.addSymbolToTable(identifier, varType, declType="FUNCTPARAM")
     self.printSymbolTable.append("name {0} type {1}\r".format(identifier,varType))
Ejemplo n.º 3
0
 def enterString_decl(self, ctx:LittleExprParser.Param_decl_listContext):
     identifier = ctx.getChild(1).getText()
     value = ctx.getChild(3).getText()
     self.addSymbolToTable(identifier, "STRING", value, declType=self.declType)
     self.printSymbolTable.append("name {0} type STRING value {1}\r".format(identifier, value))
     pass