-
Notifications
You must be signed in to change notification settings - Fork 20
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
Lexing fails for empty lines before a continuation line with DOS line endings #141
Comments
Interesting. What parser/Fortran version are you using for this? I can't replicate this with I can see why this might happen, since the continuation handling works via taking X characters (Lexer.FixedForm): isContinuation :: AlexInput -> Bool
isContinuation ai =
take 6 _next7 == "\n " && not (last _next7 `elem` [' ', '0', '\n', '\r'])
where
_next7 = takeNChars 7 ai It looks like it works by not consuming the newline. If for <0,st,keyword,iif,assn,doo> \r ; but I don't know well enough to confirm. Could you attach the example files you're using? Since GitHub swallows at least the newline formatting. |
This is on master, and I get that error code with or without Attached the file here, seems to have kept line formatting parsing-bug.txt. And yeah I thought it would be somewhere along those lines. The continuation line logic is separate from the token regex logic, so I don't think line 87 will be used there, but I tried changing the continuation line logic in various places to deal with |
Thanks. Can't figure out why I continue to get the same parse error on both Unix and DOS style, I'm building from master 72b6347. You're right, it should handle them both (gfortran does). I'll look into it further. Wonder if my issue reproducing can't be related to platform. Are you on Mac or Linux? |
Huh that is odd, I definitely get it to work with standard unix line endings. This is on mac, just tried on a linux machine and it does also successfully parse with Unix endings but not DOS, although strangely it gives says Are you running windows then? I'm also building from the same commit. |
I'm on Linux. It keeps failing on the By removing the middle empty line, I've changed my error to a parsing error. I noticed that the end of the snippet gets lexed as |
OK, it looks like all our parsers have varying behaviour on what to do with The issue lies in the empty line. Remove it and both parse. My initial thought is:
I wonder if the line provided in the error was due to the inserted newline not having its position set correctly? Feels like it should have errored on line 3. I'll see if I can print the token list before it errors out to see if this fits what is happening. |
Yes sorry should have said, we use legacy 77 for everything so that's what I default to when running fortran-src :) This isn't hugely problematic btw, I've only encountered one file with this. I thought it should be an easy enough fix, but something odd is going on. |
It's a bug (and the other issue related to parser versions probably is too). I swear I skimmed something in the lexer that seemed to attempt to skip adding a newline token in certain situations. Adding more empty lines before the continuation still works on Unix-style indicating to me that it skips them all. Adding support there for skipping Win-style newlines too should fix this |
This feels related to #45 (I think fixed in #58). The provided example: SUBROUTINE lex
IMPLICIT NONE
INTEGER X, Y,
c break
& ZZ
END works and lexes identical output for DOS and Unix line endings (using Perhaps lexing empty lines before a continuation wasn't directly intended, and working for empty |
The following fails to lex properly when the file has DOS line endings of
\r\n
Giving the error
But it does parse correctly with unix line endings of
\n
.I believe it's something to do with the logic for continuation lines which should be dealing with this, but I've not been able to pinpoint what needs fixing.
The text was updated successfully, but these errors were encountered: