mirror of
https://github.com/status-im/NimYAML.git
synced 2025-02-04 15:33:56 +00:00
Even more fixes to event output
This commit is contained in:
parent
8abe91cb32
commit
b15f3dbae9
@ -445,7 +445,9 @@ proc endLevel(c: ParserContext, e: var YamlStreamEvent):
|
||||
c.level.kind = fplMapKey
|
||||
result = lerAdditionalMapEnd
|
||||
of fplUnknown: e = emptyScalar(c)
|
||||
of fplDocument: e = endDocEvent()
|
||||
of fplDocument:
|
||||
when defined(yamlScalarRepInd): e = endDocEvent(c.lex.cur == ltDocumentEnd)
|
||||
else: e = endDocEvent()
|
||||
of fplSinglePairKey:
|
||||
internalError("Unexpected level kind: " & $c.level.kind)
|
||||
|
||||
@ -725,7 +727,8 @@ parserState expectDocEnd:
|
||||
state = startDoc
|
||||
c.ancestry.setLen(0)
|
||||
of ltDocumentEnd:
|
||||
e = endDocEvent()
|
||||
when defined(yamlScalarRepInd): e = endDocEvent(true)
|
||||
else: e = endDocEvent()
|
||||
result = true
|
||||
state = afterDocument
|
||||
c.advance()
|
||||
@ -1097,7 +1100,7 @@ proc renderAttrs(p: YamlParser, tag: TagId, anchor: AnchorId,
|
||||
when defined(yamlScalarRepInd):
|
||||
if isPlain: result &= " <!>"
|
||||
else:
|
||||
result = " <" & p.taglib.uri(tag) & ">"
|
||||
result &= " <" & p.taglib.uri(tag) & ">"
|
||||
|
||||
proc display*(p: YamlParser, event: YamlStreamEvent): string
|
||||
{.raises: [KeyError].} =
|
||||
|
@ -33,6 +33,8 @@ proc yamlTestSuiteEscape*(s: string): string =
|
||||
for c in s:
|
||||
case c
|
||||
of '\l': result.add("\\n")
|
||||
of '\c': result.add("\\c")
|
||||
of '\c': result.add("\\r")
|
||||
of '\\': result.add("\\\\")
|
||||
of '\b': result.add("\\b")
|
||||
of '\t': result.add("\\t")
|
||||
else: result.add(c)
|
@ -62,7 +62,10 @@ type
|
||||
when defined(yamlScalarRepInd):
|
||||
explicitDirectivesEnd*: bool
|
||||
else: discard
|
||||
of yamlEndMap, yamlEndSeq, yamlEndDoc: discard
|
||||
of yamlEndDoc:
|
||||
when defined(yamlScalarRepInd):
|
||||
explicitDocumentEnd*: bool
|
||||
of yamlEndMap, yamlEndSeq: discard
|
||||
of yamlAlias:
|
||||
aliasTarget* : AnchorId
|
||||
|
||||
@ -297,14 +300,19 @@ when defined(yamlScalarRepInd):
|
||||
## creates a new event that marks the start of a YAML document
|
||||
result = YamlStreamEvent(kind: yamlStartDoc,
|
||||
explicitDirectivesEnd: explicit)
|
||||
|
||||
proc endDocEvent*(explicit: bool = false): YamlStreamEvent
|
||||
{.inline, raises: [].} =
|
||||
## creates a new event that marks the end of a YAML document
|
||||
result = YamlStreamEvent(kind: yamlEndDoc, explicitDocumentEnd: explicit)
|
||||
else:
|
||||
proc startDocEvent*(): YamlStreamEvent {.inline, raises: [].} =
|
||||
## creates a new event that marks the start of a YAML document
|
||||
result = YamlStreamEvent(kind: yamlStartDoc)
|
||||
|
||||
proc endDocEvent*(): YamlStreamEvent {.inline, raises: [].} =
|
||||
## creates a new event that marks the end of a YAML document
|
||||
result = YamlStreamEvent(kind: yamlEndDoc)
|
||||
proc endDocEvent*(): YamlStreamEvent {.inline, raises: [].} =
|
||||
## creates a new event that marks the end of a YAML document
|
||||
result = YamlStreamEvent(kind: yamlEndDoc)
|
||||
|
||||
proc startMapEvent*(tag: TagId = yTagQuestionMark,
|
||||
anchor: AnchorId = yAnchorNone): YamlStreamEvent {.inline, raises: [].} =
|
||||
|
Loading…
x
Reference in New Issue
Block a user