final class CssScanner in QueryPath 6
Same name and namespace in other branches
- 7.3 QueryPath/CssParser.php \CssScanner
- 7.2 QueryPath/CssParser.php \CssScanner
Hierarchy
- class \CssScanner
Expanded class hierarchy of CssScanner
File
- QueryPath/
CssParser.php, line 527
View source
final class CssScanner {
var $is = NULL;
public $value = NULL;
public $token = NULL;
var $recurse = FALSE;
var $it = 0;
public function __construct(CssInputStream $in) {
$this->is = $in;
}
public function position() {
return $this->is->position;
}
public function peek() {
return $this->is
->peek();
}
public function nextToken() {
$tok = -1;
++$this->it;
if ($this->is
->isEmpty()) {
if ($this->recurse) {
throw new Exception("Recursion error detected at iteration " . $this->it . '.');
exit;
}
$this->recurse = TRUE;
$this->token = FALSE;
return FALSE;
}
$ch = $this->is
->consume();
if (ctype_space($ch)) {
$this->value = ' ';
$this->token = $tok = CssToken::white;
return $tok;
}
if (ctype_alnum($ch) || $ch == '-' || $ch == '_') {
$this->value = $ch;
$this->token = $tok = CssToken::char;
return $tok;
}
$this->value = $ch;
switch ($ch) {
case '*':
$tok = CssToken::star;
break;
case chr(ord('>')):
$tok = CssToken::rangle;
break;
case '.':
$tok = CssToken::dot;
break;
case '#':
$tok = CssToken::octo;
break;
case '[':
$tok = CssToken::lsquare;
break;
case ']':
$tok = CssToken::rsquare;
break;
case ':':
$tok = CssToken::colon;
break;
case '(':
$tok = CssToken::lparen;
break;
case ')':
$tok = CssToken::rparen;
break;
case '+':
$tok = CssToken::plus;
break;
case '~':
$tok = CssToken::tilde;
break;
case '=':
$tok = CssToken::eq;
break;
case '|':
$tok = CssToken::pipe;
break;
case ',':
$tok = CssToken::comma;
break;
case chr(34):
$tok = CssToken::quote;
break;
case "'":
$tok = CssToken::squote;
break;
case '\\':
$tok = CssToken::bslash;
break;
case '^':
$tok = CssToken::carat;
break;
case '$':
$tok = CssToken::dollar;
break;
case '@':
$tok = CssToken::at;
break;
}
if ($tok == -1) {
$ord = ord($ch);
if ($ord >= 32 && $ord <= 126 || $ord >= 128 && $ord <= 255) {
$tok = CssToken::stringLegal;
}
else {
throw new Exception('Illegal character found in stream: ' . $ord);
}
}
$this->token = $tok;
return $tok;
}
public function getNameString() {
$buf = '';
while ($this->token === CssToken::char) {
$buf .= $this->value;
$this
->nextToken();
}
return $buf;
}
public function getQuotedString() {
if ($this->token == CssToken::quote || $this->token == CssToken::squote || $this->token == CssToken::lparen) {
$end = $this->token == CssToken::lparen ? CssToken::rparen : $this->token;
$buf = '';
$escape = FALSE;
$this
->nextToken();
while ($this->token !== FALSE && $this->token > -1) {
if ($this->token == CssToken::bslash && !$escape) {
$escape = TRUE;
}
elseif ($escape) {
$buf .= $this->value;
$escape = FALSE;
}
elseif ($this->token === $end) {
$this
->nextToken();
break;
}
else {
$buf .= $this->value;
}
$this
->nextToken();
}
return $buf;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CssScanner:: |
property | |||
CssScanner:: |
property | |||
CssScanner:: |
property | |||
CssScanner:: |
public | property | ||
CssScanner:: |
public | property | ||
CssScanner:: |
public | function | ||
CssScanner:: |
public | function | ||
CssScanner:: |
public | function | ||
CssScanner:: |
public | function | ||
CssScanner:: |
public | function | ||
CssScanner:: |
public | function |