mirror of https://github.com/status-im/NimYAML.git
Fixed a problem with comment after plain scalar
This commit is contained in:
parent
a720abdc44
commit
54703ae577
|
@ -63,6 +63,8 @@ template parserError(message: string) {.dirty.} =
|
||||||
e.line = p.lexer.lineNumber
|
e.line = p.lexer.lineNumber
|
||||||
e.column = p.tokenstart + 1
|
e.column = p.tokenstart + 1
|
||||||
e.lineContent = p.getLineContent(true)
|
e.lineContent = p.getLineContent(true)
|
||||||
|
echo "line ", e.line, ", column ", e.column, ": ", message
|
||||||
|
echo e.lineContent
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
template lexerError(lx: BaseLexer, message: string) {.dirty.} =
|
template lexerError(lx: BaseLexer, message: string) {.dirty.} =
|
||||||
|
@ -921,8 +923,12 @@ template blockScalar(lexer: BaseLexer, content: var string,
|
||||||
stateAfter = fpBlockLineStart
|
stateAfter = fpBlockLineStart
|
||||||
break outer
|
break outer
|
||||||
else:
|
else:
|
||||||
startToken()
|
if lexer.getColNumber(lexer.bufpos) > parentIndent:
|
||||||
parserError("The text is less indented than expected")
|
startToken()
|
||||||
|
parserError("The text is less indented than expected ")
|
||||||
|
else:
|
||||||
|
stateAfter = fpBlockLineStart
|
||||||
|
break outer
|
||||||
lexer.bufpos.inc()
|
lexer.bufpos.inc()
|
||||||
else:
|
else:
|
||||||
while true:
|
while true:
|
||||||
|
@ -1191,7 +1197,7 @@ proc parse*(p: YamlParser, s: Stream): YamlStream =
|
||||||
ensureCorrectIndentation()
|
ensureCorrectIndentation()
|
||||||
state = fpBlockObjectStart
|
state = fpBlockObjectStart
|
||||||
of fpBlockContinueScalar:
|
of fpBlockContinueScalar:
|
||||||
debug("state: blockAfterPlainScalar")
|
debug("state: fpBlockContinueScalar")
|
||||||
p.lexer.skipWhitespace()
|
p.lexer.skipWhitespace()
|
||||||
case p.lexer.buf[p.lexer.bufpos]
|
case p.lexer.buf[p.lexer.bufpos]
|
||||||
of '\l':
|
of '\l':
|
||||||
|
@ -1276,7 +1282,7 @@ proc parse*(p: YamlParser, s: Stream): YamlStream =
|
||||||
of '#':
|
of '#':
|
||||||
p.lexer.lineEnding()
|
p.lexer.lineEnding()
|
||||||
handleLineEnd(true)
|
handleLineEnd(true)
|
||||||
handleObjectEnd(fpBlockLineStart)
|
state = fpBlockLineStart
|
||||||
else:
|
else:
|
||||||
startToken()
|
startToken()
|
||||||
parserError("Illegal token (expected ':', comment or line end)")
|
parserError("Illegal token (expected ':', comment or line end)")
|
||||||
|
@ -1324,6 +1330,7 @@ proc parse*(p: YamlParser, s: Stream): YamlStream =
|
||||||
var stateAfter: FastParseState
|
var stateAfter: FastParseState
|
||||||
content = ""
|
content = ""
|
||||||
p.lexer.blockScalar(content, stateAfter)
|
p.lexer.blockScalar(content, stateAfter)
|
||||||
|
if tag == yTagQuestionMark: tag = yTagExclamationMark
|
||||||
yield scalarEvent(content, tag, anchor)
|
yield scalarEvent(content, tag, anchor)
|
||||||
handleObjectEnd(stateAfter)
|
handleObjectEnd(stateAfter)
|
||||||
of '-':
|
of '-':
|
||||||
|
|
Loading…
Reference in New Issue