Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional Error (hofstadter.py:76) #2

Closed
cadebrown opened this issue Nov 9, 2021 · 0 comments
Closed

Conditional Error (hofstadter.py:76) #2

cadebrown opened this issue Nov 9, 2021 · 0 comments

Comments

@cadebrown
Copy link

Error:

Traceback (most recent call last):
  File "/home/cade/programs/hofstadter/hofstadter.py", line 221, in <module>
    evaluator = Evaluator([Line(x) for x in rawlines])
  File "/home/cade/programs/hofstadter/hofstadter.py", line 221, in <listcomp>
    evaluator = Evaluator([Line(x) for x in rawlines])
  File "/home/cade/programs/hofstadter/hofstadter.py", line 17, in __init__
    self.tokenize()
  File "/home/cade/programs/hofstadter/hofstadter.py", line 23, in tokenize
    t = self.nextToken()
  File "/home/cade/programs/hofstadter/hofstadter.py", line 76, in nextToken
    while not self.text[self.index].isspace() or escaped and self.index < length:
IndexError: string index out of range

https://github.com/AZHenley/hofstadter/blob/main/hofstadter.py#L76 has the conditional checks out of order, it change from:

            while not self.text[self.index].isspace() or escaped and self.index < length:

to:

            while self.index < length and not self.text[self.index].isspace() or escaped:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant