From a8d68d1696dcc5c453745dfb762ab4fcbe1e1590 Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Thu, 22 Sep 2016 14:25:10 +0200 Subject: [PATCH] Addressed some compiler warnings --- yaml/parser.nim | 20 +------------------- yaml/serialization.nim | 21 +++++++++------------ 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/yaml/parser.nim b/yaml/parser.nim index 496ce4e..8debfbf 100644 --- a/yaml/parser.nim +++ b/yaml/parser.nim @@ -215,10 +215,6 @@ proc handleAnchor(c: ParserContext) {.raises: [YamlParserError].} = c.lex.buf.setLen(0) c.advance() -proc continueMultilineScalar(c: ParserContext) {.raises: [].} = - c.lex.buf.add(if c.newlines == 1: " " else: repeat('\l', c.newlines - 1)) - c.newlines = 0 - proc handleTagHandle(c: ParserContext) {.raises: [YamlParserError].} = if c.level.kind != fplUnknown: raise c.generateError("Unexpected tag handle") if c.tag != yTagQuestionMark: @@ -413,7 +409,7 @@ macro parserState(name: untyped, impl: untyped): typed = parserStates(initial, blockLineStart, blockObjectStart, blockAfterObject, scalarEnd, plainScalarEnd, objectEnd, expectDocEnd, startDoc, - afterDocument, closeStream, closeMoreIndentedLevels, + afterDocument, closeMoreIndentedLevels, emitEmptyScalar, tagHandle, anchor, alias, flow, leaveFlowMap, leaveFlowSeq, flowAfterObject, leaveFlowSinglePairMap) @@ -723,20 +719,6 @@ parserState afterDocument: c.initDocValues() state = initial -parserState closeStream: - case c.level.kind - of fplDocument: discard - else: - case c.endLevel(e) - of lerNothing: discard - of lerOne: result = true - of lerAdditionalMapEnd: return true - c.level = c.ancestry.pop() - if result: return - e = endDocEvent() - result = true - c.isFinished = true - parserState closeMoreIndentedLevels: if c.ancestry.len > 0: let parent = c.ancestry[c.ancestry.high] diff --git a/yaml/serialization.nim b/yaml/serialization.nim index fb1b8f8..1bdfee2 100644 --- a/yaml/serialization.nim +++ b/yaml/serialization.nim @@ -69,7 +69,7 @@ proc constructChild*[O](s: var YamlStream, c: ConstructionContext, ## node which will be resolved using the ``ConstructionContext``. proc representChild*[O](value: ref O, ts: TagStyle, c: SerializationContext) - {.raises: [YamlStreamError].} + {.raises: [].} ## Represents an arbitrary Nim reference value as YAML object. The object ## may be represented as alias node if it is already present in the ## ``SerializationContext``. @@ -78,8 +78,7 @@ proc representChild*(value: string, ts: TagStyle, c: SerializationContext) {.inline, raises: [].} ## Represents a Nim string. Supports nil strings. -proc representChild*[O](value: O, ts: TagStyle, - c: SerializationContext) {.raises: [YamlStreamError].} +proc representChild*[O](value: O, ts: TagStyle, c: SerializationContext) ## Represents an arbitrary Nim object as YAML object. proc newConstructionContext*(): ConstructionContext = @@ -335,7 +334,7 @@ proc constructObject*[T](s: var YamlStream, c: ConstructionContext, discard s.next() proc representObject*[T](value: seq[T]|set[T], ts: TagStyle, - c: SerializationContext, tag: TagId) {.raises: [YamlStreamError].} = + c: SerializationContext, tag: TagId) = ## represents a Nim seq as YAML sequence let childTagStyle = if ts == tsRootOnly: tsNone else: ts c.put(startSeqEvent(tag)) @@ -366,7 +365,7 @@ proc constructObject*[I, T](s: var YamlStream, c: ConstructionContext, raise newException(YamlConstructionError, "Too much array values") proc representObject*[I, T](value: array[I, T], ts: TagStyle, - c: SerializationContext, tag: TagId) {.raises: [YamlStreamError].} = + c: SerializationContext, tag: TagId) = ## represents a Nim array as YAML sequence let childTagStyle = if ts == tsRootOnly: tsNone else: ts c.put(startSeqEvent(tag)) @@ -404,7 +403,7 @@ proc constructObject*[K, V](s: var YamlStream, c: ConstructionContext, discard s.next() proc representObject*[K, V](value: Table[K, V], ts: TagStyle, - c: SerializationContext, tag: TagId) {.raises:[YamlStreamError].} = + c: SerializationContext, tag: TagId) = ## represents a Nim Table as YAML mapping let childTagStyle = if ts == tsRootOnly: tsNone else: ts c.put(startMapEvent(tag)) @@ -450,7 +449,7 @@ proc constructObject*[K, V](s: var YamlStream, c: ConstructionContext, discard s.next() proc representObject*[K, V](value: OrderedTable[K, V], ts: TagStyle, - c: SerializationContext, tag: TagId) {.raises: [YamlStreamError].} = + c: SerializationContext, tag: TagId) = let childTagStyle = if ts == tsRootOnly: tsNone else: ts c.put(startSeqEvent(tag)) for key, value in value.pairs: @@ -655,7 +654,7 @@ proc constructObject*[O: object|tuple]( else: ensureAllFieldsPresent(O, result, matched) proc representObject*[O: object|tuple](value: O, ts: TagStyle, - c: SerializationContext, tag: TagId) {.raises: [YamlStreamError].} = + c: SerializationContext, tag: TagId) = ## represents a Nim object or tuple as YAML mapping let childTagStyle = if ts == tsRootOnly: tsNone else: ts when isVariantObject(O): c.put(startSeqEvent(tag, yAnchorNone)) @@ -985,8 +984,7 @@ proc setAnchor(a: var AnchorId, q: var Table[pointer, AnchorId]) if a != yAnchorNone: a = q.getOrDefault(cast[pointer](a)) proc represent*[T](value: T, ts: TagStyle = tsRootOnly, - a: AnchorStyle = asTidy): YamlStream - {.raises: [YamlStreamError].} = + a: AnchorStyle = asTidy): YamlStream = ## Represents a Nim value as ``YamlStream`` var bys = newBufferYamlStream() var context = newSerializationContext(a, proc(e: YamlStreamEvent) = @@ -1020,8 +1018,7 @@ proc dump*[K](value: K, target: Stream, tagStyle: TagStyle = tsRootOnly, proc dump*[K](value: K, tagStyle: TagStyle = tsRootOnly, anchorStyle: AnchorStyle = asTidy, options: PresentationOptions = defaultPresentationOptions): - string {.raises: [YamlPresenterJsonError, YamlPresenterOutputError, - YamlStreamError].} = + string = ## Dump a Nim value as YAML into a string var events = represent(value, if options.style == psCanonical: tsAll else: tagStyle,