From 43e10f496a07927fbb2a250fbb93977f5ed52367 Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Thu, 18 Feb 2016 22:32:25 +0100 Subject: [PATCH] Fixes #3 --- private/fastparse.nim | 6 ++++++ test/parsing.nim | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/private/fastparse.nim b/private/fastparse.nim index f0fba90..9f0ea53 100644 --- a/private/fastparse.nim +++ b/private/fastparse.nim @@ -1174,6 +1174,12 @@ proc parse*(p: YamlParser, s: Stream): YamlStream = else: ensureCorrectIndentation() state = fpBlockObjectStart + of EndOfFile: + closeEverything() + break + of '\t', '\x0A', '\c', '#': + p.lexer.lineEnding() + handleLineEnd(true) else: indentation = 0 closeMoreIndentedLevels() diff --git a/test/parsing.nim b/test/parsing.nim index 123bd6f..b823f18 100644 --- a/test/parsing.nim +++ b/test/parsing.nim @@ -263,4 +263,11 @@ suite "Parsing": test "Parsing: Whitespace before end of flow content": ensure("- [a, b, c ]", startDocEvent(), startSeqEvent(), startSeqEvent(), scalarEvent("a"), scalarEvent("b"), - scalarEvent("c"), endSeqEvent(), endSeqEvent(), endDocEvent()) \ No newline at end of file + scalarEvent("c"), endSeqEvent(), endSeqEvent(), endDocEvent()) + test "Parsing: Empty lines after document": + ensure(":\n\n", startDocEvent(), startMapEvent(), scalarEvent(""), + scalarEvent(""), endMapEvent(), endDocEvent()) + test "Parsing: Empty lines between map elements": + ensure("1: 2\n\n\n3: 4", startDocEvent(), startMapEvent(), + scalarEvent("1"), scalarEvent("2"), scalarEvent("3"), + scalarEvent("4"), endMapEvent(), endDocEvent()) \ No newline at end of file