PHP Class lessc_parser, Beans

Afficher le fichier Open project: Getbeans/Beans Class Usage Examples

Protected Properties

Свойство Type Description
$blockDirectives
$commentMulti
$commentMultiLeft
$commentMultiRight
$commentSingle
$inParens Consider: property1: 10 -5; // is two numbers, 10 and -5 property2: (10 -5); // should evaluate to 5
$lineDirectives
$literalCache caches preg escaped literals
$nextBlockId
$operatorString regex string to match any of the operators
$precedence used to uniquely identify blocks
$supressDivisionProps these properties will supress division unless it's inside parenthases
$whitePattern

Méthodes publiques

Méthode Description
__construct ( $lessc, $sourceName = null )
parse ( $buffer )
propertyValue ( &$value, $keyName = null ) consume a list of values for a property
throwError ( $msg = "parse error", $count = null ) * misc functions

Méthodes protégées

Méthode Description
append ( $prop, $pos = null ) append a property to the current block
argumentDef ( &$args, &$isVararg ) delimiter.
assign ( $name = null ) Consume an assignment operator Can optionally take a name that will be set to the current property name
color ( &$out ) a # color
end ( ) consume an end of statement delimiter
expHelper ( $lhs, $minP ) recursively parse infix equation with $lhs at precedence $minP
expression ( &$out ) Attempt to consume an expression.
expressionList ( &$exps ) a list of expressions
fixTags ( $tags )
func ( &$func ) a css function
genericList ( &$out, $parseItem, $delim = "", $flatten = true )
guard ( &$guard )
guardGroup ( &$guardGroup ) TODO rename to guardGroup
guards ( &$guards )
import ( &$out ) an import statement
interpolation ( &$out )
isDirective ( $dirname, $directives )
keyword ( &$word ) consume a keyword
literal ( $what, $eatWhitespace = null ) * raw parsing functions
match ( $regex, &$out, $eatWhitespace = null ) try to match something on head of buffer
mediaExpression ( &$out )
mediaQuery ( &$out )
mediaQueryList ( &$out )
mixinTags ( &$tags ) optionally separated by > (lazy, accepts extra >)
openString ( $end, &$out, $nestingOpen = null, $rejectStrs = null ) an unbounded string stopped by $end
parenValue ( &$out )
parseChunk ( ) Parse a single chunk off the head of the buffer and append it to the current parse environment.
peek ( $regex, &$out = null, $from = null ) match something without consuming it
pop ( ) pop something off the stack
pushBlock ( $selectors = null, $type = null )
pushSpecialBlock ( $type ) push a block that doesn't multiply tags
removeComments ( $text ) todo: make it work for all functions, not just url
seek ( $where = null ) seek to a spot in the buffer or return where we are on no argument
string ( &$out )
tag ( &$tag, $simple = false ) a space separated list of selectors
tagBracket ( &$parts, &$hasExpression ) a bracketed value (contained within in a tag definition)
tags ( &$tags, $simple = false, $delim = ',' ) this accepts a hanging delimiter
to ( $what, &$out, $until = false, $allowNewline = false ) $allowNewline, if string, will be used as valid char set
unit ( &$unit )
value ( &$value ) a single value
variable ( &$name ) consume a less variable
whitespace ( ) match some whitespace

Method Details

__construct() public méthode

public __construct ( $lessc, $sourceName = null )

append() protected méthode

append a property to the current block
protected append ( $prop, $pos = null )

argumentDef() protected méthode

delimiter.
protected argumentDef ( &$args, &$isVararg )

assign() protected méthode

Consume an assignment operator Can optionally take a name that will be set to the current property name
protected assign ( $name = null )

color() protected méthode

a # color
protected color ( &$out )

end() protected méthode

consume an end of statement delimiter
protected end ( )

expHelper() protected méthode

recursively parse infix equation with $lhs at precedence $minP
protected expHelper ( $lhs, $minP )

expression() protected méthode

Attempt to consume an expression.
protected expression ( &$out )

expressionList() protected méthode

a list of expressions
protected expressionList ( &$exps )

fixTags() protected méthode

protected fixTags ( $tags )

func() protected méthode

a css function
protected func ( &$func )

genericList() protected méthode

protected genericList ( &$out, $parseItem, $delim = "", $flatten = true )

guard() protected méthode

protected guard ( &$guard )

guardGroup() protected méthode

TODO rename to guardGroup
protected guardGroup ( &$guardGroup )

guards() protected méthode

protected guards ( &$guards )

import() protected méthode

an import statement
protected import ( &$out )

interpolation() protected méthode

protected interpolation ( &$out )

isDirective() protected méthode

protected isDirective ( $dirname, $directives )

keyword() protected méthode

consume a keyword
protected keyword ( &$word )

literal() protected méthode

* raw parsing functions
protected literal ( $what, $eatWhitespace = null )

match() protected méthode

try to match something on head of buffer
protected match ( $regex, &$out, $eatWhitespace = null )

mediaExpression() protected méthode

protected mediaExpression ( &$out )

mediaQuery() protected méthode

protected mediaQuery ( &$out )

mediaQueryList() protected méthode

protected mediaQueryList ( &$out )

mixinTags() protected méthode

optionally separated by > (lazy, accepts extra >)
protected mixinTags ( &$tags )

openString() protected méthode

an unbounded string stopped by $end
protected openString ( $end, &$out, $nestingOpen = null, $rejectStrs = null )

parenValue() protected méthode

protected parenValue ( &$out )

parse() public méthode

public parse ( $buffer )

parseChunk() protected méthode

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 lessc::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 lessc::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, lessc::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 ( )

peek() protected méthode

match something without consuming it
protected peek ( $regex, &$out = null, $from = null )

pop() protected méthode

pop something off the stack
protected pop ( )

propertyValue() public méthode

consume a list of values for a property
public propertyValue ( &$value, $keyName = null )

pushBlock() protected méthode

protected pushBlock ( $selectors = null, $type = null )

pushSpecialBlock() protected méthode

push a block that doesn't multiply tags
protected pushSpecialBlock ( $type )

removeComments() protected méthode

todo: make it work for all functions, not just url
protected removeComments ( $text )

seek() protected méthode

seek to a spot in the buffer or return where we are on no argument
protected seek ( $where = null )

string() protected méthode

protected string ( &$out )

tag() protected méthode

a space separated list of selectors
protected tag ( &$tag, $simple = false )

tagBracket() protected méthode

a bracketed value (contained within in a tag definition)
protected tagBracket ( &$parts, &$hasExpression )

tags() protected méthode

this accepts a hanging delimiter
protected tags ( &$tags, $simple = false, $delim = ',' )

throwError() public méthode

* misc functions
public throwError ( $msg = "parse error", $count = null )

to() protected méthode

$allowNewline, if string, will be used as valid char set
protected to ( $what, &$out, $until = false, $allowNewline = false )

unit() protected méthode

protected unit ( &$unit )

value() protected méthode

a single value
protected value ( &$value )

variable() protected méthode

consume a less variable
protected variable ( &$name )

whitespace() protected méthode

match some whitespace
protected whitespace ( )

Property Details

$blockDirectives protected_oe property

protected $blockDirectives

$commentMulti protected_oe static_oe property

protected static $commentMulti

$commentMultiLeft protected_oe static_oe property

protected static $commentMultiLeft

$commentMultiRight protected_oe static_oe property

protected static $commentMultiRight

$commentSingle protected_oe static_oe property

protected static $commentSingle

$inParens protected_oe property

Consider: property1: 10 -5; // is two numbers, 10 and -5 property2: (10 -5); // should evaluate to 5
protected $inParens

$lineDirectives protected_oe property

protected $lineDirectives

$literalCache protected_oe static_oe property

caches preg escaped literals
protected static $literalCache

$nextBlockId protected_oe static_oe property

protected static $nextBlockId

$operatorString protected_oe static_oe property

regex string to match any of the operators
protected static $operatorString

$precedence protected_oe static_oe property

used to uniquely identify blocks
protected static $precedence

$supressDivisionProps protected_oe static_oe property

these properties will supress division unless it's inside parenthases
protected static $supressDivisionProps

$whitePattern protected_oe static_oe property

protected static $whitePattern