Skip to content

Commit

Permalink
support -d:yamlDebug at CT
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour authored and flyx committed Nov 14, 2020
1 parent 45321ca commit fcae534
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 0 additions & 5 deletions yaml/parser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
9 changes: 6 additions & 3 deletions yaml/private/lex.nim
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,13 @@ proc streamEnd(lex: var Lexer): bool {.raises: [].}

# helpers

template debug(message: string) {.dirty.} =
template debug*(message: string) =
when defined(yamlDebug):
try: styledWriteLine(stdout, fgBlue, message)
except ValueError, IOError: discard
when nimvm:
echo "yamlDebug: ", message
else:
try: styledWriteLine(stdout, fgBlue, message)
except ValueError, IOError: discard

proc generateError(lex: Lexer, message: string):
ref LexerError {.raises: [].} =
Expand Down

0 comments on commit fcae534

Please sign in to comment.