Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 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
    private string $value;
59
 
60
    /**
61
     * Token Type (represented by TOKEN_TYPE_*).
62
     */
63
    private string $tokenType;
64
 
65
    /**
66
     * Token SubType (represented by TOKEN_SUBTYPE_*).
67
     */
68
    private string $tokenSubType;
69
 
70
    /**
71
     * Create a new FormulaToken.
72
     *
73
     * @param string $tokenType Token type (represented by TOKEN_TYPE_*)
74
     * @param string $tokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*)
75
     */
76
    public function __construct(string $value, string $tokenType = self::TOKEN_TYPE_UNKNOWN, string $tokenSubType = self::TOKEN_SUBTYPE_NOTHING)
77
    {
78
        // Initialise values
79
        $this->value = $value;
80
        $this->tokenType = $tokenType;
81
        $this->tokenSubType = $tokenSubType;
82
    }
83
 
84
    /**
85
     * Get Value.
86
     */
87
    public function getValue(): string
88
    {
89
        return $this->value;
90
    }
91
 
92
    /**
93
     * Set Value.
94
     */
95
    public function setValue(string $value): void
96
    {
97
        $this->value = $value;
98
    }
99
 
100
    /**
101
     * Get Token Type (represented by TOKEN_TYPE_*).
102
     */
103
    public function getTokenType(): string
104
    {
105
        return $this->tokenType;
106
    }
107
 
108
    /**
109
     * Set Token Type (represented by TOKEN_TYPE_*).
110
     */
111
    public function setTokenType(string $value): void
112
    {
113
        $this->tokenType = $value;
114
    }
115
 
116
    /**
117
     * Get Token SubType (represented by TOKEN_SUBTYPE_*).
118
     */
119
    public function getTokenSubType(): string
120
    {
121
        return $this->tokenSubType;
122
    }
123
 
124
    /**
125
     * Set Token SubType (represented by TOKEN_SUBTYPE_*).
126
     */
127
    public function setTokenSubType(string $value): void
128
    {
129
        $this->tokenSubType = $value;
130
    }
131
}