You are here

function PHPExcel_Writer_Excel5_Parser::_func in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php \PHPExcel_Writer_Excel5_Parser::_func()

* It parses a function call. It assumes the following rule: * Func -> ( Expr [,Expr]* ) * * @access private *

Return value

mixed The parsed ptg'd tree on success

1 call to PHPExcel_Writer_Excel5_Parser::_func()
PHPExcel_Writer_Excel5_Parser::_fact in vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php
* It parses a factor. It assumes the following rule: * Fact -> ( Expr ) * | CellRef * | CellRange * | Number * | Function * * @access private *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php, line 1458

Class

PHPExcel_Writer_Excel5_Parser
PHPExcel_Writer_Excel5_Parser

Code

function _func() {
  $num_args = 0;

  // number of arguments received
  $function = strtoupper($this->_current_token);
  $result = '';

  // initialize result
  $this
    ->_advance();
  $this
    ->_advance();

  // eat the "("
  while ($this->_current_token != ')') {

    /**/
    if ($num_args > 0) {
      if ($this->_current_token == "," or $this->_current_token == ";") {
        $this
          ->_advance();

        // eat the "," or ";"
      }
      else {
        throw new PHPExcel_Writer_Exception("Syntax error: comma expected in " . "function {$function}, arg #{$num_args}");
      }
      $result2 = $this
        ->_condition();
      $result = $this
        ->_createTree('arg', $result, $result2);
    }
    else {

      // first argument
      $result2 = $this
        ->_condition();
      $result = $this
        ->_createTree('arg', '', $result2);
    }
    ++$num_args;
  }
  if (!isset($this->_functions[$function])) {
    throw new PHPExcel_Writer_Exception("Function {$function}() doesn't exist");
  }
  $args = $this->_functions[$function][1];

  // If fixed number of args eg. TIME($i,$j,$k). Check that the number of args is valid.
  if ($args >= 0 and $args != $num_args) {
    throw new PHPExcel_Writer_Exception("Incorrect number of arguments in function {$function}() ");
  }
  $result = $this
    ->_createTree($function, $result, $num_args);
  $this
    ->_advance();

  // eat the ")"
  return $result;
}