From 38197b57aa5bd94a879c0203b75a35cb826db929 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 21 Sep 2023 15:33:51 -0700 Subject: [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. --- src/parser/input-impl.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/parser/input-impl.h') 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(); -- cgit v1.2.3