Commit 259ff4e2 authored by Teng Qin's avatar Teng Qin

Use StatusTuple constructor in mkstatus_

parent 13ebe8e8
......@@ -37,6 +37,10 @@ public:
msg_ = std::string(buf);
}
void append_msg(const std::string& msg) {
msg_ += msg;
}
int code() { return ret_; }
std::string msg() { return msg_; }
......
......@@ -115,19 +115,17 @@ class Node {
template <typename... Args>
StatusTuple mkstatus_(Node *n, const char *fmt, Args... args) {
char buf[2048];
snprintf(buf, sizeof(buf), fmt, args...);
string out_msg(buf);
StatusTuple status = StatusTuple(n->line_ ? n->line_ : -1, fmt, args...);
if (n->line_ > 0)
out_msg += "\n" + n->text_;
return StatusTuple(n->line_ ? n->line_ : -1, out_msg);
status.append_msg("\n" + n->text_);
return status;
}
static inline StatusTuple mkstatus_(Node *n, const char *msg) {
string out_msg(msg);
StatusTuple status = StatusTuple(n->line_ ? n->line_ : -1, msg);
if (n->line_ > 0)
out_msg += "\n" + n->text_;
return StatusTuple(n->line_ ? n->line_ : -1, out_msg);
status.append_msg("\n" + n->text_);
return status;
}
class StmtNode : public Node {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment