diff options
author | Araq <rumpf_a@web.de> | 2018-01-06 17:27:19 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-01-06 17:27:19 +0100 |
commit | 06e68feadb4becb653e5e55fd2ef85e1eafd9ba4 (patch) | |
tree | a90e3a9eb4cb11de41349576a416379ce2dc584b | |
parent | 9bc263839904787e68602dc55ddbd9832c1066b6 (diff) | |
download | Nim-06e68feadb4becb653e5e55fd2ef85e1eafd9ba4.tar.gz |
strscans: fix the type checking logic; improve the documentation
-rw-r--r-- | lib/pure/strscans.nim | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/pure/strscans.nim b/lib/pure/strscans.nim index 83a82dd0b..2bd87837f 100644 --- a/lib/pure/strscans.nim +++ b/lib/pure/strscans.nim @@ -333,37 +333,37 @@ macro scanf*(input: string; pattern: static[string]; results: varargs[typed]): b conds.add resLen.notZero conds.add resLen of 'w': - if i < results.len or getType(results[i]).typeKind != ntyString: + if i < results.len and getType(results[i]).typeKind == ntyString: matchBind "parseIdent" else: error("no string var given for $w") inc i of 'b': - if i < results.len or getType(results[i]).typeKind != ntyInt: + if i < results.len and getType(results[i]).typeKind == ntyInt: matchBind "parseBin" else: error("no int var given for $b") inc i of 'o': - if i < results.len or getType(results[i]).typeKind != ntyInt: + if i < results.len and getType(results[i]).typeKind == ntyInt: matchBind "parseOct" else: error("no int var given for $o") inc i of 'i': - if i < results.len or getType(results[i]).typeKind != ntyInt: + if i < results.len and getType(results[i]).typeKind == ntyInt: matchBind "parseInt" else: error("no int var given for $i") inc i of 'h': - if i < results.len or getType(results[i]).typeKind != ntyInt: + if i < results.len and getType(results[i]).typeKind == ntyInt: matchBind "parseHex" else: error("no int var given for $h") inc i of 'f': - if i < results.len or getType(results[i]).typeKind != ntyFloat: + if i < results.len and getType(results[i]).typeKind == ntyFloat: matchBind "parseFloat" else: error("no float var given for $f") @@ -378,7 +378,7 @@ macro scanf*(input: string; pattern: static[string]; results: varargs[typed]): b else: error("invalid format string") of '*', '+': - if i < results.len or getType(results[i]).typeKind != ntyString: + if i < results.len and getType(results[i]).typeKind == ntyString: var min = ord(pattern[p] == '+') var q=p+1 var token = "" @@ -462,7 +462,7 @@ template success*(x: int): bool = x != 0 template nxt*(input: string; idx, step: int = 1) = inc(idx, step) macro scanp*(input, idx: typed; pattern: varargs[untyped]): bool = - ## See top level documentation of his module of how ``scanp`` works. + ## ``scanp`` is currently undocumented. type StmtTriple = tuple[init, cond, action: NimNode] template interf(x): untyped = bindSym(x, brForceOpen) |