MediaWiki  REL1_22
lessc_parser Class Reference

List of all members.

Public Member Functions

 __construct ($lessc, $sourceName=null)
 parse ($buffer)
 propertyValue (&$value, $keyName=null)
 throwError ($msg="parse error", $count=null)

Protected Member Functions

 append ($prop, $pos=null)
 argumentDef (&$args, &$isVararg)
 assign ($name=null)
 Consume an assignment operator Can optionally take a name that will be set to the current property name.
 color (&$out)
 end ()
 expHelper ($lhs, $minP)
 recursively parse infix equation with $lhs at precedence $minP
 expression (&$out)
 Attempt to consume an expression.
 expressionList (&$exps)
 fixTags ($tags)
 func (&$func)
 genericList (&$out, $parseItem, $delim="", $flatten=true)
 guard (&$guard)
 guardGroup (&$guardGroup)
 guards (&$guards)
 import (&$out)
 interpolation (&$out)
 isDirective ($dirname, $directives)
 keyword (&$word)
 literal ($what, $eatWhitespace=null)
 match ($regex, &$out, $eatWhitespace=null)
 mediaExpression (&$out)
 mediaQuery (&$out)
 mediaQueryList (&$out)
 mixinTags (&$tags)
 openString ($end, &$out, $nestingOpen=null, $rejectStrs=null)
 parenValue (&$out)
 parseChunk ()
 Parse a single chunk off the head of the buffer and append it to the current parse environment.
 peek ($regex, &$out=null, $from=null)
 pop ()
 pushBlock ($selectors=null, $type=null)
 pushSpecialBlock ($type)
 removeComments ($text)
 seek ($where=null)
 string (&$out)
 tag (&$tag, $simple=false)
 tagBracket (&$parts, &$hasExpression)
 tags (&$tags, $simple=false, $delim= ',')
 to ($what, &$out, $until=false, $allowNewline=false)
 unit (&$unit)
 value (&$value)
 variable (&$name)
 whitespace ()

Protected Attributes

 $blockDirectives = array("font-face", "keyframes", "page", "-moz-document", "viewport", "-moz-viewport", "-o-viewport", "-ms-viewport")
 $inParens = false
 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.
 $lineDirectives = array("charset")

Static Protected Attributes

static $commentMulti
static $commentMultiLeft = "/*"
static $commentMultiRight = "*/"
static $commentSingle = "//"
static $literalCache = array()
static $nextBlockId = 0
static $operatorString
static $precedence
static $supressDivisionProps
static $whitePattern

Detailed Description

Definition at line 2246 of file lessc.inc.php.


Constructor & Destructor Documentation

lessc_parser::__construct ( lessc,
sourceName = null 
)

Member Function Documentation

lessc_parser::append ( prop,
pos = null 
) [protected]

Definition at line 3556 of file lessc.inc.php.

Referenced by parseChunk(), and whitespace().

lessc_parser::argumentDef ( &$  args,
&$  isVararg 
) [protected]

Definition at line 2991 of file lessc.inc.php.

References $s, $value, array(), as, assign(), literal(), seek(), and throwError().

Referenced by parseChunk().

lessc_parser::assign ( name = null) [protected]

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

Definition at line 3316 of file lessc.inc.php.

References $name, and literal().

Referenced by argumentDef(), and parseChunk().

lessc_parser::color ( &$  out) [protected]

Definition at line 2973 of file lessc.inc.php.

References $out, array(), and match().

Referenced by value().

lessc_parser::end ( ) [protected]

Definition at line 3331 of file lessc.inc.php.

References literal().

Referenced by openString(), and parseChunk().

lessc_parser::expHelper ( lhs,
minP 
) [protected]

recursively parse infix equation with $lhs at precedence $minP

Definition at line 2595 of file lessc.inc.php.

References array(), as, empty, match(), peek(), seek(), and value().

Referenced by expression().

lessc_parser::expression ( &$  out) [protected]
lessc_parser::expressionList ( &$  exps) [protected]

Definition at line 2554 of file lessc.inc.php.

References array(), lessc\compressList(), and expression().

Referenced by func(), and propertyValue().

lessc_parser::fixTags ( tags) [protected]

Definition at line 2544 of file lessc.inc.php.

References as.

Referenced by parseChunk().

lessc_parser::func ( &$  func) [protected]

Definition at line 3251 of file lessc.inc.php.

References $fname, $name, $s, $value, array(), expressionList(), keyword(), literal(), match(), openString(), and seek().

Referenced by value().

lessc_parser::genericList ( &$  out,
parseItem,
delim = "",
flatten = true 
) [protected]

Definition at line 3423 of file lessc.inc.php.

References $out, $s, $value, array(), literal(), and seek().

Referenced by mediaQuery(), and mediaQueryList().

lessc_parser::guard ( &$  guard) [protected]

Definition at line 3384 of file lessc.inc.php.

References $s, array(), expression(), literal(), and seek().

Referenced by guardGroup().

lessc_parser::guardGroup ( &$  guardGroup) [protected]

Definition at line 3367 of file lessc.inc.php.

References $s, array(), guard(), literal(), and seek().

Referenced by guards().

lessc_parser::guards ( &$  guards) [protected]

Definition at line 3341 of file lessc.inc.php.

References $s, array(), guardGroup(), literal(), and seek().

Referenced by parseChunk().

lessc_parser::import ( &$  out) [protected]

Definition at line 2745 of file lessc.inc.php.

References $out, $value, array(), literal(), and propertyValue().

lessc_parser::interpolation ( &$  out) [protected]

Definition at line 2938 of file lessc.inc.php.

References $out, $s, array(), literal(), openString(), seek(), and whitespace().

Referenced by openString(), string(), tag(), and tagBracket().

lessc_parser::isDirective ( dirname,
directives 
) [protected]

Definition at line 2535 of file lessc.inc.php.

References array().

Referenced by parseChunk().

lessc_parser::keyword ( &$  word) [protected]

Definition at line 3322 of file lessc.inc.php.

References match().

Referenced by func(), mediaExpression(), mediaQuery(), parseChunk(), tagBracket(), value(), and variable().

lessc_parser::match ( regex,
&$  out,
eatWhitespace = null 
) [protected]

Definition at line 3464 of file lessc.inc.php.

References $out, and whitespace().

Referenced by color(), expHelper(), func(), keyword(), literal(), openString(), string(), tag(), tagBracket(), to(), unit(), value(), and whitespace().

lessc_parser::mediaExpression ( &$  out) [protected]

Definition at line 2799 of file lessc.inc.php.

References $out, $s, $value, array(), expression(), keyword(), literal(), seek(), and variable().

lessc_parser::mediaQuery ( &$  out) [protected]

Definition at line 2766 of file lessc.inc.php.

References $out, $s, array(), empty, genericList(), keyword(), literal(), and seek().

lessc_parser::mediaQueryList ( &$  out) [protected]

Definition at line 2758 of file lessc.inc.php.

References $out, and genericList().

Referenced by parseChunk().

lessc_parser::mixinTags ( &$  tags) [protected]

Definition at line 3104 of file lessc.inc.php.

References array(), literal(), and tag().

Referenced by parseChunk().

lessc_parser::openString ( end,
&$  out,
nestingOpen = null,
rejectStrs = null 
) [protected]

Definition at line 2820 of file lessc.inc.php.

References $out, array(), empty, end(), interpolation(), and match().

Referenced by func(), interpolation(), and parseChunk().

lessc_parser::parenValue ( &$  out) [protected]

Definition at line 2665 of file lessc.inc.php.

References $inParens, $out, $s, expression(), literal(), and seek().

Referenced by value().

lessc_parser::parseChunk ( ) [protected]

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.

Definition at line 2383 of file lessc.inc.php.

References $dir, $key, $s, $value, append(), argumentDef(), array(), as, assign(), empty, end(), fixTags(), guards(), isDirective(), keyword(), literal(), mediaQueryList(), mixinTags(), openString(), pop(), propertyValue(), pushBlock(), pushSpecialBlock(), seek(), tag(), tags(), throwError(), variable(), and whitespace().

Referenced by parse().

lessc_parser::peek ( regex,
&$  out = null,
from = null 
) [protected]

Definition at line 3496 of file lessc.inc.php.

References $out, and $result.

Referenced by expHelper(), and throwError().

lessc_parser::pop ( ) [protected]

Definition at line 3562 of file lessc.inc.php.

Referenced by parseChunk().

lessc_parser::propertyValue ( &$  value,
keyName = null 
)

Definition at line 2643 of file lessc.inc.php.

References $s, $value, array(), lessc\compressList(), expressionList(), literal(), and seek().

Referenced by import(), and parseChunk().

lessc_parser::pushBlock ( selectors = null,
type = null 
) [protected]

Definition at line 3533 of file lessc.inc.php.

References array().

Referenced by parseChunk(), and pushSpecialBlock().

lessc_parser::pushSpecialBlock ( type) [protected]

Definition at line 3551 of file lessc.inc.php.

References pushBlock().

Referenced by parse(), and parseChunk().

lessc_parser::removeComments ( text) [protected]

Definition at line 3570 of file lessc.inc.php.

References $count, $out, array(), and as.

Referenced by parse().

lessc_parser::string ( &$  out) [protected]

Definition at line 2887 of file lessc.inc.php.

References $out, $s, array(), interpolation(), literal(), match(), lessc\preg_quote(), and seek().

lessc_parser::tag ( &$  tag,
simple = false 
) [protected]

Definition at line 3187 of file lessc.inc.php.

References $s, array(), interpolation(), literal(), match(), seek(), tagBracket(), unit(), and whitespace().

Referenced by mixinTags(), parseChunk(), and tags().

lessc_parser::tagBracket ( &$  parts,
&$  hasExpression 
) [protected]

Definition at line 3117 of file lessc.inc.php.

References $s, array(), as, interpolation(), keyword(), literal(), match(), and seek().

Referenced by tag().

lessc_parser::tags ( &$  tags,
simple = false,
delim = ',' 
) [protected]

Definition at line 3091 of file lessc.inc.php.

References array(), literal(), and tag().

Referenced by parseChunk().

lessc_parser::throwError ( msg = "parse error",
count = null 
)

Definition at line 3513 of file lessc.inc.php.

References $count, empty, line, and peek().

Referenced by argumentDef(), parse(), and parseChunk().

lessc_parser::to ( what,
&$  out,
until = false,
allowNewline = false 
) [protected]

Definition at line 3451 of file lessc.inc.php.

References $out, match(), and lessc\preg_quote().

lessc_parser::unit ( &$  unit) [protected]

Definition at line 2958 of file lessc.inc.php.

References array(), empty, and match().

Referenced by tag(), and value().

lessc_parser::value ( &$  value) [protected]

Definition at line 2690 of file lessc.inc.php.

References $s, $value, array(), color(), func(), keyword(), literal(), match(), parenValue(), seek(), unit(), and variable().

Referenced by expHelper(), and expression().

lessc_parser::variable ( &$  name) [protected]

Definition at line 3294 of file lessc.inc.php.

References $name, $s, array(), empty, keyword(), literal(), and seek().

Referenced by mediaExpression(), parseChunk(), and value().

lessc_parser::whitespace ( ) [protected]

Definition at line 3477 of file lessc.inc.php.

References append(), array(), empty, and match().

Referenced by interpolation(), match(), parse(), parseChunk(), and tag().


Member Data Documentation

lessc_parser::$blockDirectives = array("font-face", "keyframes", "page", "-moz-document", "viewport", "-moz-viewport", "-o-viewport", "-ms-viewport") [protected]

Definition at line 2277 of file lessc.inc.php.

lessc_parser::$commentMulti [static, protected]

Definition at line 2264 of file lessc.inc.php.

lessc_parser::$commentMultiLeft = "/*" [static, protected]

Definition at line 2267 of file lessc.inc.php.

Referenced by __construct().

lessc_parser::$commentMultiRight = "*/" [static, protected]

Definition at line 2268 of file lessc.inc.php.

Referenced by __construct().

lessc_parser::$commentSingle = "//" [static, protected]

Definition at line 2266 of file lessc.inc.php.

Referenced by __construct().

lessc_parser::$inParens = false [protected]

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

Definition at line 2289 of file lessc.inc.php.

Referenced by parenValue().

lessc_parser::$lineDirectives = array("charset") [protected]

Definition at line 2278 of file lessc.inc.php.

lessc_parser::$literalCache = array() [static, protected]

Definition at line 2292 of file lessc.inc.php.

lessc_parser::$nextBlockId = 0 [static, protected]

Definition at line 2247 of file lessc.inc.php.

lessc_parser::$operatorString [static, protected]

Definition at line 2271 of file lessc.inc.php.

lessc_parser::$precedence [static, protected]
Initial value:
 array(
        '=<' => 0,
        '>=' => 0,
        '=' => 0,
        '<' => 0,
        '>' => 0,

        '+' => 1,
        '-' => 1,
        '*' => 2,
        '/' => 2,
        '%' => 2,
    )

Definition at line 2249 of file lessc.inc.php.

lessc_parser::$supressDivisionProps [static, protected]
Initial value:
        array('/border-radius$/i', '/^font$/i')

Definition at line 2274 of file lessc.inc.php.

lessc_parser::$whitePattern [static, protected]

Definition at line 2263 of file lessc.inc.php.


The documentation for this class was generated from the following file: