Using peekByte() where possible in Scanner.
This commit is contained in:
parent
078269be36
commit
3d8de67771
|
@ -969,7 +969,7 @@ final class Scanner
|
||||||
scanYAMLDirectiveNumberToSlice(startMark);
|
scanYAMLDirectiveNumberToSlice(startMark);
|
||||||
if(error_) { return; }
|
if(error_) { return; }
|
||||||
|
|
||||||
if(reader_.peek() != '.')
|
if(reader_.peekByte() != '.')
|
||||||
{
|
{
|
||||||
error("While scanning a directive", startMark,
|
error("While scanning a directive", startMark,
|
||||||
expected("digit or '.'", reader_.peek()), reader_.mark);
|
expected("digit or '.'", reader_.peek()), reader_.mark);
|
||||||
|
@ -1045,7 +1045,7 @@ final class Scanner
|
||||||
{
|
{
|
||||||
scanTagHandleToSlice!"directive"(startMark);
|
scanTagHandleToSlice!"directive"(startMark);
|
||||||
if(error_) { return; }
|
if(error_) { return; }
|
||||||
if(reader_.peek() == ' ') { return; }
|
if(reader_.peekByte() == ' ') { return; }
|
||||||
error("While scanning a directive handle", startMark,
|
error("While scanning a directive handle", startMark,
|
||||||
expected("' '", reader_.peek()), reader_.mark);
|
expected("' '", reader_.peek()), reader_.mark);
|
||||||
}
|
}
|
||||||
|
@ -1071,7 +1071,7 @@ final class Scanner
|
||||||
void scanDirectiveIgnoredLine(const Mark startMark) @safe pure nothrow @nogc
|
void scanDirectiveIgnoredLine(const Mark startMark) @safe pure nothrow @nogc
|
||||||
{
|
{
|
||||||
findNextNonSpace();
|
findNextNonSpace();
|
||||||
if(reader_.peek() == '#') { scanToNextBreak(); }
|
if(reader_.peekByte() == '#') { scanToNextBreak(); }
|
||||||
if("\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek()))
|
if("\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek()))
|
||||||
{
|
{
|
||||||
scanLineBreak();
|
scanLineBreak();
|
||||||
|
@ -1107,7 +1107,7 @@ final class Scanner
|
||||||
if(error_) { return Token.init; }
|
if(error_) { return Token.init; }
|
||||||
|
|
||||||
if(!" \t\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek()) &&
|
if(!" \t\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek()) &&
|
||||||
!"?:,]}%@"d.canFind(reader_.peek()))
|
!"?:,]}%@"d.canFind(reader_.peekByte()))
|
||||||
{
|
{
|
||||||
enum anchorCtx = "While scanning an anchor";
|
enum anchorCtx = "While scanning an anchor";
|
||||||
enum aliasCtx = "While scanning an alias";
|
enum aliasCtx = "While scanning an alias";
|
||||||
|
@ -1149,7 +1149,7 @@ final class Scanner
|
||||||
handleEnd = 0;
|
handleEnd = 0;
|
||||||
scanTagURIToSlice!"tag"(startMark);
|
scanTagURIToSlice!"tag"(startMark);
|
||||||
if(error_) { return Token.init; }
|
if(error_) { return Token.init; }
|
||||||
if(reader_.peek() != '>')
|
if(reader_.peekByte() != '>')
|
||||||
{
|
{
|
||||||
error("While scanning a tag", startMark,
|
error("While scanning a tag", startMark,
|
||||||
expected("'>'", reader_.peek()), reader_.mark);
|
expected("'>'", reader_.peek()), reader_.mark);
|
||||||
|
@ -1252,10 +1252,10 @@ final class Scanner
|
||||||
dchar lineBreak = cast(dchar)int.max;
|
dchar lineBreak = cast(dchar)int.max;
|
||||||
|
|
||||||
// Scan the inner part of the block scalar.
|
// Scan the inner part of the block scalar.
|
||||||
while(reader_.column == indent && reader_.peek() != '\0')
|
while(reader_.column == indent && reader_.peekByte() != '\0')
|
||||||
{
|
{
|
||||||
breaksTransaction.commit();
|
breaksTransaction.commit();
|
||||||
const bool leadingNonSpace = !" \t"d.canFind(reader_.peek());
|
const bool leadingNonSpace = !" \t"d.canFind(reader_.peekByte());
|
||||||
// This is where the 'interesting' non-whitespace data gets read.
|
// This is where the 'interesting' non-whitespace data gets read.
|
||||||
scanToNextBreakToSlice();
|
scanToNextBreakToSlice();
|
||||||
lineBreak = scanLineBreak();
|
lineBreak = scanLineBreak();
|
||||||
|
@ -1272,13 +1272,13 @@ final class Scanner
|
||||||
// This will not run during the last iteration (see the if() vs the
|
// This will not run during the last iteration (see the if() vs the
|
||||||
// while()), hence breaksTransaction rollback (which happens after this
|
// while()), hence breaksTransaction rollback (which happens after this
|
||||||
// loop) will never roll back data written in this if() block.
|
// loop) will never roll back data written in this if() block.
|
||||||
if(reader_.column == indent && reader_.peek() != '\0')
|
if(reader_.column == indent && reader_.peekByte() != '\0')
|
||||||
{
|
{
|
||||||
// Unfortunately, folding rules are ambiguous.
|
// Unfortunately, folding rules are ambiguous.
|
||||||
|
|
||||||
// This is the folding according to the specification:
|
// This is the folding according to the specification:
|
||||||
if(style == ScalarStyle.Folded && lineBreak == '\n' &&
|
if(style == ScalarStyle.Folded && lineBreak == '\n' &&
|
||||||
leadingNonSpace && !" \t"d.canFind(reader_.peek()))
|
leadingNonSpace && !" \t"d.canFind(reader_.peekByte()))
|
||||||
{
|
{
|
||||||
// No breaks were scanned; no need to insert the space in the
|
// No breaks were scanned; no need to insert the space in the
|
||||||
// middle of slice.
|
// middle of slice.
|
||||||
|
@ -1301,7 +1301,7 @@ final class Scanner
|
||||||
//{
|
//{
|
||||||
// if(startLen == endLen)
|
// if(startLen == endLen)
|
||||||
// {
|
// {
|
||||||
// if(!" \t"d.canFind(reader_.peek()))
|
// if(!" \t"d.canFind(reader_.peekByte()))
|
||||||
// {
|
// {
|
||||||
// reader_.sliceBuilder.write(' ');
|
// reader_.sliceBuilder.write(' ');
|
||||||
// }
|
// }
|
||||||
|
@ -1435,7 +1435,7 @@ final class Scanner
|
||||||
void scanBlockScalarIgnoredLine(const Mark startMark) @safe pure nothrow @nogc
|
void scanBlockScalarIgnoredLine(const Mark startMark) @safe pure nothrow @nogc
|
||||||
{
|
{
|
||||||
findNextNonSpace();
|
findNextNonSpace();
|
||||||
if(reader_.peek()== '#') { scanToNextBreak(); }
|
if(reader_.peekByte()== '#') { scanToNextBreak(); }
|
||||||
|
|
||||||
if("\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek()))
|
if("\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek()))
|
||||||
{
|
{
|
||||||
|
@ -1458,7 +1458,7 @@ final class Scanner
|
||||||
|
|
||||||
while(" \n\r\u0085\u2028\u2029"d.canFind(reader_.peek()))
|
while(" \n\r\u0085\u2028\u2029"d.canFind(reader_.peek()))
|
||||||
{
|
{
|
||||||
if(reader_.peek() != ' ')
|
if(reader_.peekByte() != ' ')
|
||||||
{
|
{
|
||||||
reader_.sliceBuilder.write(scanLineBreak());
|
reader_.sliceBuilder.write(scanLineBreak());
|
||||||
endMark = reader_.mark;
|
endMark = reader_.mark;
|
||||||
|
@ -1481,7 +1481,7 @@ final class Scanner
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
while(reader_.column < indent && reader_.peek() == ' ') { reader_.forward(); }
|
while(reader_.column < indent && reader_.peekByte() == ' ') { reader_.forward(); }
|
||||||
if(!"\n\r\u0085\u2028\u2029"d.canFind(reader_.peek())) { break; }
|
if(!"\n\r\u0085\u2028\u2029"d.canFind(reader_.peek())) { break; }
|
||||||
reader_.sliceBuilder.write(scanLineBreak());
|
reader_.sliceBuilder.write(scanLineBreak());
|
||||||
endMark = reader_.mark;
|
endMark = reader_.mark;
|
||||||
|
@ -1702,7 +1702,7 @@ final class Scanner
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip any whitespaces.
|
// Skip any whitespaces.
|
||||||
while(" \t"d.canFind(reader_.peek())) { reader_.forward(); }
|
while(" \t"d.canFind(reader_.peekByte())) { reader_.forward(); }
|
||||||
|
|
||||||
// Encountered a non-whitespace non-linebreak character, so we're done.
|
// Encountered a non-whitespace non-linebreak character, so we're done.
|
||||||
if(!"\n\r\u0085\u2028\u2029"d.canFind(reader_.peek())) { break; }
|
if(!"\n\r\u0085\u2028\u2029"d.canFind(reader_.peek())) { break; }
|
||||||
|
@ -1981,7 +1981,7 @@ final class Scanner
|
||||||
}
|
}
|
||||||
|
|
||||||
enum contextMsg = "While scanning a " ~ name;
|
enum contextMsg = "While scanning a " ~ name;
|
||||||
while(reader_.peek() == '%')
|
while(reader_.peekByte() == '%')
|
||||||
{
|
{
|
||||||
reader_.forward();
|
reader_.forward();
|
||||||
if(bytesUsed == bytes.length)
|
if(bytesUsed == bytes.length)
|
||||||
|
|
Loading…
Reference in a new issue