| 1 |
<?php |
| 2 |
|
| 3 |
namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation; |
| 4 |
|
| 5 |
/** |
| 6 |
* PARTLY BASED ON: |
| 7 |
* Copyright (c) 2007 E. W. Bachtal, Inc. |
| 8 |
* |
| 9 |
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
| 10 |
* and associated documentation files (the "Software"), to deal in the Software without restriction, |
| 11 |
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 12 |
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, |
| 13 |
* subject to the following conditions: |
| 14 |
* |
| 15 |
* The above copyright notice and this permission notice shall be included in all copies or substantial |
| 16 |
* portions of the Software. |
| 17 |
* |
| 18 |
* The software is provided "as is", without warranty of any kind, express or implied, including but not |
| 19 |
* limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In |
| 20 |
* no event shall the authors or copyright holders be liable for any claim, damages or other liability, |
| 21 |
* whether in an action of contract, tort or otherwise, arising from, out of or in connection with the |
| 22 |
* software or the use or other dealings in the software. |
| 23 |
* |
| 24 |
* The following links are no longer valid. |
| 25 |
* https://ewbi.blogs.com/develops/2007/03/excel_formula_p.html |
| 26 |
* https://ewbi.blogs.com/develops/2004/12/excel_formula_p.html |
| 27 |
* |
| 28 |
* @deprecated 5.5.0 No replacement. |
| 29 |
*/ |
| 30 |
class FormulaToken |
| 31 |
{ |
| 32 |
// Token types |
| 33 |
const TOKEN_TYPE_NOOP = 'Noop'; |
| 34 |
const TOKEN_TYPE_OPERAND = 'Operand'; |
| 35 |
const TOKEN_TYPE_FUNCTION = 'Function'; |
| 36 |
const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression'; |
| 37 |
const TOKEN_TYPE_ARGUMENT = 'Argument'; |
| 38 |
const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix'; |
| 39 |
const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix'; |
| 40 |
const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix'; |
| 41 |
const TOKEN_TYPE_WHITESPACE = 'Whitespace'; |
| 42 |
const TOKEN_TYPE_UNKNOWN = 'Unknown'; |
| 43 |
|
| 44 |
// Token subtypes |
| 45 |
const TOKEN_SUBTYPE_NOTHING = 'Nothing'; |
| 46 |
const TOKEN_SUBTYPE_START = 'Start'; |
| 47 |
const TOKEN_SUBTYPE_STOP = 'Stop'; |
| 48 |
const TOKEN_SUBTYPE_TEXT = 'Text'; |
| 49 |
const TOKEN_SUBTYPE_NUMBER = 'Number'; |
| 50 |
const TOKEN_SUBTYPE_LOGICAL = 'Logical'; |
| 51 |
const TOKEN_SUBTYPE_ERROR = 'Error'; |
| 52 |
const TOKEN_SUBTYPE_RANGE = 'Range'; |
| 53 |
const TOKEN_SUBTYPE_MATH = 'Math'; |
| 54 |
const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation'; |
| 55 |
const TOKEN_SUBTYPE_INTERSECTION = 'Intersection'; |
| 56 |
const TOKEN_SUBTYPE_UNION = 'Union'; |
| 57 |
|
| 58 |
/** |
| 59 |
* Value. |
| 60 |
*/ |
| 61 |
private string $value; |
| 62 |
|
| 63 |
/** |
| 64 |
* Token Type (represented by TOKEN_TYPE_*). |
| 65 |
*/ |
| 66 |
private string $tokenType; |
| 67 |
|
| 68 |
/** |
| 69 |
* Token SubType (represented by TOKEN_SUBTYPE_*). |
| 70 |
*/ |
| 71 |
private string $tokenSubType; |
| 72 |
|
| 73 |
/** |
| 74 |
* Create a new FormulaToken. |
| 75 |
* |
| 76 |
* @param string $tokenType Token type (represented by TOKEN_TYPE_*) |
| 77 |
* @param string $tokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*) |
| 78 |
*/ |
| 79 |
public function __construct(string $value, string $tokenType = self::TOKEN_TYPE_UNKNOWN, string $tokenSubType = self::TOKEN_SUBTYPE_NOTHING) |
| 80 |
{ |
| 81 |
// Initialise values |
| 82 |
$this->value = $value; |
| 83 |
$this->tokenType = $tokenType; |
| 84 |
$this->tokenSubType = $tokenSubType; |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* Get Value. |
| 89 |
*/ |
| 90 |
public function getValue(): string |
| 91 |
{ |
| 92 |
return $this->value; |
| 93 |
} |
| 94 |
|
| 95 |
/** |
| 96 |
* Set Value. |
| 97 |
*/ |
| 98 |
public function setValue(string $value): void |
| 99 |
{ |
| 100 |
$this->value = $value; |
| 101 |
} |
| 102 |
|
| 103 |
/** |
| 104 |
* Get Token Type (represented by TOKEN_TYPE_*). |
| 105 |
*/ |
| 106 |
public function getTokenType(): string |
| 107 |
{ |
| 108 |
return $this->tokenType; |
| 109 |
} |
| 110 |
|
| 111 |
/** |
| 112 |
* Set Token Type (represented by TOKEN_TYPE_*). |
| 113 |
*/ |
| 114 |
public function setTokenType(string $value): void |
| 115 |
{ |
| 116 |
$this->tokenType = $value; |
| 117 |
} |
| 118 |
|
| 119 |
/** |
| 120 |
* Get Token SubType (represented by TOKEN_SUBTYPE_*). |
| 121 |
*/ |
| 122 |
public function getTokenSubType(): string |
| 123 |
{ |
| 124 |
return $this->tokenSubType; |
| 125 |
} |
| 126 |
|
| 127 |
/** |
| 128 |
* Set Token SubType (represented by TOKEN_SUBTYPE_*). |
| 129 |
*/ |
| 130 |
public function setTokenSubType(string $value): void |
| 131 |
{ |
| 132 |
$this->tokenSubType = $value; |
| 133 |
} |
| 134 |
} |
| 135 |
|