It seems like back references in a match
key use the captures from the match that pushed the context:
parent:
- match: '(foo)(bar)'
scope: parent
push: child
child:
- match: '(?=\1)'
pop: true
- match: baz
scope: child
foobar <- parent, push child
baz <- child
<- pop child
foo
But it seems like if child
pushes or sets a new context, the new context can no longer refer to parent
's captures. This is an issue for me, as I would like the top-level definition to work at any indentation level and any contexts pushed from that point on should be able to check if the indentation level goes below the initial indentation and pop out. This functionality is similar to embed
or with_prototype
, but one of my definitions uses branch
, and I can’t use either with branch
.
It would be nice to do something like
parent:
- match: '(foo)(bar)'
scope: parent
capture_name: parent
push: child1
child1:
- match: '(?=\1)'
capture_context: parent
pop: true
- match: baz
scope: child1
push: child2
child2:
- match: '(?=\1)'
capture_context: parent
pop: true
foobar <- parent, push child1
baz <- child1, push child2
<- pop child2
<- pop child1
foo