37 : begin(
sym.data()), cursor(begin),
39 this->end = begin +
sym.size();
43 return (c >=
'A' && c <=
'Z') ||
44 (c >=
'a' && c <=
'z') ||
49 return isWord(c) || (c ==
':') || (c >=
'0' && c <=
'9');
53 last_lexeme = current_lexeme;
54 cursor += last_lexeme.
length;
56 if(this->cursor == end) [[
unlikely]] {
58 }
else if(
isWord(*cursor)) {
59 auto epos = find_nonword();
65 return this->current_lexeme;
69 return this->current_lexeme;
73 return this->last_lexeme;
77 return this->begin[current_lexeme.
loc];
84 return this->begin[last_lexeme.
loc];
88 auto pos = find_next(cursor + current_lexeme.
length);
92 return this->begin[
pos];
102 "Invalid token length {}.",
tok.length);
108 auto pos = find_next();
110 cursor = begin +
pos;
119 const char*
pos =
nullptr)
const {
121 if(
lloc == end)
return -1;
123 "Invalid position!");
148 SymToken current_lexeme;
149 SymToken last_lexeme;
167 this->handle_symbol(c);
169 }
else if(!is_keyword(
tok)) {
170 this->handle_ident(
tok);
200 }
else if(c ==
'<') {
206 char lc = last_written();
214 bool is_keyword(SymToken
tok) {
216 "struct",
"class",
"union",
"enum",
217 "__ptr64",
"__cdecl",
"__stdcall",
218 "__thiscall",
"__fastcall",
""
224 bool is_replacement(SymToken
tok) {
226 if(
tstr ==
"std::nullptr_t") {
229 }
else if(
tstr ==
"__int64") {
243 return std::move(
parser.extract());
#define LIBREPR_ASSERT(cond,...)
Checked assertion, for constraint enforcement.
Definition assert.h:67
#define LIBREPR_HINT_INLINE
Definition macro/util.h:56
std::conditional_t< sizeof(void *)==8, std::uint32_t, std::uint16_t > uhalfptr_t
Definition denoise.h:21
std::make_signed_t< uhalfptr_t > ihalfptr_t
Definition denoise.h:23
LIBREPR_HINT_INLINE std::string denoise_name(std::string_view name)
Formats undecorated symbols to match itanium's symbols.
Definition denoise.h:240
std::string code_for()
Definition repr:39
Wrapper around std::string.
Definition buffer.h:14
void write(const char *beg, const char *end)
Definition buffer.h:23
static LIBREPR_HINT_INLINE bool isWord(char c)
Definition denoise.h:42
LIBREPR_HINT_INLINE char current_first() const noexcept
Definition denoise.h:76
SymToken next() noexcept
Definition denoise.h:52
SymLexer(std::string_view sym)
Definition denoise.h:36
char peek_first() const noexcept
Definition denoise.h:87
LIBREPR_HINT_INLINE void write(SymToken tok)
Definition denoise.h:95
LIBREPR_HINT_INLINE char last_first() const noexcept
Definition denoise.h:80
LIBREPR_HINT_INLINE SymToken current() const noexcept
Definition denoise.h:68
SymBuffer buf
Definition denoise.h:152
ihalfptr_t nest_depth
Definition denoise.h:153
LIBREPR_HINT_INLINE SymToken last() const noexcept
Definition denoise.h:72
static LIBREPR_HINT_INLINE bool isQualifiedName(char c)
Definition denoise.h:48
std::string_view to_sv(SymToken tok) const
Definition denoise.h:99
Does the actual formatting.
Definition denoise.h:157
SymParser(std::string_view sym)
Definition denoise.h:158
std::string && extract()
Definition denoise.h:179
void parse()
Definition denoise.h:162
ihalfptr_t loc
Definition denoise.h:27
uhalfptr_t length
Definition denoise.h:28