You are here

function lessc::expHelper in Less CSS Preprocessor 6.3

Same name and namespace in other branches
  1. 6 lessc.inc.php \lessc::expHelper()
1 call to lessc::expHelper()
lessc::expression in lessphp/lessc.inc.php

File

lessphp/lessc.inc.php, line 300

Class

lessc

Code

function expHelper($lhs, $minP, $needWhite = true) {
  $ss = $this
    ->seek();

  // try to find a valid operator
  while ($this
    ->match(self::$operatorString . ($needWhite ? '\\s+' : ''), $m) && self::$precedence[$m[1]] >= $minP) {
    $needWhite = true;

    // get rhs
    $s = $this
      ->seek();
    if ($this
      ->literal('(') && $this
      ->expression($exp) && $this
      ->literal(')')) {
      $needWhite = false;
      $rhs = $exp;
    }
    elseif ($this
      ->seek($s) && $this
      ->value($val)) {
      $rhs = $val;
    }
    else {
      break;
    }

    // peek for next operator to see what to do with rhs
    if ($this
      ->peek(self::$operatorString, $next) && self::$precedence[$next[1]] > $minP) {
      $rhs = $this
        ->expHelper($rhs, self::$precedence[$next[1]]);
    }

    // don't evaluate yet if it is dynamic
    if (in_array($rhs[0], self::$dtypes) || in_array($lhs[0], self::$dtypes)) {
      $lhs = array(
        'expression',
        $m[1],
        $lhs,
        $rhs,
      );
    }
    else {
      $lhs = $this
        ->evaluate($m[1], $lhs, $rhs);
    }
    $ss = $this
      ->seek();
  }
  $this
    ->seek($ss);
  return $lhs;
}