pegs/re =~ warns about scope rule change; improved docs
This commit is contained in:
parent
9fc98cefda
commit
44c4b945eb
4 changed files with 19 additions and 9 deletions
|
|
@ -870,6 +870,7 @@ template `=~`*(s: string, pattern: TPeg): bool =
|
|||
bind maxSubpatterns
|
||||
when not definedInScope(matches):
|
||||
var matches {.inject.}: array[0..maxSubpatterns-1, string]
|
||||
{.warning: "injected 'matches' might be affected by new scoping rules in 0.9.4".}
|
||||
match(s, pattern, matches)
|
||||
|
||||
# ------------------------- more string handling ------------------------------
|
||||
|
|
@ -1718,6 +1719,7 @@ when isMainModule:
|
|||
assert match("_______ana", peg"A <- 'ana' / . A")
|
||||
assert match("abcs%%%", peg"A <- ..A / .A / '%'")
|
||||
|
||||
var matches: array[0..maxSubpatterns-1, string]
|
||||
if "abc" =~ peg"{'a'}'bc' 'xyz' / {\ident}":
|
||||
assert matches[0] == "abc"
|
||||
else:
|
||||
|
|
@ -1742,8 +1744,6 @@ when isMainModule:
|
|||
else:
|
||||
assert false
|
||||
|
||||
when not definedInScope(matches):
|
||||
var matches: array[0..maxSubpatterns-1, string]
|
||||
if match("abcdefg", peg"c {d} ef {g}", matches, 2):
|
||||
assert matches[0] == "d"
|
||||
assert matches[1] == "g"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue