add debug fmt string like python's (#14808)

* add debug format string

* remove try except

* add changelog
This commit is contained in:
flywind
2020-06-30 21:21:37 +08:00
committed by GitHub
parent 89a15e417d
commit 8be54b8fa7
3 changed files with 119 additions and 2 deletions

View File

@@ -552,8 +552,18 @@ proc strformatImpl(pattern: NimNode; openChar, closeChar: char): NimNode =
var subexpr = ""
while i < f.len and f[i] != closeChar and f[i] != ':':
subexpr.add f[i]
inc i
if f[i] == '=':
let start = i
inc i
i += f.skipWhitespace(i)
if f[i] == closeChar or f[i] == ':':
result.add newCall(bindSym"add", res, newLit(subexpr & f[start ..< i]))
else:
subexpr.add f[start ..< i]
else:
subexpr.add f[i]
inc i
var x: NimNode
try:
x = parseExpr(subexpr)