diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-05-12 01:36:23 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-05-12 01:36:23 +0200 |
commit | c02963bcea8176dab175ac4652a7aad7b5d3566d (patch) | |
tree | a96f5405f236c6b7627e19ea5fffa426398138e8 /lib/pure | |
parent | 8e2528ebbc0a388c06f3d453e608f550c3e57b87 (diff) | |
download | Nim-c02963bcea8176dab175ac4652a7aad7b5d3566d.tar.gz |
Pegs: fixes edge case
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/pegs.nim | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim index b5e69595b..eea20a62c 100644 --- a/lib/pure/pegs.nim +++ b/lib/pure/pegs.nim @@ -659,7 +659,7 @@ proc rawMatch*(s: string, p: Peg, start: int, c: var Captures): int {. of pkSearch: var oldMl = c.ml result = 0 - while start+result < s.len: + while start+result <= s.len: var x = rawMatch(s, p.sons[0], start+result, c) if x >= 0: inc(result, x) @@ -671,7 +671,7 @@ proc rawMatch*(s: string, p: Peg, start: int, c: var Captures): int {. var idx = c.ml # reserve a slot for the subpattern inc(c.ml) result = 0 - while start+result < s.len: + while start+result <= s.len: var x = rawMatch(s, p.sons[0], start+result, c) if x >= 0: if idx < MaxSubpatterns: @@ -1848,3 +1848,7 @@ when isMainModule: assert("Var1=key1;var2=Key2; VAR3". replace(peg"{\ident}('='{\ident})* ';'* \s*", handleMatches)=="var1: 'key1', var2: 'Key2', var3: ''") + + + doAssert "test1".match(peg"""{@}$""") + doAssert "test2".match(peg"""{(!$ .)*} $""") |