Haanga_Compiler_Tokenizer::getTag PHP Method

getTag() public method

public getTag ( )
    function getTag()
    {
        static $lencache = array();
        $i =& $this->N;
        $data = substr($this->data, $i, 12);
        foreach (self::$close_tags as $value => $token) {
            if (!isset($lencache[$value])) {
                $lencache[$value] = strlen($value);
            }
            $len = $lencache[$value];
            if (strncmp($data, $value, $len) == 0) {
                $this->token = $token;
                $this->value = $value;
                $i += $len;
                return TRUE;
            }
        }
        foreach (self::$keywords as $value => $token) {
            if (!isset($lencache[$value])) {
                $lencache[$value] = strlen($value);
            }
            $len = $lencache[$value];
            switch (strncmp($data, $value, $len)) {
                case -1:
                    break 2;
                case 0:
                    // match
                    if (isset($data[$len]) && !$this->is_token_end($data[$len])) {
                        /* probably a variable name TRUEfoo (and not TRUE) */
                        continue;
                    }
                    $this->token = $token;
                    $this->value = $value;
                    $i += $len;
                    return TRUE;
            }
        }
        /* /end([a-zA-Z][a-zA-Z0-9]*)/ */
        if (strncmp($data, "end", 3) == 0) {
            $this->value = $this->getAlpha();
            $this->token = HG_Parser::T_CUSTOM_END;
            return TRUE;
        }
        return FALSE;
    }