Parse CSS into tokens.
More...
|
static | isWhitespace ( $char) |
| Indicate if a character is whitespace.
|
|
static | isNameStartCharacter ( $char) |
| Indicate if a character is a name-start code point.
|
|
static | isNameCharacter ( $char) |
| Indicate if a character is a name code point.
|
|
static | isNonPrintable ( $char) |
| Indicate if a character is non-printable.
|
|
static | isDigit ( $char) |
| Indicate if a character is a digit.
|
|
static | isHexDigit ( $char) |
| Indicate if a character is a hex digit.
|
|
static | isValidEscape ( $char1, $char2) |
| Determine if two characters constitute a valid escape.
|
|
static | wouldStartIdentifier ( $char1, $char2, $char3) |
| Determine if three characters would start an identifier.
|
|
static | wouldStartNumber ( $char1, $char2, $char3) |
| Determine if three characters would start a number.
|
|
|
| $source |
|
| $line = 1 |
|
| $pos = 0 |
|
| $currentCharacter = null |
|
| $nextCharacter = null |
|
| $parseErrors = [] |
|
Parse CSS into tokens.
This implements the tokenizer from the CSS Syntax Module Level 3 candidate recommendation.
- See also
- https://www.w3.org/TR/2019/CR-css-syntax-3-20190716/
◆ __construct()
Wikimedia\CSS\Parser\DataSourceTokenizer::__construct |
( |
DataSource | $source, |
|
|
array | $options = [] ) |
- Parameters
-
DataSource | $source | |
array | $options | Configuration options. (none currently defined) |
◆ clearParseErrors()
Wikimedia\CSS\Parser\DataSourceTokenizer::clearParseErrors |
( |
| ) |
|
◆ consumeBadUrlRemnants()
Wikimedia\CSS\Parser\DataSourceTokenizer::consumeBadUrlRemnants |
( |
| ) |
|
|
protected |
◆ consumeEscape()
Wikimedia\CSS\Parser\DataSourceTokenizer::consumeEscape |
( |
| ) |
|
|
protected |
◆ consumeIdentLikeToken()
Wikimedia\CSS\Parser\DataSourceTokenizer::consumeIdentLikeToken |
( |
array | $data | ) |
|
|
protected |
◆ consumeName()
Wikimedia\CSS\Parser\DataSourceTokenizer::consumeName |
( |
| ) |
|
|
protected |
◆ consumeNumber()
Wikimedia\CSS\Parser\DataSourceTokenizer::consumeNumber |
( |
| ) |
|
|
protected |
Consume a number.
Note this does not do validation on the input stream. Call self::wouldStartNumber() before calling the method if necessary.
- See also
- https://www.w3.org/TR/2019/CR-css-syntax-3-20190716/#consume-number
- Returns
- array [ string $value, int|float $number, string $type ('integer' or 'number') ] @suppress PhanPluginDuplicateAdjacentStatement
◆ consumeNumericToken()
Wikimedia\CSS\Parser\DataSourceTokenizer::consumeNumericToken |
( |
array | $data | ) |
|
|
protected |
◆ consumeStringToken()
Wikimedia\CSS\Parser\DataSourceTokenizer::consumeStringToken |
( |
| $endChar, |
|
|
array | $data ) |
|
protected |
◆ consumeToken()
Wikimedia\CSS\Parser\DataSourceTokenizer::consumeToken |
( |
| ) |
|
◆ consumeUrlToken()
Wikimedia\CSS\Parser\DataSourceTokenizer::consumeUrlToken |
( |
array | $data | ) |
|
|
protected |
◆ getParseErrors()
Wikimedia\CSS\Parser\DataSourceTokenizer::getParseErrors |
( |
| ) |
|
◆ isDigit()
static Wikimedia\CSS\Parser\DataSourceTokenizer::isDigit |
( |
| $char | ) |
|
|
staticprotected |
◆ isHexDigit()
static Wikimedia\CSS\Parser\DataSourceTokenizer::isHexDigit |
( |
| $char | ) |
|
|
staticprotected |
◆ isNameCharacter()
static Wikimedia\CSS\Parser\DataSourceTokenizer::isNameCharacter |
( |
| $char | ) |
|
|
staticprotected |
◆ isNameStartCharacter()
static Wikimedia\CSS\Parser\DataSourceTokenizer::isNameStartCharacter |
( |
| $char | ) |
|
|
staticprotected |
◆ isNonPrintable()
static Wikimedia\CSS\Parser\DataSourceTokenizer::isNonPrintable |
( |
| $char | ) |
|
|
staticprotected |
◆ isValidEscape()
static Wikimedia\CSS\Parser\DataSourceTokenizer::isValidEscape |
( |
| $char1, |
|
|
| $char2 ) |
|
staticprotected |
◆ isWhitespace()
static Wikimedia\CSS\Parser\DataSourceTokenizer::isWhitespace |
( |
| $char | ) |
|
|
staticprotected |
◆ lookAhead()
Wikimedia\CSS\Parser\DataSourceTokenizer::lookAhead |
( |
| ) |
|
|
protected |
Look ahead at the next three characters.
- Returns
- string[] Three characters
◆ nextChar()
Wikimedia\CSS\Parser\DataSourceTokenizer::nextChar |
( |
| ) |
|
|
protected |
◆ parseError()
Wikimedia\CSS\Parser\DataSourceTokenizer::parseError |
( |
| $tag, |
|
|
?array | $position = null, |
|
|
array | $data = [] ) |
|
protected |
Record a parse error.
- Parameters
-
string | $tag | Error tag |
array | null | $position | Report the error as starting at this position instead of at the current position. |
array | $data | Extra data about the error. |
◆ reconsumeCharacter()
Wikimedia\CSS\Parser\DataSourceTokenizer::reconsumeCharacter |
( |
| ) |
|
|
protected |
Reconsume the next character.
In more normal terms, this pushes a character back onto the data source, so it will be read again for the next call to self::consumeCharacter().
◆ wouldStartIdentifier()
static Wikimedia\CSS\Parser\DataSourceTokenizer::wouldStartIdentifier |
( |
| $char1, |
|
|
| $char2, |
|
|
| $char3 ) |
|
staticprotected |
◆ wouldStartNumber()
static Wikimedia\CSS\Parser\DataSourceTokenizer::wouldStartNumber |
( |
| $char1, |
|
|
| $char2, |
|
|
| $char3 ) |
|
staticprotected |
The documentation for this class was generated from the following file: