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


Python Dictionary.setObject方法代码示例

本文整理汇总了Python中Dictionary.Dictionary.setObject方法的典型用法代码示例。如果您正苦于以下问题:Python Dictionary.setObject方法的具体用法?Python Dictionary.setObject怎么用?Python Dictionary.setObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dictionary.Dictionary的用法示例。


在下文中一共展示了Dictionary.setObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: action4000

# 需要导入模块: from Dictionary import Dictionary [as 别名]
# 或者: from Dictionary.Dictionary import setObject [as 别名]
    def action4000(self, lineNumber, symbol):
#        symbol = symbol['name']
        ss1 = SS1()
        value = ss1.pop()
        name = ss1.pop()
        name.bind(value)
        dictionary = Dictionary()
        dictionary.setObject(name.name, name)
开发者ID:vicpi,项目名称:syntax-semantic-analyser,代码行数:10,代码来源:SemanticActions.py

示例2: action7000

# 需要导入模块: from Dictionary import Dictionary [as 别名]
# 或者: from Dictionary.Dictionary import setObject [as 别名]
    def action7000(self, lineNumber, symbol):
#        symbol = symbol['name']
        ss1 = SS1()
        record = ss1.pop();
        dictionary = Dictionary()
        # @todo make interface for array, record, diapason and id
        _class = dictionary.get(record.name.name)['class']
        dictionary.setObject(record.name.name, record)
        row = self.getRow(record.name.name, _class, record)
开发者ID:vicpi,项目名称:syntax-semantic-analyser,代码行数:11,代码来源:SemanticActions.py

示例3: action6000

# 需要导入模块: from Dictionary import Dictionary [as 别名]
# 或者: from Dictionary.Dictionary import setObject [as 别名]
    def action6000(self, lineNumber, symbol):
#        symbol = symbol['name']        
        ss1 = SS1()
        dictionary = Dictionary()
        type = ss1.pop()
        while ss1.top() != None:
            name = ss1.pop()
            name.bindType(type['name'])
            dictionary.setObject(name.name, name)
        ss1.pop()
开发者ID:vicpi,项目名称:syntax-semantic-analyser,代码行数:12,代码来源:SemanticActions.py

示例4: action22

# 需要导入模块: from Dictionary import Dictionary [as 别名]
# 或者: from Dictionary.Dictionary import setObject [as 别名]
    def action22(self, lineNumber, symbol):
        ' not done '
#        symbol = symbol['name']
        dictionary = Dictionary()
        ss1 = SS1()
        ss1.push(symbol)
        
        _restype = ss1.pop()
        _attrProc = ss1.pop()
        _attrProc.setResType(_restype)
        dictionary.setObject(_attrProc.name, _attrProc)
开发者ID:vicpi,项目名称:syntax-semantic-analyser,代码行数:13,代码来源:SemanticActions.py

示例5: action21

# 需要导入模块: from Dictionary import Dictionary [as 别名]
# 或者: from Dictionary.Dictionary import setObject [as 别名]
    def action21(self, lineNumber, symbol):
        ' not done '
#        symbol = symbol['name']
        dictionary = Dictionary()
        _attrProc = AtrClasses.AttrProc()
        ss1 = SS1()
        ss1.push(symbol)
        
        while not ss1.top() == 'proc_params':
            _type = ss1.pop()
            while not ss1.top() is None:
                attr = ss1.pop()
                attr.type = dictionary.get(symbol)
                _attrProc.addParam(attr)
            ss1.pop()
        ss1.pop()
        _name = ss1.pop()
        _attrProc.setName(_name)
        dictionary.setObject(_name, _attrProc)
        ss1.push(_attrProc)
开发者ID:vicpi,项目名称:syntax-semantic-analyser,代码行数:22,代码来源:SemanticActions.py

示例6: class

# 需要导入模块: from Dictionary import Dictionary [as 别名]
# 或者: from Dictionary.Dictionary import setObject [as 别名]

#.........这里部分代码省略.........
        i = 0
        First = []
        while i < len(Rule):
            if (Rule[i] == "[["):
                First.append(Rule[i+1])
                i = self.findElement(Rule, "]]", i+1)
            elif (Rule[i] == "{"):
                First.append(Rule[i+1])
                i = self.findElement(Rule, "}", i+1)
            else:
                First.append(Rule[i])
                return First
            i += 1
        return First

    def nextLevel(self, List):
        """
        Returns list with next level - non-terminals
        """
        out = []
        for symbol in List:
            if (self.isTerminal(symbol)):
                out.append(symbol)
            else:
                for _R in Rules[symbol]:
                    for symbol2 in self.PossiblePrefixes(_R):
                        out.append(symbol2)
        return out

    def findFirstSymbols(self, Rule):
        """
        Effects: Return list of first symbol
        """
        List = self.PossiblePrefixes(Rule)
        while (self.hasnonTerminals(List)):
            List = self.nextLevel(List)
        return List

    def hasnonTerminals(self, List):
        """
        Effects: Return True if list contains at least one non-terminal
        """
        for symbol in List:
            if not self.isTerminal(symbol):
                return True
        return False

    def isDerivedFrom(self, ruleSymbol):
        if (self.isTerminal(ruleSymbol)):
            return ruleSymbol == self.inputSymbol
        else:
            if ruleSymbol == self.inputSymbol:
                return True
            else:
                return (not self.chooseAppropriateRule(ruleSymbol) == None)

    def isSemanticAction(self, ruleSymbol):
        """
        Effects: Returns True if semantic action occurs and needs to be done
        """
        return ruleSymbol[0] == '#'

    def extractSemanticAction(self, ruleSymbol):
        """
        Effects: Return number of semantic action
        Requires: ruleSymbol must be in format "#\d+"
        """
        return ruleSymbol[1:]

    def addToDictionary(self):
        if (not self.lexema.isFound(self.word)):
            # @todo extract in comfortable place
            self.lexema.addSymbol( {"name" : self.word, 'class' : self.inputSymbol} )
            if self.inputSymbol == 'intConst':
                self.lexema.setObject( self.word, AtrClasses.AttrIntConst(self.word) )
            if self.inputSymbol == 'floatConst':
                self.lexema.setObject( self.word, AtrClasses.AttrFloatConst(self.word) )
            if self.inputSymbol == 'StringConst':
                self.lexema.setObject( self.word, AtrClasses.AttrStringConst(self.word) )

    def doSemanticAction(self, RuleItem, i):
        currentRuleSymbol = None
        if i+1 < len(RuleItem): currentRuleSymbol = RuleItem[i+1]
        if currentRuleSymbol is None: return False

        if self.isSemanticAction(currentRuleSymbol):
            semanticActionNumber = self.extractSemanticAction(currentRuleSymbol)
            if (semanticActionNumber.find(',') == -1):
                SemanticActions().switchAction(self.inputstream.lineNumber, semanticActionNumber, self.word)
            else:
                (semanticActionNumber1, semanticActionNumber2) = semanticActionNumber.split(',')
                SemanticActions().switchAction(self.inputstream.lineNumber, semanticActionNumber1, self.word)
                SemanticActions().switchAction(self.inputstream.lineNumber, semanticActionNumber2, self.word)
                

    def getRuleSymbol(self, RuleItem, i):
        if (i < len(RuleItem)):
            return RuleItem[i]
        else:
            return None
开发者ID:vicpi,项目名称:syntax-semantic-analyser,代码行数:104,代码来源:Parser.py


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