PHP Class FOF30\Less\Parser\Parser

lessphp v0.3.9 http://leafo.net/lessphp LESS css compiler, adapted from http://lesscss.org Copyright 2012, Leaf Corcoran Licensed under MIT or GPLv3, see LICENSE Responsible for taking a string of LESS code and converting it into a syntax tree
Since: 2.0
Afficher le fichier Open project: akeeba/fof 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 Used to uniquely identify blocks
$operatorString Regex string to match any of the operators
$precedence
$supressDivisionProps These properties will supress division unless it's inside parenthases
$whitePattern

Méthodes publiques

Méthode Description
__construct ( [type] $lessc, string $sourceName = null ) Constructor
parse ( string $buffer ) : [type] Parse text
propertyValue ( &$value, [type] $keyName = null ) : boolean Consume a list of values for a property
throwError ( string $msg = "parse error", [type] $count = null ) : void [throwError description]

Méthodes protégées

Méthode Description
append ( [type] $prop, [type] $pos = null ) : void Append a property to the current block
argumentDef ( &$args, &$isVararg, [type] $delim = ',' ) : boolean Consume an argument definition list surrounded by () each argument is a variable name with optional value or at the end a .
argumentValues ( &$args, [type] $delim = ',' ) : boolean Consume a list of property values delimited by ; and wrapped in ()
assign ( string $name = null ) : boolean Consume an assignment operator Can optionally take a name that will be set to the current property name
color ( &$out ) : boolean a # color
end ( ) : boolean Consume an end of statement delimiter
expHelper ( type $lhs, type $minP ) : string Recursively parse infix equation with $lhs at precedence $minP
expression ( &$out ) : boolean Attempt to consume an expression.
expressionList ( &$exps ) : boolean a list of expressions
fixTags ( [type] $tags ) : [type] [fixTags description]
func ( &$func ) : boolean A css function
genericList ( &$out, [type] $parseItem, string $delim = "", boolean $flatten = true ) : boolean [genericList description]
guard ( &$guard ) : boolean [guard description]
guardGroup ( &$guardGroup ) : boolean A bunch of guards that are and'd together
guards ( &$guards ) : boolean [guards description]
import ( &$out ) : boolean an import statement
interpolation ( &$out ) : boolean [interpolation description]
isDirective ( string $dirname, [type] $directives ) : boolean [isDirective description]
keyword ( &$word ) : boolean Consume a keyword
literal ( [type] $what, [type] $eatWhitespace = null ) : boolean [literal description]
match ( [type] $regex, &$out, [type] $eatWhitespace = null ) : boolean Try to match something on head of buffer
mediaExpression ( &$out ) : boolean [mediaExpression description]
mediaQuery ( &$out ) : [type] [mediaQuery description]
mediaQueryList ( &$out ) : boolean [mediaQueryList description]
mixinTags ( &$tags ) : boolean List of tags of specifying mixin path Optionally separated by > (lazy, accepts extra >)
openString ( [type] $end, &$out, [type] $nestingOpen = null, [type] $rejectStrs = null ) : boolean An unbounded string stopped by $end
parenValue ( &$out ) : boolean [parenValue description]
parseChunk ( ) : boolean Parse a single chunk off the head of the buffer and append it to the current parse environment.
peek ( [type] $regex, &$out = null, [type] $from = null ) : boolean Match something without consuming it
pop ( ) : [type] Pop something off the stack
pushBlock ( [type] $selectors = null, [type] $type = null ) : stdClass [pushBlock description]
pushSpecialBlock ( [type] $type ) : stdClass Push a block that doesn't multiply tags
removeComments ( [type] $text ) : [type] Remove comments from $text
seek ( [type] $where = null ) : boolean Seek to a spot in the buffer or return where we are on no argument
string ( &$out ) : boolean [string description]
tag ( &$tag, boolean $simple = false ) : boolean A single tag
tagBracket ( &$value ) : boolean A bracketed value (contained within in a tag definition)
tagExpression ( &$value ) : boolean [tagExpression description]
tags ( &$tags, [type] $simple = false, [type] $delim = ',' ) : boolean Consume a list of tags This accepts a hanging delimiter
to ( [type] $what, &$out, boolean $until = false, boolean $allowNewline = false ) : boolean Advance counter to next occurrence of $what $until - don't include $what in advance $allowNewline, if string, will be used as valid char set
unit ( &$unit ) : boolean [unit description]
value ( &$value ) : boolean a single value
variable ( &$name ) : boolean Consume a less variable
whitespace ( ) : boolean Watch some whitespace

Method Details

__construct() public méthode

Constructor
public __construct ( [type] $lessc, string $sourceName = null )
$lessc [type]
$sourceName string [description]

append() protected méthode

Append a property to the current block
protected append ( [type] $prop, [type] $pos = null ) : void
$prop [type]
$pos [type]
Résultat void

argumentDef() protected méthode

.. or a variable named followed by ...
protected argumentDef ( &$args, &$isVararg, [type] $delim = ',' ) : boolean
$delim [type]
Résultat boolean

argumentValues() protected méthode

Consume a list of property values delimited by ; and wrapped in ()
protected argumentValues ( &$args, [type] $delim = ',' ) : boolean
$delim [type]
Résultat boolean

assign() protected méthode

Consume an assignment operator Can optionally take a name that will be set to the current property name
protected assign ( string $name = null ) : boolean
$name string [description]
Résultat boolean

color() protected méthode

a # color
protected color ( &$out ) : boolean
Résultat boolean

end() protected méthode

Consume an end of statement delimiter
protected end ( ) : boolean
Résultat boolean

expHelper() protected méthode

Recursively parse infix equation with $lhs at precedence $minP
protected expHelper ( type $lhs, type $minP ) : string
$lhs type [description]
$minP type [description]
Résultat string

expression() protected méthode

Attempt to consume an expression.
protected expression ( &$out ) : boolean
Résultat boolean

expressionList() protected méthode

a list of expressions
protected expressionList ( &$exps ) : boolean
Résultat boolean

fixTags() protected méthode

[fixTags description]
protected fixTags ( [type] $tags ) : [type]
$tags [type]
Résultat [type]

func() protected méthode

A css function
protected func ( &$func ) : boolean
Résultat boolean

genericList() protected méthode

[genericList description]
protected genericList ( &$out, [type] $parseItem, string $delim = "", boolean $flatten = true ) : boolean
$parseItem [type]
$delim string [description]
$flatten boolean [description]
Résultat boolean

guard() protected méthode

[guard description]
protected guard ( &$guard ) : boolean
Résultat boolean

guardGroup() protected méthode

A bunch of guards that are and'd together
protected guardGroup ( &$guardGroup ) : boolean
Résultat boolean

guards() protected méthode

[guards description]
protected guards ( &$guards ) : boolean
Résultat boolean

import() protected méthode

an import statement
protected import ( &$out ) : boolean
Résultat boolean

interpolation() protected méthode

[interpolation description]
protected interpolation ( &$out ) : boolean
Résultat boolean

isDirective() protected méthode

[isDirective description]
protected isDirective ( string $dirname, [type] $directives ) : boolean
$dirname string [description]
$directives [type]
Résultat boolean

keyword() protected méthode

Consume a keyword
protected keyword ( &$word ) : boolean
Résultat boolean

literal() protected méthode

[literal description]
protected literal ( [type] $what, [type] $eatWhitespace = null ) : boolean
$what [type]
$eatWhitespace [type]
Résultat boolean

match() protected méthode

Try to match something on head of buffer
protected match ( [type] $regex, &$out, [type] $eatWhitespace = null ) : boolean
$regex [type]
$eatWhitespace [type]
Résultat boolean

mediaExpression() protected méthode

[mediaExpression description]
protected mediaExpression ( &$out ) : boolean
Résultat boolean

mediaQuery() protected méthode

[mediaQuery description]
protected mediaQuery ( &$out ) : [type]
Résultat [type]

mediaQueryList() protected méthode

[mediaQueryList description]
protected mediaQueryList ( &$out ) : boolean
Résultat boolean

mixinTags() protected méthode

List of tags of specifying mixin path Optionally separated by > (lazy, accepts extra >)
protected mixinTags ( &$tags ) : boolean
Résultat boolean

openString() protected méthode

An unbounded string stopped by $end
protected openString ( [type] $end, &$out, [type] $nestingOpen = null, [type] $rejectStrs = null ) : boolean
$end [type]
$nestingOpen [type]
$rejectStrs [type]
Résultat boolean

parenValue() protected méthode

[parenValue description]
protected parenValue ( &$out ) : boolean
Résultat boolean

parse() public méthode

Parse text
public parse ( string $buffer ) : [type]
$buffer string [description]
Résultat [type]

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 ( ) : boolean
Résultat boolean

peek() protected méthode

Match something without consuming it
protected peek ( [type] $regex, &$out = null, [type] $from = null ) : boolean
$regex [type]
$from [type]
Résultat boolean

pop() protected méthode

Pop something off the stack
protected pop ( ) : [type]
Résultat [type]

propertyValue() public méthode

Consume a list of values for a property
public propertyValue ( &$value, [type] $keyName = null ) : boolean
$keyName [type]
Résultat boolean

pushBlock() protected méthode

[pushBlock description]
protected pushBlock ( [type] $selectors = null, [type] $type = null ) : stdClass
$selectors [type]
$type [type]
Résultat stdClass

pushSpecialBlock() protected méthode

Push a block that doesn't multiply tags
protected pushSpecialBlock ( [type] $type ) : stdClass
$type [type]
Résultat stdClass

removeComments() protected méthode

Remove comments from $text
protected removeComments ( [type] $text ) : [type]
$text [type]
Résultat [type]

seek() protected méthode

Seek to a spot in the buffer or return where we are on no argument
protected seek ( [type] $where = null ) : boolean
$where [type]
Résultat boolean

string() protected méthode

[string description]
protected string ( &$out ) : boolean
Résultat boolean

tag() protected méthode

A single tag
protected tag ( &$tag, boolean $simple = false ) : boolean
$simple boolean [description]
Résultat boolean

tagBracket() protected méthode

A bracketed value (contained within in a tag definition)
protected tagBracket ( &$value ) : boolean
Résultat boolean

tagExpression() protected méthode

[tagExpression description]
protected tagExpression ( &$value ) : boolean
Résultat boolean

tags() protected méthode

Consume a list of tags This accepts a hanging delimiter
protected tags ( &$tags, [type] $simple = false, [type] $delim = ',' ) : boolean
$simple [type]
$delim [type]
Résultat boolean

throwError() public méthode

[throwError description]
public throwError ( string $msg = "parse error", [type] $count = null ) : void
$msg string [description]
$count [type]
Résultat void

to() protected méthode

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 ( [type] $what, &$out, boolean $until = false, boolean $allowNewline = false ) : boolean
$what [type]
$until boolean [description]
$allowNewline boolean [description]
Résultat boolean

unit() protected méthode

[unit description]
protected unit ( &$unit ) : boolean
Résultat boolean

value() protected méthode

a single value
protected value ( &$value ) : boolean
Résultat boolean

variable() protected méthode

Consume a less variable
protected variable ( &$name ) : boolean
Résultat boolean

whitespace() protected méthode

Watch some whitespace
protected whitespace ( ) : boolean
Résultat boolean

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

Used to uniquely identify blocks
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

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