64 #include "rnr/rnrconfig.h" 66 #include "rnr/color.h" 88 Token::Token(
const string &strValue)
89 : m_strValue(strValue), m_lineNum(0), m_posStart(0), m_posEnd(0)
93 Token::Token(
const string &strValue,
95 const size_t posStart,
97 : m_strValue(strValue),
126 ostream &Token::printAnnotated(ostream &os,
127 const string &strLine,
130 string color(ANSI_FG_BRIGHT_RED);
131 string reset(ANSI_COLOR_RESET);
133 size_t lw = strLine.length();
145 os << m_lineNum <<
":";
147 os << m_posStart <<
"," << m_posEnd;
154 if( m_posStart < lw )
161 os << strLine.substr(0, m_posStart);
167 len = m_posEnd - m_posStart + 1;
170 len = lw - m_posStart;
172 os << color << strLine.substr(m_posStart, len) << reset;
180 os << strLine.substr(pos);
189 os << strLine << endl;
size_t m_lineNum
line number
size_t m_posEnd
line end position of token
Of string spaces and their strangian operators.
size_t m_posStart
line start position of token
std::string prettify(const std::string &str)
Prettify string.
std::string m_strValue
token string value
const std::string & value() const
Return token string.
Parsed token container class.
std::ostream & operator<<(std::ostream &os, const timespec &obj)
A timespec insertion operator.
Simple, token container class interface.