public function parse_text($script) { $i = 0; $content = array(); // remove C comments $script = preg_replace('|/\\*.*?\\*/|sm', '', $script); // tokenize rules - \r is optional for backward compatibility (added 20090413) if ($tokens = preg_split('/(# rule:\\[.*\\])\\r?\\n/', $script, -1, PREG_SPLIT_DELIM_CAPTURE)) { foreach ($tokens as $token) { if (preg_match('/^# rule:\\[(.*)\\]/', $token, $matches)) { $content[$i]['name'] = $matches[1]; } elseif (isset($content[$i]['name']) && sizeof($content[$i]) == 1 && preg_match('/^# disabledRule:\\[(.*)\\]/', $token, $matches)) { $content[$i] = unserialize($this->_regular_serial($matches[1])); $i++; } elseif (isset($content[$i]['name']) && sizeof($content[$i]) == 1) { if ($rule = $this->_tokenize_rule($token)) { $content[$i] = array_merge($content[$i], $rule); $i++; } else { unset($content[$i]); } } } } return $content; }