Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
SCSSPHP
Copyright: | 2012-2020 Leaf Corcoran |
License: | http://opensource.org/licenses/MIT MIT |
File Size: | 4176 lines (114 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
Parser:: (74 methods):
__construct()
getSourceName()
throwParseError()
parseError()
parse()
parseValue()
parseSelector()
parseMediaQueryList()
parseChunk()
pushBlock()
registerPushedBlock()
pushSpecialBlock()
popBlock()
peek()
seek()
assertPlainCssValid()
isPlainCssValidElement()
matchString()
match()
matchChar()
literal()
whitespace()
appendComment()
append()
last()
mediaQueryList()
mediaQuery()
supportsQuery()
mediaExpression()
argValues()
argValue()
isKnownGenericDirective()
directiveValue()
valueList()
functionCallArgumentsList()
spaceList()
genericList()
expression()
enclosedExpression()
expHelper()
value()
parenValue()
progid()
func()
argumentList()
argumentDef()
map()
color()
unit()
string()
matchEscapeCharacter()
mixedKeyword()
openString()
interpolation()
propertyName()
customProperty()
selectors()
selector()
matchEscapeCharacterInSelector()
selectorSingle()
variable()
keyword()
restrictedKeyword()
placeholder()
url()
end()
stripAssignmentFlags()
stripOptionalFlag()
flattenList()
pregQuote()
extractLineNumbers()
getSourcePosition()
saveEncoding()
restoreEncoding()
__construct($sourceName, $sourceIndex = 0, $encoding = 'utf-8', Cache $cache = null, $cssOnly = false, LoggerInterface $logger = null) X-Ref |
Constructor param: string|null $sourceName param: int $sourceIndex param: string|null $encoding param: Cache|null $cache param: bool $cssOnly param: LoggerInterface|null $logger |
getSourceName() X-Ref |
Get source file name return: string |
throwParseError($msg = 'parse error') X-Ref |
Throw parser error param: string $msg |
parseError($msg = 'parse error') X-Ref |
Creates a parser error return: ParserException param: string $msg |
parse($buffer) X-Ref |
Parser buffer return: Block param: string $buffer |
parseValue($buffer, &$out) X-Ref |
Parse a value or value list return: bool param: string $buffer param: string|array $out |
parseSelector($buffer, &$out, $shouldValidate = true) X-Ref |
Parse a selector or selector list return: bool param: string $buffer param: string|array $out param: bool $shouldValidate |
parseMediaQueryList($buffer, &$out) X-Ref |
Parse a media Query return: bool param: string $buffer param: string|array $out |
parseChunk() X-Ref |
Parse a single chunk off the head of the buffer and append it to the current parse environment. Returns false when the buffer is empty, or when there is an error. This function is called repeatedly until the entire document is parsed. This parser is most similar to a recursive descent parser. Single functions represent discrete grammatical rules for the language, and they are able to capture the text that represents those rules. Consider the function Compiler::keyword(). (All parse functions are structured the same.) The function takes a single reference argument. When calling the function it will attempt to match a keyword on the head of the buffer. If it is successful, it will place the keyword in the referenced argument, advance the position in the buffer, and return true. If it fails then it won't advance the buffer and it will return false. All of these parse functions are powered by Compiler::match(), which behaves the same way, but takes a literal regular expression. Sometimes it is more convenient to use match instead of creating a new function. Because of the format of the functions, to parse an entire string of grammatical rules, you can chain them together using &&. But, if some of the rules in the chain succeed before one fails, then the buffer position will be left at an invalid state. In order to avoid this, Compiler::seek() is used to remember and set buffer positions. Before parsing a chain, use $s = $this->count to remember the current position into $s. Then if a chain fails, use $this->seek($s) to go back where we started. return: bool |
pushBlock($selectors, $pos = 0) X-Ref |
Push block onto parse tree return: Block param: array|null $selectors param: int $pos |
registerPushedBlock(Block $b, $pos) X-Ref |
return: void param: Block $b param: int $pos |
pushSpecialBlock($type, $pos) X-Ref |
Push special (named) block onto parse tree return: Block param: string $type param: int $pos |
popBlock() X-Ref |
Pop scope and return last block return: Block |
peek($regex, &$out, $from = null) X-Ref |
Peek input stream return: int param: string $regex param: array $out param: int $from |
seek($where) X-Ref |
Seek to position in input stream (or return current position in input stream) param: int $where |
assertPlainCssValid($parsed, $startPos = null) X-Ref |
Assert a parsed part is plain CSS Valid param: array|false $parsed param: int $startPos |
isPlainCssValidElement($parsed, $allowExpression = false) X-Ref |
Check a parsed element is plain CSS Valid return: bool|array param: array $parsed param: bool $allowExpression |
matchString(&$m, $delim) X-Ref |
Match string looking for either ending delim, escape, or string interpolation {@internal This is a workaround for preg_match's 250K string match limit. }} return: bool True if match; false otherwise param: array $m Matches (passed by reference) param: string $delim Delimiter |
match($regex, &$out, $eatWhitespace = null) X-Ref |
Try to match something on head of buffer return: bool param: string $regex param: array $out param: bool $eatWhitespace |
matchChar($char, $eatWhitespace = null) X-Ref |
Match a single string return: bool param: string $char param: bool $eatWhitespace |
literal($what, $len, $eatWhitespace = null) X-Ref |
Match literal string return: bool param: string $what param: int $len param: bool $eatWhitespace |
whitespace() X-Ref |
Match some whitespace return: bool |
appendComment($comment) X-Ref |
Append comment to current block param: array $comment |
append($statement, $pos = null) X-Ref |
Append statement to current block param: array|null $statement param: int $pos |
last() X-Ref |
Returns last child was appended return: array|null |
mediaQueryList(&$out) X-Ref |
Parse media query list return: bool param: array $out |
mediaQuery(&$out) X-Ref |
Parse media query return: bool param: array $out |
supportsQuery(&$out) X-Ref |
Parse supports query return: bool param: array $out |
mediaExpression(&$out) X-Ref |
Parse media expression return: bool param: array $out |
argValues(&$out) X-Ref |
Parse argument values return: bool param: array $out |
argValue(&$out) X-Ref |
Parse argument value return: bool param: array $out |
isKnownGenericDirective($directiveName) X-Ref |
Check if a generic directive is known to be able to allow almost any syntax or not return: bool param: mixed $directiveName |
directiveValue(&$out, $endChar = false) X-Ref |
Parse directive value list that considers $vars as keyword return: bool param: array $out param: bool|string $endChar |
valueList(&$out) X-Ref |
Parse comma separated value list return: bool param: array $out |
functionCallArgumentsList(&$out, $mandatoryEnclos = true, $charAfter = null, $eatWhiteSp = null) X-Ref |
Parse a function call, where externals () are part of the call and not of the value list return: bool param: array $out param: bool $mandatoryEnclos param: null|string $charAfter param: null|bool $eatWhiteSp |
spaceList(&$out) X-Ref |
Parse space separated value list return: bool param: array $out |
genericList(&$out, $parseItem, $delim = '', $flatten = true) X-Ref |
Parse generic list return: bool param: array $out param: string $parseItem The name of the method used to parse items param: string $delim param: bool $flatten |
expression(&$out, $listOnly = false, $lookForExp = true) X-Ref |
Parse expression return: bool param: array $out param: bool $listOnly param: bool $lookForExp |
enclosedExpression(&$out, $s, $closingParen = ') X-Ref |
Parse expression specifically checking for lists in parenthesis or brackets return: bool param: array $out param: int $s param: string $closingParen param: array $allowedTypes |
expHelper($lhs, $minP) X-Ref |
Parse left-hand side of subexpression return: array param: array $lhs param: int $minP |
value(&$out) X-Ref |
Parse value return: bool param: array $out |
parenValue(&$out) X-Ref |
Parse parenthesized value return: bool param: array $out |
progid(&$out) X-Ref |
Parse "progid:" return: bool param: array $out |
func($name, &$func) X-Ref |
Parse function call return: bool param: string $name param: array $func |
argumentList(&$out) X-Ref |
Parse function call argument list return: bool param: array $out |
argumentDef(&$out) X-Ref |
Parse mixin/function definition argument list return: bool param: array $out |
map(&$out) X-Ref |
Parse map return: bool param: array $out |
color(&$out) X-Ref |
Parse color return: bool param: array $out |
unit(&$unit) X-Ref |
Parse number with unit return: bool param: array $unit |
string(&$out, $keepDelimWithInterpolation = false) X-Ref |
Parse string return: bool param: array $out param: bool $keepDelimWithInterpolation |
matchEscapeCharacter(&$out, $inKeywords = false) X-Ref |
return: bool param: string $out param: bool $inKeywords |
mixedKeyword(&$out, $restricted = false) X-Ref |
Parse keyword or interpolation return: bool param: array $out param: bool $restricted |
openString($end, &$out, $nestOpen = null, $nestClose = null, $rtrim = true, $disallow = null) X-Ref |
Parse an unbounded string stopped by $end return: bool param: string $end param: array $out param: string $nestOpen param: string $nestClose param: bool $rtrim param: string $disallow |
interpolation(&$out, $lookWhite = true) X-Ref |
Parser interpolation return: bool param: string|array $out param: bool $lookWhite save information about whitespace before and after |
propertyName(&$out) X-Ref |
Parse property name (as an array of parts or a string) return: bool param: array $out |
customProperty(&$out) X-Ref |
Parse custom property name (as an array of parts or a string) return: bool param: array $out |
selectors(&$out, $subSelector = false) X-Ref |
Parse comma separated selector list return: bool param: array $out param: string|bool $subSelector |
selector(&$out, $subSelector = false) X-Ref |
Parse whitespace separated selector list return: bool param: array $out param: string|bool $subSelector |
matchEscapeCharacterInSelector(&$out, $keepEscapedNumber = false) X-Ref |
parsing escaped chars in selectors: - escaped single chars are kept escaped in the selector but in a normalized form (if not in 0-9a-f range as this would be ambigous) - other escaped sequences (multibyte chars or 0-9a-f) are kept in their initial escaped form, normalized to lowercase TODO: this is a fallback solution. Ideally escaped chars in selectors should be encoded as the genuine chars, and escaping added when printing in the Compiler, where/if it's mandatory - but this require a better formal selector representation instead of the array we have now return: bool param: string $out param: bool $keepEscapedNumber |
selectorSingle(&$out, $subSelector = false) X-Ref |
Parse the parts that make up a selector {@internal div[yes=no]#something.hello.world:nth-child(-2n+1)%placeholder }} return: bool param: array $out param: string|bool $subSelector |
variable(&$out) X-Ref |
Parse a variable return: bool param: array $out |
keyword(&$word, $eatWhitespace = null, $inSelector = false) X-Ref |
Parse a keyword return: bool param: string $word param: bool $eatWhitespace param: bool $inSelector |
restrictedKeyword(&$word, $eatWhitespace = null, $inSelector = false) X-Ref |
Parse a keyword that should not start with a number return: bool param: string $word param: bool $eatWhitespace param: bool $inSelector |
placeholder(&$placeholder) X-Ref |
Parse a placeholder return: bool param: string|array $placeholder |
url(&$out) X-Ref |
Parse a url return: bool param: array $out |
end($eatWhitespace = null) X-Ref |
Consume an end of statement delimiter return: bool param: bool $eatWhitespace |
stripAssignmentFlags(&$value) X-Ref |
Strip assignment flag from the list return: array param: array $value |
stripOptionalFlag(&$selectors) X-Ref |
Strip optional flag from selector list return: string param: array $selectors |
flattenList($value) X-Ref |
Turn list of length 1 into value type return: array param: array $value |
pregQuote($what) X-Ref |
Quote regular expression return: string param: string $what |
extractLineNumbers($buffer) X-Ref |
Extract line numbers from buffer param: string $buffer |
getSourcePosition($pos) X-Ref |
Get source line number and column (given character position in the buffer) return: array param: int $pos |
saveEncoding() X-Ref |
Save internal encoding of mbstring When mbstring.func_overload is used to replace the standard PHP string functions, this method configures the internal encoding to a single-byte one so that the behavior matches the normal behavior of PHP string functions while using the parser. The existing internal encoding is saved and will be restored when calling {@see restoreEncoding}. If mbstring.func_overload is not used (or does not override string functions), this method is a no-op. return: void |
restoreEncoding() X-Ref |
Restore internal encoding return: void |