From 45d8db08d1fb0e5301f61772f1f2ab217c57d510 Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Thu, 24 Jul 2014 18:43:33 +0200 Subject: [PATCH] Use of throwIfError for handling scanPlain errors. --- source/dyaml/scanner.d | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/source/dyaml/scanner.d b/source/dyaml/scanner.d index 6afcdbd..7b570c3 100644 --- a/source/dyaml/scanner.d +++ b/source/dyaml/scanner.d @@ -717,25 +717,21 @@ final class Scanner alias fetchFlowScalar!(ScalarStyle.SingleQuoted) fetchSingle; alias fetchFlowScalar!(ScalarStyle.DoubleQuoted) fetchDouble; - ///Add plain SCALAR token. + /// Add plain SCALAR token. void fetchPlain() @trusted { - //A plain scalar could be a simple key + // A plain scalar could be a simple key savePossibleSimpleKey(); - //No simple keys after plain scalars. But note that scanPlain() will - //change this flag if the scan is finished at the beginning of the line. + // No simple keys after plain scalars. But note that scanPlain() will + // change this flag if the scan is finished at the beginning of the line. allowSimpleKey_ = false; const plain = scanPlain(); - if(error_) - { - error_ = false; - throw new Error(errorData_); - } - //Scan and add SCALAR. May change allowSimpleKey_ + throwIfError(); + + // Scan and add SCALAR. May change allowSimpleKey_ tokens_.push(plain); } - ///Check if the next token is DIRECTIVE: ^ '%' ... bool checkDirective() @safe pure nothrow @nogc {