\lessc
The less compiler and parser.
Converting LESS to CSS is a three stage process. The incoming file is parsed
by `lessc_parser` into a syntax tree, then it is compiled into another tree
representing the CSS structure by `lessc`. The CSS tree is fed into a
formatter, like `lessc_formatter` which then outputs CSS as a string.
During the first compile, all values are *reduced*, which means that their
types are brought to the lowest form before being dump as strings. This
handles math equations, variable dereferences, and the like.
The `parse` function of `lessc` is the entry point.
In summary:
The `lessc` class creates an intstance of the parser, feeds it LESS code,
then transforms the resulting tree to a CSS tree. This class also holds the
evaluation context, such as all available mixins and variables at any given
time.
The `lessc_parser` class is only concerned with parsing its input.
The `lessc_formatter` takes a CSS tree, and dumps it to a formatted string,
handling things like indentation.
Synopsis
- // members
- public static string $VERSION = "v0.3.8";
- protected static array $TRUE = ;
- protected static array $FALSE = ;
- protected array $libFunctions = ;
- protected array $registeredVars = ;
- protected boolean $preserveComments = false;
- public string $vPrefix = '@';
- public string $mPrefix = '$';
- public string $parentSelector = '&';
- public boolean $importDisabled = false;
- public string $importDir = '';
- protected $numberPrecision = NULL;
- protected $sourceParser = NULL;
- protected $sourceLoc = NULL;
- public static array $defaultValue = ;
- protected static integer $nextImportId = 0;
- protected static array $cssColors = ;
- // methods
- protected void findImport()
- protected void fileExists()
- public static void compressList()
- public static void preg_quote()
- protected void tryImport()
- protected void compileImportedProps()
- protected void compileBlock()
- protected void compileCSSBlock()
- protected void compileMedia()
- protected void mediaParent()
- protected void compileNestedBlock()
- protected void compileRoot()
- protected void compileProps()
- protected void sortProps()
- protected void compileMediaQuery()
- protected void multiplyMedia()
- protected void expandParentSelectors()
- protected void findClosestSelectors()
- protected void multiplySelectors()
- protected void compileSelectors()
- protected void eq()
- protected void patternMatch()
- protected void patternMatchAll()
- protected void findBlocks()
- protected void zipSetArgs()
- protected void compileProp()
- protected void compileValue()
- protected void lib_isnumber()
- protected void lib_isstring()
- protected void lib_iscolor()
- protected void lib_iskeyword()
- protected void lib_ispixel()
- protected void lib_ispercentage()
- protected void lib_isem()
- protected void lib_isrem()
- protected void lib_rgbahex()
- protected void lib_argb()
- protected void lib_e()
- protected void lib__sprintf()
- protected void lib_floor()
- protected void lib_ceil()
- protected void lib_round()
- protected void colorArgs()
- protected void lib_darken()
- protected void lib_lighten()
- protected void lib_saturate()
- protected void lib_desaturate()
- protected void lib_spin()
- protected void lib_fadeout()
- protected void lib_fadein()
- protected void lib_hue()
- protected void lib_saturation()
- protected void lib_lightness()
- protected void lib_alpha()
- protected void lib_fade()
- protected void lib_percentage()
- protected void lib_mix()
- protected void lib_contrast()
- protected void assertColor()
- protected void assertNumber()
- protected void toHSL()
- protected void toRGB_helper()
- protected void toRGB()
- protected void clamp()
- protected void funcToColor()
- protected void reduce()
- protected void coerceColor()
- protected void coerceString()
- protected void flattenList()
- protected void toBool()
- protected void evaluate()
- protected void stringConcatenate()
- protected void fixColor()
- protected void op_number_color()
- protected void op_color_number()
- protected void op_color_color()
- public void lib_red()
- public void lib_green()
- public void lib_blue()
- protected void op_number_number()
- protected void makeOutputBlock()
- protected void pushEnv()
- protected void popEnv()
- protected void set()
- protected void get()
- protected void injectVariables()
- public void __construct()
- public void compile()
- public void compileFile()
- public void checkedCompile()
- public array cachedCompile()
- public void parse()
- protected void makeParser()
- public void setFormatter()
- protected void newFormatter()
- public void setPreserveComments()
- public void registerFunction()
- public void unregisterFunction()
- public void setVariables()
- public void unsetVariable()
- public void setImportDir()
- public void addImportDir()
- public void allParsedFiles()
- protected void addParsedFile()
- protected void throwError()
- public static void ccompile()
- public static void cexecute()
Tasks
Line | Task |
---|---|
125 | need to mark the source parser these came from this file |
150 | this is because the importDir api is stupid |
Members
protected
- $FALSE
- $TRUE
- $cssColors
- $libFunctions
- $nextImportId
- $numberPrecision
- $preserveComments
- $registeredVars
- $sourceLoc
- $sourceParser
public
- $VERSION
- $defaultValue
- $importDir
- $importDisabled
- $mPrefix
- $parentSelector
- $vPrefix
Methods
protected
- addParsedFile()
- assertColor()
- assertNumber()
- clamp()
- coerceColor()
- coerceString()
- colorArgs() — Helper function to get arguments for color manipulation functions.
- compileBlock() — Recursively compiles a block.
- compileCSSBlock()
- compileImportedProps()
- compileMedia()
- compileMediaQuery()
- compileNestedBlock()
- compileProp()
- compileProps()
- compileRoot()
- compileSelectors()
- compileValue() — Compiles a primitive value into a CSS property value.
- eq()
- evaluate()
- expandParentSelectors()
- fileExists()
- findBlocks()
- findClosestSelectors()
- findImport()
- fixColor()
- flattenList()
- funcToColor() — Convert the rgb, rgba, hsl color literals of function type as returned by the parser into values of color type.
- get()
- injectVariables()
- lib__sprintf()
- lib_alpha()
- lib_argb()
- lib_ceil()
- lib_contrast()
- lib_darken()
- lib_desaturate()
- lib_e()
- lib_fade()
- lib_fadein()
- lib_fadeout()
- lib_floor()
- lib_hue()
- lib_iscolor()
- lib_isem()
- lib_iskeyword()
- lib_isnumber()
- lib_ispercentage()
- lib_ispixel()
- lib_isrem()
- lib_isstring()
- lib_lighten()
- lib_lightness()
- lib_mix()
- lib_percentage()
- lib_rgbahex()
- lib_round()
- lib_saturate()
- lib_saturation()
- lib_spin()
- makeOutputBlock()
- makeParser()
- mediaParent()
- multiplyMedia()
- multiplySelectors()
- newFormatter()
- op_color_color()
- op_color_number()
- op_number_color()
- op_number_number()
- patternMatch()
- patternMatchAll()
- popEnv()
- pushEnv()
- reduce()
- set()
- sortProps()
- stringConcatenate()
- throwError() — Uses the current value of $this->count to show line and line number
- toBool()
- toHSL()
- toRGB() — Converts a hsl array into a color value in rgb.
- toRGB_helper()
- tryImport()
- zipSetArgs()
public
- __construct() — Initialize any static state, can initialize parser for a file $opts isn't used yet
- addImportDir()
- allParsedFiles()
- cachedCompile() — Execute lessphp on a .less file or a lessphp cache structure
- ccompile()
- cexecute()
- checkedCompile()
- compile()
- compileFile()
- compressList()
- lib_blue()
- lib_green()
- lib_red()
- parse()
- preg_quote()
- registerFunction()
- setFormatter()
- setImportDir()
- setPreserveComments()
- setVariables()
- unregisterFunction()
- unsetVariable()