first steps towards leaner common path in Lexer.advance
This commit is contained in:
parent
0c97b2f573
commit
94d3d21588
|
@ -975,10 +975,10 @@ private:
|
||||||
void lexWhitespace(bool keep)()
|
void lexWhitespace(bool keep)()
|
||||||
{
|
{
|
||||||
current.type = TokenType.whitespace;
|
current.type = TokenType.whitespace;
|
||||||
while (!isEoF() && isWhite())
|
do
|
||||||
{
|
{
|
||||||
nextChar();
|
nextChar();
|
||||||
}
|
}while (!isEoF() && isWhite());
|
||||||
static if (keep) setTokenValue();
|
static if (keep) setTokenValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2102,7 +2102,7 @@ private:
|
||||||
if (ch >= '[' && ch <= '^') return true;
|
if (ch >= '[' && ch <= '^') return true;
|
||||||
if (ch >= '{' && ch <= '~') return true;
|
if (ch >= '{' && ch <= '~') return true;
|
||||||
if (ch == '`') return true;
|
if (ch == '`') return true;
|
||||||
if (isWhite()) return true; //TODO: test only long 'whites'
|
if ((ch & 0x80) && isLongWhite()) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2111,6 +2111,15 @@ private:
|
||||||
auto c = src.front;
|
auto c = src.front;
|
||||||
if (c & 0x80) // multi-byte utf-8
|
if (c & 0x80) // multi-byte utf-8
|
||||||
{
|
{
|
||||||
|
return isLongWhite();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return c == 0x20 || (c >= 0x09 && c <= 0x0d);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isLongWhite()
|
||||||
|
{
|
||||||
|
assert(src.front & 0x80); // only non-ascii
|
||||||
//TODO: here and elsewhere we'd better have
|
//TODO: here and elsewhere we'd better have
|
||||||
// some kind of lookahead in LexSource instead of .save
|
// some kind of lookahead in LexSource instead of .save
|
||||||
auto r = src.save();
|
auto r = src.save();
|
||||||
|
@ -2126,9 +2135,6 @@ private:
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return c == 0x20 || (c >= 0x09 && c <= 0x0d);
|
|
||||||
}
|
|
||||||
|
|
||||||
void errorMessage(string s)
|
void errorMessage(string s)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue