diff options
Diffstat (limited to 'lib/pure/pegs.nim')
-rwxr-xr-x | lib/pure/pegs.nim | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim index 9b2606b33..988e510e3 100755 --- a/lib/pure/pegs.nim +++ b/lib/pure/pegs.nim @@ -736,7 +736,7 @@ proc rawMatch*(s: string, p: TPeg, start: int, c: var TCaptures): int {. var (a, b) = c.matches[p.index] var n: TPeg n.kind = succ(pkTerminal, ord(p.kind)-ord(pkBackRef)) - n.term = s.copy(a, b) + n.term = s.substr(a, b) result = rawMatch(s, n, start, c) of pkStartAnchor: if c.origStart == start: result = 0 @@ -754,7 +754,7 @@ proc match*(s: string, pattern: TPeg, matches: var openarray[string], result = rawMatch(s, pattern, start, c) == len(s) - start if result: for i in 0..c.ml-1: - matches[i] = copy(s, c.matches[i][0], c.matches[i][1]) + matches[i] = substr(s, c.matches[i][0], c.matches[i][1]) proc match*(s: string, pattern: TPeg, start = 0): bool {.nosideEffect, rtl, extern: "npegs$1".} = @@ -774,7 +774,7 @@ proc matchLen*(s: string, pattern: TPeg, matches: var openarray[string], result = rawMatch(s, pattern, start, c) if result >= 0: for i in 0..c.ml-1: - matches[i] = copy(s, c.matches[i][0], c.matches[i][1]) + matches[i] = substr(s, c.matches[i][0], c.matches[i][1]) proc matchLen*(s: string, pattern: TPeg, start = 0): int {.nosideEffect, rtl, extern: "npegs$1".} = @@ -903,7 +903,7 @@ proc replacef*(s: string, sub: TPeg, by: string): string {. else: addf(result, by, caps) inc(i, x) - add(result, copy(s, i)) + add(result, substr(s, i)) proc replace*(s: string, sub: TPeg, by = ""): string {. nosideEffect, rtl, extern: "npegs$1".} = @@ -920,7 +920,7 @@ proc replace*(s: string, sub: TPeg, by = ""): string {. else: addf(result, by, caps) inc(i, x) - add(result, copy(s, i)) + add(result, substr(s, i)) proc parallelReplace*(s: string, subs: openArray[ tuple[pattern: TPeg, repl: string]]): string {. @@ -941,7 +941,7 @@ proc parallelReplace*(s: string, subs: openArray[ add(result, s[i]) inc(i) # copy the rest: - add(result, copy(s, i)) + add(result, substr(s, i)) proc transformFile*(infile, outfile: string, subs: openArray[tuple[pattern: TPeg, repl: string]]) {. @@ -990,7 +990,7 @@ iterator split*(s: string, sep: TPeg): string = x = matchLen(s, sep, last) if x > 0: break if first < last: - yield copy(s, first, last-1) + yield substr(s, first, last-1) proc split*(s: string, sep: TPeg): seq[string] {. nosideEffect, rtl, extern: "npegs$1".} = @@ -1688,7 +1688,7 @@ when isMainModule: assert rawMatch(s, expr.rule, 0, c) == len(s) var a = "" for i in 0..c.ml-1: - a.add(copy(s, c.matches[i][0], c.matches[i][1])) + a.add(substr(s, c.matches[i][0], c.matches[i][1])) assert a == "abcdef" #echo expr.rule |