Properties

$nextBlockId

$nextBlockId

$precedence

$precedence

$whitePattern

$whitePattern

$commentMulti

$commentMulti

$commentSingle

$commentSingle

$commentMultiLeft

$commentMultiLeft

$commentMultiRight

$commentMultiRight

$operatorString

$operatorString

$supressDivisionProps

$supressDivisionProps

$blockDirectives

$blockDirectives

$lineDirectives

$lineDirectives

$inParens

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

Consider:

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

$literalCache

$literalCache

Methods

__construct()

__construct( $lessc,  $sourceName)

Parameters

$lessc
$sourceName

parse()

parse( $buffer)

Parameters

$buffer

propertyValue()

propertyValue( $value,  $keyName)

Parameters

$value
$keyName

throwError()

throwError( $msg,  $count)

Parameters

$msg
$count

parseChunk()

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.

isDirective()

isDirective( $dirname,  $directives)

Parameters

$dirname
$directives

fixTags()

fixTags( $tags)

Parameters

$tags

expressionList()

expressionList( $exps)

Parameters

$exps

expression()

expression( $out)

Attempt to consume an expression.

Parameters

$out

expHelper()

expHelper( $lhs,  $minP)

recursively parse infix equation with $lhs at precedence $minP

Parameters

$lhs
$minP

parenValue()

parenValue( $out)

Parameters

$out

value()

value( $value)

Parameters

$value

import()

import( $out)

Parameters

$out

mediaQueryList()

mediaQueryList( $out)

Parameters

$out

mediaQuery()

mediaQuery( $out)

Parameters

$out

mediaExpression()

mediaExpression( $out)

Parameters

$out

openString()

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

Parameters

$end
$out
$nestingOpen
$rejectStrs

string()

string( $out)

Parameters

$out

interpolation()

interpolation( $out)

Parameters

$out

unit()

unit( $unit)

Parameters

$unit

color()

color( $out)

Parameters

$out

argumentDef()

argumentDef( $args,  $isVararg)

Parameters

$args
$isVararg

tags()

tags( $tags,  $simple,  $delim)

Parameters

$tags
$simple
$delim

mixinTags()

mixinTags( $tags)

Parameters

$tags

tagBracket()

tagBracket( $parts,  $hasExpression)

Parameters

$parts
$hasExpression

tag()

tag( $tag,  $simple)

Parameters

$tag
$simple

func()

func( $func)

Parameters

$func

variable()

variable( $name)

Parameters

$name

assign()

assign( $name)

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

Parameters

$name

keyword()

keyword( $word)

Parameters

$word

end()

end()

guards()

guards( $guards)

Parameters

$guards

guardGroup()

guardGroup( $guardGroup)

Parameters

$guardGroup

guard()

guard( $guard)

Parameters

$guard

literal()

literal( $what,  $eatWhitespace)

Parameters

$what
$eatWhitespace

genericList()

genericList( $out,  $parseItem,  $delim,  $flatten)

Parameters

$out
$parseItem
$delim
$flatten

to()

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

Parameters

$what
$out
$until
$allowNewline

match()

match( $regex,  $out,  $eatWhitespace)

Parameters

$regex
$out
$eatWhitespace

whitespace()

whitespace()

peek()

peek( $regex,  $out,  $from)

Parameters

$regex
$out
$from

seek()

seek( $where)

Parameters

$where

pushBlock()

pushBlock( $selectors,  $type)

Parameters

$selectors
$type

pushSpecialBlock()

pushSpecialBlock( $type)

Parameters

$type

append()

append( $prop,  $pos)

Parameters

$prop
$pos

pop()

pop()

removeComments()

removeComments( $text)

Parameters

$text