class lessc_parser (View source)

Properties

static protected $nextBlockId
static protected $precedence
static protected $whitePattern
static protected $commentMulti
static protected $commentSingle
static protected $commentMultiLeft
static protected $commentMultiRight
static protected $operatorString
static protected $supressDivisionProps
protected $blockDirectives
protected $lineDirectives
protected $inParens

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.

static protected $literalCache
$env
$buffer
$count
$line
$eatWhiteDefault
$lessc
$sourceName
$writeComments
$seenComments
$currentProperty
$inExp

Methods

__construct($lessc, $sourceName = null)

No description

null|stdclass
parse(string $buffer)

Parse a string

parseChunk()

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

isDirective($dirname, $directives)

No description

fixTags($tags)

No description

expressionList($exps)

No description

expression($out)

Attempt to consume an expression.

expHelper($lhs, $minP)

recursively parse infix equation with $lhs at precedence $minP

propertyValue($value, $keyName = null)

No description

parenValue($out)

No description

value($value)

No description

import($out, $value = '')

No description

mediaQueryList($out)

No description

mediaQuery($out)

No description

mediaExpression($out)

No description

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

No description

string($out)

No description

interpolation($out)

No description

unit($unit)

No description

color($out)

No description

argumentDef($args, $isVararg)

No description

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

No description

mixinTags($tags)

No description

tagBracket($parts, $hasExpression)

No description

tag($tag, $simple = false)

No description

func($func)

No description

variable($name)

No description

assign($name = null)

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

keyword($word)

No description

end()

No description

guards($guards)

No description

guardGroup($guardGroup)

No description

guard($guard)

No description

literal($what, $eatWhitespace = null)

No description

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

No description

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

No description

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

No description

whitespace()

No description

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

No description

seek($where = null)

No description

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

No description

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

No description

pushSpecialBlock($type)

No description

append($prop, $pos = null)

No description

pop()

No description

removeComments($text)

No description

Details

__construct($lessc, $sourceName = null)

No description

Parameters

$lessc
$sourceName

null|stdclass parse(string $buffer)

Parse a string

Parameters

string $buffer

String to parse

Return Value

null|stdclass

Exceptions

exception

protected parseChunk()

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

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 isDirective($dirname, $directives)

No description

Parameters

$dirname
$directives

protected fixTags($tags)

No description

Parameters

$tags

protected expressionList($exps)

No description

Parameters

$exps

protected expression($out)

Attempt to consume an expression.

Parameters

$out

protected expHelper($lhs, $minP)

recursively parse infix equation with $lhs at precedence $minP

Parameters

$lhs
$minP

propertyValue($value, $keyName = null)

No description

Parameters

$value
$keyName

protected parenValue($out)

No description

Parameters

$out

protected value($value)

No description

Parameters

$value

protected import($out, $value = '')

No description

Parameters

$out
$value

protected mediaQueryList($out)

No description

Parameters

$out

protected mediaQuery($out)

No description

Parameters

$out

protected mediaExpression($out)

No description

Parameters

$out

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

No description

Parameters

$end
$out
$nestingOpen
$rejectStrs

protected string($out)

No description

Parameters

$out

protected interpolation($out)

No description

Parameters

$out

protected unit($unit)

No description

Parameters

$unit

protected color($out)

No description

Parameters

$out

protected argumentDef($args, $isVararg)

No description

Parameters

$args
$isVararg

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

No description

Parameters

$tags
$simple
$delim

protected mixinTags($tags)

No description

Parameters

$tags

protected tagBracket($parts, $hasExpression)

No description

Parameters

$parts
$hasExpression

protected tag($tag, $simple = false)

No description

Parameters

$tag
$simple

protected func($func)

No description

Parameters

$func

protected variable($name)

No description

Parameters

$name

protected assign($name = null)

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

Parameters

$name

protected keyword($word)

No description

Parameters

$word

protected end()

No description

protected guards($guards)

No description

Parameters

$guards

protected guardGroup($guardGroup)

No description

Parameters

$guardGroup

protected guard($guard)

No description

Parameters

$guard

protected literal($what, $eatWhitespace = null)

No description

Parameters

$what
$eatWhitespace

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

No description

Parameters

$out
$parseItem
$delim
$flatten

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

No description

Parameters

$what
$out
$until
$allowNewline

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

No description

Parameters

$regex
$out
$eatWhitespace

protected whitespace()

No description

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

No description

Parameters

$regex
$out
$from

protected seek($where = null)

No description

Parameters

$where

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

No description

Parameters

$msg
$count

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

No description

Parameters

$selectors
$type

protected pushSpecialBlock($type)

No description

Parameters

$type

protected append($prop, $pos = null)

No description

Parameters

$prop
$pos

protected pop()

No description

protected removeComments($text)

No description

Parameters

$text