function PHPExcel_Writer_Excel5_Parser::_expression in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php \PHPExcel_Writer_Excel5_Parser::_expression()
* It parses a expression. It assumes the following rule: * Expr -> Term [("+" | "-") Term] * -> "string" * -> "-" Term : Negative value * -> "+" Term : Positive value * -> Error code * * @access private *
Return value
mixed The parsed ptg'd tree on success
2 calls to PHPExcel_Writer_Excel5_Parser::_expression()
- PHPExcel_Writer_Excel5_Parser::_condition in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Writer/ Excel5/ Parser.php - * It parses a condition. It assumes the following rule: * Cond -> Expr [(">" | "<") Expr] * * @access private *
- PHPExcel_Writer_Excel5_Parser::_parenthesizedExpression in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Writer/ Excel5/ Parser.php - * This function just introduces a ptgParen element in the tree, so that Excel * doesn't get confused when working with a parenthesized formula afterwards. * * @access private * *
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Writer/ Excel5/ Parser.php, line 1267
Class
- PHPExcel_Writer_Excel5_Parser
- PHPExcel_Writer_Excel5_Parser
Code
function _expression() {
// If it's a string return a string node
if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $this->_current_token)) {
$tmp = str_replace('""', '"', $this->_current_token);
if ($tmp == '"' || $tmp == '') {
$tmp = '""';
}
// Trap for "" that has been used for an empty string
$result = $this
->_createTree($tmp, '', '');
$this
->_advance();
return $result;
// If it's an error code
}
elseif (preg_match("/^#[A-Z0\\/]{3,5}[!?]{1}\$/", $this->_current_token) or $this->_current_token == '#N/A') {
$result = $this
->_createTree($this->_current_token, 'ptgErr', '');
$this
->_advance();
return $result;
// If it's a negative value
}
elseif ($this->_current_token == "-") {
// catch "-" Term
$this
->_advance();
$result2 = $this
->_expression();
$result = $this
->_createTree('ptgUminus', $result2, '');
return $result;
// If it's a positive value
}
elseif ($this->_current_token == "+") {
// catch "+" Term
$this
->_advance();
$result2 = $this
->_expression();
$result = $this
->_createTree('ptgUplus', $result2, '');
return $result;
}
$result = $this
->_term();
while ($this->_current_token == "+" or $this->_current_token == "-" or $this->_current_token == "^") {
/**/
if ($this->_current_token == "+") {
$this
->_advance();
$result2 = $this
->_term();
$result = $this
->_createTree('ptgAdd', $result, $result2);
}
elseif ($this->_current_token == "-") {
$this
->_advance();
$result2 = $this
->_term();
$result = $this
->_createTree('ptgSub', $result, $result2);
}
else {
$this
->_advance();
$result2 = $this
->_term();
$result = $this
->_createTree('ptgPower', $result, $result2);
}
}
return $result;
}