21 virtual void add(
unsigned col, T_Char c) = 0;
37template<
class T_LexCh>
40 static void appendUTF8(std::string &u8s,
const T_LexCh &ch);
59 return __isascii(
int(ch.m_U32)) ?1U :2U;
61 return (
unsigned)wcwidth(
wchar_t(ch.m_U32));
93template<
class T_LexCh>
94[[nodiscard]]
auto toString(
const T_LexCh *c,
size_t start,
size_t end)
noexcept(
noexcept(
98 for (
size_t i = start; i < end; C_LexTraits<T_LexCh>::appendUTF8(buf, c[i++]));
102template<T_LexID _ID,
class T_LexCh>
108 RUNTIME_ERROR(
"parseEscapeChar() returns {} != {}", len, n -2);
113template<T_LexID _ID,
class T_LexCh>
119template<T_LexID _ID,
class T_LexCh>
125template<T_LexID _ID,
class T_LexCh>
131template<T_LexID _ID,
class T_LexCh>
137template<T_LexID _ID,
class T_LexCh,
size_t TRIMLEFT = 0,
size_t TRIMRIGHT = 0>
143template<T_LexID _ID,
class T_LexCh,
size_t TRIMLEFT = 0,
size_t TRIMRIGHT = 0>
149template<
class T_Char>
153 unsigned line = 1, col = 1;
161 while (C_Traits::read(src, c))
164 switch (C_Traits::id(c))
171 col += 4 - (col - 1) % 4;
174 col += C_Traits::columnsInDisplay(c);
177 C_Traits::setId(c, endToken);
#define RUNTIME_ERROR(fmtStr,...)
Wrap FILE(DATE)#__LINE__ FUNCTION: msg into std::runtime_error.
THE common namespace of bux library.
std::string_view to_utf8(T_Utf32 uc)
C_ActionRet createNothing(const T_LexCh *, size_t)
bool isIdentifier(std::string_view s) noexcept
std::string escseq2str(std::string s)
auto createDecNum(const T_LexCh *c, size_t n)
auto createEscapeString(const T_LexCh *c, size_t n)
auto createLex(const T &t)
auto createCharLiteral(const T_LexCh *c, size_t n)
auto toString(const T_LexCh *c, size_t start, size_t end) noexcept(noexcept(C_LexTraits< T_LexCh >::appendUTF8(std::declval< std::string & >(), T_LexCh())))
void scanFile(std::string_view filename, std::istream &in, I_Scanner< T_Char > &scanner, T_LexID endToken=TID_EOF, T_Encoding encoding=0)
auto createHexNum(const T_LexCh *c, size_t n)
size_t parseEscapeChar(std::string_view s, uint32_t &c, size_t pos)
size_t skipIdentifier(std::string_view s, size_t pos) noexcept
auto createOctNum(const T_LexCh *c, size_t n)
auto createPlainString(const T_LexCh *c, size_t n)
constexpr C_ActionRet(T_LexID id, I_LexAttr *unownedAttr=nullptr)
virtual void setLine(unsigned line)=0
virtual ~I_Scanner()=default
virtual void setSource(std::string_view src)=0
virtual void add(unsigned col, T_Char c)=0