Reputation: 1
i have done some project of Nand2tetris for my class and i have huge probleme on the 10 , it's about the reader i think after the evaluation of the 3 first token it's say that the next token is None but it detect the characters of the next words so idk what to do i've been working on that bug since 4 days ago and i'm starting to be out of time (sorry for my poor english)
Here my ¨Process who globaly write most of the text in the xml document:
def process(self, str):
token = self.lexer.next()
print('next token from process ='+token.__str__())
if (token is not None and token['token'] == str):
print('le token est '+token['token'])
self.xml.write(f"""<{token['type']}>{token['token']}</{token['type']}>\n""")
else:
self.error(token)
And here the error :
Traceback (most recent call last):
File "C:\Users\PC\Documents\informatique\Projet_VM_Translator\d-3\Jack\Jack\ParserXML.py", line 369, in <module>
parser.jackclass()
File "C:\Users\PC\Documents\informatique\Projet_VM_Translator\d-3\Jack\Jack\ParserXML.py", line 35, in jackclass
self.subroutineDec()
File "C:\Users\PC\Documents\informatique\Projet_VM_Translator\d-3\Jack\Jack\ParserXML.py", line 73, in subroutineDec
self.xml.write(f"""<{token['type']}>{token['token']}</{token['type']}>\n""")
~~~~~^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
i hope someone can find the solution and if anybody how to do a syntax tree as a table I'll be really happy
I've tried to not use the process function and write the things in the xml documents by a method , I've tried to find if that was not a problem from my reader.py code but I didn't find anything so idk and normaly the only things in that project that can be wrong is in the parser.py cause the rest is normally good cause it's made by some teachers(normally good cause some of them do mistakes too sometimes)
i've a put link to a wetransfer with my whole project if you want to try: https://www.swisstransfer.com/d/92bb994d-a051-46dd-b762-48dfcfca420b
Upvotes: 0
Views: 35