o << ts;
}
else
- o << colorize(*tok);
+ o << colorize(tok);
last_token = tok;
}
if (pe.tok || found_junk)
{
- cerr << _("\tat: ") << colorize(*tok) << endl;
+ cerr << _("\tat: ") << colorize(tok) << endl;
print_error_source (cerr, align_parse_error, tok);
}
else if (tok) // "expected" type error
{
- cerr << _("\tsaw: ") << colorize(*tok) << endl;
+ cerr << _("\tsaw: ") << colorize(tok) << endl;
print_error_source (cerr, align_parse_error, tok);
}
else
// print chained macro invocations
while (tok && tok->chain) {
tok = tok->chain;
- cerr << _("\tin expansion of macro: ") << colorize(*tok) << endl;
+ cerr << _("\tin expansion of macro: ") << colorize(tok) << endl;
print_error_source (cerr, align_parse_error, tok);
}
}
}
std::string
-systemtap_session::colorize(std::string str, std::string type)
+systemtap_session::colorize(const std::string& str, const std::string& type)
{
if (str.empty() || !color_errors)
return str;
// Colorizes the path:row:col part of the token
std::string
-systemtap_session::colorize(const token& tok)
+systemtap_session::colorize(const token* tok)
{
+ if (tok == NULL)
+ return "";
+
stringstream tmp;
- tmp << tok;
+ tmp << *tok;
if (!color_errors)
return tmp.str(); // Might as well stop now to save time
// Print token location, which is also the tail of ts
stringstream loc;
- loc << tok.location;
+ loc << tok->location;
// Remove token location and re-add it colorized
ts.erase(ts.size()-loc.str().size());
'error=01;31:warning=00;33:source=00;34:caret=01:token=01'
*/
std::string
-systemtap_session::parse_stap_color(std::string type)
+systemtap_session::parse_stap_color(const std::string& type)
{
const char *key, *col, *eq;
int n = type.size();
// NB: It is very important for all of the above (and below) fields
// to be cleared in the systemtap_session ctor (session.cxx).
- std::string colorize(std::string str, std::string type);
- std::string colorize(const token& tok);
- std::string parse_stap_color(std::string type);
+ std::string colorize(const std::string& str, const std::string& type);
+ std::string colorize(const token* tok);
+ std::string parse_stap_color(const std::string& type);
};
struct exit_exception: public std::runtime_error