function parse_tag()
{
$start = $this->pos;
$this->status['self_close'] = false;
$this->parse_text();
$next = $this->pos + 1 < $this->size ? $this->doc[$this->pos + 1] : '';
if ($next === '!') {
$this->status['closing_tag'] = false;
if (substr($this->doc, $this->pos + 2, 2) === '--') {
$this->status['comment'] = true;
if ($this->doc[$this->pos + 4] === '[' && strcasecmp(substr($this->doc, $this->pos + 5, 2), 'if') === 0) {
return $this->parse_conditional();
} else {
return $this->parse_comment();
}
} else {
$this->status['comment'] = false;
if ($this->doc[$this->pos + 2] === '[') {
if (strcasecmp(substr($this->doc, $this->pos + 3, 2), 'if') === 0) {
return $this->parse_conditional();
} elseif (strcasecmp(substr($this->doc, $this->pos + 3, 5), 'endif') === 0) {
$this->status['closing_tag'] = true;
return $this->parse_conditional();
} elseif (strcasecmp(substr($this->doc, $this->pos + 3, 5), 'cdata') === 0) {
return $this->parse_cdata();
}
}
}
} elseif ($next === '/') {
$this->status['closing_tag'] = true;
++$this->pos;
} else {
$this->status['closing_tag'] = false;
}
if ($this->next() !== self::TOK_IDENTIFIER) {
$this->addError('Tagname expected');
//if ($this->next_pos('>', false) === self::TOK_UNKNOWN) {
$this->status['last_pos'] = $start - 1;
return true;
//} else {
// return false;
//}
}
$tag = $this->getTokenString();
$this->status['tag_name'] = $tag;
$tag = strtolower($tag);
if (isset($this->tag_map[$tag])) {
$res = $this->{$this->tag_map[$tag]}();
} else {
$res = $this->parse_tag_default();
}
$this->status['last_pos'] = $this->pos;
return $res;
}