clearFusionCMS 3.0.0
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • clearFusionCMS
    • module
      • cloudflare
      • comments
      • content
      • forms
      • members
      • search
  • fusionLib
  • None

Classes

  • lessc
  • lessc_formatter_classic
  • lessc_formatter_compressed
  • lessc_formatter_lessjs
  • lessc_parser

Class lessc_parser

Located at system/app/lessphp/lessc.inc.php

Methods summary

public
# __construct( $lessc, $sourceName = null )
public
# parse( $buffer )
protected
# 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.

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.

protected
# isDirective( $dirname, $directives )
protected
# fixTags( $tags )
protected
# expressionList( & $exps )
protected
# expression( & $out )

Attempt to consume an expression.

Attempt to consume an expression.

Link

http://en.wikipedia.org/wiki/Operator-precedence_parser#Pseudo-code
protected
# expHelper( $lhs, $minP )

recursively parse infix equation with $lhs at precedence $minP

recursively parse infix equation with $lhs at precedence $minP

public
# propertyValue( & $value, $keyName = null )
protected
# parenValue( & $out )
protected
# value( & $value )
protected
# import( & $out )
protected
# mediaQueryList( & $out )
protected
# mediaQuery( & $out )
protected
# mediaExpression( & $out )
protected
# openString( $end, & $out, $nestingOpen = null, $rejectStrs = null )
protected
# string( & $out )
protected
# interpolation( & $out )
protected
# unit( & $unit )
protected
# color( & $out )
protected
# argumentDef( & $args, & $isVararg )
protected
# tags( & $tags, $simple = false, $delim = ',' )
protected
# mixinTags( & $tags )
protected
# tagBracket( & $parts, & $hasExpression )
protected
# tag( & $tag, $simple = false )
protected
# func( & $func )
protected
# variable( & $name )
protected
# assign( $name = null )

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

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

protected
# keyword( & $word )
protected
# end( )
protected
# guards( & $guards )
protected
# guardGroup( & $guardGroup )
protected
# guard( & $guard )
protected
# literal( $what, $eatWhitespace = null )
protected
# genericList( & $out, $parseItem, $delim = "", $flatten = true )
protected
# to( $what, & $out, $until = false, $allowNewline = false )
protected
# match( $regex, & $out, $eatWhitespace = null )
protected
# whitespace( )
protected
# peek( $regex, & $out = null, $from = null )
protected
# seek( $where = null )
public
# throwError( $msg = "parse error", $count = null )
protected
# pushBlock( $selectors = null, $type = null )
protected
# pushSpecialBlock( $type )
protected
# append( $prop, $pos = null )
protected
# pop( )
protected
# removeComments( $text )

Properties summary

protected static integer $nextBlockId
# 0
protected static array $precedence
# array( '=<' => 0, '>=' => 0, '=' => 0, '<' => 0, '>' => 0, '+' => 1, '-' => 1, '*' => 2, '/' => 2, '%' => 2, )
protected static $whitePattern
#
protected static $commentMulti
#
protected static string $commentSingle
# "//"
protected static string $commentMultiLeft
# "/*"
protected static string $commentMultiRight
# "*/"
protected static $operatorString
#
protected static array $supressDivisionProps
# array('/border-radius$/i', '/^font$/i')
protected array $blockDirectives
# array("font-face", "keyframes", "page", "-moz-document", "viewport", "-moz-viewport", "-o-viewport", "-ms-viewport")
protected array $lineDirectives
# array("charset")
protected boolean $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.

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

# false
protected static array $literalCache
# array()
clearFusionCMS 3.0.0 API documentation generated by ApiGen