mirror of
https://github.com/status-im/NimYAML.git
synced 2025-01-11 20:14:19 +00:00
fastparse: Improvements to flow parsing
This commit is contained in:
parent
f670c5c86b
commit
c89f07e1fd
@ -1076,7 +1076,11 @@ proc fastparse*(tagLib: TagLibrary, s: Stream): YamlStream =
|
||||
anchor = yAnchorNone
|
||||
level.kind = fplMapKey
|
||||
of fplMapKey:
|
||||
discard
|
||||
if tag != yTagQuestionmark or anchor != yAnchorNone:
|
||||
yield scalarEvent("", tag, anchor)
|
||||
tag = yTagQuestionmark
|
||||
anchor = yAnchorNone
|
||||
yield scalarEvent("", tag, anchor)
|
||||
of fplSequence:
|
||||
raiseError("Unexpected token (expected ']')", lexer.bufpos)
|
||||
of fplUnknown, fplScalar:
|
||||
@ -1088,7 +1092,10 @@ proc fastparse*(tagLib: TagLibrary, s: Stream): YamlStream =
|
||||
level = ancestry.pop()
|
||||
case level.kind
|
||||
of fplSequence:
|
||||
yield endSeqEvent()
|
||||
if tag != yTagQuestionmark or anchor != yAnchorNone:
|
||||
yield scalarEvent("", tag, anchor)
|
||||
tag = yTagQuestionmark
|
||||
anchor = yAnchorNone
|
||||
of fplMapKey, fplMapValue:
|
||||
raiseError("Unexpected token (expected '}')", lexer.bufpos)
|
||||
of fplUnknown, fplScalar:
|
||||
|
@ -124,6 +124,7 @@ proc constructJson*(s: YamlStream): seq[JsonNode] =
|
||||
levels[levels.high].node.elems.add(level.node)
|
||||
of JObject:
|
||||
if isNil(levels[levels.high].key):
|
||||
echo level.node.pretty()
|
||||
raise newException(ValueError,
|
||||
"non-scalar as key not allowed in JSON")
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user