Fixed some bugs

* Ensure that no event is yielded twice at explicit document end
 * Properly handle indentation when comment occurs in a line before the
   start of the node
 * Allow multiline implicit map keys in flow map
This commit is contained in:
Felix Krause 2016-03-19 15:54:19 +01:00
parent 0fc30241b9
commit e45eb7b514
1 changed files with 5 additions and 5 deletions

View File

@ -106,7 +106,9 @@ template handleLineEnd(insideDocument: bool) {.dirty.} =
newlines.inc()
template handleObjectEnd(nextState: FastParseState) {.dirty.} =
if ancestry.len == 0: state = fpExpectDocEnd
if ancestry.len == 0:
level.kind = fplUnknown
state = fpExpectDocEnd
else:
level = ancestry.pop()
if level.kind == fplSinglePairValue:
@ -738,10 +740,7 @@ template handleFlowPlainScalar() {.dirty.} =
content.add(repeat(' ', newlines - 1))
newlines = 0
p.lexer.plainScalar(content, cFlow)
elif explicitFlowKey:
break
else:
parserError("Multiline scalar is not allowed as implicit key")
of '#', EndOfFile: break
of '\l':
p.lexer.bufpos = p.lexer.handleLF(p.lexer.bufpos)
@ -1333,6 +1332,7 @@ proc parse*(p: YamlParser, s: Stream): YamlStream =
p.lexer.lineEnding()
handleLineEnd(true)
state = fpBlockLineStart
level.indentation = -1
of '\'':
handleBlockItemStart()
content = ""