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
{.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) =
debug("parser: push " & newState.astToStr & ", indent = " & $newIndent)
c.levels.add(Level(state: newState, indentation: newIndent))

View File

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