-
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
Construct SrcSpans in Blocks #102
Comments
That sounds reasonable, I'm away for the next 5 days so I'll have to take a closer look next week; sorry! |
Can you clarify what you meant by
They should be, as AST node What may not be included is any line-comments that share the same line with a piece of code such as |
Through my own experience, I haven't been seeing the comments included in the Indeed, the comments are included for the Any thoughts on a way to tackle this? Or will this likely never be handled due to continuation lines? I can understand that it would be difficult to pull out a comment like a =
c Some comment I decided to put here for some reason
+ b - 43543 but I'm surprised that comments like c I am a strong, independent comment
a = b - 43543 wouldn't be included. |
The reason is that there is a case test in the fixed form lexer that
explicitly drops all comments if the legacy parser is running. I do not
know the reason this test was inserted so I've preserved it for the time
being.
…On Fri, 3 May 2019, 20:29 Anthony Burzillo, ***@***.***> wrote:
Through my own experience, I haven't been seeing the comments included in
the [[Block a]] within the BlIf, so I created a test!
master...burz:77legacy-comments
<master...burz:77legacy-comments>
Indeed, the comments are included for the fortran77Parser, *but not* for
the legacy77Parser. I believe that this is due to them being free and
fixed form, respectively.
Any thoughts on a way to tackle this? Or will this likely never be handled
due to continuation lines?
I can understand that it would be difficult to pull out a comment like
a =
c Some comment I decided to put here for some reason
+ b - 43543
but I'm surprised that comments like
c I am a strong, independent comment
a = b - 43543
wouldn't be included.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#102 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACCMOECGOCEIGUZN2SXSYDPTSHAJANCNFSM4HGLXFDQ>
.
|
ya - it does help my case. thanks! |
Note: I am going to present this issue in the context of
BlIf
but I am pretty sure it applies to other blocks as well.Currently
BlIf
construct has a fewSrcSpan
s that we can utilizeSrcSpan
of the block fromif
toendif
.SrcSpan
of each individual condition via theMaybe (Expression a)
s so long as the conditions are actually present.SrcSpan
s of the inner blocks that correspond to these conditions via[[Block a]]
.This covers 99% of the cases where
SrcSpan
s would be needed, but there is a case where these are not sufficient.Suppose I am creating a tool to rewrite
BlIf
code usingfortran-src
. First consider a simple exampleIf I know that
cond
is false, I would like to rewrite this asThis is simple enough to do with the
SrcSpan
of the overallBlIf
-- call thisifSS
-- combined with theSrcSpan
of theelse
branch (i.e. theSrcSpan
the final element in[[Block a]]
) that we'll callblockSS
, by rewriting from the beginning ofifSS
to the beginning ofblockSS
and then from the end ofblockSS
to the end ofifSS
.On the other hand if we have comments in our code
we would certainly like to keep these comments around!
But our previous method of rewriting no longer works since comments are not included within
[[Block a]]
. Furthermore, there there does not seem to be a reasonable way to determine where the constructs likeif (cond) then
,else if (cond2) then
,else
, andendif
begin and end, due to comments, line continuations, or similar.In order for this sort of thing to work correctly it would seem that the
SrcSpan
s of the actual constructs mentioned above to be included somehow within the types of the blocks since they are certainly known to the parser.I am creating this issue to determine what the best course of action is. I would be willing to do the work to make this work (and perhaps not in this way if there is some better/more elegant way), but what I think might work would be to add another field
[SrcSpan]
toBlIf
wherelength [[Block a]] + 1 = length [SrcSpan]
, i.e.[SrcSpan]
includes one additional span corresponding toendif
. Regardless of how we see fit to proceed, I believe this will be a rather large code change so I want to ensure I am going in the right direction before starting off.@mrd @ruoso
The text was updated successfully, but these errors were encountered: