idank / bashlex

Python parser for bash
GNU General Public License v3.0
550 stars 94 forks source link

Multiple new lines at end of file #74

Closed lacraig2 closed 1 year ago

lacraig2 commented 2 years ago

Working off of the base for PR #71 so this will be relevant after that PR is merged.

Multiple new lines at the end of an input triggers an "Unexpected EOF" error in line 546, in p_error.

Minimal example:

from bashlex import parse

parts = parse('cmd1\n\n')

This is not the case for a single newline at the end of the file (as of PR #71).

idank commented 2 years ago

I'm a bit hesitant to merge it then. Could a fix alter the new logic significantly?

lacraig2 commented 2 years ago

That depends on how it's implemented. This is such a narrow case that I could see it being handled at preprocessing (i.e. before handing to the lexer).

idank commented 2 years ago

Got it, that makes sense. I'm a bit cautious to steer from bash but if we think the direction we've taken with these changes is the right one then I'm good to merge.