-
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
F90 parsing failure for multiple comments in case constructs #267
Comments
(For info on trying to solve this, single comments were enabled by this commit: 401fd71) |
Nice catch. The relevant parser snippet in F90 is here: -- We store line comments as statements, but this raises an issue: we have
-- nowhere to place comments after a SELECT CASE but before a CASE. So we drop
-- them. The inner CASES_ rule does /not/ use this, because comments can always
-- be parsed as belonging to to the above CASE block.
CASES :: { ([(AList Index A0, [Block A0])], Maybe [Block A0], SrcSpan, Maybe (Expression A0)) }
: COMMENT_BLOCK CASES_ { $2 }
| CASES_ { $1 }
CASES_ :: { ([(AList Index A0, [Block A0])], Maybe [Block A0], SrcSpan, Maybe (Expression A0)) }
: maybe(INTEGER_LITERAL) case '(' INDICIES ')' MAYBE_COMMENT NEWLINE BLOCKS CASES_
{ let (clauses, defaultCase, endSpan, endLabel) = $9
in ((fromReverseList $4, reverse $8) : clauses, defaultCase, endSpan, endLabel) }
| maybe(INTEGER_LITERAL) case default MAYBE_COMMENT NEWLINE BLOCKS END_SELECT
{ let (endSpan, endLabel) = $7
in ([], Just $6, endSpan, endLabel) }
| END_SELECT
{ let (endSpan, endLabel) = $1
in ([], Nothing, endSpan, endLabel) }
-- ...
MAYBE_COMMENT :: { Maybe Token }
: comment { Just $1 }
| {- EMPTY -} { Nothing } Previously, we would fail on parsing any comments there. Maybe we could change from |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following code fails to parse in the f90 and above parsers
Outputting:
It appears the
MAYBE_COMMENT
grammar used in quite a few places, seems to only accept a single comment, but is structured such that getting it to accept multiple comments causes other grammars to fail. Having a single comment (or oddly an inline comment afterselect case (x)
and another line comment), parses correctly.The text was updated successfully, but these errors were encountered: