diff options
author | Thomas Lively <tlively@google.com> | 2024-05-29 10:35:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-29 10:35:25 -0700 |
commit | f622b8e47c69dcbdf2666c795fb3658dc4da52af (patch) | |
tree | 27a0c58cb6b932e8251fa6dd2aa68b41f138a1a1 /src/parser | |
parent | 525f0761496c6aafea80a2d2e8cb709515eb06c5 (diff) | |
download | binaryen-f622b8e47c69dcbdf2666c795fb3658dc4da52af.tar.gz binaryen-f622b8e47c69dcbdf2666c795fb3658dc4da52af.tar.bz2 binaryen-f622b8e47c69dcbdf2666c795fb3658dc4da52af.zip |
Use new wast parser in wasm2js (#6606)
When generating assertions, traverse the `WASTScript` data structure rather than
interleaving assertion parsing with emitting.
Diffstat (limited to 'src/parser')
-rw-r--r-- | src/parser/wast-parser.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/parser/wast-parser.cpp b/src/parser/wast-parser.cpp index 87060b9fc..9473da9fb 100644 --- a/src/parser/wast-parser.cpp +++ b/src/parser/wast-parser.cpp @@ -397,11 +397,15 @@ Result<WASTScript> wast(Lexer& in) { while (!in.empty()) { size_t line = in.position().line; auto cmd = command(in); - if (cmd.getErr() && cmds.empty()) { + if (auto* err = cmd.getErr(); err && cmds.empty()) { // The entire script might be a single module comprising a sequence of // module fields with a top-level `(module ...)`. auto wasm = std::make_shared<Module>(); - CHECK_ERR(parseModule(*wasm, in.buffer)); + auto parsed = parseModule(*wasm, in.buffer); + if (parsed.getErr()) { + // No, that wasn't the problem. Return the original error. + return Err{err->msg}; + } cmds.push_back({WASTModule{std::move(wasm)}, line}); return cmds; } |