updated tests, fixed problems

This commit is contained in:
Felix Krause 2021-10-22 17:42:48 +02:00
parent c1cc0be3f3
commit c681498701
4 changed files with 23 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import lexbase, streams, tables, strutils
type
LexerToken = enum
plusStr, minusStr, plusDoc, minusDoc, plusMap, minusMap, plusSeq, minusSeq,
mapBraces, seqBrackets,
eqVal, eqAli, chevTag, andAnchor, starAnchor, colonContent, sqContent,
dqContent, litContent, foContent,
explDirEnd, explDocEnd, noToken
@ -89,6 +90,18 @@ proc nextToken(lex: var EventLexer): LexerToken =
lex.content.add(lex.buf[lex.bufpos])
lex.bufpos.inc()
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:
lex.content = ""
while lex.buf[lex.bufpos] notin {' ', '\t', '\r', '\l', EndOfFile}:
@ -210,6 +223,12 @@ proc parseEventStream*(input: Stream): YamlStream =
of minusSeq: eventStart(yamlEndSeq)
of eqVal: eventStart(yamlScalar)
of eqAli: eventStart(yamlAlias)
of mapBraces:
assertInEvent("braces")
curEvent.mapStyle = csFlow
of seqBrackets:
assertInEvent("brackets")
curEvent.seqStyle = csFlow
of chevTag:
assertInEvent("tag")
if curTag() != yTagQuestionMark:

View File

@ -73,7 +73,7 @@ macro genTests(): untyped =
let errorTests = toHashSet(staticExec("cd " & (absolutePath / "tags" / "error") &
" && ls -1d *").splitLines())
var ignored = toHashSet([".git", "name", "tags", "meta", "G5U8"]) # G5U8 seems wrong
var ignored = toHashSet([".git", "name", "tags", "meta"])
result = newStmtList()
# walkDir for some crude reason does not work with travis build

@ -1 +1 @@
Subproject commit de56edb2d317fdf47ab4bca8a0ae42c06b4afa66
Subproject commit 80f289435a56189bbc5ca2f318574e48dbeef8aa

View File

@ -267,6 +267,8 @@ proc beforeDoc(c: Context, e: var Event): bool =
c.pushLevel(afterDirectivesEnd, -1)
return true
of StreamEnd:
if seenDirectives:
raise c.generateError("Missing `---` after directives")
c.popLevel()
return false
of Indentation: