diff --git a/source/dyaml/scanner.d b/source/dyaml/scanner.d index 1048e87..b054ddc 100644 --- a/source/dyaml/scanner.d +++ b/source/dyaml/scanner.d @@ -188,29 +188,6 @@ final class Scanner reader_ = null; } - /// If error_ is true, throws a ScannerException constructed from errorData_ and - /// sets error_ to false. - void throwIfError() @safe pure - { - if(!error_) { return; } - error_ = false; - throw new ScannerException(errorData_); - } - - /// Called by internal nothrow/@nogc methods to set an error to be thrown by - /// their callers. - /// - /// See_Also: dyaml.exception.MarkedYamlException - void setError(string context, const Mark contextMark, string problem, - const Mark problemMark) @safe pure nothrow @nogc - { - assert(error_ == false, - "Setting an error when there already is a not yet thrown error"); - error_ = true; - errorData_ = - MarkedYAMLExceptionData(context, contextMark, problem, problemMark); - } - /** * Check if the next token is one of specified types. * @@ -270,6 +247,34 @@ final class Scanner } private: + /// Build an error message in msgBuffer_ and return it as a string. + string buildMsg(S ...)(S args) @trusted pure nothrow @nogc + { + return cast(string)msgBuffer_.printNoGC(args); + } + + /// If error_ is true, throws a ScannerException constructed from errorData_ and + /// sets error_ to false. + void throwIfError() @safe pure + { + if(!error_) { return; } + error_ = false; + throw new ScannerException(errorData_); + } + + /// Called by internal nothrow/@nogc methods to set an error to be thrown by + /// their callers. + /// + /// See_Also: dyaml.exception.MarkedYamlException + void setError(string context, const Mark contextMark, string problem, + const Mark problemMark) @safe pure nothrow @nogc + { + assert(error_ == false, + "Setting an error when there already is a not yet thrown error"); + error_ = true; + errorData_ = MarkedYAMLExceptionData(context, contextMark, problem, problemMark); + } + ///Determine whether or not we need to fetch more tokens before peeking/getting a token. bool needMoreTokens() @safe pure {