Advertisement
ShrekOP

SymbolTable.py

Dec 16th, 2022
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import pandas as pd
  2. f = open("filename.txt" , 'r')
  3. data = (f.read()).split("\n")
  4. f.close()
  5.  
  6. f.open()
  7. data_in_list = (f.read()).split()
  8. f.close()
  9.  
  10. MOT = {
  11. 'ADD' : ('IS' , 1),
  12. 'SUB' : ('IS' , 1),
  13. 'DIV' : ('IS' , 1),
  14. 'START' : ('AD' , 1)
  15. }
  16.  
  17. ST = pd.DataFrame(columns = ['index' , 'symbol' , 'address'])
  18. counter = 0
  19. index = 1
  20.  
  21. for i in data_in_list:
  22. if i.isalpha():
  23. if i not in MOT.keys():
  24. for y in data:
  25. d = y.split():
  26. if i in d:
  27. entry1 = (index , i , data.index(y))
  28. ST.loc[counter] = entry1
  29. counter += 1
  30. index += 1
  31.  
  32.  
  33. print(ST)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement