upd: fix bug in Any2String
This commit is contained in:
@ -133,7 +133,20 @@ std::any EvalVisitor::visitFactor(Python3Parser::FactorContext *ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::any EvalVisitor::visitAtom_expr(Python3Parser::Atom_exprContext *ctx) {
|
std::any EvalVisitor::visitAtom_expr(Python3Parser::Atom_exprContext *ctx) {
|
||||||
return visitChildren(ctx);
|
if (!ctx->trailer()) {
|
||||||
|
auto val = visitAtom(ctx->atom());
|
||||||
|
std::cerr << "[Log] The Atom returns : ";
|
||||||
|
if (auto ptr = std::any_cast<NoneType>(&val)) {
|
||||||
|
std::cerr << "NoneType" << std::endl;
|
||||||
|
} else if (auto ptr = std::any_cast<RawVarible>(&val)) {
|
||||||
|
std::cerr << "Variable Name=" << ptr->name
|
||||||
|
<< " val=" << Any2String(Variables.ReadVariable(ptr->name))
|
||||||
|
<< std::endl;
|
||||||
|
} else
|
||||||
|
std::cerr << Any2String(val) << std::endl;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
throw FatalError("Not implemented in function visitAtom_expr: function call");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::any EvalVisitor::visitTrailer(Python3Parser::TrailerContext *ctx) {
|
std::any EvalVisitor::visitTrailer(Python3Parser::TrailerContext *ctx) {
|
||||||
@ -164,6 +177,7 @@ std::any EvalVisitor::visitAtom(Python3Parser::AtomContext *ctx) {
|
|||||||
const std::string &tmp = item->getText();
|
const std::string &tmp = item->getText();
|
||||||
res.append(tmp, 1, tmp.size() - 2);
|
res.append(tmp, 1, tmp.size() - 2);
|
||||||
}
|
}
|
||||||
|
// std::cerr<<"[Log] The string is : "<<res<<std::endl;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,8 @@ std::string Any2String(const std::any &value) {
|
|||||||
buf << "False";
|
buf << "False";
|
||||||
} else if (auto ptr = std::any_cast<ZYM::int2048>(&value))
|
} else if (auto ptr = std::any_cast<ZYM::int2048>(&value))
|
||||||
buf << *ptr;
|
buf << *ptr;
|
||||||
|
else if (auto ptr = std::any_cast<std::string>(&value))
|
||||||
|
buf << *ptr;
|
||||||
else
|
else
|
||||||
throw FatalError("Any2String: unknown type");
|
throw FatalError("Any2String: unknown type");
|
||||||
buf >> res;
|
buf >> res;
|
||||||
|
Reference in New Issue
Block a user