1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Hoa |
4
|
|
|
* |
5
|
|
|
* |
6
|
|
|
* @license |
7
|
|
|
* |
8
|
|
|
* BSD 3-Clause License |
9
|
|
|
* |
10
|
|
|
* Copyright © 2007-2017, Hoa community. All rights reserved. |
11
|
|
|
* |
12
|
|
|
* Redistribution and use in source and binary forms, with or without |
13
|
|
|
* modification, are permitted provided that the following conditions are met: |
14
|
|
|
* |
15
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this |
16
|
|
|
* list of conditions and the following disclaimer. |
17
|
|
|
* |
18
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice, |
19
|
|
|
* this list of conditions and the following disclaimer in the documentation |
20
|
|
|
* and/or other materials provided with the distribution. |
21
|
|
|
* |
22
|
|
|
* 3. Neither the name of the copyright holder nor the names of its |
23
|
|
|
* contributors may be used to endorse or promote products derived from |
24
|
|
|
* this software without specific prior written permission. |
25
|
|
|
* |
26
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
27
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
28
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
29
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
30
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
31
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
32
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
33
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
34
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
35
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
36
|
|
|
* |
37
|
|
|
*/ |
38
|
|
|
|
39
|
|
|
namespace JMS\Serializer\Type\Compiler\Llk\Rule; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Class \JMS\Serializer\Type\Compiler\Llk\Rule\Invocation. |
43
|
|
|
* |
44
|
|
|
* Parent of entry and ekzit rules. |
45
|
|
|
* |
46
|
|
|
* @copyright Copyright © 2007-2017 Hoa community |
47
|
|
|
* @license New BSD License |
48
|
|
|
*/ |
49
|
|
|
abstract class Invocation |
50
|
|
|
{ |
51
|
|
|
/** |
52
|
|
|
* Rule. |
53
|
|
|
* |
54
|
|
|
* @var string|null |
55
|
|
|
*/ |
56
|
|
|
protected $_rule = null; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Data. |
60
|
|
|
* |
61
|
|
|
* @var mixed |
62
|
|
|
*/ |
63
|
|
|
protected $_data = null; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Piece of todo sequence. |
67
|
|
|
* |
68
|
|
|
* @var array|null |
69
|
|
|
*/ |
70
|
|
|
protected $_todo = null; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Depth in the trace. |
74
|
|
|
* |
75
|
|
|
* @var int |
76
|
|
|
*/ |
77
|
|
|
protected $_depth = -1; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Whether the rule is transitional or not (i.e. not declared in the grammar |
81
|
|
|
* but created by the analyzer). |
82
|
|
|
* |
83
|
|
|
* @var bool |
84
|
|
|
*/ |
85
|
|
|
protected $_transitional = false; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Constructor. |
89
|
|
|
* |
90
|
|
|
* @param string|int $rule Rule name. |
91
|
|
|
* @param mixed $data Data. |
92
|
|
|
* @param array $todo Todo. |
93
|
|
|
* @param int $depth Depth. |
94
|
|
|
*/ |
95
|
|
|
public function __construct( |
96
|
|
|
$rule, |
97
|
|
|
$data, |
98
|
|
|
array $todo = null, |
99
|
|
|
$depth = -1 |
100
|
|
|
) { |
101
|
|
|
$this->_rule = $rule; |
102
|
|
|
$this->_data = $data; |
103
|
|
|
$this->_todo = $todo; |
104
|
|
|
$this->_depth = $depth; |
105
|
|
|
$this->_transitional = \is_int($rule); |
106
|
|
|
|
107
|
|
|
return; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Get rule name. |
112
|
|
|
* |
113
|
|
|
* @return string |
114
|
|
|
*/ |
115
|
|
|
public function getRule() |
116
|
|
|
{ |
117
|
|
|
return $this->_rule; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Get data. |
122
|
|
|
* |
123
|
|
|
* @return mixed |
124
|
|
|
*/ |
125
|
|
|
public function getData() |
126
|
|
|
{ |
127
|
|
|
return $this->_data; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Get todo sequence. |
132
|
|
|
* |
133
|
|
|
* @return array |
134
|
|
|
*/ |
135
|
|
|
public function getTodo() |
136
|
|
|
{ |
137
|
|
|
return $this->_todo; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Set depth in trace. |
142
|
|
|
* |
143
|
|
|
* @param int $depth Depth. |
144
|
|
|
* @return int |
145
|
|
|
*/ |
146
|
|
|
public function setDepth($depth) |
147
|
|
|
{ |
148
|
|
|
$old = $this->_depth; |
149
|
|
|
$this->_depth = $depth; |
150
|
|
|
|
151
|
|
|
return $old; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Get depth in trace. |
156
|
|
|
* |
157
|
|
|
* @return int |
158
|
|
|
*/ |
159
|
|
|
public function getDepth() |
160
|
|
|
{ |
161
|
|
|
return $this->_depth; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Check whether the rule is transitional or not. |
166
|
|
|
* |
167
|
|
|
* @return bool |
168
|
|
|
*/ |
169
|
|
|
public function isTransitional() |
170
|
|
|
{ |
171
|
|
|
return $this->_transitional; |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
|