FormulaToken.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. /*
  8. PARTLY BASED ON:
  9. Copyright (c) 2007 E. W. Bachtal, Inc.
  10. Permission is hereby granted, free of charge, to any person obtaining a copy of this software
  11. and associated documentation files (the "Software"), to deal in the Software without restriction,
  12. including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
  13. and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
  14. subject to the following conditions:
  15. The above copyright notice and this permission notice shall be included in all copies or substantial
  16. portions of the Software.
  17. The software is provided "as is", without warranty of any kind, express or implied, including but not
  18. limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In
  19. no event shall the authors or copyright holders be liable for any claim, damages or other liability,
  20. whether in an action of contract, tort or otherwise, arising from, out of or in connection with the
  21. software or the use or other dealings in the software.
  22. http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
  23. http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
  24. */
  25. /**
  26. * PHPExcel_Calculation_FormulaToken
  27. *
  28. * Copyright (c) 2006 - 2015 PHPExcel
  29. *
  30. * This library is free software; you can redistribute it and/or
  31. * modify it under the terms of the GNU Lesser General Public
  32. * License as published by the Free Software Foundation; either
  33. * version 2.1 of the License, or (at your option) any later version.
  34. *
  35. * This library is distributed in the hope that it will be useful,
  36. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  37. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  38. * Lesser General Public License for more details.
  39. *
  40. * You should have received a copy of the GNU Lesser General Public
  41. * License along with this library; if not, write to the Free Software
  42. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  43. *
  44. * @category PHPExcel
  45. * @package PHPExcel_Calculation
  46. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  47. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  48. * @version ##VERSION##, ##DATE##
  49. */
  50. class PHPExcel_Calculation_FormulaToken
  51. {
  52. /* Token types */
  53. const TOKEN_TYPE_NOOP = 'Noop';
  54. const TOKEN_TYPE_OPERAND = 'Operand';
  55. const TOKEN_TYPE_FUNCTION = 'Function';
  56. const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression';
  57. const TOKEN_TYPE_ARGUMENT = 'Argument';
  58. const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix';
  59. const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix';
  60. const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix';
  61. const TOKEN_TYPE_WHITESPACE = 'Whitespace';
  62. const TOKEN_TYPE_UNKNOWN = 'Unknown';
  63. /* Token subtypes */
  64. const TOKEN_SUBTYPE_NOTHING = 'Nothing';
  65. const TOKEN_SUBTYPE_START = 'Start';
  66. const TOKEN_SUBTYPE_STOP = 'Stop';
  67. const TOKEN_SUBTYPE_TEXT = 'Text';
  68. const TOKEN_SUBTYPE_NUMBER = 'Number';
  69. const TOKEN_SUBTYPE_LOGICAL = 'Logical';
  70. const TOKEN_SUBTYPE_ERROR = 'Error';
  71. const TOKEN_SUBTYPE_RANGE = 'Range';
  72. const TOKEN_SUBTYPE_MATH = 'Math';
  73. const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation';
  74. const TOKEN_SUBTYPE_INTERSECTION = 'Intersection';
  75. const TOKEN_SUBTYPE_UNION = 'Union';
  76. /**
  77. * Value
  78. *
  79. * @var string
  80. */
  81. private $value;
  82. /**
  83. * Token Type (represented by TOKEN_TYPE_*)
  84. *
  85. * @var string
  86. */
  87. private $tokenType;
  88. /**
  89. * Token SubType (represented by TOKEN_SUBTYPE_*)
  90. *
  91. * @var string
  92. */
  93. private $tokenSubType;
  94. /**
  95. * Create a new PHPExcel_Calculation_FormulaToken
  96. *
  97. * @param string $pValue
  98. * @param string $pTokenType Token type (represented by TOKEN_TYPE_*)
  99. * @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*)
  100. */
  101. public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
  102. {
  103. // Initialise values
  104. $this->value = $pValue;
  105. $this->tokenType = $pTokenType;
  106. $this->tokenSubType = $pTokenSubType;
  107. }
  108. /**
  109. * Get Value
  110. *
  111. * @return string
  112. */
  113. public function getValue()
  114. {
  115. return $this->value;
  116. }
  117. /**
  118. * Set Value
  119. *
  120. * @param string $value
  121. */
  122. public function setValue($value)
  123. {
  124. $this->value = $value;
  125. }
  126. /**
  127. * Get Token Type (represented by TOKEN_TYPE_*)
  128. *
  129. * @return string
  130. */
  131. public function getTokenType()
  132. {
  133. return $this->tokenType;
  134. }
  135. /**
  136. * Set Token Type
  137. *
  138. * @param string $value
  139. */
  140. public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN)
  141. {
  142. $this->tokenType = $value;
  143. }
  144. /**
  145. * Get Token SubType (represented by TOKEN_SUBTYPE_*)
  146. *
  147. * @return string
  148. */
  149. public function getTokenSubType()
  150. {
  151. return $this->tokenSubType;
  152. }
  153. /**
  154. * Set Token SubType
  155. *
  156. * @param string $value
  157. */
  158. public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
  159. {
  160. $this->tokenSubType = $value;
  161. }
  162. }