A nothrow parser does not report parsing errors by throwing an exception. Instead in case of an error it adds the error to the error collection of the lexer and continues parsing.
parser minixml { uselexer TrivialLexer; nothrow; main; // ... }
The parsing errors can be accessed using the lexer.Errors() member function:
#include <minixml.hpp> #include <soulng/util/Unicode.hpp> #include <soulng/util/MappedInputFile.hpp> #include <soulng/lexer/TrivialLexer.hpp> #include <iostream> using namespace soulng::unicode; using namespace soulng::util; int main() { try { std::string fileName = "philosophers.xml"; std::string file = ReadFile(fileName); std::u32string content = ToUtf32(file); TrivialLexer lexer(content, fileName, 0); minixml::Parse(lexer); int n = lexer.Errors().size(); for (int i = 0; i < n; ++i) { const std::exception& error = lexer.Errors()[i]; std::cout << error.what() << std::endl; } } catch (const std::exception& ex) { std::cerr << ex.what() << std::endl; return 1; } return 0; }