summaryrefslogtreecommitdiff
path: root/src/parser/input-impl.h
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-09-21 15:33:51 -0700
committerGitHub <noreply@github.com>2023-09-21 15:33:51 -0700
commit38197b57aa5bd94a879c0203b75a35cb826db929 (patch)
treebd03181fa5e9ac804a58db2e1d65ca26d19763d7 /src/parser/input-impl.h
parent2c09a60ecbb0ba0276982204d8788b4343356417 (diff)
downloadbinaryen-38197b57aa5bd94a879c0203b75a35cb826db929.tar.gz
binaryen-38197b57aa5bd94a879c0203b75a35cb826db929.tar.bz2
binaryen-38197b57aa5bd94a879c0203b75a35cb826db929.zip
[Parser] Allow any number of foldedinsts in `foldedinsts` (#5965)
Somewhat counterintuitively, the text syntax for a folded `if` allows any number of folded instructions in the condition position, not just one. Update the corresponding `foldedinsts` parsing function to parse arbitrary sequences of folded instructions and add a test.
Diffstat (limited to 'src/parser/input-impl.h')
-rw-r--r--src/parser/input-impl.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/parser/input-impl.h b/src/parser/input-impl.h
index 35a39b2f3..7ee358f12 100644
--- a/src/parser/input-impl.h
+++ b/src/parser/input-impl.h
@@ -257,6 +257,16 @@ inline bool ParseInput::takeSExprStart(std::string_view expected) {
return false;
}
+inline bool ParseInput::peekSExprStart(std::string_view expected) {
+ auto original = lexer;
+ if (!takeLParen()) {
+ return false;
+ }
+ bool ret = takeKeyword(expected);
+ lexer = original;
+ return ret;
+}
+
inline Index ParseInput::getPos() {
if (auto t = peek()) {
return lexer.getIndex() - t->span.size();