Made the symbols dictonary a dic of dics, added the direction field to it

This commit is contained in:
Mariano Uvalle 2019-04-11 21:49:18 +00:00
parent 92b679e13c
commit 743ea07796

View file

@ -16,19 +16,19 @@ for i in range(50):
avail.append('T' + str(i)) avail.append('T' + str(i))
# Operations related to the table of symbols # Operations related to the table of symbols
symbolsNames = []
symbolsTypes = []
symbols = {} symbols = {}
currentIndex = 0
# # Implementation using lists.
# def addSymbol(name, symbolType):
# symbolsNames.append(name)
# symbolsTypes.append(symbolType)
# Implementation using a dictionary # Implementation using a dictionary
def addSymbol(name, symbolType): def addSymbol(name, symbolType):
global currentIndex
initialValue = 0 if symbolType == 'integer' else 0.0 initialValue = 0 if symbolType == 'integer' else 0.0
symbols[name] = [symbolType, initialValue] symbols[name] = {
'symbolType': symbolType,
'value': initialValue,
'direction': currentIndex
}
currentIndex += 1
def peek(list): def peek(list):
if (len(list) == 0): if (len(list) == 0):