diff options
author | xzfc <xzfc@users.noreply.github.com> | 2018-10-28 19:35:30 +0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-10-28 13:35:30 +0100 |
commit | 95a60dc780cf2f87ae4fb15001cb6bc882ae9c7b (patch) | |
tree | 7c526628914c746e6c91ce817491257140366169 /lib | |
parent | ee54d6977bdc70e01af97c7783361477ec811c13 (diff) | |
download | Nim-95a60dc780cf2f87ae4fb15001cb6bc882ae9c7b.tar.gz |
Fix strscans.scanp (#9518)
* strscans: fix typo * strscans: fix #9240 * strscans: add tests
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/strscans.nim | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/pure/strscans.nim b/lib/pure/strscans.nim index 77763ff43..c1c535e55 100644 --- a/lib/pure/strscans.nim +++ b/lib/pure/strscans.nim @@ -129,7 +129,7 @@ to use prefix instead of postfix operators. ``+E`` One or more ``?E`` Zero or One ``E{n,m}`` From ``n`` up to ``m`` times ``E`` -``~Ε`` Not predicate +``~E`` Not predicate ``a ^* b`` Shortcut for ``?(a *(b a))``. Usually used for separators. ``a ^* b`` Shortcut for ``?(a +(b a))``. Usually used for separators. ``'a'`` Matches a single character @@ -456,10 +456,11 @@ macro scanf*(input: string; pattern: static[string]; results: varargs[typed]): b template atom*(input: string; idx: int; c: char): bool = ## Used in scanp for the matching of atoms (usually chars). - idx < input.len and input[idx] == c + ## EOF is matched as ``'\0'``. + (idx < input.len and input[idx] == c) or (idx == input.len and c == '\0') template atom*(input: string; idx: int; s: set[char]): bool = - idx < input.len and input[idx] in s + (idx < input.len and input[idx] in s) or (idx == input.len and '\0' in s) template hasNxt*(input: string; idx: int): bool = idx < input.len |