xo-interpreter2 stack: wrap TokenizerError as DRuntimeError
Also fix _read_eval_print() to report them!
This commit is contained in:
parent
1d3af64a7a
commit
ff471bbc72
4 changed files with 22 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ include(CMakeFindDependencyMacro)
|
||||||
# must coordinate with xo_dependency() calls
|
# must coordinate with xo_dependency() calls
|
||||||
# in src/tokenizer2/CMakeLists.txt
|
# in src/tokenizer2/CMakeLists.txt
|
||||||
#
|
#
|
||||||
|
find_dependency(xo_stringtable2)
|
||||||
find_dependency(xo_arena)
|
find_dependency(xo_arena)
|
||||||
find_dependency(indentlog)
|
find_dependency(indentlog)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@
|
||||||
#include "TkInputState.hpp"
|
#include "TkInputState.hpp"
|
||||||
#include "tokentype.hpp"
|
#include "tokentype.hpp"
|
||||||
#include "span.hpp"
|
#include "span.hpp"
|
||||||
|
#include <xo/stringtable2/String.hpp>
|
||||||
|
#include <xo/alloc2/Allocator.hpp>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
|
|
@ -19,6 +21,7 @@ namespace xo {
|
||||||
**/
|
**/
|
||||||
class TokenizerError {
|
class TokenizerError {
|
||||||
public:
|
public:
|
||||||
|
using AAllocator = xo::mm::AAllocator;
|
||||||
using CharT = char;
|
using CharT = char;
|
||||||
using span_type = xo::mm::span<const CharT>;
|
using span_type = xo::mm::span<const CharT>;
|
||||||
|
|
||||||
|
|
@ -89,6 +92,9 @@ namespace xo {
|
||||||
/** Print human-oriented error report on @p os. **/
|
/** Print human-oriented error report on @p os. **/
|
||||||
void report(std::ostream & os) const;
|
void report(std::ostream & os) const;
|
||||||
|
|
||||||
|
/** Similar to report, but capture as string, allocated from @p mm **/
|
||||||
|
DString * report_to_string(obj<AAllocator> mm) const;
|
||||||
|
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ set(SELF_SRCS
|
||||||
|
|
||||||
xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS})
|
xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS})
|
||||||
# deps must coordinate with xo-tokenizer/cmake/xo_tokenizer2Config.cmake.in
|
# deps must coordinate with xo-tokenizer/cmake/xo_tokenizer2Config.cmake.in
|
||||||
|
xo_dependency(${SELF_LIB} xo_stringtable2)
|
||||||
xo_dependency(${SELF_LIB} xo_arena)
|
xo_dependency(${SELF_LIB} xo_arena)
|
||||||
xo_dependency(${SELF_LIB} indentlog)
|
xo_dependency(${SELF_LIB} indentlog)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,20 @@ namespace xo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DString *
|
||||||
|
TokenizerError::report_to_string(obj<AAllocator> dest_mm) const
|
||||||
|
{
|
||||||
|
// FIXME:
|
||||||
|
// using heap here for scratch space.
|
||||||
|
// Would prefer to checkpoint + realloc.
|
||||||
|
|
||||||
|
std::stringstream ss;
|
||||||
|
|
||||||
|
this->report(ss);
|
||||||
|
|
||||||
|
return DString::from_str(dest_mm, ss.str());
|
||||||
|
}
|
||||||
|
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue