Skip to content

Commit

Permalink
[Parser] Parse annotations, including source map comments (WebAssembl…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
tlively authored and radekdoulik committed Jul 12, 2024
1 parent 1915957 commit 1b30f3c
Show file tree
Hide file tree
Showing 9 changed files with 2,400 additions and 1,188 deletions.
4 changes: 2 additions & 2 deletions scripts/gen-s-parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,8 @@ def instruction_parser(new_parser=False):

def print_leaf(expr, inst):
if new_parser:
expr = expr.replace("()", "(ctx, pos)")
expr = expr.replace("(s", "(ctx, pos")
expr = expr.replace("()", "(ctx, pos, annotations)")
expr = expr.replace("(s", "(ctx, pos, annotations")
printer.print_line("if (op == \"{inst}\"sv) {{".format(inst=inst))
with printer.indent():
printer.print_line("CHECK_ERR({expr});".format(expr=expr))
Expand Down
1,206 changes: 603 additions & 603 deletions src/gen-s-parser.inc

Large diffs are not rendered by default.

Loading

0 comments on commit 1b30f3c

Please sign in to comment.