Improved error reporting, fixes #23

This commit is contained in:
Felix Krause 2016-09-14 14:53:13 +02:00
parent 1e399aca70
commit 2655d4205f
2 changed files with 4 additions and 3 deletions

View File

@ -195,7 +195,7 @@ proc lineWithMarker(lex: YamlLexer, t: typedesc[BaseLexer], marker: bool):
if lex.curStartPos.line == lex.blSource.lineNumber:
result = lex.blSource.getCurrentLine(false)
if marker: result.add(spaces(lex.curStartPos.column - 1) & "^\n")
else: result = nil
else: result = ""
proc lineWithMarker(lex: YamlLexer, t: typedesc[StringSource], marker: bool):
string =
@ -219,8 +219,7 @@ proc lineWithMarker(lex: YamlLexer, t: typedesc[StringSource], marker: bool):
dec(lineStartIndex)
dec(lineEndIndex)
dec(curLine)
result = lex.sSource.src.substr(lineStartIndex,
lineEndIndex - lineStartIndex - 1) & "\n"
result = lex.sSource.src.substr(lineStartIndex, lineEndIndex - 1) & "\n"
if marker: result.add(spaces(lex.curStartPos.column - 1) & "^\n")
# lexer states

View File

@ -523,6 +523,7 @@ parserState blockObjectStart:
state = scalarEnd
of ltScalarPart:
result = c.handleBlockItemStart(e)
let cachedPos = c.lex.curStartPos
while true:
c.advance()
case c.lex.cur
@ -532,6 +533,7 @@ parserState blockObjectStart:
of ltScalarPart: discard
of ltEmptyLine: c.lex.newlines.inc()
else: break
c.lex.curStartPos = cachedPos
c.lex.newlines = 0
state = plainScalarEnd
stored = blockAfterObject