PHP 클래스 Leafo\ScssPhp\Parser

저자: Leaf Corcoran ([email protected])
파일 보기 프로젝트 열기: leafo/scssphp 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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