summaryrefslogtreecommitdiff
path: root/src/parser/wast-parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/wast-parser.cpp')
-rw-r--r--src/parser/wast-parser.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/parser/wast-parser.cpp b/src/parser/wast-parser.cpp
index 5eaf352b7..0f7887f8f 100644
--- a/src/parser/wast-parser.cpp
+++ b/src/parser/wast-parser.cpp
@@ -49,7 +49,7 @@ Result<Literals> consts(Lexer& in) {
return lits;
}
-MaybeResult<Action> action(Lexer& in) {
+MaybeResult<Action> maybeAction(Lexer& in) {
if (in.takeSExprStart("invoke"sv)) {
auto id = in.takeID();
auto name = in.takeName();
@@ -79,6 +79,14 @@ MaybeResult<Action> action(Lexer& in) {
return {};
}
+Result<Action> action(Lexer& in) {
+ if (auto a = maybeAction(in)) {
+ CHECK_ERR(a);
+ return *a;
+ }
+ return in.err("expected action");
+}
+
// (module id? binary string*)
// (module id? quote string*)
// (module ...)
@@ -348,7 +356,7 @@ MaybeResult<Assertion> assertTrap(Lexer& in) {
return {};
}
auto pos = in.getPos();
- if (auto a = action(in)) {
+ if (auto a = maybeAction(in)) {
CHECK_ERR(a);
auto msg = in.takeString();
if (!msg) {
@@ -423,7 +431,7 @@ Result<WASTCommand> command(Lexer& in) {
CHECK_ERR(cmd);
return *cmd;
}
- if (auto cmd = action(in)) {
+ if (auto cmd = maybeAction(in)) {
CHECK_ERR(cmd);
return *cmd;
}