Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
namespace 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
 * https://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
25
 * https://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
26
 */
27
class FormulaToken
28
{
29
    // Token types
30
    const TOKEN_TYPE_NOOP = 'Noop';
31
    const TOKEN_TYPE_OPERAND = 'Operand';
32
    const TOKEN_TYPE_FUNCTION = 'Function';
33
    const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression';
34
    const TOKEN_TYPE_ARGUMENT = 'Argument';
35
    const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix';
36
    const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix';
37
    const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix';
38
    const TOKEN_TYPE_WHITESPACE = 'Whitespace';
39
    const TOKEN_TYPE_UNKNOWN = 'Unknown';
40
 
41
    // Token subtypes
42
    const TOKEN_SUBTYPE_NOTHING = 'Nothing';
43
    const TOKEN_SUBTYPE_START = 'Start';
44
    const TOKEN_SUBTYPE_STOP = 'Stop';
45
    const TOKEN_SUBTYPE_TEXT = 'Text';
46
    const TOKEN_SUBTYPE_NUMBER = 'Number';
47
    const TOKEN_SUBTYPE_LOGICAL = 'Logical';
48
    const TOKEN_SUBTYPE_ERROR = 'Error';
49
    const TOKEN_SUBTYPE_RANGE = 'Range';
50
    const TOKEN_SUBTYPE_MATH = 'Math';
51
    const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation';
52
    const TOKEN_SUBTYPE_INTERSECTION = 'Intersection';
53
    const TOKEN_SUBTYPE_UNION = 'Union';
54
 
55
    /**
56
     * Value.
57
     *
58
     * @var string
59
     */
60
    private $value;
61
 
62
    /**
63
     * Token Type (represented by TOKEN_TYPE_*).
64
     *
65
     * @var string
66
     */
67
    private $tokenType;
68
 
69
    /**
70
     * Token SubType (represented by TOKEN_SUBTYPE_*).
71
     *
72
     * @var string
73
     */
74
    private $tokenSubType;
75
 
76
    /**
77
     * Create a new FormulaToken.
78
     *
79
     * @param string $value
80
     * @param string $tokenType Token type (represented by TOKEN_TYPE_*)
81
     * @param string $tokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*)
82
     */
83
    public function __construct($value, $tokenType = self::TOKEN_TYPE_UNKNOWN, $tokenSubType = self::TOKEN_SUBTYPE_NOTHING)
84
    {
85
        // Initialise values
86
        $this->value = $value;
87
        $this->tokenType = $tokenType;
88
        $this->tokenSubType = $tokenSubType;
89
    }
90
 
91
    /**
92
     * Get Value.
93
     *
94
     * @return string
95
     */
96
    public function getValue()
97
    {
98
        return $this->value;
99
    }
100
 
101
    /**
102
     * Set Value.
103
     *
104
     * @param string $value
105
     */
106
    public function setValue($value): void
107
    {
108
        $this->value = $value;
109
    }
110
 
111
    /**
112
     * Get Token Type (represented by TOKEN_TYPE_*).
113
     *
114
     * @return string
115
     */
116
    public function getTokenType()
117
    {
118
        return $this->tokenType;
119
    }
120
 
121
    /**
122
     * Set Token Type (represented by TOKEN_TYPE_*).
123
     *
124
     * @param string $value
125
     */
126
    public function setTokenType($value): void
127
    {
128
        $this->tokenType = $value;
129
    }
130
 
131
    /**
132
     * Get Token SubType (represented by TOKEN_SUBTYPE_*).
133
     *
134
     * @return string
135
     */
136
    public function getTokenSubType()
137
    {
138
        return $this->tokenSubType;
139
    }
140
 
141
    /**
142
     * Set Token SubType (represented by TOKEN_SUBTYPE_*).
143
     *
144
     * @param string $value
145
     */
146
    public function setTokenSubType($value): void
147
    {
148
        $this->tokenSubType = $value;
149
    }
150
}