scanYAMLDirectiveValue is now nothrow @nogc.
This commit is contained in:
parent
58b42750aa
commit
271eca053a
|
@ -948,11 +948,9 @@ final class Scanner
|
||||||
|
|
||||||
// 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"d) { scanYAMLDirectiveValueToSlice(startMark); }
|
||||||
scope(failure) { reader_.sliceBuilder.finish(); }
|
else if(name == "TAG"d) { scanTagDirectiveValueToSlice(startMark, tagHandleEnd); }
|
||||||
if(name == "YAML"d) { scanYAMLDirectiveValueToSlice(startMark); }
|
throwIfError();
|
||||||
else if(name == "TAG"d) { scanTagDirectiveValueToSlice(startMark, tagHandleEnd); }
|
|
||||||
}
|
|
||||||
const value = reader_.sliceBuilder.finish();
|
const value = reader_.sliceBuilder.finish();
|
||||||
|
|
||||||
Mark endMark = reader_.mark;
|
Mark endMark = reader_.mark;
|
||||||
|
@ -995,36 +993,51 @@ final class Scanner
|
||||||
///
|
///
|
||||||
/// Assumes that the caller is building a slice in Reader, and puts the scanned
|
/// Assumes that the caller is building a slice in Reader, and puts the scanned
|
||||||
/// characters into that slice.
|
/// characters into that slice.
|
||||||
void scanYAMLDirectiveValueToSlice(const Mark startMark) @system pure
|
///
|
||||||
|
/// In case of an error, error_ is set. Use throwIfError() to handle this.
|
||||||
|
void scanYAMLDirectiveValueToSlice(const Mark startMark)
|
||||||
|
@system pure nothrow @nogc
|
||||||
{
|
{
|
||||||
findNextNonSpace();
|
findNextNonSpace();
|
||||||
|
|
||||||
scanYAMLDirectiveNumberToSlice(startMark);
|
scanYAMLDirectiveNumberToSlice(startMark);
|
||||||
enforce(reader_.peek() == '.',
|
if(error_) { return; }
|
||||||
new Error("While scanning a directive", startMark,
|
|
||||||
"expected a digit or '.', but found: "
|
if(reader_.peek() != '.')
|
||||||
~ to!string(reader_.peek()), reader_.mark));
|
{
|
||||||
|
error("While scanning a directive", startMark,
|
||||||
|
expected("digit or '.'", reader_.peek()), reader_.mark);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Skip the '.'.
|
// Skip the '.'.
|
||||||
reader_.forward();
|
reader_.forward();
|
||||||
|
|
||||||
reader_.sliceBuilder.write('.');
|
reader_.sliceBuilder.write('.');
|
||||||
scanYAMLDirectiveNumberToSlice(startMark);
|
scanYAMLDirectiveNumberToSlice(startMark);
|
||||||
enforce(" \0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek()),
|
if(error_) { return; }
|
||||||
new Error("While scanning a directive", startMark,
|
|
||||||
"expected a digit or '.', but found: "
|
if(!" \0\n\r\u0085\u2028\u2029"d.canFind(reader_.peek()))
|
||||||
~ to!string(reader_.peek()), reader_.mark));
|
{
|
||||||
|
error("While scanning a directive", startMark,
|
||||||
|
expected("digit or '.'", reader_.peek()), reader_.mark);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scan a number from a YAML directive.
|
/// Scan a number from a YAML directive.
|
||||||
///
|
///
|
||||||
/// Assumes that the caller is building a slice in Reader, and puts the scanned
|
/// Assumes that the caller is building a slice in Reader, and puts the scanned
|
||||||
/// characters into that slice.
|
/// characters into that slice.
|
||||||
void scanYAMLDirectiveNumberToSlice(const Mark startMark) @system pure
|
///
|
||||||
|
/// In case of an error, error_ is set. Use throwIfError() to handle this.
|
||||||
|
void scanYAMLDirectiveNumberToSlice(const Mark startMark)
|
||||||
|
@system pure nothrow @nogc
|
||||||
{
|
{
|
||||||
enforce(isDigit(reader_.peek()),
|
if(!isDigit(reader_.peek()))
|
||||||
new Error("While scanning a directive", startMark,
|
{
|
||||||
"expected a digit, but found: " ~
|
error("While scanning a directive", startMark,
|
||||||
reader_.peek().to!string, reader_.mark));
|
expected("digit", reader_.peek()), reader_.mark);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Already found the first digit in the enforce(), so set length to 1.
|
// Already found the first digit in the enforce(), so set length to 1.
|
||||||
uint length = 1;
|
uint length = 1;
|
||||||
|
|
Loading…
Reference in a new issue