mirror of https://github.com/status-im/NimYAML.git
updated tests, fixed problems
This commit is contained in:
parent
c1cc0be3f3
commit
c681498701
|
@ -10,6 +10,7 @@ import lexbase, streams, tables, strutils
|
||||||
type
|
type
|
||||||
LexerToken = enum
|
LexerToken = enum
|
||||||
plusStr, minusStr, plusDoc, minusDoc, plusMap, minusMap, plusSeq, minusSeq,
|
plusStr, minusStr, plusDoc, minusDoc, plusMap, minusMap, plusSeq, minusSeq,
|
||||||
|
mapBraces, seqBrackets,
|
||||||
eqVal, eqAli, chevTag, andAnchor, starAnchor, colonContent, sqContent,
|
eqVal, eqAli, chevTag, andAnchor, starAnchor, colonContent, sqContent,
|
||||||
dqContent, litContent, foContent,
|
dqContent, litContent, foContent,
|
||||||
explDirEnd, explDocEnd, noToken
|
explDirEnd, explDocEnd, noToken
|
||||||
|
@ -89,6 +90,18 @@ proc nextToken(lex: var EventLexer): LexerToken =
|
||||||
lex.content.add(lex.buf[lex.bufpos])
|
lex.content.add(lex.buf[lex.bufpos])
|
||||||
lex.bufpos.inc()
|
lex.bufpos.inc()
|
||||||
result = starAnchor
|
result = starAnchor
|
||||||
|
of '{':
|
||||||
|
lex.bufpos.inc()
|
||||||
|
if lex.buf[lex.bufpos] == '}':
|
||||||
|
result = mapBraces
|
||||||
|
else: raise newException(EventStreamError, "Invalid token: {" & lex.buf[lex.bufpos])
|
||||||
|
lex.bufpos.inc()
|
||||||
|
of '[':
|
||||||
|
lex.bufpos.inc()
|
||||||
|
if lex.buf[lex.bufpos] == ']':
|
||||||
|
result = seqBrackets
|
||||||
|
else: raise newException(EventStreamError, "Invalid token: [" & lex.buf[lex.bufpos])
|
||||||
|
lex.bufpos.inc()
|
||||||
else:
|
else:
|
||||||
lex.content = ""
|
lex.content = ""
|
||||||
while lex.buf[lex.bufpos] notin {' ', '\t', '\r', '\l', EndOfFile}:
|
while lex.buf[lex.bufpos] notin {' ', '\t', '\r', '\l', EndOfFile}:
|
||||||
|
@ -210,6 +223,12 @@ proc parseEventStream*(input: Stream): YamlStream =
|
||||||
of minusSeq: eventStart(yamlEndSeq)
|
of minusSeq: eventStart(yamlEndSeq)
|
||||||
of eqVal: eventStart(yamlScalar)
|
of eqVal: eventStart(yamlScalar)
|
||||||
of eqAli: eventStart(yamlAlias)
|
of eqAli: eventStart(yamlAlias)
|
||||||
|
of mapBraces:
|
||||||
|
assertInEvent("braces")
|
||||||
|
curEvent.mapStyle = csFlow
|
||||||
|
of seqBrackets:
|
||||||
|
assertInEvent("brackets")
|
||||||
|
curEvent.seqStyle = csFlow
|
||||||
of chevTag:
|
of chevTag:
|
||||||
assertInEvent("tag")
|
assertInEvent("tag")
|
||||||
if curTag() != yTagQuestionMark:
|
if curTag() != yTagQuestionMark:
|
||||||
|
|
|
@ -73,7 +73,7 @@ macro genTests(): untyped =
|
||||||
|
|
||||||
let errorTests = toHashSet(staticExec("cd " & (absolutePath / "tags" / "error") &
|
let errorTests = toHashSet(staticExec("cd " & (absolutePath / "tags" / "error") &
|
||||||
" && ls -1d *").splitLines())
|
" && ls -1d *").splitLines())
|
||||||
var ignored = toHashSet([".git", "name", "tags", "meta", "G5U8"]) # G5U8 seems wrong
|
var ignored = toHashSet([".git", "name", "tags", "meta"])
|
||||||
|
|
||||||
result = newStmtList()
|
result = newStmtList()
|
||||||
# walkDir for some crude reason does not work with travis build
|
# walkDir for some crude reason does not work with travis build
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit de56edb2d317fdf47ab4bca8a0ae42c06b4afa66
|
Subproject commit 80f289435a56189bbc5ca2f318574e48dbeef8aa
|
|
@ -267,6 +267,8 @@ proc beforeDoc(c: Context, e: var Event): bool =
|
||||||
c.pushLevel(afterDirectivesEnd, -1)
|
c.pushLevel(afterDirectivesEnd, -1)
|
||||||
return true
|
return true
|
||||||
of StreamEnd:
|
of StreamEnd:
|
||||||
|
if seenDirectives:
|
||||||
|
raise c.generateError("Missing `---` after directives")
|
||||||
c.popLevel()
|
c.popLevel()
|
||||||
return false
|
return false
|
||||||
of Indentation:
|
of Indentation:
|
||||||
|
|
Loading…
Reference in New Issue