Reduced dead code and compiler warnings

This commit is contained in:
Felix Krause 2016-04-03 11:45:48 +02:00
parent f2c83cc170
commit 6ad7e33bb5
5 changed files with 6 additions and 36 deletions

View File

@ -5,24 +5,15 @@
# distribution, for details about the copyright.
proc newYamlNode*(content: string, tag: string = "?"): YamlNode =
new(result)
result.kind = yScalar
result.content = content
result.tag = tag
YamlNode(kind: yScalar, content: content, tag: tag)
proc newYamlNode*(children: openarray[YamlNode], tag: string = "?"):
YamlNode =
new(result)
result.kind = ySequence
result.children = @children
result.tag = tag
YamlNode(kind: ySequence, children: @children, tag: tag)
proc newYamlNode*(pairs: openarray[tuple[key, value: YamlNode]],
tag: string = "?"): YamlNode =
new(result)
result.kind = yMapping
result.pairs = @pairs
result.tag = tag
YamlNode(kind: yMapping, pairs: @pairs, tag: tag)
proc initYamlDoc*(root: YamlNode): YamlDocument = result.root = root

View File

@ -22,10 +22,7 @@ type
LexedDirective = enum
ldYaml, ldTag, ldUnknown
LexedPossibleDirectivesEnd = enum
lpdeDirectivesEnd, lpdeSequenceItem, lpdeScalarContent
YamlContext = enum
cBlock, cFlow
@ -805,12 +802,6 @@ template handleFlowPlainScalar() {.dirty.} =
yieldShallowScalar(content)
handleObjectEnd(fpFlowAfterObject)
template ensureCorrectIndentation() {.dirty.} =
if level.indentation != indentation:
startToken()
parserError("Invalid indentation: " & $indentation &
" (expected indentation of " & $level.indentation & ")")
template tagHandle(lexer: var BaseLexer, content: var string,
shorthandEnd: var int) =
debug("lex: tagHandle")
@ -924,7 +915,6 @@ template blockScalarHeader() {.dirty.} =
template blockScalarLine() {.dirty.} =
debug("lex: blockScalarLine")
let startedAt = content.len
if indentation < level.indentation:
if p.lexer.buf[p.lexer.bufpos] == '#':
# skip all following comment lines
@ -975,7 +965,6 @@ proc parse*(p: YamlParser, s: Stream): YamlStream =
anchors: Table[string, AnchorId]
nextAnchorId: AnchorId
content: string = ""
curContent = 1
after: string = ""
tagUri: string = ""
tag: TagId

View File

@ -4,11 +4,6 @@
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
proc initRefNodeData(p: pointer): RefNodeData =
result.p = p
result.count = 1
result.anchor = yAnchorNone
proc newConstructionContext*(): ConstructionContext =
new(result)
result.refs = initTable[AnchorId, pointer]()

View File

@ -173,7 +173,7 @@ proc parseEventStream*(input: Stream, tagLib: TagLibrary): YamlStream =
var
inEvent = false
curEvent: YamlStreamEvent
streamPos = beforeStream
streamPos: StreamPos = beforeStream
anchors = initTable[string, AnchorId]()
nextAnchorId = 0.AnchorId
while lex.buf[lex.bufpos] != EndOfFile:

View File

@ -227,12 +227,7 @@ type
indentationStep*: int
newlines*: NewLineStyle
outputVersion*: OutputYamlVersion
RefNodeData = object
p: pointer
count: int
anchor: AnchorId
ConstructionContext* = ref object
## Context information for the process of constructing Nim values from YAML.
refs: Table[AnchorId, pointer]