WpvLesscParser

Methods

__construct

__construct($lessc, $sourceName = null) 

Arguments

$lessc

$sourceName

parse

parse($buffer) 

Arguments

$buffer

Parse a single chunk off the head of the buffer and append it to the current parse environment.

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 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.

isDirective

isDirective($dirname, $directives) 

Arguments

$dirname

$directives

fixTags

fixTags($tags) 

Arguments

$tags

expressionList

expressionList(&$exps) 

Arguments

$exps

Attempt to consume an expression.

expression(&$out) 

recursively parse infix equation with $lhs at precedence $minP

expHelper($lhs, $minP) 

Arguments

$lhs

$minP

propertyValue

propertyValue(&$value, $keyName = null) 

Arguments

$value

$keyName

parenValue

parenValue(&$out) 

Arguments

$out

value

value(&$value) 

Arguments

$value

import

import(&$out) 

Arguments

$out

mediaQueryList

mediaQueryList(&$out) 

Arguments

$out

mediaQuery

mediaQuery(&$out) 

Arguments

$out

mediaExpression

mediaExpression(&$out) 

Arguments

$out

openString

openString($end, &$out, $nestingOpen = null, $rejectStrs = null) 

Arguments

$end

$out

$nestingOpen

$rejectStrs

string

string(&$out) 

Arguments

$out

interpolation

interpolation(&$out) 

Arguments

$out

unit

unit(&$unit) 

Arguments

$unit

color

color(&$out) 

Arguments

$out

argumentDef

argumentDef(&$args, &$isVararg) 

Arguments

$args

$isVararg

tags

tags(&$tags, $simple = false, $delim = ',') 

Arguments

$tags

$simple

$delim

mixinTags

mixinTags(&$tags) 

Arguments

$tags

tagBracket

tagBracket(&$parts, &$hasExpression) 

Arguments

$parts

$hasExpression

tag

tag(&$tag, $simple = false) 

Arguments

$tag

$simple

func

func(&$func) 

Arguments

$func

variable

variable(&$name) 

Arguments

$name

Consume an assignment operator Can optionally take a name that will be set to the current property name

assign($name = null) 

Arguments

$name

keyword

keyword(&$word) 

Arguments

$word

end

end() 

guards

guards(&$guards) 

Arguments

$guards

guardGroup

guardGroup(&$guardGroup) 

Arguments

$guardGroup

guard

guard(&$guard) 

Arguments

$guard

literal

literal($what, $eatWhitespace = null) 

Arguments

$what

$eatWhitespace

genericList

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

Arguments

$out

$parseItem

$delim

$flatten

to

to($what, &$out, $until = false, $allowNewline = false) 

Arguments

$what

$out

$until

$allowNewline

match

match($regex, &$out, $eatWhitespace = null) 

Arguments

$regex

$out

$eatWhitespace

whitespace

whitespace() 

peek

peek($regex, &$out = null, $from = null) 

Arguments

$regex

$out

$from

seek

seek($where = null) 

Arguments

$where

throwError

throwError($msg = "parse error", $count = null) 

Arguments

$msg

$count

pushBlock

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

Arguments

$selectors

$type

pushSpecialBlock

pushSpecialBlock($type) 

Arguments

$type

append

append($prop, $pos = null) 

Arguments

$prop

$pos

pop

pop() 

removeComments

removeComments($text) 

Arguments

$text

Properties

nextBlockId

nextBlockId : 
static

precedence

precedence : 
static

whitePattern

whitePattern : 
static

commentMulti

commentMulti : 
static

commentSingle

commentSingle : 
static

commentMultiLeft

commentMultiLeft : 
static

commentMultiRight

commentMultiRight : 
static

operatorString

operatorString : 
static

supressDivisionProps

supressDivisionProps : 
static

blockDirectives

blockDirectives : 

lineDirectives

lineDirectives : 

if we are in parens we can be more liberal with whitespace around operators because it must evaluate to a single value and thus is less ambiguous.

inParens : 

Consider:

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

literalCache

literalCache : 
static