Skip to content

Instantly share code, notes, and snippets.

@Varriount
Created September 14, 2021 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Varriount/bc815b21ca6df742b19f22e8f8844b59 to your computer and use it in GitHub Desktop.
Save Varriount/bc815b21ca6df742b19f22e8f8844b59 to your computer and use it in GitHub Desktop.
when npegTrace:
proc doTrace[sType](
msg : string,
opname: string,
iname : string,
ip : int,
s : openArray[sType],
si : int,
ms : var MatchState,
) =
sleep(500)
echo align(if ip >= 0: $ip else: "", 3) &
"|" & align($(peek(ms.precStack)), 3) &
"|" & align($`si`, 3) &
"|" & alignLeft(dumpSubject(s, `si`, 24), 24) &
"|" & alignLeft(iname, 15) &
"|" & alignLeft(opname & " " & msg, 40) &
"|" & repeat("*", ms.backStack.top)
result = quote:
template trace(`ms`: var MatchState, iname, opname: string, `s`: openArray[`sType`], msg = "") =
doTrace(msg, opname, iname, `ip`, `s`, `si`, `ms`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment