def test_get(self): d = Dictionary() d['raymond'] = 'red' self.assertEqual(d['raymond'], 'red') d['rachel'] = 'blue' self.assertEqual(d['rachel'], 'blue') d['critter'] = 'yellow' self.assertEqual(d.get('raymond', 'not found'), 'red') self.assertEqual(d.get('john', 'not found'), 'not found')
def action20000(self, lineNumber, symbol): # symbol = symbol['name'] dictionary = Dictionary() if not dictionary.isFound(symbol): E.E(lineNumber, 0).typeUnknown(symbol) type = dictionary.get(symbol) ss1 = SS1() ss1.push(type)
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)
def getType(self, right): dictionary = Dictionary() isright = isinstance(right, AtrClasses.AttrElemAction) or isinstance(right, AtrClasses.AttrVar) or isinstance(right, AtrClasses.AttrIntConst) or isinstance(right, AtrClasses.AttrFloatConst) or isinstance(right, AtrClasses.AttrStringConst) or isinstance(right, AtrClasses.AttrField) or isinstance(right, AtrClasses.AttrParam) or isinstance(right, AtrClasses.AttrRelation) if isright: rightType = right.type else: right = right.getValue() rightType = dictionary.get(right) if not rightType.has_key('object'): E.E(self.lineNumber, 0).unknownIdentifier(right) rightType = rightType['object'].type return rightType
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)