/** * @throws \ErrorException * * @return object */ protected function scanAttributes() { if (substr($this->input, 0, 1) === '(') { // cant use ^ anchor in the regex because the pattern is recursive // but this restriction is asserted by the if above //$this->input = preg_replace('/([a-zA-Z0-9\'"\\]\\}\\)])([\t ]+[a-zA-Z])/', '$1,$2', $this->input); if (!preg_match('/\\((?:"(?:\\\\.|[^"\\\\])*"|\'(?:\\\\.|[^\'\\\\])*\'|[^()\'"]++|(?R))*+\\)/', $this->input, $matches)) { throw new \ErrorException('Unable to find attributes closing parenthesis.', 21); } $this->consume($matches[0]); //$str = preg_replace('/()([a-zA-Z0-9_\\x7f-\\xff\\)\\]\\}"\'])(\s+[a-zA-Z_])/', '$1,$2', $str); $token = $this->token('attributes'); $token->attributes = array(); $token->escaped = array(); $token->selfClosing = false; $parser = new Attributes($token); $parser->parseWith(substr($matches[0], 1, strlen($matches[0]) - 2)); if ($this->length() && '/' === $this->input[0]) { $this->consume(1); $token->selfClosing = true; } return $token; } }