diff options
author | Araq <rumpf_a@web.de> | 2012-08-20 01:13:13 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-08-20 01:13:13 +0200 |
commit | 5e15dec1757e6013cbeb5d6baf9d9579cf025361 (patch) | |
tree | 2157b7f03f5f596060ad9ed52427118964912e50 /lib/pure | |
parent | 0cac8d9b6fa2c982468899db109a964df979b186 (diff) | |
download | Nim-5e15dec1757e6013cbeb5d6baf9d9579cf025361.tar.gz |
first steps to make templates hygienic
Diffstat (limited to 'lib/pure')
-rwxr-xr-x | lib/pure/pegs.nim | 5 |
1 files changed, 4 insertions, 1 deletions
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 ------------------------------ |