lean2/src/library/script_evaluator.cpp
Leonardo de Moura 19533c811b feat(library/script_evaluator): add abstract class that exposes only the API needed by frontend objects
The main motivation is to break the remove the dependency frontends/lean <-- bindings/lua.
This dependency is undesirable because we want to expose the frontends/lean parser and pretty printer objects at bindings/lua.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-15 12:13:09 -08:00

23 lines
721 B
C++

/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include <sstream>
#include <string>
#include "library/script_evaluator.h"
namespace lean {
char const * script_exception::what() const noexcept {
static thread_local std::string buffer;
std::ostringstream strm;
switch (get_source()) {
case source::String: strm << "[string]:" << get_line() << ":" << get_msg() << "\n"; break;
case source::File: strm << get_filename() << ":" << get_line() << ":" << get_msg() << "\n"; break;
case source::Unknown: return get_msg();
}
buffer = strm.str();
return buffer.c_str();
}
}