support -d:yamlDebug at CT

This commit is contained in:
Timothee Cour 2020-11-14 10:58:52 -08:00 committed by flyx
parent 45321cad13
commit fcae534148
2 changed files with 6 additions and 8 deletions

View File

@ -125,11 +125,6 @@ proc afterPairValue(c: Context, e: var Event): bool
proc emitCached(c: Context, e: var Event): bool proc emitCached(c: Context, e: var Event): bool
{.pop.} {.pop.}
template debug(message: string) {.dirty.} =
when defined(yamlDebug):
try: styledWriteLine(stdout, fgBlue, message)
except ValueError, IOError: discard
template pushLevel(c: Context, newState: State, newIndent: int) = template pushLevel(c: Context, newState: State, newIndent: int) =
debug("parser: push " & newState.astToStr & ", indent = " & $newIndent) debug("parser: push " & newState.astToStr & ", indent = " & $newIndent)
c.levels.add(Level(state: newState, indentation: newIndent)) c.levels.add(Level(state: newState, indentation: newIndent))

View File

@ -167,10 +167,13 @@ proc streamEnd(lex: var Lexer): bool {.raises: [].}
# helpers # helpers
template debug(message: string) {.dirty.} = template debug*(message: string) =
when defined(yamlDebug): when defined(yamlDebug):
try: styledWriteLine(stdout, fgBlue, message) when nimvm:
except ValueError, IOError: discard echo "yamlDebug: ", message
else:
try: styledWriteLine(stdout, fgBlue, message)
except ValueError, IOError: discard
proc generateError(lex: Lexer, message: string): proc generateError(lex: Lexer, message: string):
ref LexerError {.raises: [].} = ref LexerError {.raises: [].} =