private function inlineModifierInner(MacroTokens $tokens)
{
$isFunctionOrArray = $tokens->isPrev($tokens::T_VARIABLE, $tokens::T_SYMBOL) || $tokens->isCurrent('[');
$result = new MacroTokens();
$args = new MacroTokens();
$modifiers = new MacroTokens();
$current = $args;
$anyModifier = FALSE;
$result->append($tokens->currentToken());
while ($tokens->nextToken()) {
if ($tokens->isCurrent('(', '[')) {
$current->tokens = array_merge($current->tokens, $this->inlineModifierInner($tokens));
} elseif ($current !== $modifiers && $tokens->isCurrent('|')) {
$anyModifier = TRUE;
$current = $modifiers;
} elseif ($tokens->isCurrent(')', ']') || $isFunctionOrArray && $tokens->isCurrent(',')) {
$partTokens = count($modifiers->tokens) ? $this->modifierPass($modifiers, $args->tokens)->tokens : $args->tokens;
$result->tokens = array_merge($result->tokens, $partTokens);
if ($tokens->isCurrent(',')) {
$result->append($tokens->currentToken());
$args = new MacroTokens();
$modifiers = new MacroTokens();
$current = $args;
continue;
} elseif ($isFunctionOrArray || !$anyModifier) {
$result->append($tokens->currentToken());
} else {
array_shift($result->tokens);
}
return $result->tokens;
} else {
$current->append($tokens->currentToken());
}
}
throw new CompileException('Unbalanced brackets.');
}