1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of Smarty. |
4
|
|
|
* |
5
|
|
|
* (c) 2015 Uwe Tews |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Smarty_Internal_Templatelexer |
13
|
|
|
* This is the template file lexer. |
14
|
|
|
* It is generated from the smarty_internal_templatelexer.plex file |
15
|
|
|
* |
16
|
|
|
* |
17
|
|
|
* @author Uwe Tews <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class Smarty_Internal_Templatelexer |
20
|
|
|
{ |
21
|
|
|
const TEXT = 1; |
22
|
|
|
const TAG = 2; |
23
|
|
|
const TAGBODY = 3; |
24
|
|
|
const LITERAL = 4; |
25
|
|
|
const DOUBLEQUOTEDSTRING = 5; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Source |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
public $data; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Source length |
36
|
|
|
* |
37
|
|
|
* @var int |
38
|
|
|
*/ |
39
|
|
|
public $dataLength = null; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* byte counter |
43
|
|
|
* |
44
|
|
|
* @var int |
45
|
|
|
*/ |
46
|
|
|
public $counter; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* token number |
50
|
|
|
* |
51
|
|
|
* @var int |
52
|
|
|
*/ |
53
|
|
|
public $token; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* token value |
57
|
|
|
* |
58
|
|
|
* @var string |
59
|
|
|
*/ |
60
|
|
|
public $value; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* current line |
64
|
|
|
* |
65
|
|
|
* @var int |
66
|
|
|
*/ |
67
|
|
|
public $line; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* tag start line |
71
|
|
|
* |
72
|
|
|
* @var |
73
|
|
|
*/ |
74
|
|
|
public $taglineno; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* php code type |
78
|
|
|
* |
79
|
|
|
* @var string |
80
|
|
|
*/ |
81
|
|
|
public $phpType = ''; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* state number |
85
|
|
|
* |
86
|
|
|
* @var int |
87
|
|
|
*/ |
88
|
|
|
public $state = 1; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Smarty object |
92
|
|
|
* |
93
|
|
|
* @var Smarty |
94
|
|
|
*/ |
95
|
|
|
public $smarty = null; |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* compiler object |
99
|
|
|
* |
100
|
|
|
* @var Smarty_Internal_TemplateCompilerBase |
101
|
|
|
*/ |
102
|
|
|
public $compiler = null; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* trace file |
106
|
|
|
* |
107
|
|
|
* @var resource |
108
|
|
|
*/ |
109
|
|
|
public $yyTraceFILE; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* trace prompt |
113
|
|
|
* |
114
|
|
|
* @var string |
115
|
|
|
*/ |
116
|
|
|
public $yyTracePrompt; |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* XML flag true while processing xml |
120
|
|
|
* |
121
|
|
|
* @var bool |
122
|
|
|
*/ |
123
|
|
|
public $is_xml = false; |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* state names |
127
|
|
|
* |
128
|
|
|
* @var array |
129
|
|
|
*/ |
130
|
|
|
public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',); |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* token names |
134
|
|
|
* |
135
|
|
|
* @var array |
136
|
|
|
*/ |
137
|
|
|
public $smarty_token_names = array( // Text for parser error messages |
138
|
|
|
'NOT' => '(!,not)', |
139
|
|
|
'OPENP' => '(', |
140
|
|
|
'CLOSEP' => ')', |
141
|
|
|
'OPENB' => '[', |
142
|
|
|
'CLOSEB' => ']', |
143
|
|
|
'PTR' => '->', |
144
|
|
|
'APTR' => '=>', |
145
|
|
|
'EQUAL' => '=', |
146
|
|
|
'NUMBER' => 'number', |
147
|
|
|
'UNIMATH' => '+" , "-', |
148
|
|
|
'MATH' => '*" , "/" , "%', |
149
|
|
|
'INCDEC' => '++" , "--', |
150
|
|
|
'SPACE' => ' ', |
151
|
|
|
'DOLLAR' => '$', |
152
|
|
|
'SEMICOLON' => ';', |
153
|
|
|
'COLON' => ':', |
154
|
|
|
'DOUBLECOLON' => '::', |
155
|
|
|
'AT' => '@', |
156
|
|
|
'HATCH' => '#', |
157
|
|
|
'QUOTE' => '"', |
158
|
|
|
'BACKTICK' => '`', |
159
|
|
|
'VERT' => '"|" modifier', |
160
|
|
|
'DOT' => '.', |
161
|
|
|
'COMMA' => '","', |
162
|
|
|
'QMARK' => '"?"', |
163
|
|
|
'ID' => 'id, name', |
164
|
|
|
'TEXT' => 'text', |
165
|
|
|
'LDELSLASH' => '{/..} closing tag', |
166
|
|
|
'LDEL' => '{...} Smarty tag', |
167
|
|
|
'COMMENT' => 'comment', |
168
|
|
|
'AS' => 'as', |
169
|
|
|
'TO' => 'to', |
170
|
|
|
'PHP' => '"<?php", "<%", "{php}" tag', |
171
|
|
|
'LOGOP' => '"<", "==" ... logical operator', |
172
|
|
|
'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition', |
173
|
|
|
'SCOND' => '"is even" ... if condition', |
174
|
|
|
); |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* literal tag nesting level |
178
|
|
|
* |
179
|
|
|
* @var int |
180
|
|
|
*/ |
181
|
|
|
private $literal_cnt = 0; |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* preg token pattern for state TEXT |
185
|
|
|
* |
186
|
|
|
* @var string |
187
|
|
|
*/ |
188
|
|
|
private $yy_global_pattern1 = null; |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* preg token pattern for state TAG |
192
|
|
|
* |
193
|
|
|
* @var string |
194
|
|
|
*/ |
195
|
|
|
private $yy_global_pattern2 = null; |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* preg token pattern for state TAGBODY |
199
|
|
|
* |
200
|
|
|
* @var string |
201
|
|
|
*/ |
202
|
|
|
private $yy_global_pattern3 = null; |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* preg token pattern for state LITERAL |
206
|
|
|
* |
207
|
|
|
* @var string |
208
|
|
|
*/ |
209
|
|
|
private $yy_global_pattern4 = null; |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* preg token pattern for state DOUBLEQUOTEDSTRING |
213
|
|
|
* |
214
|
|
|
* @var null |
215
|
|
|
*/ |
216
|
|
|
private $yy_global_pattern5 = null; |
217
|
|
|
|
218
|
|
|
private $_yy_state = 1; |
219
|
|
|
|
220
|
|
|
private $_yy_stack = array(); |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* constructor |
224
|
|
|
* |
225
|
|
|
* @param string $source template source |
226
|
|
|
* @param Smarty_Internal_TemplateCompilerBase $compiler |
227
|
|
|
*/ |
228
|
|
|
public function __construct($source, Smarty_Internal_TemplateCompilerBase $compiler) |
229
|
|
|
{ |
230
|
|
|
$this->data = $source; |
231
|
|
|
$this->dataLength = strlen($this->data); |
232
|
|
|
$this->counter = 0; |
233
|
|
|
if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) { |
234
|
|
|
$this->counter += strlen($match[ 0 ]); |
235
|
|
|
} |
236
|
|
|
$this->line = 1; |
237
|
|
|
$this->smarty = $compiler->template->smarty; |
238
|
|
|
$this->compiler = $compiler; |
239
|
|
|
$this->compiler->initDelimiterPreg(); |
240
|
|
|
$this->smarty_token_names[ 'LDEL' ] = $this->smarty->getLeftDelimiter(); |
241
|
|
|
$this->smarty_token_names[ 'RDEL' ] = $this->smarty->getRightDelimiter(); |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* open lexer/parser trace file |
246
|
|
|
* |
247
|
|
|
*/ |
248
|
|
|
public function PrintTrace() |
249
|
|
|
{ |
250
|
|
|
$this->yyTraceFILE = fopen('php://output', 'w'); |
251
|
|
|
$this->yyTracePrompt = '<br>'; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* replace placeholders with runtime preg code |
256
|
|
|
* |
257
|
|
|
* @param string $preg |
258
|
|
|
* |
259
|
|
|
* @return string |
260
|
|
|
*/ |
261
|
|
|
public function replace($preg) |
262
|
|
|
{ |
263
|
|
|
return $this->compiler->replaceDelimiter($preg); |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
/** |
267
|
|
|
* check if current value is an autoliteral left delimiter |
268
|
|
|
* |
269
|
|
|
* @return bool |
270
|
|
|
*/ |
271
|
|
|
public function isAutoLiteral() |
272
|
|
|
{ |
273
|
|
|
return $this->smarty->getAutoLiteral() && isset($this->value[ $this->compiler->getLdelLength() ]) ? |
274
|
|
|
strpos(" \n\t\r", $this->value[ $this->compiler->getLdelLength() ]) !== false : false; |
275
|
|
|
} // end function |
276
|
|
|
|
277
|
|
|
public function yylex() |
278
|
|
|
{ |
279
|
|
|
return $this->{'yylex' . $this->_yy_state}(); |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
public function yypushstate($state) |
283
|
|
|
{ |
284
|
|
|
if ($this->yyTraceFILE) { |
285
|
|
|
fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, |
286
|
|
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state); |
287
|
|
|
} |
288
|
|
|
array_push($this->_yy_stack, $this->_yy_state); |
289
|
|
|
$this->_yy_state = $state; |
290
|
|
|
if ($this->yyTraceFILE) { |
291
|
|
|
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, |
292
|
|
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state); |
293
|
|
|
} |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
public function yypopstate() |
297
|
|
|
{ |
298
|
|
|
if ($this->yyTraceFILE) { |
299
|
|
|
fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, |
300
|
|
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state); |
301
|
|
|
} |
302
|
|
|
$this->_yy_state = array_pop($this->_yy_stack); |
303
|
|
|
if ($this->yyTraceFILE) { |
304
|
|
|
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, |
305
|
|
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state); |
306
|
|
|
} |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
public function yybegin($state) |
310
|
|
|
{ |
311
|
|
|
$this->_yy_state = $state; |
312
|
|
|
if ($this->yyTraceFILE) { |
313
|
|
|
fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, |
314
|
|
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state); |
315
|
|
|
} |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
public function yylex1() |
319
|
|
|
{ |
320
|
|
|
if (!isset($this->yy_global_pattern1)) { |
321
|
|
|
$this->yy_global_pattern1 = |
322
|
|
|
$this->replace("/\G([{][}])|\G((SMARTYldel)SMARTYal[*])|\G((SMARTYldel)SMARTYalphp([ ].*?)?SMARTYrdel|(SMARTYldel)SMARTYal[\/]phpSMARTYrdel)|\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([<][?]((php\\s+|=)|\\s+)|[<][%]|[<][?]xml\\s+|[<]script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*[>]|[?][>]|[%][>])|\G((.*?)(?=((SMARTYldel)SMARTYal|[<][?]((php\\s+|=)|\\s+)|[<][%]|[<][?]xml\\s+|[<]script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*[>]|[?][>]|[%][>]SMARTYliteral))|[\s\S]+)/isS"); |
323
|
|
|
} |
324
|
|
|
if (!isset($this->dataLength)) { |
325
|
|
|
$this->dataLength = strlen($this->data); |
326
|
|
|
} |
327
|
|
|
if ($this->counter >= $this->dataLength) { |
328
|
|
|
return false; // end of input |
329
|
|
|
} |
330
|
|
|
do { |
331
|
|
|
if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, 0, $this->counter)) { |
332
|
|
|
if (!isset($yymatches[ 0 ][ 1 ])) { |
333
|
|
|
$yymatches = preg_grep("/(.|\s)+/", $yymatches); |
334
|
|
|
} else { |
335
|
|
|
$yymatches = array_filter($yymatches); |
336
|
|
|
} |
337
|
|
|
if (empty($yymatches)) { |
338
|
|
|
throw new Exception('Error: lexing failed because a rule matched' . |
339
|
|
|
' an empty string. Input "' . substr( |
340
|
|
|
$this->data, |
341
|
|
|
$this->counter, |
342
|
|
|
5 |
343
|
|
|
) . '... state TEXT'); |
344
|
|
|
} |
345
|
|
|
next($yymatches); // skip global match |
346
|
|
|
$this->token = key($yymatches); // token number |
347
|
|
|
$this->value = current($yymatches); // token value |
348
|
|
|
$r = $this->{'yy_r1_' . $this->token}(); |
349
|
|
|
if ($r === null) { |
350
|
|
|
$this->counter += strlen($this->value); |
351
|
|
|
$this->line += substr_count($this->value, "\n"); |
352
|
|
|
// accept this token |
353
|
|
|
return true; |
354
|
|
|
} elseif ($r === true) { |
355
|
|
|
// we have changed state |
356
|
|
|
// process this token in the new state |
357
|
|
|
return $this->yylex(); |
358
|
|
|
} elseif ($r === false) { |
359
|
|
|
$this->counter += strlen($this->value); |
360
|
|
|
$this->line += substr_count($this->value, "\n"); |
361
|
|
|
if ($this->counter >= $this->dataLength) { |
362
|
|
|
return false; // end of input |
363
|
|
|
} |
364
|
|
|
// skip this token |
365
|
|
|
continue; |
366
|
|
|
} |
367
|
|
|
} else { |
368
|
|
|
throw new Exception('Unexpected input at line' . $this->line . |
369
|
|
|
': ' . $this->data[ $this->counter ]); |
370
|
|
|
} |
371
|
|
|
break; |
372
|
|
|
} while (true); |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
public function yy_r1_1() |
376
|
|
|
{ |
377
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT; |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
public function yy_r1_2() |
381
|
|
|
{ |
382
|
|
|
preg_match("/[*]{$this->compiler->getRdelPreg()}[\n]?/", $this->data, $match, PREG_OFFSET_CAPTURE, |
383
|
|
|
$this->counter); |
384
|
|
|
if (isset($match[ 0 ][ 1 ])) { |
385
|
|
|
$to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]); |
386
|
|
|
} else { |
387
|
|
|
$this->compiler->trigger_template_error("missing or misspelled comment closing tag '{$this->smarty->getRightDelimiter()}'"); |
388
|
|
|
} |
389
|
|
|
$this->value = substr($this->data, $this->counter, $to - $this->counter); |
|
|
|
|
390
|
|
|
return false; |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
public function yy_r1_4() |
394
|
|
|
{ |
395
|
|
|
$this->compiler->getTagCompiler('private_php')->parsePhp($this); |
|
|
|
|
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
public function yy_r1_8() |
399
|
|
|
{ |
400
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT; |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
public function yy_r1_10() |
404
|
|
|
{ |
405
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART; |
406
|
|
|
$this->yypushstate(self::LITERAL); |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
public function yy_r1_12() |
410
|
|
|
{ |
411
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LITERALEND; |
412
|
|
|
$this->yypushstate(self::LITERAL); |
413
|
|
|
} // end function |
414
|
|
|
|
415
|
|
|
public function yy_r1_14() |
416
|
|
|
{ |
417
|
|
|
$this->yypushstate(self::TAG); |
418
|
|
|
return true; |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
public function yy_r1_16() |
422
|
|
|
{ |
423
|
|
|
$this->compiler->getTagCompiler('private_php')->parsePhp($this); |
|
|
|
|
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
public function yy_r1_19() |
427
|
|
|
{ |
428
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT; |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
public function yylex2() |
432
|
|
|
{ |
433
|
|
|
if (!isset($this->yy_global_pattern2)) { |
434
|
|
|
$this->yy_global_pattern2 = |
435
|
|
|
$this->replace("/\G((SMARTYldel)SMARTYal(if|elseif|else if|while)\\s+)|\G((SMARTYldel)SMARTYalfor\\s+)|\G((SMARTYldel)SMARTYalforeach(?![^\s]))|\G((SMARTYldel)SMARTYalsetfilter\\s+)|\G((SMARTYldel)SMARTYalmake_nocache\\s+)|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$]smarty\\.block\\.(child|parent)\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/][0-9]*[a-zA-Z_]\\w*\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal)/isS"); |
436
|
|
|
} |
437
|
|
|
if (!isset($this->dataLength)) { |
438
|
|
|
$this->dataLength = strlen($this->data); |
439
|
|
|
} |
440
|
|
|
if ($this->counter >= $this->dataLength) { |
441
|
|
|
return false; // end of input |
442
|
|
|
} |
443
|
|
|
do { |
444
|
|
|
if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, 0, $this->counter)) { |
445
|
|
|
if (!isset($yymatches[ 0 ][ 1 ])) { |
446
|
|
|
$yymatches = preg_grep("/(.|\s)+/", $yymatches); |
447
|
|
|
} else { |
448
|
|
|
$yymatches = array_filter($yymatches); |
449
|
|
|
} |
450
|
|
|
if (empty($yymatches)) { |
451
|
|
|
throw new Exception('Error: lexing failed because a rule matched' . |
452
|
|
|
' an empty string. Input "' . substr( |
453
|
|
|
$this->data, |
454
|
|
|
$this->counter, |
455
|
|
|
5 |
456
|
|
|
) . '... state TAG'); |
457
|
|
|
} |
458
|
|
|
next($yymatches); // skip global match |
459
|
|
|
$this->token = key($yymatches); // token number |
460
|
|
|
$this->value = current($yymatches); // token value |
461
|
|
|
$r = $this->{'yy_r2_' . $this->token}(); |
462
|
|
|
if ($r === null) { |
463
|
|
|
$this->counter += strlen($this->value); |
464
|
|
|
$this->line += substr_count($this->value, "\n"); |
465
|
|
|
// accept this token |
466
|
|
|
return true; |
467
|
|
|
} elseif ($r === true) { |
468
|
|
|
// we have changed state |
469
|
|
|
// process this token in the new state |
470
|
|
|
return $this->yylex(); |
471
|
|
|
} elseif ($r === false) { |
472
|
|
|
$this->counter += strlen($this->value); |
473
|
|
|
$this->line += substr_count($this->value, "\n"); |
474
|
|
|
if ($this->counter >= $this->dataLength) { |
475
|
|
|
return false; // end of input |
476
|
|
|
} |
477
|
|
|
// skip this token |
478
|
|
|
continue; |
479
|
|
|
} |
480
|
|
|
} else { |
481
|
|
|
throw new Exception('Unexpected input at line' . $this->line . |
482
|
|
|
': ' . $this->data[ $this->counter ]); |
483
|
|
|
} |
484
|
|
|
break; |
485
|
|
|
} while (true); |
486
|
|
|
} |
487
|
|
|
|
488
|
|
|
public function yy_r2_1() |
489
|
|
|
{ |
490
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LDELIF; |
491
|
|
|
$this->yybegin(self::TAGBODY); |
492
|
|
|
$this->taglineno = $this->line; |
493
|
|
|
} |
494
|
|
|
|
495
|
|
|
public function yy_r2_4() |
496
|
|
|
{ |
497
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LDELFOR; |
498
|
|
|
$this->yybegin(self::TAGBODY); |
499
|
|
|
$this->taglineno = $this->line; |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
public function yy_r2_6() |
503
|
|
|
{ |
504
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; |
505
|
|
|
$this->yybegin(self::TAGBODY); |
506
|
|
|
$this->taglineno = $this->line; |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
public function yy_r2_8() |
510
|
|
|
{ |
511
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER; |
512
|
|
|
$this->yybegin(self::TAGBODY); |
513
|
|
|
$this->taglineno = $this->line; |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
public function yy_r2_10() |
517
|
|
|
{ |
518
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE; |
519
|
|
|
$this->yybegin(self::TAGBODY); |
520
|
|
|
$this->taglineno = $this->line; |
521
|
|
|
} |
522
|
|
|
|
523
|
|
|
public function yy_r2_12() |
524
|
|
|
{ |
525
|
|
|
$this->yypopstate(); |
526
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG; |
527
|
|
|
$this->taglineno = $this->line; |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
public function yy_r2_15() |
531
|
|
|
{ |
532
|
|
|
$this->yypopstate(); |
533
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT; |
534
|
|
|
$this->taglineno = $this->line; |
535
|
|
|
} |
536
|
|
|
|
537
|
|
|
public function yy_r2_18() |
538
|
|
|
{ |
539
|
|
|
$this->yypopstate(); |
540
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_CLOSETAG; |
541
|
|
|
$this->taglineno = $this->line; |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
public function yy_r2_20() |
545
|
|
|
{ |
546
|
|
|
if ($this->_yy_stack[ count($this->_yy_stack) - 1 ] === self::TEXT) { |
547
|
|
|
$this->yypopstate(); |
548
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT; |
549
|
|
|
$this->taglineno = $this->line; |
550
|
|
|
} else { |
551
|
|
|
$this->value = $this->smarty->getLeftDelimiter(); |
552
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LDEL; |
553
|
|
|
$this->yybegin(self::TAGBODY); |
554
|
|
|
$this->taglineno = $this->line; |
555
|
|
|
} |
556
|
|
|
} // end function |
557
|
|
|
|
558
|
|
|
public function yy_r2_23() |
559
|
|
|
{ |
560
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; |
561
|
|
|
$this->yybegin(self::TAGBODY); |
562
|
|
|
$this->taglineno = $this->line; |
563
|
|
|
} |
564
|
|
|
|
565
|
|
|
public function yy_r2_25() |
566
|
|
|
{ |
567
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LDEL; |
568
|
|
|
$this->yybegin(self::TAGBODY); |
569
|
|
|
$this->taglineno = $this->line; |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
public function yylex3() |
573
|
|
|
{ |
574
|
|
|
if (!isset($this->yy_global_pattern3)) { |
575
|
|
|
$this->yy_global_pattern3 = |
576
|
|
|
$this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|][@]?)|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS"); |
577
|
|
|
} |
578
|
|
|
if (!isset($this->dataLength)) { |
579
|
|
|
$this->dataLength = strlen($this->data); |
580
|
|
|
} |
581
|
|
|
if ($this->counter >= $this->dataLength) { |
582
|
|
|
return false; // end of input |
583
|
|
|
} |
584
|
|
|
do { |
585
|
|
|
if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, 0, $this->counter)) { |
586
|
|
|
if (!isset($yymatches[ 0 ][ 1 ])) { |
587
|
|
|
$yymatches = preg_grep("/(.|\s)+/", $yymatches); |
588
|
|
|
} else { |
589
|
|
|
$yymatches = array_filter($yymatches); |
590
|
|
|
} |
591
|
|
|
if (empty($yymatches)) { |
592
|
|
|
throw new Exception('Error: lexing failed because a rule matched' . |
593
|
|
|
' an empty string. Input "' . substr( |
594
|
|
|
$this->data, |
595
|
|
|
$this->counter, |
596
|
|
|
5 |
597
|
|
|
) . '... state TAGBODY'); |
598
|
|
|
} |
599
|
|
|
next($yymatches); // skip global match |
600
|
|
|
$this->token = key($yymatches); // token number |
601
|
|
|
$this->value = current($yymatches); // token value |
602
|
|
|
$r = $this->{'yy_r3_' . $this->token}(); |
603
|
|
|
if ($r === null) { |
604
|
|
|
$this->counter += strlen($this->value); |
605
|
|
|
$this->line += substr_count($this->value, "\n"); |
606
|
|
|
// accept this token |
607
|
|
|
return true; |
608
|
|
|
} elseif ($r === true) { |
609
|
|
|
// we have changed state |
610
|
|
|
// process this token in the new state |
611
|
|
|
return $this->yylex(); |
612
|
|
|
} elseif ($r === false) { |
613
|
|
|
$this->counter += strlen($this->value); |
614
|
|
|
$this->line += substr_count($this->value, "\n"); |
615
|
|
|
if ($this->counter >= $this->dataLength) { |
616
|
|
|
return false; // end of input |
617
|
|
|
} |
618
|
|
|
// skip this token |
619
|
|
|
continue; |
620
|
|
|
} |
621
|
|
|
} else { |
622
|
|
|
throw new Exception('Unexpected input at line' . $this->line . |
623
|
|
|
': ' . $this->data[ $this->counter ]); |
624
|
|
|
} |
625
|
|
|
break; |
626
|
|
|
} while (true); |
627
|
|
|
} |
628
|
|
|
|
629
|
|
|
public function yy_r3_1() |
630
|
|
|
{ |
631
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_RDEL; |
632
|
|
|
$this->yypopstate(); |
633
|
|
|
} |
634
|
|
|
|
635
|
|
|
public function yy_r3_2() |
636
|
|
|
{ |
637
|
|
|
$this->yypushstate(self::TAG); |
638
|
|
|
return true; |
639
|
|
|
} |
640
|
|
|
|
641
|
|
|
public function yy_r3_4() |
642
|
|
|
{ |
643
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; |
644
|
|
|
$this->yypushstate(self::DOUBLEQUOTEDSTRING); |
645
|
|
|
$this->compiler->enterDoubleQuote(); |
646
|
|
|
} |
647
|
|
|
|
648
|
|
|
public function yy_r3_5() |
649
|
|
|
{ |
650
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING; |
651
|
|
|
} |
652
|
|
|
|
653
|
|
|
public function yy_r3_6() |
654
|
|
|
{ |
655
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID; |
656
|
|
|
} |
657
|
|
|
|
658
|
|
|
public function yy_r3_7() |
659
|
|
|
{ |
660
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_DOLLAR; |
661
|
|
|
} |
662
|
|
|
|
663
|
|
|
public function yy_r3_8() |
664
|
|
|
{ |
665
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_ISIN; |
666
|
|
|
} |
667
|
|
|
|
668
|
|
|
public function yy_r3_9() |
669
|
|
|
{ |
670
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_AS; |
671
|
|
|
} |
672
|
|
|
|
673
|
|
|
public function yy_r3_10() |
674
|
|
|
{ |
675
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_TO; |
676
|
|
|
} |
677
|
|
|
|
678
|
|
|
public function yy_r3_11() |
679
|
|
|
{ |
680
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_STEP; |
681
|
|
|
} |
682
|
|
|
|
683
|
|
|
public function yy_r3_12() |
684
|
|
|
{ |
685
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF; |
686
|
|
|
} |
687
|
|
|
|
688
|
|
|
public function yy_r3_13() |
689
|
|
|
{ |
690
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LOGOP; |
691
|
|
|
} |
692
|
|
|
|
693
|
|
|
public function yy_r3_15() |
694
|
|
|
{ |
695
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_SLOGOP; |
696
|
|
|
} |
697
|
|
|
|
698
|
|
|
public function yy_r3_17() |
699
|
|
|
{ |
700
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_TLOGOP; |
701
|
|
|
} |
702
|
|
|
|
703
|
|
|
public function yy_r3_20() |
704
|
|
|
{ |
705
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_SINGLECOND; |
706
|
|
|
} |
707
|
|
|
|
708
|
|
|
public function yy_r3_23() |
709
|
|
|
{ |
710
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_NOT; |
711
|
|
|
} |
712
|
|
|
|
713
|
|
|
public function yy_r3_24() |
714
|
|
|
{ |
715
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_TYPECAST; |
716
|
|
|
} |
717
|
|
|
|
718
|
|
|
public function yy_r3_28() |
719
|
|
|
{ |
720
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_OPENP; |
721
|
|
|
} |
722
|
|
|
|
723
|
|
|
public function yy_r3_29() |
724
|
|
|
{ |
725
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_CLOSEP; |
726
|
|
|
} |
727
|
|
|
|
728
|
|
|
public function yy_r3_30() |
729
|
|
|
{ |
730
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_OPENB; |
731
|
|
|
} |
732
|
|
|
|
733
|
|
|
public function yy_r3_31() |
734
|
|
|
{ |
735
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB; |
736
|
|
|
} |
737
|
|
|
|
738
|
|
|
public function yy_r3_32() |
739
|
|
|
{ |
740
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_PTR; |
741
|
|
|
} |
742
|
|
|
|
743
|
|
|
public function yy_r3_33() |
744
|
|
|
{ |
745
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_APTR; |
746
|
|
|
} |
747
|
|
|
|
748
|
|
|
public function yy_r3_34() |
749
|
|
|
{ |
750
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_EQUAL; |
751
|
|
|
} |
752
|
|
|
|
753
|
|
|
public function yy_r3_35() |
754
|
|
|
{ |
755
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_INCDEC; |
756
|
|
|
} |
757
|
|
|
|
758
|
|
|
public function yy_r3_37() |
759
|
|
|
{ |
760
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_UNIMATH; |
761
|
|
|
} |
762
|
|
|
|
763
|
|
|
public function yy_r3_39() |
764
|
|
|
{ |
765
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_MATH; |
766
|
|
|
} |
767
|
|
|
|
768
|
|
|
public function yy_r3_41() |
769
|
|
|
{ |
770
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_AT; |
771
|
|
|
} |
772
|
|
|
|
773
|
|
|
public function yy_r3_42() |
774
|
|
|
{ |
775
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_HATCH; |
776
|
|
|
} |
777
|
|
|
|
778
|
|
|
public function yy_r3_43() |
779
|
|
|
{ |
780
|
|
|
// resolve conflicts with shorttag and right_delimiter starting with '=' |
781
|
|
|
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) === |
782
|
|
|
$this->smarty->getRightDelimiter()) { |
783
|
|
|
preg_match('/\s+/', $this->value, $match); |
784
|
|
|
$this->value = $match[ 0 ]; |
785
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_SPACE; |
786
|
|
|
} else { |
787
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_ATTR; |
788
|
|
|
} |
789
|
|
|
} |
790
|
|
|
|
791
|
|
|
public function yy_r3_44() |
792
|
|
|
{ |
793
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_NAMESPACE; |
794
|
|
|
} |
795
|
|
|
|
796
|
|
|
public function yy_r3_47() |
797
|
|
|
{ |
798
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_ID; |
799
|
|
|
} |
800
|
|
|
|
801
|
|
|
public function yy_r3_48() |
802
|
|
|
{ |
803
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_INTEGER; |
804
|
|
|
} |
805
|
|
|
|
806
|
|
|
public function yy_r3_49() |
807
|
|
|
{ |
808
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK; |
809
|
|
|
$this->yypopstate(); |
810
|
|
|
} |
811
|
|
|
|
812
|
|
|
public function yy_r3_50() |
813
|
|
|
{ |
814
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_VERT; |
815
|
|
|
} |
816
|
|
|
|
817
|
|
|
public function yy_r3_51() |
818
|
|
|
{ |
819
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_DOT; |
820
|
|
|
} |
821
|
|
|
|
822
|
|
|
public function yy_r3_52() |
823
|
|
|
{ |
824
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_COMMA; |
825
|
|
|
} |
826
|
|
|
|
827
|
|
|
public function yy_r3_53() |
828
|
|
|
{ |
829
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_SEMICOLON; |
830
|
|
|
} |
831
|
|
|
|
832
|
|
|
public function yy_r3_54() |
833
|
|
|
{ |
834
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON; |
835
|
|
|
} |
836
|
|
|
|
837
|
|
|
public function yy_r3_55() |
838
|
|
|
{ |
839
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_COLON; |
840
|
|
|
} |
841
|
|
|
|
842
|
|
|
public function yy_r3_56() |
843
|
|
|
{ |
844
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_QMARK; |
845
|
|
|
} |
846
|
|
|
|
847
|
|
|
public function yy_r3_57() |
848
|
|
|
{ |
849
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_HEX; |
850
|
|
|
} |
851
|
|
|
|
852
|
|
|
public function yy_r3_58() |
853
|
|
|
{ |
854
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_SPACE; |
855
|
|
|
} // end function |
856
|
|
|
|
857
|
|
|
public function yy_r3_59() |
858
|
|
|
{ |
859
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT; |
860
|
|
|
} |
861
|
|
|
|
862
|
|
|
public function yylex4() |
863
|
|
|
{ |
864
|
|
|
if (!isset($this->yy_global_pattern4)) { |
865
|
|
|
$this->yy_global_pattern4 = |
866
|
|
|
$this->replace("/\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((.*?)(?=(SMARTYldel)SMARTYal[\/]?literalSMARTYrdel))/isS"); |
867
|
|
|
} |
868
|
|
|
if (!isset($this->dataLength)) { |
869
|
|
|
$this->dataLength = strlen($this->data); |
870
|
|
|
} |
871
|
|
|
if ($this->counter >= $this->dataLength) { |
872
|
|
|
return false; // end of input |
873
|
|
|
} |
874
|
|
|
do { |
875
|
|
|
if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, 0, $this->counter)) { |
876
|
|
|
if (!isset($yymatches[ 0 ][ 1 ])) { |
877
|
|
|
$yymatches = preg_grep("/(.|\s)+/", $yymatches); |
878
|
|
|
} else { |
879
|
|
|
$yymatches = array_filter($yymatches); |
880
|
|
|
} |
881
|
|
|
if (empty($yymatches)) { |
882
|
|
|
throw new Exception('Error: lexing failed because a rule matched' . |
883
|
|
|
' an empty string. Input "' . substr( |
884
|
|
|
$this->data, |
885
|
|
|
$this->counter, |
886
|
|
|
5 |
887
|
|
|
) . '... state LITERAL'); |
888
|
|
|
} |
889
|
|
|
next($yymatches); // skip global match |
890
|
|
|
$this->token = key($yymatches); // token number |
891
|
|
|
$this->value = current($yymatches); // token value |
892
|
|
|
$r = $this->{'yy_r4_' . $this->token}(); |
893
|
|
|
if ($r === null) { |
894
|
|
|
$this->counter += strlen($this->value); |
895
|
|
|
$this->line += substr_count($this->value, "\n"); |
896
|
|
|
// accept this token |
897
|
|
|
return true; |
898
|
|
|
} elseif ($r === true) { |
899
|
|
|
// we have changed state |
900
|
|
|
// process this token in the new state |
901
|
|
|
return $this->yylex(); |
902
|
|
|
} elseif ($r === false) { |
903
|
|
|
$this->counter += strlen($this->value); |
904
|
|
|
$this->line += substr_count($this->value, "\n"); |
905
|
|
|
if ($this->counter >= $this->dataLength) { |
906
|
|
|
return false; // end of input |
907
|
|
|
} |
908
|
|
|
// skip this token |
909
|
|
|
continue; |
910
|
|
|
} |
911
|
|
|
} else { |
912
|
|
|
throw new Exception('Unexpected input at line' . $this->line . |
913
|
|
|
': ' . $this->data[ $this->counter ]); |
914
|
|
|
} |
915
|
|
|
break; |
916
|
|
|
} while (true); |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
public function yy_r4_1() |
920
|
|
|
{ |
921
|
|
|
$this->literal_cnt++; |
922
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LITERAL; |
923
|
|
|
} |
924
|
|
|
|
925
|
|
|
public function yy_r4_3() |
926
|
|
|
{ |
927
|
|
|
if ($this->literal_cnt) { |
928
|
|
|
$this->literal_cnt--; |
929
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LITERAL; |
930
|
|
|
} else { |
931
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LITERALEND; |
932
|
|
|
$this->yypopstate(); |
933
|
|
|
} |
934
|
|
|
} |
935
|
|
|
|
936
|
|
|
public function yy_r4_5() |
937
|
|
|
{ |
938
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LITERAL; |
939
|
|
|
} // end function |
940
|
|
|
|
941
|
|
|
public function yylex5() |
942
|
|
|
{ |
943
|
|
|
if (!isset($this->yy_global_pattern5)) { |
944
|
|
|
$this->yy_global_pattern5 = |
945
|
|
|
$this->replace("/\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=((SMARTYldel)SMARTYal|\\$|`\\$|\"SMARTYliteral)))/isS"); |
|
|
|
|
946
|
|
|
} |
947
|
|
|
if (!isset($this->dataLength)) { |
948
|
|
|
$this->dataLength = strlen($this->data); |
949
|
|
|
} |
950
|
|
|
if ($this->counter >= $this->dataLength) { |
951
|
|
|
return false; // end of input |
952
|
|
|
} |
953
|
|
|
do { |
954
|
|
|
if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, 0, $this->counter)) { |
955
|
|
|
if (!isset($yymatches[ 0 ][ 1 ])) { |
956
|
|
|
$yymatches = preg_grep("/(.|\s)+/", $yymatches); |
957
|
|
|
} else { |
958
|
|
|
$yymatches = array_filter($yymatches); |
959
|
|
|
} |
960
|
|
|
if (empty($yymatches)) { |
961
|
|
|
throw new Exception('Error: lexing failed because a rule matched' . |
962
|
|
|
' an empty string. Input "' . substr( |
963
|
|
|
$this->data, |
964
|
|
|
$this->counter, |
965
|
|
|
5 |
966
|
|
|
) . '... state DOUBLEQUOTEDSTRING'); |
967
|
|
|
} |
968
|
|
|
next($yymatches); // skip global match |
969
|
|
|
$this->token = key($yymatches); // token number |
970
|
|
|
$this->value = current($yymatches); // token value |
971
|
|
|
$r = $this->{'yy_r5_' . $this->token}(); |
972
|
|
|
if ($r === null) { |
973
|
|
|
$this->counter += strlen($this->value); |
974
|
|
|
$this->line += substr_count($this->value, "\n"); |
975
|
|
|
// accept this token |
976
|
|
|
return true; |
977
|
|
|
} elseif ($r === true) { |
978
|
|
|
// we have changed state |
979
|
|
|
// process this token in the new state |
980
|
|
|
return $this->yylex(); |
981
|
|
|
} elseif ($r === false) { |
982
|
|
|
$this->counter += strlen($this->value); |
983
|
|
|
$this->line += substr_count($this->value, "\n"); |
984
|
|
|
if ($this->counter >= $this->dataLength) { |
985
|
|
|
return false; // end of input |
986
|
|
|
} |
987
|
|
|
// skip this token |
988
|
|
|
continue; |
989
|
|
|
} |
990
|
|
|
} else { |
991
|
|
|
throw new Exception('Unexpected input at line' . $this->line . |
992
|
|
|
': ' . $this->data[ $this->counter ]); |
993
|
|
|
} |
994
|
|
|
break; |
995
|
|
|
} while (true); |
996
|
|
|
} |
997
|
|
|
|
998
|
|
|
public function yy_r5_1() |
999
|
|
|
{ |
1000
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT; |
1001
|
|
|
} |
1002
|
|
|
|
1003
|
|
|
public function yy_r5_3() |
1004
|
|
|
{ |
1005
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT; |
1006
|
|
|
} |
1007
|
|
|
|
1008
|
|
|
public function yy_r5_5() |
1009
|
|
|
{ |
1010
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT; |
1011
|
|
|
} |
1012
|
|
|
|
1013
|
|
|
public function yy_r5_7() |
1014
|
|
|
{ |
1015
|
|
|
$this->yypushstate(self::TAG); |
1016
|
|
|
return true; |
1017
|
|
|
} |
1018
|
|
|
|
1019
|
|
|
public function yy_r5_9() |
1020
|
|
|
{ |
1021
|
|
|
$this->yypushstate(self::TAG); |
1022
|
|
|
return true; |
1023
|
|
|
} |
1024
|
|
|
|
1025
|
|
|
public function yy_r5_11() |
1026
|
|
|
{ |
1027
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_LDEL; |
1028
|
|
|
$this->taglineno = $this->line; |
1029
|
|
|
$this->yypushstate(self::TAGBODY); |
1030
|
|
|
} |
1031
|
|
|
|
1032
|
|
|
public function yy_r5_13() |
1033
|
|
|
{ |
1034
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; |
1035
|
|
|
$this->yypopstate(); |
1036
|
|
|
} |
1037
|
|
|
|
1038
|
|
|
public function yy_r5_14() |
1039
|
|
|
{ |
1040
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK; |
1041
|
|
|
$this->value = substr($this->value, 0, -1); |
1042
|
|
|
$this->yypushstate(self::TAGBODY); |
1043
|
|
|
$this->taglineno = $this->line; |
1044
|
|
|
} |
1045
|
|
|
|
1046
|
|
|
public function yy_r5_15() |
1047
|
|
|
{ |
1048
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID; |
1049
|
|
|
} |
1050
|
|
|
|
1051
|
|
|
public function yy_r5_16() |
1052
|
|
|
{ |
1053
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT; |
1054
|
|
|
} |
1055
|
|
|
|
1056
|
|
|
public function yy_r5_17() |
1057
|
|
|
{ |
1058
|
|
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT; |
1059
|
|
|
} |
1060
|
|
|
} |
1061
|
|
|
|
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: