Browse Source

Begin pattern content names are now removed before end patterns

main
Dustin Wilson 3 years ago
parent
commit
8fba5ebee5
  1. 31
      lib/Tokenizer.php

31
lib/Tokenizer.php

@ -249,6 +249,15 @@ class Tokenizer {
$this->offset = $match[0][1];
}
// If the pattern is an end pattern and its corresponding begin pattern has a
// content name remove that from the scope stack before continuing.
if ($pattern->endPattern) {
$previousRule = end($this->ruleStack);
if ($previousRule->beginPattern && $previousRule->contentName !== null) {
array_pop($this->scopeStack);
}
}
// Add the name to the scope stack if present.
if ($pattern->name !== null) {
$this->scopeStack[] = $this->resolveScopeName($pattern->name, $match);
@ -450,12 +459,7 @@ class Tokenizer {
}
$popped = array_pop($this->ruleStack);
// If what was just popped is a begin pattern and has a content name pop it off
// the scope stack.
if ($popped->beginPattern && $popped->contentName !== null) {
array_pop($this->scopeStack);
}
// Pop the rule's name from the stack.
if ($popped->name !== null) {
array_pop($this->scopeStack);
}
@ -472,21 +476,6 @@ class Tokenizer {
}
}
/*if ($this->activeInjection === null && $this->grammar->injections !== null) {
foreach ($this->grammar->injections as $selector => $injection) {
$selector = ScopeParser::parseSelector($selector);
if ($selector->matches($this->scopeStack) && $selector->getPrefix($this->scopeStack) !== Filter::PREFIX_LEFT) {
$this->ruleStack[] = $injection;
$this->activeInjection = $injection;
if ($this->offset < $stopOffset) {
continue 2;
}
}
}
}*/
break;
}

Loading…
Cancel
Save