-
Notifications
You must be signed in to change notification settings - Fork 37
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
Fix parsing files with multiple line continuations #937
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I agree that it might be desirable to re-write this at some point (although I am sure no one will ever have time for that).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand how this change resolves the above issue, but seems like it soils be pretty easy to add a test to catch this, right?
I now stared at this for some time and also don't fully understand how this fixes the issue. |
I gave it a shot? I'm honestly not too sure how I could make it clearer or what I could say, sorry. The This is a very common first mistake when writing state-machine parsers (I've made it myself). At risk of sounding sanctimonious, I think this is decent evidence for why we shouldn't be maintaining our own file parser when the problem's been solved well in so many other places. |
I was referring to
For example, I'm reading |
The conditionals handle the 2 extra states possible when parsing a line, for a total of 3:
This is a bog-standard 3-state parser, like CS101 assignment simple, which it looks like Josh threw together very early in Parthenon development. I heavily expect that if either of you spend a few minutes with it, you could understand exactly what's going on, as I did to fix the bug flushing buffers. I do agree the variables could be named better, and I'll add basic comments outlining the states so it can be understood a little more easily. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bprather the naming is much clearer now. I know we don't want to put too much effort into this, as it's just a simpler parser, but I do think some unit tests are in order if anyone ever has time.
(Or a rewrite, as @lroberts36 suggests.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bprather
The updated comments make this indeed much easier to parse (pun intended ;))
Fixes #936
PR Checklist