summaryrefslogtreecommitdiff
path: root/scripts/gen-s-parser.py
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-11-30 02:52:01 +0100
committerGitHub <noreply@github.com>2023-11-29 17:52:01 -0800
commit71b9cc0b50b119988b7ad3a5f5d2feec4d6c4a95 (patch)
tree70a560571537f51d78b75f7804259b8881d368bc /scripts/gen-s-parser.py
parent24742589f5471a5e72755d8fe1da9e49923a35ff (diff)
downloadbinaryen-71b9cc0b50b119988b7ad3a5f5d2feec4d6c4a95.tar.gz
binaryen-71b9cc0b50b119988b7ad3a5f5d2feec4d6c4a95.tar.bz2
binaryen-71b9cc0b50b119988b7ad3a5f5d2feec4d6c4a95.zip
[Parser] Parse try/catch/catch_all/delegate (#6128)
Parse the legacy v3 syntax for try/catch/catch_all/delegate in both its folded and unfolded forms. The first sources of significant complexity is the optional IDs after `catch` and `catch_all` in the unfolded form, which can be confused for tag indices and require backtracking to parse correctly. The second source of complexity is the handling of delegate labels, which are relative to the try's parent scope despite being parsed after the try's scope has already started. Handling this correctly requires punching a whole big enough to drive a truck through through both the parser and IRBuilder abstractions.
Diffstat (limited to 'scripts/gen-s-parser.py')
-rwxr-xr-xscripts/gen-s-parser.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py
index 08c5fe31f..bd29f4f10 100755
--- a/scripts/gen-s-parser.py
+++ b/scripts/gen-s-parser.py
@@ -709,15 +709,13 @@ class Node:
def instruction_parser(new_parser=False):
"""Build a trie out of all the instructions, then emit it as C++ code."""
global instructions
- if new_parser:
- # Filter out instructions that the new parser does not need.
- instructions = [(inst, code) for (inst, code) in instructions
- if inst not in ('block', 'loop', 'if', 'then', 'else')]
trie = Node()
inst_length = 0
for inst, expr in instructions:
- if new_parser and inst in {"then", "else"}:
- # These are not real instructions! skip them.
+ if new_parser and inst in {"block", "loop", "if", "try", "then",
+ "else"}:
+ # These are either control flow handled manually or not real
+ # instructions. Skip them.
continue
inst_length = max(inst_length, len(inst))
trie.insert(inst, expr)