\Less_Parser

Class for parsing and compiling less files into css

Summary

Methods
Properties
Constants
__construct()
Reset()
SetOptions()
SetOption()
registerFunction()
unregisterFunction()
getCss()
parse()
parseFile()
ModifyVars()
SetFileInfo()
SetCacheDir()
SetImportDirs()
SetInput()
UnsetInput()
CacheFile()
AddParsedFile()
AllParsedFiles()
FileParsed()
save()
PeekReg()
PeekChar()
skipWhitespace()
expect()
expectChar()
parseUnicodeDescriptor()
parseExtend()
parseAnonymousValue()
parseMultiplication()
serializeVars()
is_method()
round()
NewObj0()
NewObj1()
NewObj2()
NewObj3()
NewObj4()
NewObj5()
NewObj6()
NewObj7()
ObjCache()
ArgCache()
ArgString()
Error()
WinPath()
CacheEnabled()
$default_options
$options
$has_extends
$next_id
$contentsMap
No constants found
No protected methods found
$input
N/A
PreVisitors()
PostVisitors()
_parse()
GetRules()
restore()
forget()
isWhitespace()
match()
MatchFuncs()
MatchChar()
MatchReg()
parsePrimary()
parseComment()
parseComments()
parseEntitiesQuoted()
parseEntitiesKeyword()
FromKeyword()
parseEntitiesCall()
parseEntitiesArguments()
parseEntitiesLiteral()
parseEntitiesAssignment()
parseEntitiesUrl()
parseEntitiesVariable()
parseEntitiesVariableCurly()
parseEntitiesColor()
parseEntitiesDimension()
parseEntitiesJavascript()
parseVariable()
parseRulesetCall()
parseMixinCall()
parseMixinCallElements()
parseMixinArgs()
parseMixinDefinition()
parseEntity()
parseEnd()
parseAlpha()
parseElement()
parseCombinator()
parseLessSelector()
parseSelector()
parseTag()
parseAttribute()
parseBlock()
parseBlockRuleset()
parseDetachedRuleset()
parseRuleset()
parseNameValue()
parseRule()
parseImport()
parseImportOptions()
parseImportOption()
parseMediaFeature()
parseMediaFeatures()
parseMedia()
parseDirective()
parseValue()
parseImportant()
parseSub()
parseAddition()
parseConditions()
parseCondition()
parseOperand()
parseExpression()
parseProperty()
parseRuleProperty()
rulePropertyMatch()
$input_len
$pos
$saveStack
$furthest
$env
$rules
$imports
N/A

Properties

$default_options

$default_options : 

Default parser options

Type

$options

$options : 

Type

$has_extends

$has_extends : 

Type

$next_id

$next_id : 

Type

$contentsMap

$contentsMap : array

Filename to contents of all parsed the files

Type

array

$input

$input : 

Type

$input_len

$input_len : 

Type

$pos

$pos : 

Type

$saveStack

$saveStack : 

Type

$furthest

$furthest : 

Type

$rules

$rules : 

Type

$imports

$imports : 

Type

Methods

__construct()

__construct(\Less_Environment|array|null  $env = null) 

Parameters

\Less_Environment|array|null $env

Reset()

Reset(  $options = null) 

Reset the parser state completely

Parameters

$options

SetOptions()

SetOptions(  $options) 

Set one or more compiler options options: import_dirs, cache_dir, cache_method

Parameters

$options

SetOption()

SetOption(  $option,   $value) 

Set one compiler option

Parameters

$option
$value

registerFunction()

registerFunction(string  $name, callable  $callback) 

Registers a new custom function

Parameters

string $name

function name

callable $callback

callback

unregisterFunction()

unregisterFunction(string  $name) 

Removed an already registered function

Parameters

string $name

function name

getCss()

getCss() : string

Get the current css buffer

Returns

string

parse()

parse(string  $str,   $file_uri = null) : \Less_Tree_Ruleset|\Less_Parser

Parse a Less string into css

Parameters

string $str

The string to convert

$file_uri

Returns

\Less_Tree_Ruleset|\Less_Parser

parseFile()

parseFile(string  $filename, string  $uri_root = '', boolean  $returnRoot = false) : \Less_Tree_Ruleset|\Less_Parser

Parse a Less string from a given file

Parameters

string $filename

The file to parse

string $uri_root

The url of the file

boolean $returnRoot

Indicates whether the return value should be a css string a root node

Throws

\Less_Exception_Parser

Returns

\Less_Tree_Ruleset|\Less_Parser

ModifyVars()

ModifyVars(array  $vars) : \Less_Parser

Allows a user to set variables values

Parameters

array $vars

Returns

\Less_Parser

SetFileInfo()

SetFileInfo(string  $filename,   $uri_root = '') 

Parameters

string $filename
$uri_root

SetCacheDir()

SetCacheDir(  $dir) 

Parameters

$dir

SetImportDirs()

SetImportDirs(array  $dirs) 

Set a list of directories or callbacks the parser should use for determining import paths

Parameters

array $dirs

SetInput()

SetInput(  $file_path) 

Set up the input buffer

Parameters

$file_path

UnsetInput()

UnsetInput() 

Free up some memory

CacheFile()

CacheFile(  $file_path) 

Parameters

$file_path

AddParsedFile()

AddParsedFile(  $file) 

Parameters

$file

AllParsedFiles()

AllParsedFiles() 

FileParsed()

FileParsed(string  $file) 

Parameters

string $file

save()

save() 

PeekReg()

PeekReg(string  $tok) : integer

Same as match(), but don't change the state of the parser, just return the match.

Parameters

string $tok

Returns

integer

PeekChar()

PeekChar(string  $tok) 

Parameters

string $tok

skipWhitespace()

skipWhitespace(integer  $length) 

Parameters

integer $length

expect()

expect(string  $tok, string|null  $msg = NULL) 

Parameters

string $tok
string|null $msg

expectChar()

expectChar(string  $tok,   $msg = null) 

Parameters

string $tok
$msg

parseUnicodeDescriptor()

parseUnicodeDescriptor() 

parseExtend()

parseExtend(  $isRule = false) 

Parameters

$isRule

parseAnonymousValue()

parseAnonymousValue() 

parseMultiplication()

parseMultiplication() : \Less_Tree_Operation|null

Parses multiplication operation

Returns

\Less_Tree_Operation|null

serializeVars()

serializeVars(  $vars) 

Parameters

$vars

is_method()

is_method(  $a, string  $b) 

Some versions of php have trouble with method_exists($a,$b) if $a is not an object

Parameters

$a
string $b

round()

round(  $i,   $precision) 

Round numbers similarly to javascript eg: 1.499999 to 1 instead of 2

Parameters

$i
$precision

NewObj0()

NewObj0(  $class) : mixed

Create Less_Tree_* objects and optionally generate a cache string

Parameters

$class

Returns

mixed

NewObj1()

NewObj1(  $class,   $arg) 

Parameters

$class
$arg

NewObj2()

NewObj2(  $class,   $args) 

Parameters

$class
$args

NewObj3()

NewObj3(  $class,   $args) 

Parameters

$class
$args

NewObj4()

NewObj4(  $class,   $args) 

Parameters

$class
$args

NewObj5()

NewObj5(  $class,   $args) 

Parameters

$class
$args

NewObj6()

NewObj6(  $class,   $args) 

Parameters

$class
$args

NewObj7()

NewObj7(  $class,   $args) 

Parameters

$class
$args

ObjCache()

ObjCache(  $obj,   $class,   $args = array()) 

Parameters

$obj
$class
$args

ArgCache()

ArgCache(  $args) 

Parameters

$args

ArgString()

ArgString(  $arg) : string

Convert an argument to a string for use in the parser cache

Parameters

$arg

Returns

string

Error()

Error(  $msg) 

Parameters

$msg

WinPath()

WinPath(  $path) 

Parameters

$path

CacheEnabled()

CacheEnabled() 

PreVisitors()

PreVisitors(  $root) 

Run pre-compile visitors

Parameters

$root

PostVisitors()

PostVisitors(  $evaldRoot) 

Run post-compile visitors

Parameters

$evaldRoot

_parse()

_parse(string  $file_path = null) 

Parameters

string $file_path

GetRules()

GetRules(string|null  $file_path) 

Return the results of parsePrimary for $file_path Use cache and save cached results if possible

Parameters

string|null $file_path

restore()

restore() 

forget()

forget() 

isWhitespace()

isWhitespace(  $offset) 

Parameters

$offset

match()

match(array  $toks) : array

Parse from a token, regexp or string, and move forward if match

Parameters

array $toks

Returns

array

MatchFuncs()

MatchFuncs(array<mixed,string>  $toks) : string

Parameters

array<mixed,string> $toks

Returns

string

MatchChar()

MatchChar(  $tok) 

Parameters

$tok

MatchReg()

MatchReg(  $tok) 

Parameters

$tok

parsePrimary()

parsePrimary() 

parseComment()

parseComment() 

parseComments()

parseComments() 

parseEntitiesQuoted()

parseEntitiesQuoted() 

parseEntitiesKeyword()

parseEntitiesKeyword() 

FromKeyword()

FromKeyword(  $keyword) 

Parameters

$keyword

parseEntitiesCall()

parseEntitiesCall() 

parseEntitiesArguments()

parseEntitiesArguments() : array

Parse a list of arguments

Returns

array

parseEntitiesLiteral()

parseEntitiesLiteral() 

parseEntitiesAssignment()

parseEntitiesAssignment() 

parseEntitiesUrl()

parseEntitiesUrl() 

parseEntitiesVariable()

parseEntitiesVariable() 

parseEntitiesVariableCurly()

parseEntitiesVariableCurly() 

parseEntitiesColor()

parseEntitiesColor() 

parseEntitiesDimension()

parseEntitiesDimension() 

parseEntitiesJavascript()

parseEntitiesJavascript() 

parseVariable()

parseVariable() 

parseRulesetCall()

parseRulesetCall() 

parseMixinCall()

parseMixinCall() 

parseMixinCallElements()

parseMixinCallElements() 

parseMixinArgs()

parseMixinArgs(boolean  $isCall) 

Parameters

boolean $isCall

parseMixinDefinition()

parseMixinDefinition() 

parseEntity()

parseEntity() 

parseEnd()

parseEnd() 

parseAlpha()

parseAlpha() 

parseElement()

parseElement() 

parseCombinator()

parseCombinator() 

parseLessSelector()

parseLessSelector() 

parseSelector()

parseSelector(  $isLess = false) 

Parameters

$isLess

parseTag()

parseTag() 

parseAttribute()

parseAttribute() 

parseBlock()

parseBlock() 

parseBlockRuleset()

parseBlockRuleset() 

parseDetachedRuleset()

parseDetachedRuleset() 

parseRuleset()

parseRuleset() 

parseNameValue()

parseNameValue() 

Custom less.php parse function for finding simple name-value css pairs ex: width:100px;

parseRule()

parseRule(  $tryAnonymous = null) 

Parameters

$tryAnonymous

parseImport()

parseImport() 

parseImportOptions()

parseImportOptions() 

parseImportOption()

parseImportOption() 

parseMediaFeature()

parseMediaFeature() 

parseMediaFeatures()

parseMediaFeatures() 

parseMedia()

parseMedia() 

parseDirective()

parseDirective() 

parseValue()

parseValue() 

parseImportant()

parseImportant() 

parseSub()

parseSub() 

parseAddition()

parseAddition() : \Less_Tree_Operation|null

Parses an addition operation

Returns

\Less_Tree_Operation|null

parseConditions()

parseConditions() : \Less_Tree_Condition|null

Parses the conditions

Returns

\Less_Tree_Condition|null

parseCondition()

parseCondition() 

parseOperand()

parseOperand() 

An operand is anything that can be part of an operation, such as a Color, or a Variable

parseExpression()

parseExpression() : \Less_Tree_Expression|null

Expressions either represent mathematical operations, or white-space delimited Entities.

1px solid black

Returns

\Less_Tree_Expression|null

parseProperty()

parseProperty() : string

Parse a property eg: 'min-width', 'orientation', etc

Returns

string

parseRuleProperty()

parseRuleProperty() : string

Parse a rule property eg: 'color', 'width', 'height', etc

Returns

string

rulePropertyMatch()

rulePropertyMatch(  $re,   $offset,   $length,   $index,   $name) 

Parameters

$re
$offset
$length
$index
$name