From d491136eeb94b748225be50bdcc86c74cdbd154e Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 21 Sep 2023 12:42:07 -0700 Subject: [Parser] Parse if-else in the new wat parser and IRBuilder (#5963) Parse both the straight-line and folded versions of if, including the abbreviations that allow omitting the else clause. In the IRBuilder, generalize the scope stack to be able to track scopes other than blocks and add methods for visiting the beginnings of ifs and elses. --- scripts/gen-s-parser.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scripts/gen-s-parser.py') diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py index 78637991b..029fe2b0e 100755 --- a/scripts/gen-s-parser.py +++ b/scripts/gen-s-parser.py @@ -712,6 +712,9 @@ def instruction_parser(new_parser=False): 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. + continue inst_length = max(inst_length, len(inst)) trie.insert(inst, expr) -- cgit v1.2.3