diff options
author | Thomas Lively <tlively@google.com> | 2023-09-21 13:46:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-21 13:46:51 -0700 |
commit | 2c09a60ecbb0ba0276982204d8788b4343356417 (patch) | |
tree | 459f657111276a48fb9ee40520203c764c8a464d /scripts/gen-s-parser.py | |
parent | d491136eeb94b748225be50bdcc86c74cdbd154e (diff) | |
download | binaryen-2c09a60ecbb0ba0276982204d8788b4343356417.tar.gz binaryen-2c09a60ecbb0ba0276982204d8788b4343356417.tar.bz2 binaryen-2c09a60ecbb0ba0276982204d8788b4343356417.zip |
[NFC][Parser] Simplify instruction handling (#5964)
The new wat parser previously returned InstrT types when parsing individual
instructions and collected InstrsT types when parsing sequences of instructions.
However, instructions were always actually tracked in the internal state of the
parsing context, so these types never held any interesting or necessary data.
Simplify the parser by removing these types and leaning into the pattern that
the parser context will keep track of parsed instructions.
This allows for a much cleaner separation between the `instrs` and
`foldedinstrs` parser functions.
Diffstat (limited to 'scripts/gen-s-parser.py')
-rwxr-xr-x | scripts/gen-s-parser.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py index 029fe2b0e..831e217ba 100755 --- a/scripts/gen-s-parser.py +++ b/scripts/gen-s-parser.py @@ -735,9 +735,8 @@ def instruction_parser(new_parser=False): expr = expr.replace("(s", "(ctx, pos") printer.print_line("if (op == \"{inst}\"sv) {{".format(inst=inst)) with printer.indent(): - printer.print_line("auto ret = {expr};".format(expr=expr)) - printer.print_line("CHECK_ERR(ret);") - printer.print_line("return *ret;") + printer.print_line("CHECK_ERR({expr});".format(expr=expr)) + printer.print_line("return Ok{};") printer.print_line("}") else: printer.print_line("if (op == \"{inst}\"sv) {{ return {expr}; }}" |