UTF-8 scanAlphaNumeric.

This commit is contained in:
Ferdinand Majerech 2014-07-29 03:07:31 +02:00
parent a9def88eed
commit 6dd53b55a0

View file

@ -839,6 +839,23 @@ final class Scanner
reader_.sliceBuilder.write(reader_.get(length)); reader_.sliceBuilder.write(reader_.get(length));
} }
void scanAlphaNumericToSlice8(string name)(const Mark startMark)
@system pure nothrow @nogc
{
size_t length = 0;
dchar c = reader_.peek();
while(c.isAlphaNum || "-_"d.canFind(c)) { c = reader_.peek(++length); }
if(length == 0)
{
enum contextMsg = "While scanning " ~ name;
error(contextMsg, startMark, expected("alphanumeric, '-' or '_'", c),
reader_.mark);
return;
}
reader_.sliceBuilder8.write(reader_.get8(length));
}
/// Scan and throw away all characters until next line break. /// Scan and throw away all characters until next line break.
void scanToNextBreak() @safe pure nothrow @nogc void scanToNextBreak() @safe pure nothrow @nogc