From c8293a3f9112ad486f6f3639fc5680d73e7559ca Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 12 May 2016 16:02:03 -0700 Subject: show parse errors in wasm-dis and wasm-as --- src/wasm-as.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/wasm-as.cpp') diff --git a/src/wasm-as.cpp b/src/wasm-as.cpp index 6995859a7..40839ea55 100644 --- a/src/wasm-as.cpp +++ b/src/wasm-as.cpp @@ -43,13 +43,18 @@ int main(int argc, const char *argv[]) { auto input(read_file(options.extra["infile"], Flags::Text, options.debug ? Flags::Debug : Flags::Release)); - if (options.debug) std::cerr << "s-parsing..." << std::endl; - SExpressionParser parser(const_cast(input.c_str())); - Element& root = *parser.root; - - if (options.debug) std::cerr << "w-parsing..." << std::endl; Module wasm; - SExpressionWasmBuilder builder(wasm, *root[0]); + + try{ + if (options.debug) std::cerr << "s-parsing..." << std::endl; + SExpressionParser parser(const_cast(input.c_str())); + Element& root = *parser.root; + if (options.debug) std::cerr << "w-parsing..." << std::endl; + SExpressionWasmBuilder builder(wasm, *root[0]); + } catch (ParseException& p) { + p.dump(std::cerr); + Fatal() << "error in parsing wasm binary"; + } if (options.debug) std::cerr << "binarification..." << std::endl; BufferWithRandomAccess buffer(options.debug); -- cgit v1.2.3