scanTagHandle is now nothrow @nogc.

This commit is contained in:
Ferdinand Majerech 2014-07-25 16:55:15 +02:00
parent 3574555c3a
commit fe33be52e4

View file

@ -982,7 +982,8 @@ final class Scanner
reader_.sliceBuilder.begin(); reader_.sliceBuilder.begin();
{ {
scope(failure) { reader_.sliceBuilder.finish(); } scope(failure) { reader_.sliceBuilder.finish(); }
scanTagHandleToSlice("directive", startMark); scanTagHandleToSlice!"directive"(startMark);
throwIfError();
} }
auto value = reader_.sliceBuilder.finish(); auto value = reader_.sliceBuilder.finish();
enforce(reader_.peek() == ' ', enforce(reader_.peek() == ' ',
@ -1108,8 +1109,9 @@ final class Scanner
if(useHandle) if(useHandle)
{ {
scanTagHandleToSlice("tag", startMark); scanTagHandleToSlice!"tag"(startMark);
handleEnd = cast(uint)reader_.sliceBuilder.length; handleEnd = cast(uint)reader_.sliceBuilder.length;
throwIfError();
} }
else else
{ {
@ -1669,12 +1671,19 @@ 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 scanTagHandleToSlice(const string name, const Mark startMark) @system pure ///
/// In case of an error, error_ is set. Use throwIfError() to handle this.
void scanTagHandleToSlice(string name)(const Mark startMark)
@system pure nothrow @nogc
{ {
dchar c = reader_.peek(); dchar c = reader_.peek();
enforce(c == '!', enum contextMsg = "While scanning a " ~ name;
new Error("While scanning a " ~ name, startMark, if(c != '!')
"expected a '!', but found: " ~ c.to!string, reader_.mark)); {
auto msg = msgBuffer_.printNoGC("expected a '!', but found: ", c);
setError(contextMsg, startMark, cast(string)msg, reader_.mark);
return;
}
uint length = 1; uint length = 1;
c = reader_.peek(length); c = reader_.peek(length);
@ -1688,9 +1697,9 @@ final class Scanner
if(c != '!') if(c != '!')
{ {
reader_.forward(length); reader_.forward(length);
throw new Error("While scanning a " ~ name, startMark, auto msg = msgBuffer_.printNoGC("expected a '!', but found: ", c);
"expected a '!', but found: " ~ c.to!string, setError(contextMsg, startMark, cast(string)msg, reader_.mark);
reader_.mark); return;
} }
++length; ++length;
} }