Removed -8 suffixes from Reader methods.
This commit is contained in:
parent
eb266b4e27
commit
c473ef7dee
|
@ -135,7 +135,7 @@ final class Reader
|
||||||
validateResult.sequence.to!string));
|
validateResult.sequence.to!string));
|
||||||
characterCount_ = validateResult.characterCount;
|
characterCount_ = validateResult.characterCount;
|
||||||
|
|
||||||
this.sliceBuilder8 = SliceBuilder8(this);
|
this.sliceBuilder = SliceBuilder(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get character at specified index relative to current position.
|
/// Get character at specified index relative to current position.
|
||||||
|
@ -198,9 +198,9 @@ final class Reader
|
||||||
/// returned slice will be shorter.
|
/// returned slice will be shorter.
|
||||||
///
|
///
|
||||||
/// Returns: Characters starting at current position or an empty slice if out of bounds.
|
/// Returns: Characters starting at current position or an empty slice if out of bounds.
|
||||||
char[] prefix8(const size_t length) @safe pure nothrow @nogc
|
char[] prefix(const size_t length) @safe pure nothrow @nogc
|
||||||
{
|
{
|
||||||
return slice8(length);
|
return slice(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a slice view of the internal buffer, starting at the current position.
|
/// Get a slice view of the internal buffer, starting at the current position.
|
||||||
|
@ -213,7 +213,7 @@ final class Reader
|
||||||
/// be shorter.
|
/// be shorter.
|
||||||
///
|
///
|
||||||
/// Returns: Slice into the internal buffer or an empty slice if out of bounds.
|
/// Returns: Slice into the internal buffer or an empty slice if out of bounds.
|
||||||
char[] slice8(const size_t end) @safe pure nothrow @nogc
|
char[] slice(const size_t end) @safe pure nothrow @nogc
|
||||||
{
|
{
|
||||||
// Fast path in case the caller has already peek()ed all the way to end.
|
// Fast path in case the caller has already peek()ed all the way to end.
|
||||||
if(end == lastDecodedCharOffset_)
|
if(end == lastDecodedCharOffset_)
|
||||||
|
@ -252,9 +252,9 @@ final class Reader
|
||||||
/// Params: length = Number or characters (code points, not bytes) to get.
|
/// Params: length = Number or characters (code points, not bytes) to get.
|
||||||
///
|
///
|
||||||
/// Returns: Characters starting at current position.
|
/// Returns: Characters starting at current position.
|
||||||
char[] get8(const size_t length) @safe pure nothrow @nogc
|
char[] get(const size_t length) @safe pure nothrow @nogc
|
||||||
{
|
{
|
||||||
auto result = prefix8(length);
|
auto result = prefix(length);
|
||||||
forward(length);
|
forward(length);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ final class Reader
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used to build slices of read data in Reader; to avoid allocations.
|
/// Used to build slices of read data in Reader; to avoid allocations.
|
||||||
SliceBuilder8 sliceBuilder8;
|
SliceBuilder sliceBuilder;
|
||||||
|
|
||||||
/// Get a string describing current buffer position, used for error messages.
|
/// Get a string describing current buffer position, used for error messages.
|
||||||
final Mark mark() @safe pure nothrow const @nogc { return Mark(line_, column_); }
|
final Mark mark() @safe pure nothrow const @nogc { return Mark(line_, column_); }
|
||||||
|
@ -349,12 +349,12 @@ private:
|
||||||
/// changed due to how YAML interprets certain characters/strings.
|
/// changed due to how YAML interprets certain characters/strings.
|
||||||
///
|
///
|
||||||
/// See begin() documentation.
|
/// See begin() documentation.
|
||||||
struct SliceBuilder8
|
struct SliceBuilder
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// No copying by the user.
|
// No copying by the user.
|
||||||
@disable this(this);
|
@disable this(this);
|
||||||
@disable void opAssign(ref SliceBuilder8);
|
@disable void opAssign(ref SliceBuilder);
|
||||||
|
|
||||||
// Reader this builder works in.
|
// Reader this builder works in.
|
||||||
Reader reader_;
|
Reader reader_;
|
||||||
|
@ -521,7 +521,7 @@ public:
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// The slice builder affected by the transaction.
|
// The slice builder affected by the transaction.
|
||||||
SliceBuilder8* builder_ = null;
|
SliceBuilder* builder_ = null;
|
||||||
// Index of the return point of the transaction in StringBuilder.endStack_.
|
// Index of the return point of the transaction in StringBuilder.endStack_.
|
||||||
size_t stackLevel_;
|
size_t stackLevel_;
|
||||||
// True after commit() has been called.
|
// True after commit() has been called.
|
||||||
|
@ -535,7 +535,7 @@ public:
|
||||||
/// ended either by commit()-ing or reverting through the destructor.
|
/// ended either by commit()-ing or reverting through the destructor.
|
||||||
///
|
///
|
||||||
/// Saves the current state of a slice.
|
/// Saves the current state of a slice.
|
||||||
this(ref SliceBuilder8 builder) @system pure nothrow @nogc
|
this(ref SliceBuilder builder) @system pure nothrow @nogc
|
||||||
{
|
{
|
||||||
builder_ = &builder;
|
builder_ = &builder;
|
||||||
stackLevel_ = builder_.endStackUsed_;
|
stackLevel_ = builder_.endStackUsed_;
|
||||||
|
@ -816,7 +816,7 @@ void testPeekPrefixForward(R)()
|
||||||
assert(reader.peek(2) == 't');
|
assert(reader.peek(2) == 't');
|
||||||
assert(reader.peek(3) == 'a');
|
assert(reader.peek(3) == 'a');
|
||||||
assert(reader.peek(4) == '\0');
|
assert(reader.peek(4) == '\0');
|
||||||
assert(reader.prefix8(4) == "data");
|
assert(reader.prefix(4) == "data");
|
||||||
// assert(reader.prefix(6) == "data\0");
|
// assert(reader.prefix(6) == "data\0");
|
||||||
reader.forward(2);
|
reader.forward(2);
|
||||||
assert(reader.peek(1) == 'a');
|
assert(reader.peek(1) == 'a');
|
||||||
|
|
|
@ -741,7 +741,7 @@ final class Scanner
|
||||||
// Check one char first, then all 3, to prevent reading outside the buffer.
|
// Check one char first, then all 3, to prevent reading outside the buffer.
|
||||||
return reader_.column == 0 &&
|
return reader_.column == 0 &&
|
||||||
reader_.peek() == '-' &&
|
reader_.peek() == '-' &&
|
||||||
reader_.prefix8(3) == "---" &&
|
reader_.prefix(3) == "---" &&
|
||||||
" \t\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek(3));
|
" \t\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -751,7 +751,7 @@ final class Scanner
|
||||||
// Check one char first, then all 3, to prevent reading outside the buffer.
|
// Check one char first, then all 3, to prevent reading outside the buffer.
|
||||||
return reader_.column == 0 &&
|
return reader_.column == 0 &&
|
||||||
reader_.peek() == '.' &&
|
reader_.peek() == '.' &&
|
||||||
reader_.prefix8(3) == "..." &&
|
reader_.prefix(3) == "..." &&
|
||||||
" \t\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek(3));
|
" \t\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -831,7 +831,7 @@ final class Scanner
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
reader_.sliceBuilder8.write(reader_.get8(length));
|
reader_.sliceBuilder.write(reader_.get(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scan and throw away all characters until next line break.
|
/// Scan and throw away all characters until next line break.
|
||||||
|
@ -854,7 +854,7 @@ final class Scanner
|
||||||
{
|
{
|
||||||
++length;
|
++length;
|
||||||
}
|
}
|
||||||
reader_.sliceBuilder8.write(reader_.get8(length));
|
reader_.sliceBuilder.write(reader_.get(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -904,19 +904,19 @@ final class Scanner
|
||||||
reader_.forward();
|
reader_.forward();
|
||||||
|
|
||||||
// Scan directive name
|
// Scan directive name
|
||||||
reader_.sliceBuilder8.begin();
|
reader_.sliceBuilder.begin();
|
||||||
scanDirectiveNameToSlice(startMark);
|
scanDirectiveNameToSlice(startMark);
|
||||||
if(error_) { return Token.init; }
|
if(error_) { return Token.init; }
|
||||||
const name = reader_.sliceBuilder8.finish();
|
const name = reader_.sliceBuilder.finish();
|
||||||
|
|
||||||
reader_.sliceBuilder8.begin();
|
reader_.sliceBuilder.begin();
|
||||||
|
|
||||||
// Index where tag handle ends and suffix starts in a tag directive value.
|
// Index where tag handle ends and suffix starts in a tag directive value.
|
||||||
uint tagHandleEnd = uint.max;
|
uint tagHandleEnd = uint.max;
|
||||||
if(name == "YAML") { scanYAMLDirectiveValueToSlice(startMark); }
|
if(name == "YAML") { scanYAMLDirectiveValueToSlice(startMark); }
|
||||||
else if(name == "TAG") { tagHandleEnd = scanTagDirectiveValueToSlice(startMark); }
|
else if(name == "TAG") { tagHandleEnd = scanTagDirectiveValueToSlice(startMark); }
|
||||||
if(error_) { return Token.init; }
|
if(error_) { return Token.init; }
|
||||||
const value = reader_.sliceBuilder8.finish();
|
const value = reader_.sliceBuilder.finish();
|
||||||
|
|
||||||
Mark endMark = reader_.mark;
|
Mark endMark = reader_.mark;
|
||||||
|
|
||||||
|
@ -975,7 +975,7 @@ final class Scanner
|
||||||
// Skip the '.'.
|
// Skip the '.'.
|
||||||
reader_.forward();
|
reader_.forward();
|
||||||
|
|
||||||
reader_.sliceBuilder8.write('.');
|
reader_.sliceBuilder.write('.');
|
||||||
scanYAMLDirectiveNumberToSlice(startMark);
|
scanYAMLDirectiveNumberToSlice(startMark);
|
||||||
if(error_) { return; }
|
if(error_) { return; }
|
||||||
|
|
||||||
|
@ -1006,7 +1006,7 @@ final class Scanner
|
||||||
uint length = 1;
|
uint length = 1;
|
||||||
while(isDigit(reader_.peek(length))) { ++length; }
|
while(isDigit(reader_.peek(length))) { ++length; }
|
||||||
|
|
||||||
reader_.sliceBuilder8.write(reader_.get8(length));
|
reader_.sliceBuilder.write(reader_.get(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scan value of a tag directive.
|
/// Scan value of a tag directive.
|
||||||
|
@ -1021,10 +1021,10 @@ final class Scanner
|
||||||
@system pure nothrow
|
@system pure nothrow
|
||||||
{
|
{
|
||||||
findNextNonSpace();
|
findNextNonSpace();
|
||||||
const startLength = reader_.sliceBuilder8.length;
|
const startLength = reader_.sliceBuilder.length;
|
||||||
scanTagDirectiveHandleToSlice(startMark);
|
scanTagDirectiveHandleToSlice(startMark);
|
||||||
if(error_) { return uint.max; }
|
if(error_) { return uint.max; }
|
||||||
const handleLength = cast(uint)(reader_.sliceBuilder8.length - startLength);
|
const handleLength = cast(uint)(reader_.sliceBuilder.length - startLength);
|
||||||
findNextNonSpace();
|
findNextNonSpace();
|
||||||
scanTagDirectivePrefixToSlice(startMark);
|
scanTagDirectivePrefixToSlice(startMark);
|
||||||
|
|
||||||
|
@ -1095,11 +1095,11 @@ final class Scanner
|
||||||
const startMark = reader_.mark;
|
const startMark = reader_.mark;
|
||||||
const dchar i = reader_.get();
|
const dchar i = reader_.get();
|
||||||
|
|
||||||
reader_.sliceBuilder8.begin();
|
reader_.sliceBuilder.begin();
|
||||||
if(i == '*') { scanAlphaNumericToSlice!"an alias"(startMark); }
|
if(i == '*') { scanAlphaNumericToSlice!"an alias"(startMark); }
|
||||||
else { scanAlphaNumericToSlice!"an anchor"(startMark); }
|
else { scanAlphaNumericToSlice!"an anchor"(startMark); }
|
||||||
// On error, value is discarded as we return immediately
|
// On error, value is discarded as we return immediately
|
||||||
const value = reader_.sliceBuilder8.finish();
|
const value = reader_.sliceBuilder.finish();
|
||||||
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()) &&
|
||||||
|
@ -1131,8 +1131,8 @@ final class Scanner
|
||||||
const startMark = reader_.mark;
|
const startMark = reader_.mark;
|
||||||
dchar c = reader_.peek(1);
|
dchar c = reader_.peek(1);
|
||||||
|
|
||||||
reader_.sliceBuilder8.begin();
|
reader_.sliceBuilder.begin();
|
||||||
scope(failure) { reader_.sliceBuilder8.finish(); }
|
scope(failure) { reader_.sliceBuilder.finish(); }
|
||||||
// Index where tag handle ends and tag suffix starts in the tag value
|
// Index where tag handle ends and tag suffix starts in the tag value
|
||||||
// (slice) we will produce.
|
// (slice) we will produce.
|
||||||
uint handleEnd;
|
uint handleEnd;
|
||||||
|
@ -1156,7 +1156,7 @@ final class Scanner
|
||||||
{
|
{
|
||||||
reader_.forward();
|
reader_.forward();
|
||||||
handleEnd = 0;
|
handleEnd = 0;
|
||||||
reader_.sliceBuilder8.write('!');
|
reader_.sliceBuilder.write('!');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1177,14 +1177,14 @@ final class Scanner
|
||||||
if(useHandle)
|
if(useHandle)
|
||||||
{
|
{
|
||||||
scanTagHandleToSlice!"tag"(startMark);
|
scanTagHandleToSlice!"tag"(startMark);
|
||||||
handleEnd = cast(uint)reader_.sliceBuilder8.length;
|
handleEnd = cast(uint)reader_.sliceBuilder.length;
|
||||||
if(error_) { return Token.init; }
|
if(error_) { return Token.init; }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reader_.forward();
|
reader_.forward();
|
||||||
reader_.sliceBuilder8.write('!');
|
reader_.sliceBuilder.write('!');
|
||||||
handleEnd = cast(uint)reader_.sliceBuilder8.length;
|
handleEnd = cast(uint)reader_.sliceBuilder.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
scanTagURIToSlice!"tag"(startMark);
|
scanTagURIToSlice!"tag"(startMark);
|
||||||
|
@ -1193,7 +1193,7 @@ final class Scanner
|
||||||
|
|
||||||
if(" \0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek()))
|
if(" \0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek()))
|
||||||
{
|
{
|
||||||
const slice = reader_.sliceBuilder8.finish();
|
const slice = reader_.sliceBuilder.finish();
|
||||||
return tagToken(startMark, reader_.mark, slice, handleEnd);
|
return tagToken(startMark, reader_.mark, slice, handleEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1224,13 +1224,13 @@ final class Scanner
|
||||||
Mark endMark;
|
Mark endMark;
|
||||||
uint indent = max(1, indent_ + 1);
|
uint indent = max(1, indent_ + 1);
|
||||||
|
|
||||||
reader_.sliceBuilder8.begin();
|
reader_.sliceBuilder.begin();
|
||||||
alias Transaction = SliceBuilder8.Transaction;
|
alias Transaction = SliceBuilder.Transaction;
|
||||||
// Used to strip the last line breaks written to the slice at the end of the
|
// Used to strip the last line breaks written to the slice at the end of the
|
||||||
// scalar, which may be needed based on chomping.
|
// scalar, which may be needed based on chomping.
|
||||||
Transaction breaksTransaction = Transaction(reader_.sliceBuilder8);
|
Transaction breaksTransaction = Transaction(reader_.sliceBuilder);
|
||||||
// Read the first indentation/line breaks before the scalar.
|
// Read the first indentation/line breaks before the scalar.
|
||||||
size_t startLen = reader_.sliceBuilder8.length;
|
size_t startLen = reader_.sliceBuilder.length;
|
||||||
if(increment == int.min)
|
if(increment == int.min)
|
||||||
{
|
{
|
||||||
auto indentation = scanBlockScalarIndentationToSlice();
|
auto indentation = scanBlockScalarIndentationToSlice();
|
||||||
|
@ -1258,8 +1258,8 @@ final class Scanner
|
||||||
|
|
||||||
// This transaction serves to rollback data read in the
|
// This transaction serves to rollback data read in the
|
||||||
// scanBlockScalarBreaksToSlice() call.
|
// scanBlockScalarBreaksToSlice() call.
|
||||||
breaksTransaction = Transaction(reader_.sliceBuilder8);
|
breaksTransaction = Transaction(reader_.sliceBuilder);
|
||||||
startLen = reader_.sliceBuilder8.length;
|
startLen = reader_.sliceBuilder.length;
|
||||||
// The line breaks should actually be written _after_ the if() block
|
// The line breaks should actually be written _after_ the if() block
|
||||||
// below. We work around that by inserting
|
// below. We work around that by inserting
|
||||||
endMark = scanBlockScalarBreaksToSlice(indent);
|
endMark = scanBlockScalarBreaksToSlice(indent);
|
||||||
|
@ -1277,16 +1277,16 @@ final class Scanner
|
||||||
{
|
{
|
||||||
// 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.
|
||||||
if(startLen == reader_.sliceBuilder8.length)
|
if(startLen == reader_.sliceBuilder.length)
|
||||||
{
|
{
|
||||||
reader_.sliceBuilder8.write(' ');
|
reader_.sliceBuilder.write(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We need to insert in the middle of the slice in case any line
|
// We need to insert in the middle of the slice in case any line
|
||||||
// breaks were scanned.
|
// breaks were scanned.
|
||||||
reader_.sliceBuilder8.insert(lineBreak, startLen);
|
reader_.sliceBuilder.insert(lineBreak, startLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
////this is Clark Evans's interpretation (also in the spec
|
////this is Clark Evans's interpretation (also in the spec
|
||||||
|
@ -1298,7 +1298,7 @@ final class Scanner
|
||||||
// {
|
// {
|
||||||
// if(!" \t"d.canFind(reader_.peek()))
|
// if(!" \t"d.canFind(reader_.peek()))
|
||||||
// {
|
// {
|
||||||
// reader_.sliceBuilder8.write(' ');
|
// reader_.sliceBuilder.write(' ');
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
|
@ -1308,7 +1308,7 @@ final class Scanner
|
||||||
//}
|
//}
|
||||||
//else
|
//else
|
||||||
//{
|
//{
|
||||||
// reader_.sliceBuilder8.insertBack(lineBreak, endLen - startLen);
|
// reader_.sliceBuilder.insertBack(lineBreak, endLen - startLen);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1329,18 +1329,18 @@ final class Scanner
|
||||||
// be inserted _before_ the other line breaks.
|
// be inserted _before_ the other line breaks.
|
||||||
if(chomping == Chomping.Keep)
|
if(chomping == Chomping.Keep)
|
||||||
{
|
{
|
||||||
reader_.sliceBuilder8.insert(lineBreak, startLen);
|
reader_.sliceBuilder.insert(lineBreak, startLen);
|
||||||
}
|
}
|
||||||
// If chomping is not Keep, breaksTransaction was cancelled so we can
|
// If chomping is not Keep, breaksTransaction was cancelled so we can
|
||||||
// directly write the first line break (as it isn't stripped - chomping
|
// directly write the first line break (as it isn't stripped - chomping
|
||||||
// is not Strip)
|
// is not Strip)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reader_.sliceBuilder8.write(lineBreak);
|
reader_.sliceBuilder.write(lineBreak);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const slice = reader_.sliceBuilder8.finish();
|
const slice = reader_.sliceBuilder.finish();
|
||||||
return scalarToken(startMark, endMark, slice, style);
|
return scalarToken(startMark, endMark, slice, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1455,7 +1455,7 @@ final class Scanner
|
||||||
{
|
{
|
||||||
if(reader_.peek() != ' ')
|
if(reader_.peek() != ' ')
|
||||||
{
|
{
|
||||||
reader_.sliceBuilder8.write(scanLineBreak());
|
reader_.sliceBuilder.write(scanLineBreak());
|
||||||
endMark = reader_.mark;
|
endMark = reader_.mark;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1478,7 +1478,7 @@ final class Scanner
|
||||||
{
|
{
|
||||||
while(reader_.column < indent && reader_.peek() == ' ') { reader_.forward(); }
|
while(reader_.column < indent && reader_.peek() == ' ') { 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_.sliceBuilder8.write(scanLineBreak());
|
reader_.sliceBuilder.write(scanLineBreak());
|
||||||
endMark = reader_.mark;
|
endMark = reader_.mark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1493,8 +1493,8 @@ final class Scanner
|
||||||
const startMark = reader_.mark;
|
const startMark = reader_.mark;
|
||||||
const quote = reader_.get();
|
const quote = reader_.get();
|
||||||
|
|
||||||
reader_.sliceBuilder8.begin();
|
reader_.sliceBuilder.begin();
|
||||||
scope(exit) if(error_) { reader_.sliceBuilder8.finish(); }
|
scope(exit) if(error_) { reader_.sliceBuilder.finish(); }
|
||||||
|
|
||||||
scanFlowScalarNonSpacesToSlice(quotes, startMark);
|
scanFlowScalarNonSpacesToSlice(quotes, startMark);
|
||||||
if(error_) { return Token.init; }
|
if(error_) { return Token.init; }
|
||||||
|
@ -1508,7 +1508,7 @@ final class Scanner
|
||||||
}
|
}
|
||||||
reader_.forward();
|
reader_.forward();
|
||||||
|
|
||||||
auto slice = reader_.sliceBuilder8.finish();
|
auto slice = reader_.sliceBuilder.finish();
|
||||||
return scalarToken(startMark, reader_.mark, slice, quotes);
|
return scalarToken(startMark, reader_.mark, slice, quotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1532,7 +1532,7 @@ final class Scanner
|
||||||
// while(!search.canFind(reader_.peek(length))) { ++length; }
|
// while(!search.canFind(reader_.peek(length))) { ++length; }
|
||||||
outer: for(;;)
|
outer: for(;;)
|
||||||
{
|
{
|
||||||
const char[] slice = reader_.slice8(length + 32);
|
const char[] slice = reader_.slice(length + 32);
|
||||||
if(slice.length == length)
|
if(slice.length == length)
|
||||||
{
|
{
|
||||||
error("While reading a flow scalar", startMark,
|
error("While reading a flow scalar", startMark,
|
||||||
|
@ -1548,19 +1548,19 @@ final class Scanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reader_.sliceBuilder8.write(reader_.get8(length));
|
reader_.sliceBuilder.write(reader_.get(length));
|
||||||
|
|
||||||
c = reader_.peek();
|
c = reader_.peek();
|
||||||
if(quotes == SingleQuoted && c == '\'' && reader_.peek(1) == '\'')
|
if(quotes == SingleQuoted && c == '\'' && reader_.peek(1) == '\'')
|
||||||
{
|
{
|
||||||
reader_.forward(2);
|
reader_.forward(2);
|
||||||
reader_.sliceBuilder8.write('\'');
|
reader_.sliceBuilder.write('\'');
|
||||||
}
|
}
|
||||||
else if((quotes == DoubleQuoted && c == '\'') ||
|
else if((quotes == DoubleQuoted && c == '\'') ||
|
||||||
(quotes == SingleQuoted && "\"\\"d.canFind(c)))
|
(quotes == SingleQuoted && "\"\\"d.canFind(c)))
|
||||||
{
|
{
|
||||||
reader_.forward();
|
reader_.forward();
|
||||||
reader_.sliceBuilder8.write(c);
|
reader_.sliceBuilder.write(c);
|
||||||
}
|
}
|
||||||
else if(quotes == DoubleQuoted && c == '\\')
|
else if(quotes == DoubleQuoted && c == '\\')
|
||||||
{
|
{
|
||||||
|
@ -1573,7 +1573,7 @@ final class Scanner
|
||||||
// place (in a slice) in case of '\P' and '\L' (very uncommon,
|
// place (in a slice) in case of '\P' and '\L' (very uncommon,
|
||||||
// but we don't want to break the spec)
|
// but we don't want to break the spec)
|
||||||
char[2] escapeSequence = ['\\', cast(char)c];
|
char[2] escapeSequence = ['\\', cast(char)c];
|
||||||
reader_.sliceBuilder8.write(escapeSequence);
|
reader_.sliceBuilder.write(escapeSequence);
|
||||||
}
|
}
|
||||||
else if(dyaml.escapes.escapeHexCodeList.canFind(c))
|
else if(dyaml.escapes.escapeHexCodeList.canFind(c))
|
||||||
{
|
{
|
||||||
|
@ -1587,10 +1587,10 @@ final class Scanner
|
||||||
reader_.peek(i)), reader_.mark);
|
reader_.peek(i)), reader_.mark);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char[] hex = reader_.get8(hexLength);
|
char[] hex = reader_.get(hexLength);
|
||||||
char[2] escapeStart = ['\\', cast(char) c];
|
char[2] escapeStart = ['\\', cast(char) c];
|
||||||
reader_.sliceBuilder8.write(escapeStart);
|
reader_.sliceBuilder.write(escapeStart);
|
||||||
reader_.sliceBuilder8.write(hex);
|
reader_.sliceBuilder.write(hex);
|
||||||
bool overflow;
|
bool overflow;
|
||||||
// Note: This is just error checking; Parser does the actual
|
// Note: This is just error checking; Parser does the actual
|
||||||
// escaping (otherwise we could accidentally create an
|
// escaping (otherwise we could accidentally create an
|
||||||
|
@ -1636,7 +1636,7 @@ final class Scanner
|
||||||
// Increase length as long as we see whitespace.
|
// Increase length as long as we see whitespace.
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
while(" \t"d.canFind(reader_.peek(length))) { ++length; }
|
while(" \t"d.canFind(reader_.peek(length))) { ++length; }
|
||||||
auto whitespaces = reader_.prefix8(length);
|
auto whitespaces = reader_.prefix(length);
|
||||||
|
|
||||||
// Can check the last byte without striding because '\0' is ASCII
|
// Can check the last byte without striding because '\0' is ASCII
|
||||||
const c = reader_.peek(length);
|
const c = reader_.peek(length);
|
||||||
|
@ -1651,7 +1651,7 @@ final class Scanner
|
||||||
if(!"\n\r\u0085\u2028\u2029"d.canFind(c))
|
if(!"\n\r\u0085\u2028\u2029"d.canFind(c))
|
||||||
{
|
{
|
||||||
reader_.forward(length);
|
reader_.forward(length);
|
||||||
reader_.sliceBuilder8.write(whitespaces);
|
reader_.sliceBuilder.write(whitespaces);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1659,7 +1659,7 @@ final class Scanner
|
||||||
reader_.forward(length);
|
reader_.forward(length);
|
||||||
const lineBreak = scanLineBreak();
|
const lineBreak = scanLineBreak();
|
||||||
|
|
||||||
if(lineBreak != '\n') { reader_.sliceBuilder8.write(lineBreak); }
|
if(lineBreak != '\n') { reader_.sliceBuilder.write(lineBreak); }
|
||||||
|
|
||||||
// If we have extra line breaks after the first, scan them into the
|
// If we have extra line breaks after the first, scan them into the
|
||||||
// slice.
|
// slice.
|
||||||
|
@ -1667,7 +1667,7 @@ final class Scanner
|
||||||
if(error_) { return; }
|
if(error_) { return; }
|
||||||
|
|
||||||
// No extra breaks, one normal line break. Replace it with a space.
|
// No extra breaks, one normal line break. Replace it with a space.
|
||||||
if(lineBreak == '\n' && !extraBreaks) { reader_.sliceBuilder8.write(' '); }
|
if(lineBreak == '\n' && !extraBreaks) { reader_.sliceBuilder.write(' '); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scan line breaks in a flow scalar.
|
/// Scan line breaks in a flow scalar.
|
||||||
|
@ -1684,7 +1684,7 @@ final class Scanner
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
// Instead of checking indentation, we check for document separators.
|
// Instead of checking indentation, we check for document separators.
|
||||||
const prefix = reader_.prefix8(3);
|
const prefix = reader_.prefix(3);
|
||||||
if((prefix == "---" || prefix == "...") &&
|
if((prefix == "---" || prefix == "...") &&
|
||||||
" \t\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek(3)))
|
" \t\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek(3)))
|
||||||
{
|
{
|
||||||
|
@ -1701,7 +1701,7 @@ final class Scanner
|
||||||
|
|
||||||
const lineBreak = scanLineBreak();
|
const lineBreak = scanLineBreak();
|
||||||
anyBreaks = true;
|
anyBreaks = true;
|
||||||
reader_.sliceBuilder8.write(lineBreak);
|
reader_.sliceBuilder.write(lineBreak);
|
||||||
}
|
}
|
||||||
return anyBreaks;
|
return anyBreaks;
|
||||||
}
|
}
|
||||||
|
@ -1723,9 +1723,9 @@ final class Scanner
|
||||||
|
|
||||||
mixin FastCharSearch!" \t\0\n\r\u0085\u2028\u2029"d search;
|
mixin FastCharSearch!" \t\0\n\r\u0085\u2028\u2029"d search;
|
||||||
|
|
||||||
reader_.sliceBuilder8.begin();
|
reader_.sliceBuilder.begin();
|
||||||
|
|
||||||
alias Transaction = SliceBuilder8.Transaction;
|
alias Transaction = SliceBuilder.Transaction;
|
||||||
Transaction spacesTransaction;
|
Transaction spacesTransaction;
|
||||||
// Stop at a comment.
|
// Stop at a comment.
|
||||||
while(reader_.peek() != '#')
|
while(reader_.peek() != '#')
|
||||||
|
@ -1750,7 +1750,7 @@ final class Scanner
|
||||||
{
|
{
|
||||||
// This is an error; throw the slice away.
|
// This is an error; throw the slice away.
|
||||||
spacesTransaction.commit();
|
spacesTransaction.commit();
|
||||||
reader_.sliceBuilder8.finish();
|
reader_.sliceBuilder.finish();
|
||||||
reader_.forward(length);
|
reader_.forward(length);
|
||||||
error("While scanning a plain scalar", startMark,
|
error("While scanning a plain scalar", startMark,
|
||||||
"found unexpected ':' . Please check "
|
"found unexpected ':' . Please check "
|
||||||
|
@ -1763,16 +1763,16 @@ final class Scanner
|
||||||
|
|
||||||
allowSimpleKey_ = false;
|
allowSimpleKey_ = false;
|
||||||
|
|
||||||
reader_.sliceBuilder8.write(reader_.get8(length));
|
reader_.sliceBuilder.write(reader_.get(length));
|
||||||
|
|
||||||
endMark = reader_.mark;
|
endMark = reader_.mark;
|
||||||
|
|
||||||
spacesTransaction.commit();
|
spacesTransaction.commit();
|
||||||
spacesTransaction = Transaction(reader_.sliceBuilder8);
|
spacesTransaction = Transaction(reader_.sliceBuilder);
|
||||||
|
|
||||||
const startLength = reader_.sliceBuilder8.length;
|
const startLength = reader_.sliceBuilder.length;
|
||||||
scanPlainSpacesToSlice(startMark);
|
scanPlainSpacesToSlice(startMark);
|
||||||
if(startLength == reader_.sliceBuilder8.length ||
|
if(startLength == reader_.sliceBuilder.length ||
|
||||||
(flowLevel_ == 0 && reader_.column < indent))
|
(flowLevel_ == 0 && reader_.column < indent))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -1780,7 +1780,7 @@ final class Scanner
|
||||||
}
|
}
|
||||||
|
|
||||||
spacesTransaction.__dtor();
|
spacesTransaction.__dtor();
|
||||||
const slice = reader_.sliceBuilder8.finish();
|
const slice = reader_.sliceBuilder.finish();
|
||||||
|
|
||||||
return scalarToken(startMark, endMark, slice, ScalarStyle.Plain);
|
return scalarToken(startMark, endMark, slice, ScalarStyle.Plain);
|
||||||
}
|
}
|
||||||
|
@ -1797,14 +1797,14 @@ final class Scanner
|
||||||
// Get as many plain spaces as there are.
|
// Get as many plain spaces as there are.
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
while(reader_.peek(length) == ' ') { ++length; }
|
while(reader_.peek(length) == ' ') { ++length; }
|
||||||
char[] whitespaces = reader_.get8(length);
|
char[] whitespaces = reader_.get(length);
|
||||||
|
|
||||||
dchar c = reader_.peek();
|
dchar c = reader_.peek();
|
||||||
// No newline after the spaces (if any)
|
// No newline after the spaces (if any)
|
||||||
if(!"\n\r\u0085\u2028\u2029"d.canFind(c))
|
if(!"\n\r\u0085\u2028\u2029"d.canFind(c))
|
||||||
{
|
{
|
||||||
// We have spaces, but no newline.
|
// We have spaces, but no newline.
|
||||||
if(whitespaces.length > 0) { reader_.sliceBuilder8.write(whitespaces); }
|
if(whitespaces.length > 0) { reader_.sliceBuilder.write(whitespaces); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1814,7 +1814,7 @@ final class Scanner
|
||||||
|
|
||||||
static bool end(Reader reader_) @safe pure nothrow @nogc
|
static bool end(Reader reader_) @safe pure nothrow @nogc
|
||||||
{
|
{
|
||||||
return ("---" == reader_.prefix8(3) || "..." == reader_.prefix8(3))
|
return ("---" == reader_.prefix(3) || "..." == reader_.prefix(3))
|
||||||
&& " \t\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek(3));
|
&& " \t\0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1822,9 +1822,9 @@ final class Scanner
|
||||||
|
|
||||||
bool extraBreaks = false;
|
bool extraBreaks = false;
|
||||||
|
|
||||||
alias Transaction = SliceBuilder8.Transaction;
|
alias Transaction = SliceBuilder.Transaction;
|
||||||
auto transaction = Transaction(reader_.sliceBuilder8);
|
auto transaction = Transaction(reader_.sliceBuilder);
|
||||||
if(lineBreak != '\n') { reader_.sliceBuilder8.write(lineBreak); }
|
if(lineBreak != '\n') { reader_.sliceBuilder.write(lineBreak); }
|
||||||
while(" \n\r\u0085\u2028\u2029"d.canFind(reader_.peek()))
|
while(" \n\r\u0085\u2028\u2029"d.canFind(reader_.peek()))
|
||||||
{
|
{
|
||||||
if(reader_.peek() == ' ') { reader_.forward(); }
|
if(reader_.peek() == ' ') { reader_.forward(); }
|
||||||
|
@ -1832,7 +1832,7 @@ final class Scanner
|
||||||
{
|
{
|
||||||
const lBreak = scanLineBreak();
|
const lBreak = scanLineBreak();
|
||||||
extraBreaks = true;
|
extraBreaks = true;
|
||||||
reader_.sliceBuilder8.write(lBreak);
|
reader_.sliceBuilder.write(lBreak);
|
||||||
|
|
||||||
if(end(reader_)) { return; }
|
if(end(reader_)) { return; }
|
||||||
}
|
}
|
||||||
|
@ -1840,7 +1840,7 @@ final class Scanner
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
|
|
||||||
// No line breaks, only a space.
|
// No line breaks, only a space.
|
||||||
if(lineBreak == '\n' && !extraBreaks) { reader_.sliceBuilder8.write(' '); }
|
if(lineBreak == '\n' && !extraBreaks) { reader_.sliceBuilder.write(' '); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scan handle of a tag token.
|
/// Scan handle of a tag token.
|
||||||
|
@ -1878,7 +1878,7 @@ final class Scanner
|
||||||
++length;
|
++length;
|
||||||
}
|
}
|
||||||
|
|
||||||
reader_.sliceBuilder8.write(reader_.get8(length));
|
reader_.sliceBuilder.write(reader_.get(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scan URI in a tag token.
|
/// Scan URI in a tag token.
|
||||||
|
@ -1892,15 +1892,15 @@ final class Scanner
|
||||||
{
|
{
|
||||||
// Note: we do not check if URI is well-formed.
|
// Note: we do not check if URI is well-formed.
|
||||||
dchar c = reader_.peek();
|
dchar c = reader_.peek();
|
||||||
const startLen = reader_.sliceBuilder8.length;
|
const startLen = reader_.sliceBuilder.length;
|
||||||
{
|
{
|
||||||
uint length = 0;
|
uint length = 0;
|
||||||
while(c.isAlphaNum || "-;/?:@&=+$,_.!~*\'()[]%"d.canFind(c))
|
while(c.isAlphaNum || "-;/?:@&=+$,_.!~*\'()[]%"d.canFind(c))
|
||||||
{
|
{
|
||||||
if(c == '%')
|
if(c == '%')
|
||||||
{
|
{
|
||||||
auto chars = reader_.get8(length);
|
auto chars = reader_.get(length);
|
||||||
reader_.sliceBuilder8.write(chars);
|
reader_.sliceBuilder.write(chars);
|
||||||
length = 0;
|
length = 0;
|
||||||
scanURIEscapesToSlice!name(startMark);
|
scanURIEscapesToSlice!name(startMark);
|
||||||
if(error_) { return; }
|
if(error_) { return; }
|
||||||
|
@ -1910,13 +1910,13 @@ final class Scanner
|
||||||
}
|
}
|
||||||
if(length > 0)
|
if(length > 0)
|
||||||
{
|
{
|
||||||
auto chars = reader_.get8(length);
|
auto chars = reader_.get(length);
|
||||||
reader_.sliceBuilder8.write(chars);
|
reader_.sliceBuilder.write(chars);
|
||||||
length = 0;
|
length = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// OK if we scanned something, error otherwise.
|
// OK if we scanned something, error otherwise.
|
||||||
if(reader_.sliceBuilder8.length > startLen) { return; }
|
if(reader_.sliceBuilder.length > startLen) { return; }
|
||||||
|
|
||||||
enum contextMsg = "While parsing a " ~ name;
|
enum contextMsg = "While parsing a " ~ name;
|
||||||
error(contextMsg, startMark, expected("URI", c), reader_.mark);
|
error(contextMsg, startMark, expected("URI", c), reader_.mark);
|
||||||
|
@ -1947,7 +1947,7 @@ final class Scanner
|
||||||
import std.utf;
|
import std.utf;
|
||||||
size_t nextChar;
|
size_t nextChar;
|
||||||
const c = std.utf.decode(bytes[], nextChar);
|
const c = std.utf.decode(bytes[], nextChar);
|
||||||
reader_.sliceBuilder8.write(c);
|
reader_.sliceBuilder.write(c);
|
||||||
if(bytes.length - nextChar > 0)
|
if(bytes.length - nextChar > 0)
|
||||||
{
|
{
|
||||||
core.stdc.string.memmove(bytes.ptr, bytes.ptr + nextChar,
|
core.stdc.string.memmove(bytes.ptr, bytes.ptr + nextChar,
|
||||||
|
@ -2024,7 +2024,7 @@ final class Scanner
|
||||||
|
|
||||||
if(c == '\n' || c == '\r' || c == '\u0085')
|
if(c == '\n' || c == '\r' || c == '\u0085')
|
||||||
{
|
{
|
||||||
if(reader_.prefix8(2) == "\r\n") { reader_.forward(2); }
|
if(reader_.prefix(2) == "\r\n") { reader_.forward(2); }
|
||||||
else { reader_.forward(); }
|
else { reader_.forward(); }
|
||||||
return '\n';
|
return '\n';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue