Patch the PEG library to work with the JS backend (#7866)
* Added compiler check on transformFile
This commit is contained in:
parent
c6a9a9c30b
commit
799674168d
1 changed files with 12 additions and 8 deletions
|
|
@ -1010,14 +1010,18 @@ proc replace*(s: string, sub: Peg, cb: proc(
|
||||||
inc(m)
|
inc(m)
|
||||||
add(result, substr(s, i))
|
add(result, substr(s, i))
|
||||||
|
|
||||||
proc transformFile*(infile, outfile: string,
|
when not defined(js):
|
||||||
subs: varargs[tuple[pattern: Peg, repl: string]]) {.
|
proc transformFile*(infile, outfile: string,
|
||||||
rtl, extern: "npegs$1".} =
|
subs: varargs[tuple[pattern: Peg, repl: string]]) {.
|
||||||
## reads in the file `infile`, performs a parallel replacement (calls
|
rtl, extern: "npegs$1".} =
|
||||||
## `parallelReplace`) and writes back to `outfile`. Raises ``EIO`` if an
|
## reads in the file `infile`, performs a parallel replacement (calls
|
||||||
## error occurs. This is supposed to be used for quick scripting.
|
## `parallelReplace`) and writes back to `outfile`. Raises ``EIO`` if an
|
||||||
var x = readFile(infile).string
|
## error occurs. This is supposed to be used for quick scripting.
|
||||||
writeFile(outfile, x.parallelReplace(subs))
|
##
|
||||||
|
## **Note**: this proc does not exist while using the JS backend.
|
||||||
|
var x = readFile(infile).string
|
||||||
|
writeFile(outfile, x.parallelReplace(subs))
|
||||||
|
|
||||||
|
|
||||||
iterator split*(s: string, sep: Peg): string =
|
iterator split*(s: string, sep: Peg): string =
|
||||||
## Splits the string `s` into substrings.
|
## Splits the string `s` into substrings.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue