diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/impure/re.nim | 5 | ||||
-rwxr-xr-x | lib/pure/pegs.nim | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/impure/re.nim b/lib/impure/re.nim index 7ef3d247a..57dc3a313 100755 --- a/lib/impure/re.nim +++ b/lib/impure/re.nim @@ -218,6 +218,9 @@ proc findAll*(s: string, pattern: TRegEx, start = 0): seq[string] = ## If it does not match, @[] is returned. accumulateResult(findAll(s, pattern, start)) +when not defined(nimhygiene): + {.pragma: inject.} + template `=~` *(s: string, pattern: TRegEx): expr = ## This calls ``match`` with an implicit declared ``matches`` array that ## can be used in the scope of the ``=~`` call: @@ -237,7 +240,7 @@ template `=~` *(s: string, pattern: TRegEx): expr = ## echo("syntax error") ## when not definedInScope(matches): - var matches: array[0..re.maxSubPatterns-1, string] + var matches {.inject.}: array[0..re.maxSubPatterns-1, string] match(s, pattern, matches) # ------------------------- more string handling ------------------------------ diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim index efa77199b..e37c072f1 100755 --- a/lib/pure/pegs.nim +++ b/lib/pure/pegs.nim @@ -845,6 +845,9 @@ proc findAll*(s: string, pattern: TPeg, start = 0): seq[string] {. ## returns all matching *substrings* of `s` that match `pattern`. ## If it does not match, @[] is returned. accumulateResult(findAll(s, pattern, start)) + +when not defined(nimhygiene): + {.pragma: inject.} template `=~`*(s: string, pattern: TPeg): bool = ## This calls ``match`` with an implicit declared ``matches`` array that @@ -865,7 +868,7 @@ template `=~`*(s: string, pattern: TPeg): bool = ## echo("syntax error") ## when not definedInScope(matches): - var matches: array[0..pegs.maxSubpatterns-1, string] + var matches {.inject.}: array[0..pegs.maxSubpatterns-1, string] match(s, pattern, matches) # ------------------------- more string handling ------------------------------ |