{"action":"created","issue":{"url":"https://api.github.com/repos/idank/bashlex/issues/8","repository_url":"https://api.github.com/repos/idank/bashlex","labels_url":"https://api.github.com/repos/idank/bashlex/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/idank/bashlex/issues/8/comments","events_url":"https://api.github.com/repos/idank/bashlex/issues/8/events","html_url":"https://github.com/idank/bashlex/pull/8","id":135057517,"number":8,"title":"parse empty lines and comments","user":{"login":"blurrymoi","id":11298672,"avatar_url":"https://avatars.githubusercontent.com/u/11298672?v=3","gravatar_id":"","url":"https://api.github.com/users/blurrymoi","html_url":"https://github.com/blurrymoi","followers_url":"https://api.github.com/users/blurrymoi/followers","following_url":"https://api.github.com/users/blurrymoi/following{/other_user}","gists_url":"https://api.github.com/users/blurrymoi/gists{/gist_id}","starred_url":"https://api.github.com/users/blurrymoi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blurrymoi/subscriptions","organizations_url":"https://api.github.com/users/blurrymoi/orgs","repos_url":"https://api.github.com/users/blurrymoi/repos","events_url":"https://api.github.com/users/blurrymoi/events{/privacy}","received_events_url":"https://api.github.com/users/blurrymoi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-20T10:12:52Z","updated_at":"2016-02-21T21:54:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/idank/bashlex/pulls/8","html_url":"https://github.com/idank/bashlex/pull/8","diff_url":"https://github.com/idank/bashlex/pull/8.diff","patch_url":"https://github.com/idank/bashlex/pull/8.patch"},"body":"Allows to parse whole files.\r\n\r\nThe idea is that I force-reduce on inputunit -> NEWLINE rule and accept by creating a dummy newline node that only retains position (needed for further parsing). These nodes are filtered in the end to prevent output such as:\r\nNewlineNode\r\nNewlineNode\r\nCommandNode\r\n...\r\n\r\nI handpicked the relevant changes, so I hope I didn't miss anything."},"comment":{"url":"https://api.github.com/repos/idank/bashlex/issues/comments/186925993","html_url":"https://github.com/idank/bashlex/pull/8#issuecomment-186925993","issue_url":"https://api.github.com/repos/idank/bashlex/issues/8","id":186925993,"user":{"login":"idank","id":1277636,"avatar_url":"https://avatars.githubusercontent.com/u/1277636?v=3","gravatar_id":"","url":"https://api.github.com/users/idank","html_url":"https://github.com/idank","followers_url":"https://api.github.com/users/idank/followers","following_url":"https://api.github.com/users/idank/following{/other_user}","gists_url":"https://api.github.com/users/idank/gists{/gist_id}","starred_url":"https://api.github.com/users/idank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idank/subscriptions","organizations_url":"https://api.github.com/users/idank/orgs","repos_url":"https://api.github.com/users/idank/repos","events_url":"https://api.github.com/users/idank/events{/privacy}","received_events_url":"https://api.github.com/users/idank/received_events","type":"User","site_admin":false},"created_at":"2016-02-21T21:54:27Z","updated_at":"2016-02-21T21:54:27Z","body":"Maybe. I tried a more naive approach:\r\n\r\n@@ -593,6 +597,9 @@ def parse(s, strictmode=True, expansionlimit=None, convertpos=False):\r\n     ef.visit(parts[-1])\r\n     index = max(parts[-1].pos[1], ef.end) + 1\r\n     while index < len(s):\r\n+        if s[index].isspace():\r\n+            index += 1\r\n+            continue\r\n         part = _parser(s[index:], strictmode=strictmode).parse()\r\n\r\n         if not isinstance(part, ast.node):\r\n\r\nBut then started thinking about recursive parsing and indeed this fails when there's a newline in a command substitution, try: a $(b\\nc). I also tried your fix and it fails as well. I'll try debugging this for a bit and see if I can find how the C parser deals with this.\r\n\r\nI'll still merge this, but let's see if we can fix this case too."}}