first steps to make templates hygienic
This commit is contained in:
parent
0cac8d9b6f
commit
5e15dec175
23 changed files with 486 additions and 187 deletions
|
|
@ -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 ------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue