summaryrefslogtreecommitdiff
path: root/src/HTML5/Parser/Scanner.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/HTML5/Parser/Scanner.php')
-rw-r--r--src/HTML5/Parser/Scanner.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/HTML5/Parser/Scanner.php b/src/HTML5/Parser/Scanner.php
index f952704..b58b662 100644
--- a/src/HTML5/Parser/Scanner.php
+++ b/src/HTML5/Parser/Scanner.php
@@ -13,6 +13,9 @@ class Scanner {
protected $is;
+ // Flipping this to TRUE will give minisculely more debugging info.
+ public $debug = FALSE;
+
/**
* Create a new Scanner.
*
@@ -54,6 +57,7 @@ class Scanner {
public function next() {
$this->is->next();
if ($this->is->valid()) {
+ if ($this->debug) fprintf(STDOUT, "> %s\n", $this->is->current());
return $this->is->current();
}
return FALSE;
@@ -137,6 +141,15 @@ class Scanner {
}
/**
+ * Consume whitespace.
+ *
+ * Whitespace in HTML5 is: formfeed, tab, newline, space.
+ */
+ public function whitespace() {
+ return $this->is->charsWhile("\n\t\f ");
+ }
+
+ /**
* Returns the current line that is being consumed.
*
* @return int
@@ -146,6 +159,13 @@ class Scanner {
return $this->is->currentLine();
}
+ public function charsUntil($mask) {
+ return $this->is->charsUntil($mask);
+ }
+ public function charsWhile($mask) {
+ return $this->is->charsWhile($mask);
+ }
+
/**
* Returns the current column of the current line that the tokenizer is at.
*