Ejemplo n.º 1
0
 public function tokenize($test, $flag)
 {
     $flag = constant("HTML5_Tokenizer::{$flag}");
     if (!isset($test->lastStartTag)) {
         $test->lastStartTag = null;
     }
     $tokenizer = new HTML5_TestableTokenizer($test->input, $flag, $test->lastStartTag);
     $GLOBALS['TIME'] -= get_microtime();
     $tokenizer->parse();
     $GLOBALS['TIME'] += get_microtime();
     return $tokenizer->outputTokens;
 }
 protected function emitToken($token, $checkStream = true, $dry = false)
 {
     parent::emitToken($token, $checkStream, $dry);
     // XXX: The tests should really include the parse errors, but I'm lazy.
     switch ($token['type']) {
         case self::PARSEERROR:
             return;
         case self::CHARACTER:
             if ($this->characterTokens) {
                 array_pop($this->outputLines);
                 array_pop($this->outputCols);
             }
             $this->characterTokens[] = $token;
         default:
             $this->outputLines[] = $this->stream()->getCurrentLine();
             $this->outputCols[] = $this->stream()->getColumnOffset();
     }
     if ($token['type'] !== self::CHARACTER) {
         $this->characterTokens = array();
     }
 }