Browse Source

Minor cleanup

split-manual
J. King 3 years ago
parent
commit
6cac402375
  1. 10
      lib/ParseError.php
  2. 15
      lib/Tokenizer.php

10
lib/ParseError.php

@ -3,8 +3,6 @@ declare(strict_types=1);
namespace dW\HTML5;
class ParseError {
protected $data;
// tokenization parse errors; these have been standardized
const ENCODING_ERROR = 100;
const UNEXPECTED_NULL_CHARACTER = 101;
@ -159,7 +157,7 @@ class ParseError {
public function setHandler() {
// Set the errror handler and honor already-set error reporting rules.
set_error_handler([$this, 'errorHandler'], error_reporting());
set_error_handler([$this, 'errorHandler'], \E_USER_WARNING);
}
public function clearHandler() {
@ -207,9 +205,7 @@ class ParseError {
return trigger_error($this->prepareMessage($file, $line, $column, $code, ...$arg), \E_USER_WARNING);
}
public function errorHandler(int $code, string $message, string $file, int $line) {
if ($code === E_USER_WARNING) {
echo "$message\n";
}
public function errorHandler(int $code, string $message) {
echo "$message\n";
}
}

15
lib/Tokenizer.php

@ -2019,13 +2019,9 @@ class Tokenizer {
elseif ($char === '') {
# Emit the comment.
# Emit an end-of-file token.
// DEVIATION:
// We cannot emit two tokens, so we switch to
// the data state, which will emit the EOF token
$this->state = self::DATA_STATE;
yield $token;
goto Reconsume;
yield new EOFToken;
return;
}
# U+0000 NULL
elseif ($char === "\0") {
@ -2148,12 +2144,9 @@ class Tokenizer {
# Emit the comment token.
# Emit an end-of-file token.
$this->error(ParseError::EOF_IN_COMMENT);
// DEVIATION:
// We cannot emit two tokens, so we switch to
// the data state, which will emit the EOF token
$this->state = self::DATA_STATE;
yield $token;
goto Reconsume;
yield new EOFToken;
return;
}
# Anything else
else {

Loading…
Cancel
Save