Skip to content

Commit 1b30f3c

Browse files
tlivelyradekdoulik
authored andcommitted
[Parser] Parse annotations, including source map comments (WebAssembly#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.
1 parent 1915957 commit 1b30f3c

File tree

9 files changed

+2400
-1188
lines changed

9 files changed

+2400
-1188
lines changed

scripts/gen-s-parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,8 @@ def instruction_parser(new_parser=False):
739739

740740
def print_leaf(expr, inst):
741741
if new_parser:
742-
expr = expr.replace("()", "(ctx, pos)")
743-
expr = expr.replace("(s", "(ctx, pos")
742+
expr = expr.replace("()", "(ctx, pos, annotations)")
743+
expr = expr.replace("(s", "(ctx, pos, annotations")
744744
printer.print_line("if (op == \"{inst}\"sv) {{".format(inst=inst))
745745
with printer.indent():
746746
printer.print_line("CHECK_ERR({expr});".format(expr=expr))

src/gen-s-parser.inc

Lines changed: 603 additions & 603 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)