mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 05:20:31 +00:00
Add support for strictEffects to std/pegs (#18949)
* Add support for `strictEffects` to `std/pegs` * Fixed support of older Nim versions Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
This commit is contained in:
@@ -1285,9 +1285,12 @@ proc parallelReplace*(s: string, subs: varargs[
|
||||
# copy the rest:
|
||||
add(result, substr(s, i))
|
||||
|
||||
when not defined(nimHasEffectsOf):
|
||||
{.pragma: effectsOf.}
|
||||
|
||||
proc replace*(s: string, sub: Peg, cb: proc(
|
||||
match: int, cnt: int, caps: openArray[string]): string): string {.
|
||||
rtl, extern: "npegs$1cb".} =
|
||||
rtl, extern: "npegs$1cb", effectsOf: cb.} =
|
||||
## Replaces `sub` in `s` by the resulting strings from the callback.
|
||||
## The callback proc receives the index of the current match (starting with 0),
|
||||
## the count of captures and an open array with the captures of each match. Examples:
|
||||
|
||||
@@ -51,6 +51,9 @@ Event parser output
|
||||
'''
|
||||
"""
|
||||
|
||||
when defined(nimHasEffectsOf):
|
||||
{.experimental: "strictEffects".}
|
||||
|
||||
import std/[strutils, streams, pegs]
|
||||
|
||||
const
|
||||
|
||||
Reference in New Issue
Block a user