mirror of https://github.com/status-im/NimYAML.git
Fixes #5
This commit is contained in:
parent
b13d8fa201
commit
c9dae4430c
|
@ -309,7 +309,8 @@ template leaveFlowLevel() {.dirty.} =
|
|||
template handlePossibleMapStart() {.dirty.} =
|
||||
if level.indentation == -1:
|
||||
var flowDepth = 0
|
||||
for pos in countup(p.lexer.bufpos, p.lexer.bufpos + 1024):
|
||||
var pos = p.lexer.bufpos
|
||||
while pos < p.lexer.bufpos + 1024:
|
||||
case p.lexer.buf[pos]
|
||||
of ':':
|
||||
if flowDepth == 0 and p.lexer.buf[pos + 1] in spaceOrLineEnd:
|
||||
|
@ -317,17 +318,20 @@ template handlePossibleMapStart() {.dirty.} =
|
|||
break
|
||||
of lineEnd:
|
||||
break
|
||||
of '[', '{':
|
||||
flowDepth.inc()
|
||||
of '}', ']':
|
||||
flowDepth.inc(-1)
|
||||
of '[', '{': flowDepth.inc()
|
||||
of '}', ']': flowDepth.inc(-1)
|
||||
of '?':
|
||||
if flowDepth == 0: break
|
||||
of '#':
|
||||
if p.lexer.buf[pos - 1] in space:
|
||||
break
|
||||
else:
|
||||
discard
|
||||
if p.lexer.buf[pos - 1] in space: break
|
||||
of '"':
|
||||
pos.inc()
|
||||
while p.lexer.buf[pos] notin {'"', EndOfFile, '\x0A', '\c'}:
|
||||
if p.lexer.buf[pos] == '\\': pos.inc()
|
||||
pos.inc()
|
||||
if p.lexer.buf[pos] != '"': break
|
||||
else: discard
|
||||
pos.inc()
|
||||
if level.indentation == -1:
|
||||
level.indentation = indentation
|
||||
|
||||
|
|
|
@ -219,4 +219,8 @@ suite "Parsing":
|
|||
ensure(" foo:\n - bar\n baz:", startDocEvent(), startMapEvent(),
|
||||
scalarEvent("foo"), startSeqEvent(), scalarEvent("bar"),
|
||||
endSeqEvent(), scalarEvent("baz"), scalarEvent(""),
|
||||
endMapEvent(), endDocEvent())
|
||||
endMapEvent(), endDocEvent())
|
||||
test "Parsing: Colon in double quoted string":
|
||||
ensure("\"foo: bar\\\": baz\"", startDocEvent(),
|
||||
scalarEvent("foo: bar\": baz", yTagExclamationMark),
|
||||
endDocEvent())
|
Loading…
Reference in New Issue