PHP Класс Leafo\ScssPhp\Parser

Автор: Leaf Corcoran ([email protected])
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$commentPattern
$operatorPattern
$precedence array
$whitePattern

Открытые методы

Метод Описание
__construct ( string $sourceName, integer $sourceIndex, string $encoding = 'utf-8' ) Constructor
getSourceName ( ) : string Get source file name
parse ( string $buffer ) : Leafo\ScssPhp\Block Parser buffer
parseSelector ( string $buffer, string &$out ) : boolean Parse a selector or selector list
parseValue ( string $buffer, string &$out ) : boolean Parse a value or value list
throwParseError ( string $msg = 'parse error' ) Throw parser error

Защищенные методы

Метод Описание
append ( array $statement, integer $pos = null ) Append statement to current block
appendComment ( array $comment ) Append comment to current block
argValue ( array &$out ) : boolean Parse argument value
argValues ( array &$out ) : boolean Parse argument values
argumentDef ( array &$out ) : boolean Parse mixin/function definition argument list
argumentList ( array &$out ) : boolean Parse function call argument list
color ( array &$out ) : boolean Parse color
end ( ) : boolean Consume an end of statement delimiter
expHelper ( array $lhs, integer $minP ) : array Parse left-hand side of subexpression
expression ( array &$out ) : boolean Parse expression
flattenList ( array $value ) : array Turn list of length 1 into value type
func ( &$func ) : boolean Parse function call
genericList ( array &$out, callable $parseItem, string $delim = '', boolean $flatten = true ) : boolean Parse generic list
interpolation ( array &$out, boolean $lookWhite = true ) : boolean Parser interpolation
keyword ( string &$word, boolean $eatWhitespace = null ) : boolean Parse a keyword
last ( ) : array | null Returns last child was appended
literal ( string $what, boolean $eatWhitespace = null ) : boolean Match literal string
map ( array &$out ) : boolean Parse map
match ( string $regex, array &$out, boolean $eatWhitespace = null ) : boolean Try to match something on head of buffer
matchString ( array &$m, string $delim ) : boolean Match string looking for either ending delim, escape, or string interpolation
mediaExpression ( array &$out ) : boolean Parse media expression
mediaQuery ( array &$out ) : boolean Parse media query
mediaQueryList ( array &$out ) : boolean Parse media query list
mixedKeyword ( array &$out ) : boolean Parse keyword or interpolation
openString ( string $end, array &$out, string $nestingOpen = null ) : boolean Parse an unbounded string stopped by $end
parenValue ( array &$out ) : boolean Parse parenthesized value
parseChunk ( ) : boolean Parse a single chunk off the head of the buffer and append it to the current parse environment.
peek ( string $regex, array &$out, integer $from = null ) : integer Peek input stream
placeholder ( string &$placeholder ) : boolean Parse a placeholder
popBlock ( ) : Leafo\ScssPhp\Block Pop scope and return last block
progid ( array &$out ) : boolean Parse "progid:"
propertyName ( array &$out ) : boolean Parse property name (as an array of parts or a string)
pushBlock ( array $selectors, integer $pos ) : Leafo\ScssPhp\Block Push block onto parse tree
pushSpecialBlock ( string $type, integer $pos ) : Leafo\ScssPhp\Block Push special (named) block onto parse tree
seek ( integer $where = null ) : integer Seek to position in input stream (or return current position in input stream)
selector ( array &$out ) : boolean Parse whitespace separated selector list
selectorSingle ( array &$out ) : boolean Parse the parts that make up a selector
selectors ( array &$out ) : boolean Parse comma separated selector list
show ( )
spaceList ( array &$out ) : boolean Parse space separated value list
string ( array &$out ) : boolean Parse string
stripAssignmentFlags ( array &$value ) : array Strip assignment flag from the list
stripOptionalFlag ( array &$selectors ) : string Strip optional flag from selector list
to ( $what, &$out, $until = false, $allowNewline = false )
unit ( &$unit ) : boolean Parse number with unit
url ( array &$out ) : boolean Parse a url
value ( array &$out ) : boolean Parse value
valueList ( string &$out ) : boolean Parse comma separated value list
variable ( array &$out ) : boolean Parse a variable
whitespace ( ) : boolean Match some whitespace

Приватные методы

Метод Описание
extractLineNumbers ( string $buffer ) Extract line numbers from buffer
getSourcePosition ( integer $pos ) : integer Get source line number and column (given character position in the buffer)
pregQuote ( string $what ) : string Quote regular expression
restoreEncoding ( ) Restore internal encoding
saveEncoding ( ) Save internal encoding

Описание методов

__construct() публичный Метод

Constructor
public __construct ( string $sourceName, integer $sourceIndex, string $encoding = 'utf-8' )
$sourceName string
$sourceIndex integer
$encoding string

append() защищенный Метод

Append statement to current block
protected append ( array $statement, integer $pos = null )
$statement array
$pos integer

appendComment() защищенный Метод

Append comment to current block
protected appendComment ( array $comment )
$comment array

argValue() защищенный Метод

Parse argument value
protected argValue ( array &$out ) : boolean
$out array
Результат boolean

argValues() защищенный Метод

Parse argument values
protected argValues ( array &$out ) : boolean
$out array
Результат boolean

argumentDef() защищенный Метод

Parse mixin/function definition argument list
protected argumentDef ( array &$out ) : boolean
$out array
Результат boolean

argumentList() защищенный Метод

Parse function call argument list
protected argumentList ( array &$out ) : boolean
$out array
Результат boolean

color() защищенный Метод

Parse color
protected color ( array &$out ) : boolean
$out array
Результат boolean

end() защищенный Метод

Consume an end of statement delimiter
protected end ( ) : boolean
Результат boolean

expHelper() защищенный Метод

Parse left-hand side of subexpression
protected expHelper ( array $lhs, integer $minP ) : array
$lhs array
$minP integer
Результат array

expression() защищенный Метод

Parse expression
protected expression ( array &$out ) : boolean
$out array
Результат boolean

flattenList() защищенный Метод

Turn list of length 1 into value type
protected flattenList ( array $value ) : array
$value array
Результат array

func() защищенный Метод

Parse function call
protected func ( &$func ) : boolean
Результат boolean

genericList() защищенный Метод

Parse generic list
protected genericList ( array &$out, callable $parseItem, string $delim = '', boolean $flatten = true ) : boolean
$out array
$parseItem callable
$delim string
$flatten boolean
Результат boolean

getSourceName() публичный Метод

Get source file name
public getSourceName ( ) : string
Результат string

interpolation() защищенный Метод

Parser interpolation
protected interpolation ( array &$out, boolean $lookWhite = true ) : boolean
$out array
$lookWhite boolean save information about whitespace before and after
Результат boolean

keyword() защищенный Метод

Parse a keyword
protected keyword ( string &$word, boolean $eatWhitespace = null ) : boolean
$word string
$eatWhitespace boolean
Результат boolean

last() защищенный Метод

Returns last child was appended
protected last ( ) : array | null
Результат array | null

literal() защищенный Метод

Match literal string
protected literal ( string $what, boolean $eatWhitespace = null ) : boolean
$what string
$eatWhitespace boolean
Результат boolean

map() защищенный Метод

Parse map
protected map ( array &$out ) : boolean
$out array
Результат boolean

match() защищенный Метод

Try to match something on head of buffer
protected match ( string $regex, array &$out, boolean $eatWhitespace = null ) : boolean
$regex string
$out array
$eatWhitespace boolean
Результат boolean

matchString() защищенный Метод

{@internal This is a workaround for preg_match's 250K string match limit.}}
protected matchString ( array &$m, string $delim ) : boolean
$m array Matches (passed by reference)
$delim string Delimeter
Результат boolean True if match; false otherwise

mediaExpression() защищенный Метод

Parse media expression
protected mediaExpression ( array &$out ) : boolean
$out array
Результат boolean

mediaQuery() защищенный Метод

Parse media query
protected mediaQuery ( array &$out ) : boolean
$out array
Результат boolean

mediaQueryList() защищенный Метод

Parse media query list
protected mediaQueryList ( array &$out ) : boolean
$out array
Результат boolean

mixedKeyword() защищенный Метод

Parse keyword or interpolation
protected mixedKeyword ( array &$out ) : boolean
$out array
Результат boolean

openString() защищенный Метод

Parse an unbounded string stopped by $end
protected openString ( string $end, array &$out, string $nestingOpen = null ) : boolean
$end string
$out array
$nestingOpen string
Результат boolean

parenValue() защищенный Метод

Parse parenthesized value
protected parenValue ( array &$out ) : boolean
$out array
Результат boolean

parse() публичный Метод

Parser buffer
public parse ( string $buffer ) : Leafo\ScssPhp\Block
$buffer string
Результат Leafo\ScssPhp\Block

parseChunk() защищенный Метод

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->seek() to remember the current position into $s. Then if a chain fails, use $this->seek($s) to go back where we started.
protected parseChunk ( ) : boolean
Результат boolean

parseSelector() публичный Метод

Parse a selector or selector list
public parseSelector ( string $buffer, string &$out ) : boolean
$buffer string
$out string
Результат boolean

parseValue() публичный Метод

Parse a value or value list
public parseValue ( string $buffer, string &$out ) : boolean
$buffer string
$out string
Результат boolean

peek() защищенный Метод

Peek input stream
protected peek ( string $regex, array &$out, integer $from = null ) : integer
$regex string
$out array
$from integer
Результат integer

placeholder() защищенный Метод

Parse a placeholder
protected placeholder ( string &$placeholder ) : boolean
$placeholder string
Результат boolean

popBlock() защищенный Метод

Pop scope and return last block
protected popBlock ( ) : Leafo\ScssPhp\Block
Результат Leafo\ScssPhp\Block

progid() защищенный Метод

Parse "progid:"
protected progid ( array &$out ) : boolean
$out array
Результат boolean

propertyName() защищенный Метод

Parse property name (as an array of parts or a string)
protected propertyName ( array &$out ) : boolean
$out array
Результат boolean

pushBlock() защищенный Метод

Push block onto parse tree
protected pushBlock ( array $selectors, integer $pos ) : Leafo\ScssPhp\Block
$selectors array
$pos integer
Результат Leafo\ScssPhp\Block

pushSpecialBlock() защищенный Метод

Push special (named) block onto parse tree
protected pushSpecialBlock ( string $type, integer $pos ) : Leafo\ScssPhp\Block
$type string
$pos integer
Результат Leafo\ScssPhp\Block

seek() защищенный Метод

Seek to position in input stream (or return current position in input stream)
protected seek ( integer $where = null ) : integer
$where integer
Результат integer

selector() защищенный Метод

Parse whitespace separated selector list
protected selector ( array &$out ) : boolean
$out array
Результат boolean

selectorSingle() защищенный Метод

{@internal div[yes=no]#something.hello.world:nth-child(-2n+1)%placeholder}}
protected selectorSingle ( array &$out ) : boolean
$out array
Результат boolean

selectors() защищенный Метод

Parse comma separated selector list
protected selectors ( array &$out ) : boolean
$out array
Результат boolean

show() защищенный Метод

Устаревший:
protected show ( )

spaceList() защищенный Метод

Parse space separated value list
protected spaceList ( array &$out ) : boolean
$out array
Результат boolean

string() защищенный Метод

Parse string
protected string ( array &$out ) : boolean
$out array
Результат boolean

stripAssignmentFlags() защищенный Метод

Strip assignment flag from the list
protected stripAssignmentFlags ( array &$value ) : array
$value array
Результат array

stripOptionalFlag() защищенный Метод

Strip optional flag from selector list
protected stripOptionalFlag ( array &$selectors ) : string
$selectors array
Результат string

throwParseError() публичный Метод

Throw parser error
public throwParseError ( string $msg = 'parse error' )
$msg string

to() защищенный Метод

Устаревший: {@internal advance counter to next occurrence of $what $until - don't include $what in advance $allowNewline, if string, will be used as valid char set}}
protected to ( $what, &$out, $until = false, $allowNewline = false )

unit() защищенный Метод

Parse number with unit
protected unit ( &$unit ) : boolean
Результат boolean

url() защищенный Метод

Parse a url
protected url ( array &$out ) : boolean
$out array
Результат boolean

value() защищенный Метод

Parse value
protected value ( array &$out ) : boolean
$out array
Результат boolean

valueList() защищенный Метод

Parse comma separated value list
protected valueList ( string &$out ) : boolean
$out string
Результат boolean

variable() защищенный Метод

Parse a variable
protected variable ( array &$out ) : boolean
$out array
Результат boolean

whitespace() защищенный Метод

Match some whitespace
protected whitespace ( ) : boolean
Результат boolean

Описание свойств

$commentPattern защищенное статическое свойство

protected static $commentPattern

$operatorPattern защищенное статическое свойство

protected static $operatorPattern

$precedence защищенное статическое свойство

protected static array $precedence
Результат array

$whitePattern защищенное статическое свойство

protected static $whitePattern