xo-reader2: fix clearing result in SchematikaReader
This commit is contained in:
parent
b12555067c
commit
0fb0f7a1bf
8 changed files with 41 additions and 6 deletions
|
|
@ -65,15 +65,15 @@ namespace xo {
|
|||
bool
|
||||
DConstant::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
obj<APrintable> value
|
||||
obj<APrintable> value_pr
|
||||
= FacetRegistry::instance().variant<APrintable,AGCObject>(value_);
|
||||
|
||||
return ppii.pps()->pretty_struct
|
||||
(ppii,
|
||||
"DConstant",
|
||||
refrtag("value_.tseq", value_._typeseq()),
|
||||
refrtag("value.tseq", value._typeseq()),
|
||||
refrtag("value", value));
|
||||
refrtag("value.tseq", value_pr._typeseq()),
|
||||
refrtag("value", value_pr));
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace xo {
|
|||
|
||||
private:
|
||||
/** boxed boolean value **/
|
||||
bool value_;
|
||||
bool value_ = false;
|
||||
};
|
||||
|
||||
template <typename AFacet>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ namespace xo {
|
|||
bool
|
||||
DBoolean::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
return ppdetail_atomic<long>::print_pretty(ppii, value_);
|
||||
return ppdetail_atomic<bool>::print_pretty
|
||||
(ppii,
|
||||
(value_ ? "true" : "false"));
|
||||
}
|
||||
|
||||
size_t
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ namespace xo {
|
|||
log && log(xtag("DVariantPlaceholder.tseq", typeseq::id<DVariantPlaceholder>()));
|
||||
|
||||
log && log(xtag("DList.tseq", typeseq::id<DList>()));
|
||||
log && log(xtag("DBoolean.tseq", typeseq::id<DFloat>()));
|
||||
log && log(xtag("DBoolean.tseq", typeseq::id<DBoolean>()));
|
||||
log && log(xtag("DFloat.tseq", typeseq::id<DFloat>()));
|
||||
log && log(xtag("DInteger.tseq", typeseq::id<DInteger>()));
|
||||
log && log(xtag("DString.tseq", typeseq::id<DString>()));
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ namespace {
|
|||
|
||||
pps.prettyn(expr_pr);
|
||||
|
||||
p_reader->reset_result();
|
||||
|
||||
*p_input = remaining;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,9 @@ namespace xo {
|
|||
/** consume input @p input_cstr **/
|
||||
const ReaderResult & read_expr(span_type input_span, bool eof);
|
||||
|
||||
/** reset @ref result_ to nominal value **/
|
||||
void reset_result();
|
||||
|
||||
/** reset to known starting point after encountering an error.
|
||||
* - remainder of stashed current line.
|
||||
* Necesary for well-formatted error reporting.
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
#include <xo/expression2/detail/IExpression_DConstant.hpp>
|
||||
#include <xo/object2/DFloat.hpp>
|
||||
#include <xo/object2/number/IGCObject_DFloat.hpp>
|
||||
#include <xo/object2/DBoolean.hpp>
|
||||
#include <xo/object2/boolean/IGCObject_DBoolean.hpp>
|
||||
#include <xo/gc/GCObject.hpp>
|
||||
|
||||
namespace xo {
|
||||
|
|
@ -221,6 +223,26 @@ namespace xo {
|
|||
DExprSeqState::on_bool_token(const Token & tk,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
switch (seqtype_) {
|
||||
case exprseqtype::toplevel_interactive:
|
||||
{
|
||||
auto dvalue = DBoolean::box<AGCObject>(p_psm->expr_alloc(),
|
||||
tk.bool_value());
|
||||
auto * dconst = DConstant::make(p_psm->expr_alloc(), dvalue);
|
||||
auto expr = with_facet<AExpression>::mkobj(dconst);
|
||||
|
||||
DProgressSsm::start(p_psm->parser_alloc(),
|
||||
expr,
|
||||
p_psm);
|
||||
return;
|
||||
}
|
||||
case exprseqtype::toplevel_batch:
|
||||
break;
|
||||
case exprseqtype::N:
|
||||
assert(false); // unreachable
|
||||
break;
|
||||
}
|
||||
|
||||
p_psm->illegal_input_on_token("DExprSeqState::on_bool_token",
|
||||
tk,
|
||||
this->get_expect_str());
|
||||
|
|
|
|||
|
|
@ -142,6 +142,12 @@ namespace xo {
|
|||
return this->result_;
|
||||
}
|
||||
|
||||
void
|
||||
SchematikaReader::reset_result()
|
||||
{
|
||||
this->parser_.reset_result();
|
||||
}
|
||||
|
||||
void
|
||||
SchematikaReader::reset_to_idle_toplevel()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue