From 09b11470acd26c307253ebbec7d0dacc228e74b2 Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Sat, 26 Jul 2014 02:53:05 +0200 Subject: [PATCH] scanBlockScalar is now nothrow. --- source/dyaml/scanner.d | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/dyaml/scanner.d b/source/dyaml/scanner.d index 37e7afb..9642165 100644 --- a/source/dyaml/scanner.d +++ b/source/dyaml/scanner.d @@ -709,7 +709,9 @@ final class Scanner //A simple key may follow a block scalar. allowSimpleKey_ = true; - tokens_.push(scanBlockScalar(style)); + auto blockScalar = scanBlockScalar(style); + throwIfError(); + tokens_.push(blockScalar); } /// Aliases to add literal or folded block scalar. @@ -1162,8 +1164,9 @@ final class Scanner } /// Scan a block scalar token with specified style. - Token scanBlockScalar(const ScalarStyle style) - @trusted pure + /// + /// In case of an error, error_ is set. Use throwIfError() to handle this. + Token scanBlockScalar(const ScalarStyle style) @trusted pure nothrow { const startMark = reader_.mark; @@ -1171,12 +1174,12 @@ final class Scanner reader_.forward(); const indicators = scanBlockScalarIndicators(startMark); - throwIfError(); + if(error_) { return Token.init; } const chomping = indicators[0]; const increment = indicators[1]; scanBlockScalarIgnoredLine(startMark); - throwIfError(); + if(error_) { return Token.init; } // Determine the indentation level and go to the first non-empty line. Mark endMark;