From 743ea077967780411617d8ec127a1d6fc549c673 Mon Sep 17 00:00:00 2001 From: AYM1607 Date: Thu, 11 Apr 2019 21:49:18 +0000 Subject: [PATCH] Made the symbols dictonary a dic of dics, added the direction field to it --- final_lang/fort.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/final_lang/fort.py b/final_lang/fort.py index f614670..3e35ee6 100644 --- a/final_lang/fort.py +++ b/final_lang/fort.py @@ -16,19 +16,19 @@ for i in range(50): avail.append('T' + str(i)) # Operations related to the table of symbols -symbolsNames = [] -symbolsTypes = [] symbols = {} - -# # Implementation using lists. -# def addSymbol(name, symbolType): -# symbolsNames.append(name) -# symbolsTypes.append(symbolType) +currentIndex = 0 # Implementation using a dictionary def addSymbol(name, symbolType): + global currentIndex 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): if (len(list) == 0):