Highlight (escape) the current buffer using a custom syntax.
- Parameters
-
[in] | syntax | a POSIX extended regular expression |
[in] | icase | true to ignore case while parsing |
- Returns
- the escaped text (heap allocated)
- Exceptions
-
Definition at line 593 of file parser.cpp.
References csdbg::string::append(), csdbg::style::apply(), csdbg::string::at(), csdbg::chain< T >::at(), csdbg::string::cmp(), get_style(), likely, lookup(), m_fallback, csdbg::string::match(), parse(), csdbg::chain< T >::size(), csdbg::string::string(), and unlikely.
Referenced by csdbg::operator<<().
595 const i8 *num =
"^0x[0-9a-f]+$|^[0-9]+$";
597 string *retval =
new string;
598 chain<string> *tokens = NULL;
603 tokens =
parse(syntax, icase);
606 for (
u32 i = 0, sz = tokens->size();
likely(i < sz); i++) {
607 string *token = tokens->at(i);
614 else if (
unlikely(token->match(num,
true)) )
628 else if (
likely(i < sz - 1) ) {
629 string *delim = tokens->at(i + 1);
630 i8 ch = delim->at(0);
632 if (
unlikely(delim->cmp(
"::") == 0) )
635 else if (
unlikely(ch ==
'(' || ch ==
'<' || ch ==
'\r') )
645 retval->append(*token);
char i8
8-bit signed integer
virtual chain< string > * parse(const i8 *=NULL, bool=false) const
Parse the current buffer using a custom syntax.
virtual style & apply(string &) const
Apply the style to some text.
string(u32=0)
Object constructor.
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
virtual style * get_style(const i8 *) const
Get a style, indexed by name.
unsigned int u32
32-bit unsigned integer
virtual bool lookup(const string &, const i8 *, bool=false) const
Lookup an expression in one of the parser dictionaries.
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
static style * m_fallback
Shared fallback style.