BBCodeLexer::NextToken()

Description

Source

File: bp-forums/admin/parser.php

function NextToken() {
if ($this->unget) {
$this->unget = false;
return $this->token;
}
while (true) {
if ($this->ptr >= count($this->input)) {
$this->text = "";
$this->tag = false;
return $this->token = BBCODE_EOI;
}
$this->text = preg_replace("/[\\x00-\\x08\\x0B-\\x0C\\x0E-\\x1F]/", "",
$this->input[$this->ptr++]);
if ($this->verbatim) {
$this->tag = false;
if ($this->state == BBCODE_LEXSTATE_TEXT) {
$this->state = BBCODE_LEXSTATE_TAG;
$token_type = BBCODE_TEXT;
}
else {
$this->state = BBCODE_LEXSTATE_TEXT;
switch (ord(substr($this->text, 0, 1))) {
case 10:
case 13:
$token_type = BBCODE_NL;
break;
default:
$token_type = BBCODE_WS;
break;
case 45:
case 40:
case 60:
case 91:
case 123:
$token_type = BBCODE_TEXT;
break;
}
}
if (strlen($this->text) > 0)
return $this->token = $token_type;
}
else if ($this->state == BBCODE_LEXSTATE_TEXT) {
$this->state = BBCODE_LEXSTATE_TAG;
$this->tag = false;
if (strlen($this->text) > 0)
return $this->token = BBCODE_TEXT;
}
else {
switch (ord(substr($this->text, 0, 1))) {
case 10:
case 13:
$this->tag = false;
$this->state = BBCODE_LEXSTATE_TEXT;
return $this->token = BBCODE_NL;
case 45:
if (preg_match("/^-----/", $this->text)) {
$this->tag = Array('_name' => 'rule', '_endtag' => false, '_default' => '');
$this->state = BBCODE_LEXSTATE_TEXT;
return $this->token = BBCODE_TAG;
}
else {
$this->tag = false;
$this->state = BBCODE_LEXSTATE_TEXT;
if (strlen($this->text) > 0)
return $this->token = BBCODE_TEXT;
continue;
}
default:
$this->tag = false;
$this->state = BBCODE_LEXSTATE_TEXT;
return $this->token = BBCODE_WS;
case 40:
case 60:
case 91:
case 123:
if (preg_match($this->pat_comment, $this->text)) {
$this->state = BBCODE_LEXSTATE_TEXT;
continue;
}
if (preg_match($this->pat_comment2, $this->text)) {
$this->state = BBCODE_LEXSTATE_TEXT;
continue;
}
if (preg_match($this->pat_wiki, $this->text, $matches)) {
$this->tag = Array('_name' => 'wiki', '_endtag' => false,
'_default' => @$matches[1], 'title' => @$matches[2]);
$this->state = BBCODE_LEXSTATE_TEXT;
return $this->token = BBCODE_TAG;
}
$this->tag = $this->Internal_DecodeTag($this->text);
$this->state = BBCODE_LEXSTATE_TEXT;
return $this->token = ($this->tag['_end'] ? BBCODE_ENDTAG : BBCODE_TAG);
}
}
}
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.