public function tokenize($in, $line = 1, $file = '')
    {
        $out = array();
        $mem = $in;

        while (strlen($in) > 0) {
            foreach ($this->tokens as $token => $regexp) {
                if (preg_match('/^(' . $regexp . ')/', $in, $m)) {
                    if (!in_array($token, $this->ignore)) {
                        // collect only tokens not in ignore-list
                        $out[] = array(
                            'token' => $token,
                            'value' => $m[1],
                            'line'  => $line,
                            'file'  => $file
                        );
                    }

                    $in    = substr($in, strlen($m[1]));
                    $line += substr_count($m[1], "\n");
                    continue 2;
                }
            }

            $this->setError(__FILE__, __LINE__, $line, 0, sprintf(
                'parse error %sat "%s" of "%s"',
                ($file != '' ? 'in "' . $file . '" ' : ''),
                $in,
                $mem
            ));

            return false;
        }

        return $out;
    }