[Parser] Parse annotations, including source map comments#6345
Conversation
Parse annotations using the standards-track `(@annotation ...)` format as well as the `;;@ source-map:0:1` format. Have the lexer implicitly collect annotations while it skips whitespace and add lexer APIs to access the annotations since the last token was parsed. Collect annotations before parsing each instruction and pass the annotations explicitly to the parser and parser context functions for instructions. Add an API to `IRBuilder` to set a debug location to be attached to the next visited or created instruction and use it from the parser.
|
Current dependencies on/for this PR: This stack of pull requests is managed by Graphite. |
| } | ||
|
|
||
| Result<> IRBuilder::visitTryTableStart(TryTable* trytable, Name label) { | ||
| applyDebugLoc(trytable); |
There was a problem hiding this comment.
Why do we applyDebugLoc in control flow structures in this file but not to e.g. visitStructSet?
There was a problem hiding this comment.
For normal instructions, the applyDebugLoc in push is sufficient. For control flow, however, we need to apply the debug location at the beginning of the scope. Since the control flow isn't pushed until the end of the scope, we can't rely on the same applyDebugLoc as for normal instructions.
There was a problem hiding this comment.
Ah, yes, thanks, that makes sense, and I think we have similar code for the old parser in fact...
| ;; Annotations | ||
| (@annotation this is a meaningless (@annotation ) ;; This is still a comment )) | ||
| it spans multiple lines just fine and can include $ids 0x42 numbers and "strings" | ||
| ) |
There was a problem hiding this comment.
Nope, the parser never does anything with it, so it's essentially a comment.
There was a problem hiding this comment.
Doesn't it need to roundtrip it?
There was a problem hiding this comment.
No. There is a specific kind of annotation ((@custom ...)) that specifies arbitrary custom section contents that should be round-tripped, but we don't support that yet.
There was a problem hiding this comment.
I see, thanks, that's what I was missing.
…y#6345) Parse annotations using the standards-track `(@annotation ...)` format as well as the `;;@ source-map:0:1` format. Have the lexer implicitly collect annotations while it skips whitespace and add lexer APIs to access the annotations since the last token was parsed. Collect annotations before parsing each instruction and pass the annotations explicitly to the parser and parser context functions for instructions. Add an API to `IRBuilder` to set a debug location to be attached to the next visited or created instruction and use it from the parser.

Parse annotations using the standards-track
(@annotation ...)format as wellas the
;;@ source-map:0:1format. Have the lexer implicitly collectannotations while it skips whitespace and add lexer APIs to access the
annotations since the last token was parsed. Collect annotations before parsing
each instruction and pass the annotations explicitly to the parser and parser
context functions for instructions. Add an API to
IRBuilderto set a debuglocation to be attached to the next visited or created instruction and use it
from the parser.