static function preprocessor_filter_cb($matches) { if (isset($matches['STR']) && $matches['STR'] !== '') { return LuminousUtils::tag_block('STRING', $matches[0]); } else { return LuminousUtils::tag_block('COMMENT', $matches[0]); } }
static function preprocessor_filter_cb($matches) { if (!isset($matches[0]) || !isset($matches[0][0])) { return ''; } // shouldn't ever happen if ($matches[0][0] === '"') { return LuminousUtils::tag_block('STRING', $matches[0]); } else { if ($matches[0][0] === '&') { return '<' . LuminousUtils::tag_block('STRING', $matches[1]) . '>'; } else { return LuminousUtils::tag_block('COMMENT', $matches[0]); } } }
/** * Recursive function to collapse the token tree into XML * @internal */ protected function collapse_token_tree($node) { $text = ''; foreach ($node['children'] as $c) { if (is_string($c)) { $text .= LuminousUtils::escape_string($c); } else { $text .= $this->collapse_token_tree($c); } } $token_name = $node['token_name']; $token = array($node['token_name'], $text, true); $token_ = $this->rule_mapper_filter(array($token)); $token = $token_[0]; if (isset($this->filters[$token_name])) { foreach ($this->filters[$token_name] as $filter) { $token = call_user_func($filter[1], $token); } } list($token_name, $text, ) = $token; return $token_name === null ? $text : LuminousUtils::tag_block($token_name, $text); }