MediaWiki  1.23.8
lessc_parser Class Reference

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. More...
 
 color (&$out)
 
 end ()
 
 expHelper ($lhs, $minP)
 recursively parse infix equation with $lhs at precedence $minP More...
 
 expression (&$out)
 Attempt to consume an expression. More...
 
 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. More...
 
 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. More...
 
 $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 2300 of file lessc.inc.php.

Member Function Documentation

◆ __construct()

lessc_parser::__construct (   $lessc,
  $sourceName = null 
)

◆ append()

lessc_parser::append (   $prop,
  $pos = null 
)
protected

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

Referenced by parseChunk(), and whitespace().

◆ argumentDef()

lessc_parser::argumentDef ( $args,
$isVararg 
)
protected

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

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

Referenced by parseChunk().

◆ assign()

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 3370 of file lessc.inc.php.

References $name, and literal().

Referenced by argumentDef(), and parseChunk().

◆ color()

lessc_parser::color ( $out)
protected

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

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

Referenced by value().

◆ end()

lessc_parser::end ( )
protected

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

References literal().

Referenced by openString(), and parseChunk().

◆ expHelper()

lessc_parser::expHelper (   $lhs,
  $minP 
)
protected

recursively parse infix equation with $lhs at precedence $minP

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

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

Referenced by expression().

◆ expression()

lessc_parser::expression ( $out)
protected

◆ expressionList()

lessc_parser::expressionList ( $exps)
protected

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

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

Referenced by func(), and propertyValue().

◆ fixTags()

lessc_parser::fixTags (   $tags)
protected

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

References as.

Referenced by parseChunk().

◆ func()

lessc_parser::func ( $func)
protected

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

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

Referenced by value().

◆ genericList()

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

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

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

Referenced by mediaQuery(), and mediaQueryList().

◆ guard()

lessc_parser::guard ( $guard)
protected

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

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

Referenced by guardGroup().

◆ guardGroup()

lessc_parser::guardGroup ( $guardGroup)
protected

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

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

Referenced by guards().

◆ guards()

lessc_parser::guards ( $guards)
protected

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

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

Referenced by parseChunk().

◆ import()

lessc_parser::import ( $out)
protected

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

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

◆ interpolation()

lessc_parser::interpolation ( $out)
protected

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

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

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

◆ isDirective()

lessc_parser::isDirective (   $dirname,
  $directives 
)
protected

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

References array().

Referenced by parseChunk().

◆ keyword()

lessc_parser::keyword ( $word)
protected

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

References match().

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

◆ literal()

lessc_parser::literal (   $what,
  $eatWhitespace = null 
)
protected

◆ match()

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

Definition at line 3518 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().

◆ mediaExpression()

lessc_parser::mediaExpression ( $out)
protected

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

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

◆ mediaQuery()

lessc_parser::mediaQuery ( $out)
protected

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

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

◆ mediaQueryList()

lessc_parser::mediaQueryList ( $out)
protected

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

References $out, and genericList().

Referenced by parseChunk().

◆ mixinTags()

lessc_parser::mixinTags ( $tags)
protected

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

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

Referenced by parseChunk().

◆ openString()

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

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

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

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

◆ parenValue()

lessc_parser::parenValue ( $out)
protected

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

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

Referenced by value().

◆ parse()

lessc_parser::parse (   $buffer)

◆ parseChunk()

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 2437 of file lessc.inc.php.

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

Referenced by parse().

◆ peek()

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

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

References $count, $from, and $out.

Referenced by expHelper(), and throwError().

◆ pop()

lessc_parser::pop ( )
protected

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

Referenced by parseChunk().

◆ propertyValue()

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

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

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

Referenced by import(), and parseChunk().

◆ pushBlock()

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

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

References $type, and array().

Referenced by parseChunk(), and pushSpecialBlock().

◆ pushSpecialBlock()

lessc_parser::pushSpecialBlock (   $type)
protected

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

References $type, and pushBlock().

Referenced by parse(), and parseChunk().

◆ removeComments()

lessc_parser::removeComments (   $text)
protected

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

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

Referenced by parse().

◆ seek()

◆ string()

lessc_parser::string ( $out)
protected

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

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

◆ tag()

lessc_parser::tag ( $tag,
  $simple = false 
)
protected

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

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

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

◆ tagBracket()

lessc_parser::tagBracket ( $parts,
$hasExpression 
)
protected

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

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

Referenced by tag().

◆ tags()

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

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

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

Referenced by parseChunk().

◆ throwError()

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

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

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

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

◆ to()

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

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

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

◆ unit()

lessc_parser::unit ( $unit)
protected

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

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

Referenced by tag(), and value().

◆ value()

lessc_parser::value ( $value)
protected

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

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

Referenced by expHelper(), and expression().

◆ variable()

lessc_parser::variable ( $name)
protected

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

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

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

◆ whitespace()

lessc_parser::whitespace ( )
protected

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

References $count, append(), array(), and match().

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

Member Data Documentation

◆ $blockDirectives

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

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

◆ $commentMulti

lessc_parser::$commentMulti
staticprotected

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

◆ $commentMultiLeft

lessc_parser::$commentMultiLeft = "/*"
staticprotected

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

Referenced by __construct().

◆ $commentMultiRight

lessc_parser::$commentMultiRight = "*/"
staticprotected

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

Referenced by __construct().

◆ $commentSingle

lessc_parser::$commentSingle = "//"
staticprotected

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

Referenced by __construct().

◆ $inParens

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 2343 of file lessc.inc.php.

Referenced by expHelper(), and parenValue().

◆ $lineDirectives

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

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

◆ $literalCache

lessc_parser::$literalCache = array()
staticprotected

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

◆ $nextBlockId

lessc_parser::$nextBlockId = 0
staticprotected

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

◆ $operatorString

lessc_parser::$operatorString
staticprotected

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

◆ $precedence

lessc_parser::$precedence
staticprotected
Initial value:
'=<' => 0,
'>=' => 0,
'=' => 0,
'<' => 0,
'>' => 0,
'+' => 1,
'-' => 1,
'*' => 2,
'/' => 2,
'%' => 2,
)

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

◆ $supressDivisionProps

lessc_parser::$supressDivisionProps
staticprotected
Initial value:
=
array('/border-radius$/i', '/^font$/i')

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

◆ $whitePattern

lessc_parser::$whitePattern
staticprotected

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


The documentation for this class was generated from the following file:
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.