You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to be able to manipulate #line directives with language-c-quote. I'm particularly interested in setting source locations for statements.
I can imagine two approaches to implement this:
Parse #line directives and set SrcLocs accordingly. When pretty-printing, if an element of the AST has a Loc, use the file and line from its starting Pos to emit a #line directive. As an optimization, it might be nice to suppress any #line directive with the same filename as the previous directive, and where the difference in line numbers between the two Locs is the same as the number of lines pretty-printed since the last #line. If you don't want these directives you can rewrite all SrcLocs to NoLoc before pretty-printing.
Add a Line constructor to Stm, like Pragma.
Which would you prefer?
The text was updated successfully, but these errors were encountered:
It's of course @mainland's call, but Option (1) sounds more attractive to me. As a special case, it should also be possible to emit #line directives even when the parsed source didn't have any directives — i.e., to emit info about the original source location of the quoted C code.
It would be nice to be able to manipulate
#line
directives with language-c-quote. I'm particularly interested in setting source locations for statements.I can imagine two approaches to implement this:
#line
directives and setSrcLoc
s accordingly. When pretty-printing, if an element of the AST has aLoc
, use the file and line from its startingPos
to emit a#line
directive. As an optimization, it might be nice to suppress any#line
directive with the same filename as the previous directive, and where the difference in line numbers between the twoLoc
s is the same as the number of lines pretty-printed since the last#line
. If you don't want these directives you can rewrite allSrcLoc
s toNoLoc
before pretty-printing.Line
constructor toStm
, likePragma
.Which would you prefer?
The text was updated successfully, but these errors were encountered: