ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PhpOffice\PhpSpreadsheet\Calculation\FormulaParser Class Reference

PARTLY BASED ON: Copyright (c) 2007 E. More...

+ Collaboration diagram for PhpOffice\PhpSpreadsheet\Calculation\FormulaParser:

Public Member Functions

 __construct ($pFormula='')
 Create a new FormulaParser. More...
 
 getFormula ()
 Get Formula. More...
 
 getToken (int $pId=0)
 Get Token. More...
 
 getTokenCount ()
 Get Token count. More...
 
 getTokens ()
 Get Tokens. More...
 

Data Fields

const QUOTE_DOUBLE = '"'
 
const QUOTE_SINGLE = '\''
 
const BRACKET_CLOSE = ']'
 
const BRACKET_OPEN = '['
 
const BRACE_OPEN = '{'
 
const BRACE_CLOSE = '}'
 
const PAREN_OPEN = '('
 
const PAREN_CLOSE = ')'
 
const SEMICOLON = ';'
 
const WHITESPACE = ' '
 
const COMMA = ','
 
const ERROR_START = '#'
 
const OPERATORS_SN = '+-'
 
const OPERATORS_INFIX = '+-*/^&=><'
 
const OPERATORS_POSTFIX = '%'
 

Private Member Functions

 parseToTokens ()
 Parse to tokens. More...
 

Private Attributes

 $formula
 
 $tokens = []
 

Detailed Description

PARTLY BASED ON: Copyright (c) 2007 E.

W. Bachtal, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

https://ewbi.blogs.com/develops/2007/03/excel_formula_p.html https://ewbi.blogs.com/develops/2004/12/excel_formula_p.html

Definition at line 27 of file FormulaParser.php.

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::__construct (   $pFormula = '')

Create a new FormulaParser.

Parameters
string$pFormulaFormula to parse

Definition at line 66 of file FormulaParser.php.

References PhpOffice\PhpSpreadsheet\Calculation\FormulaParser\parseToTokens().

67  {
68  // Check parameters
69  if ($pFormula === null) {
70  throw new Exception('Invalid parameter passed: formula');
71  }
72 
73  // Initialise values
74  $this->formula = trim($pFormula);
75  // Parse!
76  $this->parseToTokens();
77  }
+ Here is the call graph for this function:

Member Function Documentation

◆ getFormula()

PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::getFormula ( )

Get Formula.

Returns
string

Definition at line 84 of file FormulaParser.php.

References PhpOffice\PhpSpreadsheet\Calculation\FormulaParser\$formula.

◆ getToken()

PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::getToken ( int  $pId = 0)

Get Token.

Parameters
int$pIdToken id

Definition at line 94 of file FormulaParser.php.

94  : FormulaToken
95  {
96  if (isset($this->tokens[$pId])) {
97  return $this->tokens[$pId];
98  }
99 
100  throw new Exception("Token with id $pId does not exist.");
101  }

◆ getTokenCount()

PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::getTokenCount ( )

Get Token count.

Returns
int

Definition at line 108 of file FormulaParser.php.

109  {
110  return count($this->tokens);
111  }

◆ getTokens()

PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::getTokens ( )

◆ parseToTokens()

PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::parseToTokens ( )
private

Parse to tokens.

Definition at line 126 of file FormulaParser.php.

References $i, $index, PHPMailer\PHPMailer\$token, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_SUBTYPE_CONCATENATION, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_SUBTYPE_ERROR, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_SUBTYPE_INTERSECTION, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_SUBTYPE_LOGICAL, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_SUBTYPE_MATH, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_SUBTYPE_NOTHING, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_SUBTYPE_NUMBER, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_SUBTYPE_RANGE, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_SUBTYPE_START, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_SUBTYPE_STOP, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_SUBTYPE_TEXT, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_SUBTYPE_UNION, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_TYPE_ARGUMENT, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_TYPE_FUNCTION, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_TYPE_OPERAND, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_TYPE_OPERATORINFIX, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_TYPE_OPERATORPOSTFIX, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_TYPE_OPERATORPREFIX, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_TYPE_SUBEXPRESSION, PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_TYPE_UNKNOWN, and PhpOffice\PhpSpreadsheet\Calculation\FormulaToken\TOKEN_TYPE_WHITESPACE.

Referenced by PhpOffice\PhpSpreadsheet\Calculation\FormulaParser\__construct().

126  : void
127  {
128  // No attempt is made to verify formulas; assumes formulas are derived from Excel, where
129  // they can only exist if valid; stack overflows/underflows sunk as nulls without exceptions.
130 
131  // Check if the formula has a valid starting =
132  $formulaLength = strlen($this->formula);
133  if ($formulaLength < 2 || $this->formula[0] != '=') {
134  return;
135  }
136 
137  // Helper variables
138  $tokens1 = $tokens2 = $stack = [];
139  $inString = $inPath = $inRange = $inError = false;
140  $token = $previousToken = $nextToken = null;
141 
142  $index = 1;
143  $value = '';
144 
145  $ERRORS = ['#NULL!', '#DIV/0!', '#VALUE!', '#REF!', '#NAME?', '#NUM!', '#N/A'];
146  $COMPARATORS_MULTI = ['>=', '<=', '<>'];
147 
148  while ($index < $formulaLength) {
149  // state-dependent character evaluation (order is important)
150 
151  // double-quoted strings
152  // embeds are doubled
153  // end marks token
154  if ($inString) {
155  if ($this->formula[$index] == self::QUOTE_DOUBLE) {
156  if ((($index + 2) <= $formulaLength) && ($this->formula[$index + 1] == self::QUOTE_DOUBLE)) {
157  $value .= self::QUOTE_DOUBLE;
158  ++$index;
159  } else {
160  $inString = false;
161  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND, FormulaToken::TOKEN_SUBTYPE_TEXT);
162  $value = '';
163  }
164  } else {
165  $value .= $this->formula[$index];
166  }
167  ++$index;
168 
169  continue;
170  }
171 
172  // single-quoted strings (links)
173  // embeds are double
174  // end does not mark a token
175  if ($inPath) {
176  if ($this->formula[$index] == self::QUOTE_SINGLE) {
177  if ((($index + 2) <= $formulaLength) && ($this->formula[$index + 1] == self::QUOTE_SINGLE)) {
178  $value .= self::QUOTE_SINGLE;
179  ++$index;
180  } else {
181  $inPath = false;
182  }
183  } else {
184  $value .= $this->formula[$index];
185  }
186  ++$index;
187 
188  continue;
189  }
190 
191  // bracked strings (R1C1 range index or linked workbook name)
192  // no embeds (changed to "()" by Excel)
193  // end does not mark a token
194  if ($inRange) {
195  if ($this->formula[$index] == self::BRACKET_CLOSE) {
196  $inRange = false;
197  }
198  $value .= $this->formula[$index];
199  ++$index;
200 
201  continue;
202  }
203 
204  // error values
205  // end marks a token, determined from absolute list of values
206  if ($inError) {
207  $value .= $this->formula[$index];
208  ++$index;
209  if (in_array($value, $ERRORS)) {
210  $inError = false;
211  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND, FormulaToken::TOKEN_SUBTYPE_ERROR);
212  $value = '';
213  }
214 
215  continue;
216  }
217 
218  // scientific notation check
219  if (strpos(self::OPERATORS_SN, $this->formula[$index]) !== false) {
220  if (strlen($value) > 1) {
221  if (preg_match('/^[1-9]{1}(\\.\\d+)?E{1}$/', $this->formula[$index]) != 0) {
222  $value .= $this->formula[$index];
223  ++$index;
224 
225  continue;
226  }
227  }
228  }
229 
230  // independent character evaluation (order not important)
231 
232  // establish state-dependent character evaluations
233  if ($this->formula[$index] == self::QUOTE_DOUBLE) {
234  if (strlen($value) > 0) {
235  // unexpected
236  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN);
237  $value = '';
238  }
239  $inString = true;
240  ++$index;
241 
242  continue;
243  }
244 
245  if ($this->formula[$index] == self::QUOTE_SINGLE) {
246  if (strlen($value) > 0) {
247  // unexpected
248  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN);
249  $value = '';
250  }
251  $inPath = true;
252  ++$index;
253 
254  continue;
255  }
256 
257  if ($this->formula[$index] == self::BRACKET_OPEN) {
258  $inRange = true;
259  $value .= self::BRACKET_OPEN;
260  ++$index;
261 
262  continue;
263  }
264 
265  if ($this->formula[$index] == self::ERROR_START) {
266  if (strlen($value) > 0) {
267  // unexpected
268  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN);
269  $value = '';
270  }
271  $inError = true;
272  $value .= self::ERROR_START;
273  ++$index;
274 
275  continue;
276  }
277 
278  // mark start and end of arrays and array rows
279  if ($this->formula[$index] == self::BRACE_OPEN) {
280  if (strlen($value) > 0) {
281  // unexpected
282  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_UNKNOWN);
283  $value = '';
284  }
285 
286  $tmp = new FormulaToken('ARRAY', FormulaToken::TOKEN_TYPE_FUNCTION, FormulaToken::TOKEN_SUBTYPE_START);
287  $tokens1[] = $tmp;
288  $stack[] = clone $tmp;
289 
290  $tmp = new FormulaToken('ARRAYROW', FormulaToken::TOKEN_TYPE_FUNCTION, FormulaToken::TOKEN_SUBTYPE_START);
291  $tokens1[] = $tmp;
292  $stack[] = clone $tmp;
293 
294  ++$index;
295 
296  continue;
297  }
298 
299  if ($this->formula[$index] == self::SEMICOLON) {
300  if (strlen($value) > 0) {
301  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
302  $value = '';
303  }
304 
305  $tmp = array_pop($stack);
306  $tmp->setValue('');
307  $tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP);
308  $tokens1[] = $tmp;
309 
310  $tmp = new FormulaToken(',', FormulaToken::TOKEN_TYPE_ARGUMENT);
311  $tokens1[] = $tmp;
312 
313  $tmp = new FormulaToken('ARRAYROW', FormulaToken::TOKEN_TYPE_FUNCTION, FormulaToken::TOKEN_SUBTYPE_START);
314  $tokens1[] = $tmp;
315  $stack[] = clone $tmp;
316 
317  ++$index;
318 
319  continue;
320  }
321 
322  if ($this->formula[$index] == self::BRACE_CLOSE) {
323  if (strlen($value) > 0) {
324  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
325  $value = '';
326  }
327 
328  $tmp = array_pop($stack);
329  $tmp->setValue('');
330  $tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP);
331  $tokens1[] = $tmp;
332 
333  $tmp = array_pop($stack);
334  $tmp->setValue('');
335  $tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP);
336  $tokens1[] = $tmp;
337 
338  ++$index;
339 
340  continue;
341  }
342 
343  // trim white-space
344  if ($this->formula[$index] == self::WHITESPACE) {
345  if (strlen($value) > 0) {
346  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
347  $value = '';
348  }
349  $tokens1[] = new FormulaToken('', FormulaToken::TOKEN_TYPE_WHITESPACE);
350  ++$index;
351  while (($this->formula[$index] == self::WHITESPACE) && ($index < $formulaLength)) {
352  ++$index;
353  }
354 
355  continue;
356  }
357 
358  // multi-character comparators
359  if (($index + 2) <= $formulaLength) {
360  if (in_array(substr($this->formula, $index, 2), $COMPARATORS_MULTI)) {
361  if (strlen($value) > 0) {
362  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
363  $value = '';
364  }
365  $tokens1[] = new FormulaToken(substr($this->formula, $index, 2), FormulaToken::TOKEN_TYPE_OPERATORINFIX, FormulaToken::TOKEN_SUBTYPE_LOGICAL);
366  $index += 2;
367 
368  continue;
369  }
370  }
371 
372  // standard infix operators
373  if (strpos(self::OPERATORS_INFIX, $this->formula[$index]) !== false) {
374  if (strlen($value) > 0) {
375  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
376  $value = '';
377  }
378  $tokens1[] = new FormulaToken($this->formula[$index], FormulaToken::TOKEN_TYPE_OPERATORINFIX);
379  ++$index;
380 
381  continue;
382  }
383 
384  // standard postfix operators (only one)
385  if (strpos(self::OPERATORS_POSTFIX, $this->formula[$index]) !== false) {
386  if (strlen($value) > 0) {
387  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
388  $value = '';
389  }
390  $tokens1[] = new FormulaToken($this->formula[$index], FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
391  ++$index;
392 
393  continue;
394  }
395 
396  // start subexpression or function
397  if ($this->formula[$index] == self::PAREN_OPEN) {
398  if (strlen($value) > 0) {
400  $tokens1[] = $tmp;
401  $stack[] = clone $tmp;
402  $value = '';
403  } else {
405  $tokens1[] = $tmp;
406  $stack[] = clone $tmp;
407  }
408  ++$index;
409 
410  continue;
411  }
412 
413  // function, subexpression, or array parameters, or operand unions
414  if ($this->formula[$index] == self::COMMA) {
415  if (strlen($value) > 0) {
416  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
417  $value = '';
418  }
419 
420  $tmp = array_pop($stack);
421  $tmp->setValue('');
422  $tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP);
423  $stack[] = $tmp;
424 
425  if ($tmp->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) {
427  } else {
428  $tokens1[] = new FormulaToken(',', FormulaToken::TOKEN_TYPE_ARGUMENT);
429  }
430  ++$index;
431 
432  continue;
433  }
434 
435  // stop subexpression
436  if ($this->formula[$index] == self::PAREN_CLOSE) {
437  if (strlen($value) > 0) {
438  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
439  $value = '';
440  }
441 
442  $tmp = array_pop($stack);
443  $tmp->setValue('');
444  $tmp->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_STOP);
445  $tokens1[] = $tmp;
446 
447  ++$index;
448 
449  continue;
450  }
451 
452  // token accumulation
453  $value .= $this->formula[$index];
454  ++$index;
455  }
456 
457  // dump remaining accumulation
458  if (strlen($value) > 0) {
459  $tokens1[] = new FormulaToken($value, FormulaToken::TOKEN_TYPE_OPERAND);
460  }
461 
462  // move tokenList to new set, excluding unnecessary white-space tokens and converting necessary ones to intersections
463  $tokenCount = count($tokens1);
464  for ($i = 0; $i < $tokenCount; ++$i) {
465  $token = $tokens1[$i];
466  if (isset($tokens1[$i - 1])) {
467  $previousToken = $tokens1[$i - 1];
468  } else {
469  $previousToken = null;
470  }
471  if (isset($tokens1[$i + 1])) {
472  $nextToken = $tokens1[$i + 1];
473  } else {
474  $nextToken = null;
475  }
476 
477  if ($token === null) {
478  continue;
479  }
480 
481  if ($token->getTokenType() != FormulaToken::TOKEN_TYPE_WHITESPACE) {
482  $tokens2[] = $token;
483 
484  continue;
485  }
486 
487  if ($previousToken === null) {
488  continue;
489  }
490 
491  if (
492  !(
493  (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
494  (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
495  ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)
496  )
497  ) {
498  continue;
499  }
500 
501  if ($nextToken === null) {
502  continue;
503  }
504 
505  if (
506  !(
507  (($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && ($nextToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_START)) ||
508  (($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($nextToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_START)) ||
509  ($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)
510  )
511  ) {
512  continue;
513  }
514 
516  }
517 
518  // move tokens to final list, switching infix "-" operators to prefix when appropriate, switching infix "+" operators
519  // to noop when appropriate, identifying operand and infix-operator subtypes, and pulling "@" from function names
520  $this->tokens = [];
521 
522  $tokenCount = count($tokens2);
523  for ($i = 0; $i < $tokenCount; ++$i) {
524  $token = $tokens2[$i];
525  if (isset($tokens2[$i - 1])) {
526  $previousToken = $tokens2[$i - 1];
527  } else {
528  $previousToken = null;
529  }
530  if (isset($tokens2[$i + 1])) {
531  $nextToken = $tokens2[$i + 1];
532  } else {
533  $nextToken = null;
534  }
535 
536  if ($token === null) {
537  continue;
538  }
539 
540  if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '-') {
541  if ($i == 0) {
543  } elseif (
544  (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) &&
545  ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
546  (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
547  ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
548  ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
549  ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)
550  ) {
551  $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_MATH);
552  } else {
554  }
555 
556  $this->tokens[] = $token;
557 
558  continue;
559  }
560 
561  if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '+') {
562  if ($i == 0) {
563  continue;
564  } elseif (
565  (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) &&
566  ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
567  (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
568  ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
569  ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
570  ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)
571  ) {
572  $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_MATH);
573  } else {
574  continue;
575  }
576 
577  $this->tokens[] = $token;
578 
579  continue;
580  }
581 
582  if (
583  $token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX &&
584  $token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING
585  ) {
586  if (strpos('<>=', substr($token->getValue(), 0, 1)) !== false) {
588  } elseif ($token->getValue() == '&') {
590  } else {
591  $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_MATH);
592  }
593 
594  $this->tokens[] = $token;
595 
596  continue;
597  }
598 
599  if (
600  $token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND &&
601  $token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING
602  ) {
603  if (!is_numeric($token->getValue())) {
604  if (strtoupper($token->getValue()) == 'TRUE' || strtoupper($token->getValue()) == 'FALSE') {
606  } else {
607  $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_RANGE);
608  }
609  } else {
610  $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_NUMBER);
611  }
612 
613  $this->tokens[] = $token;
614 
615  continue;
616  }
617 
618  if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) {
619  if (strlen($token->getValue()) > 0) {
620  if (substr($token->getValue(), 0, 1) == '@') {
621  $token->setValue(substr($token->getValue(), 1));
622  }
623  }
624  }
625 
626  $this->tokens[] = $token;
627  }
628  }
$index
Definition: metadata.php:60
$i
Definition: disco.tpl.php:19
+ Here is the caller graph for this function:

Field Documentation

◆ $formula

PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::$formula
private

◆ $tokens

PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::$tokens = []
private

◆ BRACE_CLOSE

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::BRACE_CLOSE = '}'

Definition at line 35 of file FormulaParser.php.

◆ BRACE_OPEN

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::BRACE_OPEN = '{'

Definition at line 34 of file FormulaParser.php.

◆ BRACKET_CLOSE

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::BRACKET_CLOSE = ']'

Definition at line 32 of file FormulaParser.php.

◆ BRACKET_OPEN

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::BRACKET_OPEN = '['

Definition at line 33 of file FormulaParser.php.

◆ COMMA

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::COMMA = ','

Definition at line 40 of file FormulaParser.php.

◆ ERROR_START

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::ERROR_START = '#'

Definition at line 41 of file FormulaParser.php.

◆ OPERATORS_INFIX

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::OPERATORS_INFIX = '+-*/^&=><'

Definition at line 44 of file FormulaParser.php.

◆ OPERATORS_POSTFIX

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::OPERATORS_POSTFIX = '%'

Definition at line 45 of file FormulaParser.php.

◆ OPERATORS_SN

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::OPERATORS_SN = '+-'

Definition at line 43 of file FormulaParser.php.

◆ PAREN_CLOSE

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::PAREN_CLOSE = ')'

Definition at line 37 of file FormulaParser.php.

◆ PAREN_OPEN

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::PAREN_OPEN = '('

Definition at line 36 of file FormulaParser.php.

◆ QUOTE_DOUBLE

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::QUOTE_DOUBLE = '"'

Definition at line 30 of file FormulaParser.php.

◆ QUOTE_SINGLE

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::QUOTE_SINGLE = '\''

Definition at line 31 of file FormulaParser.php.

◆ SEMICOLON

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::SEMICOLON = ';'

Definition at line 38 of file FormulaParser.php.

◆ WHITESPACE

const PhpOffice\PhpSpreadsheet\Calculation\FormulaParser::WHITESPACE = ' '

Definition at line 39 of file FormulaParser.php.


The documentation for this class was generated from the following file: