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
|
anchor = yAnchorNone
|
||||||
level.kind = fplMapKey
|
level.kind = fplMapKey
|
||||||
of fplMapKey:
|
of fplMapKey:
|
||||||
discard
|
if tag != yTagQuestionmark or anchor != yAnchorNone:
|
||||||
|
yield scalarEvent("", tag, anchor)
|
||||||
|
tag = yTagQuestionmark
|
||||||
|
anchor = yAnchorNone
|
||||||
|
yield scalarEvent("", tag, anchor)
|
||||||
of fplSequence:
|
of fplSequence:
|
||||||
raiseError("Unexpected token (expected ']')", lexer.bufpos)
|
raiseError("Unexpected token (expected ']')", lexer.bufpos)
|
||||||
of fplUnknown, fplScalar:
|
of fplUnknown, fplScalar:
|
||||||
@ -1088,7 +1092,10 @@ proc fastparse*(tagLib: TagLibrary, s: Stream): YamlStream =
|
|||||||
level = ancestry.pop()
|
level = ancestry.pop()
|
||||||
case level.kind
|
case level.kind
|
||||||
of fplSequence:
|
of fplSequence:
|
||||||
yield endSeqEvent()
|
if tag != yTagQuestionmark or anchor != yAnchorNone:
|
||||||
|
yield scalarEvent("", tag, anchor)
|
||||||
|
tag = yTagQuestionmark
|
||||||
|
anchor = yAnchorNone
|
||||||
of fplMapKey, fplMapValue:
|
of fplMapKey, fplMapValue:
|
||||||
raiseError("Unexpected token (expected '}')", lexer.bufpos)
|
raiseError("Unexpected token (expected '}')", lexer.bufpos)
|
||||||
of fplUnknown, fplScalar:
|
of fplUnknown, fplScalar:
|
||||||
|
@ -124,6 +124,7 @@ proc constructJson*(s: YamlStream): seq[JsonNode] =
|
|||||||
levels[levels.high].node.elems.add(level.node)
|
levels[levels.high].node.elems.add(level.node)
|
||||||
of JObject:
|
of JObject:
|
||||||
if isNil(levels[levels.high].key):
|
if isNil(levels[levels.high].key):
|
||||||
|
echo level.node.pretty()
|
||||||
raise newException(ValueError,
|
raise newException(ValueError,
|
||||||
"non-scalar as key not allowed in JSON")
|
"non-scalar as key not allowed in JSON")
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user