Total Complexity | 155 |
Total Lines | 1020 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like Smarty_Internal_Configfileparser often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Smarty_Internal_Configfileparser, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
24 | class Smarty_Internal_Configfileparser |
||
25 | { |
||
26 | // line 25 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
27 | const TPC_OPENB = 1; |
||
28 | const TPC_SECTION = 2; |
||
29 | const TPC_CLOSEB = 3; |
||
30 | const TPC_DOT = 4; |
||
31 | const TPC_ID = 5; |
||
32 | const TPC_EQUAL = 6; |
||
33 | const TPC_FLOAT = 7; |
||
34 | const TPC_INT = 8; |
||
35 | const TPC_BOOL = 9; |
||
36 | const TPC_SINGLE_QUOTED_STRING = 10; |
||
37 | const TPC_DOUBLE_QUOTED_STRING = 11; |
||
38 | const TPC_TRIPPLE_QUOTES = 12; |
||
39 | const TPC_TRIPPLE_TEXT = 13; |
||
40 | const TPC_TRIPPLE_QUOTES_END = 14; |
||
41 | const TPC_NAKED_STRING = 15; |
||
42 | const TPC_OTHER = 16; |
||
43 | const TPC_NEWLINE = 17; |
||
44 | const TPC_COMMENTSTART = 18; |
||
45 | const YY_NO_ACTION = 60; |
||
46 | const YY_ACCEPT_ACTION = 59; |
||
47 | const YY_ERROR_ACTION = 58; |
||
48 | const YY_SZ_ACTTAB = 38; |
||
49 | const YY_SHIFT_USE_DFLT = -8; |
||
50 | const YY_SHIFT_MAX = 19; |
||
51 | const YY_REDUCE_USE_DFLT = -17; |
||
52 | const YY_REDUCE_MAX = 10; |
||
53 | const YYNOCODE = 29; |
||
54 | const YYSTACKDEPTH = 100; |
||
55 | const YYNSTATE = 36; |
||
56 | const YYNRULE = 22; |
||
57 | const YYERRORSYMBOL = 19; |
||
58 | const YYERRSYMDT = 'yy0'; |
||
59 | const YYFALLBACK = 0; |
||
60 | |||
61 | public static $yy_action = array( |
||
62 | 32, 31, 30, 29, 35, 13, 19, 3, 24, 26, |
||
63 | 59, 9, 14, 1, 16, 25, 11, 28, 25, 11, |
||
64 | 17, 27, 34, 20, 18, 15, 23, 5, 6, 22, |
||
65 | 10, 8, 4, 12, 2, 33, 7, 21, |
||
66 | ); |
||
67 | |||
68 | public static $yy_lookahead = array( |
||
69 | 7, 8, 9, 10, 11, 12, 5, 23, 15, 16, |
||
70 | 20, 21, 2, 23, 4, 17, 18, 14, 17, 18, |
||
71 | 13, 14, 25, 26, 15, 2, 17, 3, 3, 17, |
||
72 | 25, 25, 6, 1, 23, 27, 22, 24, |
||
73 | ); |
||
74 | |||
75 | public static $yy_shift_ofst = array( |
||
76 | -8, 1, 1, 1, -7, -2, -2, 32, -8, -8, |
||
77 | -8, 9, 10, 7, 25, 24, 23, 3, 12, 26, |
||
78 | ); |
||
79 | |||
80 | public static $yy_reduce_ofst = array( |
||
81 | -10, -3, -3, -3, 8, 6, 5, 13, 11, 14, |
||
82 | -16, |
||
83 | ); |
||
84 | |||
85 | public static $yyExpectedTokens = array( |
||
86 | array(), |
||
87 | array(5, 17, 18,), |
||
88 | array(5, 17, 18,), |
||
89 | array(5, 17, 18,), |
||
90 | array(7, 8, 9, 10, 11, 12, 15, 16,), |
||
91 | array(17, 18,), |
||
92 | array(17, 18,), |
||
93 | array(1,), |
||
94 | array(), |
||
95 | array(), |
||
96 | array(), |
||
97 | array(15, 17,), |
||
98 | array(2, 4,), |
||
99 | array(13, 14,), |
||
100 | array(3,), |
||
101 | array(3,), |
||
102 | array(2,), |
||
103 | array(14,), |
||
104 | array(17,), |
||
105 | array(6,), |
||
106 | array(), |
||
107 | array(), |
||
108 | array(), |
||
109 | array(), |
||
110 | array(), |
||
111 | array(), |
||
112 | array(), |
||
113 | array(), |
||
114 | array(), |
||
115 | array(), |
||
116 | array(), |
||
117 | array(), |
||
118 | array(), |
||
119 | array(), |
||
120 | array(), |
||
121 | array(), |
||
122 | ); |
||
123 | |||
124 | public static $yy_default = array( |
||
125 | 44, 37, 41, 40, 58, 58, 58, 36, 44, 39, |
||
126 | 44, 58, 58, 58, 58, 58, 58, 58, 58, 58, |
||
127 | 43, 38, 57, 56, 53, 55, 54, 52, 51, 49, |
||
128 | 48, 47, 46, 45, 42, 50, |
||
129 | ); |
||
130 | |||
131 | public static $yyFallback = array(); |
||
132 | |||
133 | public static $yyRuleName = array( |
||
134 | 'start ::= global_vars sections', |
||
135 | 'global_vars ::= var_list', |
||
136 | 'sections ::= sections section', |
||
137 | 'sections ::=', |
||
138 | 'section ::= OPENB SECTION CLOSEB newline var_list', |
||
139 | 'section ::= OPENB DOT SECTION CLOSEB newline var_list', |
||
140 | 'var_list ::= var_list newline', |
||
141 | 'var_list ::= var_list var', |
||
142 | 'var_list ::=', |
||
143 | 'var ::= ID EQUAL value', |
||
144 | 'value ::= FLOAT', |
||
145 | 'value ::= INT', |
||
146 | 'value ::= BOOL', |
||
147 | 'value ::= SINGLE_QUOTED_STRING', |
||
148 | 'value ::= DOUBLE_QUOTED_STRING', |
||
149 | 'value ::= TRIPPLE_QUOTES TRIPPLE_TEXT TRIPPLE_QUOTES_END', |
||
150 | 'value ::= TRIPPLE_QUOTES TRIPPLE_QUOTES_END', |
||
151 | 'value ::= NAKED_STRING', |
||
152 | 'value ::= OTHER', |
||
153 | 'newline ::= NEWLINE', |
||
154 | 'newline ::= COMMENTSTART NEWLINE', |
||
155 | 'newline ::= COMMENTSTART NAKED_STRING NEWLINE', |
||
156 | ); |
||
157 | |||
158 | public static $yyRuleInfo = array( |
||
159 | array(0 => 20, 1 => 2), |
||
160 | array(0 => 21, 1 => 1), |
||
161 | array(0 => 22, 1 => 2), |
||
162 | array(0 => 22, 1 => 0), |
||
163 | array(0 => 24, 1 => 5), |
||
164 | array(0 => 24, 1 => 6), |
||
165 | array(0 => 23, 1 => 2), |
||
166 | array(0 => 23, 1 => 2), |
||
167 | array(0 => 23, 1 => 0), |
||
168 | array(0 => 26, 1 => 3), |
||
169 | array(0 => 27, 1 => 1), |
||
170 | array(0 => 27, 1 => 1), |
||
171 | array(0 => 27, 1 => 1), |
||
172 | array(0 => 27, 1 => 1), |
||
173 | array(0 => 27, 1 => 1), |
||
174 | array(0 => 27, 1 => 3), |
||
175 | array(0 => 27, 1 => 2), |
||
176 | array(0 => 27, 1 => 1), |
||
177 | array(0 => 27, 1 => 1), |
||
178 | array(0 => 25, 1 => 1), |
||
179 | array(0 => 25, 1 => 2), |
||
180 | array(0 => 25, 1 => 3), |
||
181 | ); |
||
182 | |||
183 | public static $yyReduceMap = array( |
||
184 | 0 => 0, |
||
185 | 2 => 0, |
||
186 | 3 => 0, |
||
187 | 19 => 0, |
||
188 | 20 => 0, |
||
189 | 21 => 0, |
||
190 | 1 => 1, |
||
191 | 4 => 4, |
||
192 | 5 => 5, |
||
193 | 6 => 6, |
||
194 | 7 => 7, |
||
195 | 8 => 8, |
||
196 | 9 => 9, |
||
197 | 10 => 10, |
||
198 | 11 => 11, |
||
199 | 12 => 12, |
||
200 | 13 => 13, |
||
201 | 14 => 14, |
||
202 | 15 => 15, |
||
203 | 16 => 16, |
||
204 | 17 => 17, |
||
205 | 18 => 17, |
||
206 | ); |
||
207 | |||
208 | /** |
||
209 | * helper map |
||
210 | * |
||
211 | * @var array |
||
212 | */ |
||
213 | private static $escapes_single = array( |
||
214 | '\\' => '\\', |
||
215 | '\'' => '\'' |
||
216 | ); |
||
217 | |||
218 | /** |
||
219 | * result status |
||
220 | * |
||
221 | * @var bool |
||
222 | */ |
||
223 | public $successful = true; |
||
224 | |||
225 | /** |
||
226 | * return value |
||
227 | * |
||
228 | * @var mixed |
||
229 | */ |
||
230 | public $retvalue = 0; |
||
231 | |||
232 | /** |
||
233 | * @var |
||
234 | */ |
||
235 | public $yymajor; |
||
236 | |||
237 | /** |
||
238 | * compiler object |
||
239 | * |
||
240 | * @var Smarty_Internal_Config_File_Compiler |
||
241 | */ |
||
242 | public $compiler = null; |
||
243 | |||
244 | /** |
||
245 | * smarty object |
||
246 | * |
||
247 | * @var Smarty |
||
248 | */ |
||
249 | public $smarty = null; |
||
250 | |||
251 | public $yyTraceFILE; |
||
252 | |||
253 | public $yyTracePrompt; |
||
254 | |||
255 | public $yyidx; |
||
256 | |||
257 | public $yyerrcnt; |
||
258 | |||
259 | public $yystack = array(); |
||
260 | |||
261 | public $yyTokenName = array( |
||
262 | '$', 'OPENB', 'SECTION', 'CLOSEB', |
||
263 | 'DOT', 'ID', 'EQUAL', 'FLOAT', |
||
264 | 'INT', 'BOOL', 'SINGLE_QUOTED_STRING', 'DOUBLE_QUOTED_STRING', |
||
265 | 'TRIPPLE_QUOTES', 'TRIPPLE_TEXT', 'TRIPPLE_QUOTES_END', 'NAKED_STRING', |
||
266 | 'OTHER', 'NEWLINE', 'COMMENTSTART', 'error', |
||
267 | 'start', 'global_vars', 'sections', 'var_list', |
||
268 | 'section', 'newline', 'var', 'value', |
||
269 | ); |
||
270 | |||
271 | /** |
||
272 | * lexer object |
||
273 | * |
||
274 | * @var Smarty_Internal_Configfilelexer |
||
275 | */ |
||
276 | private $lex; |
||
277 | |||
278 | /** |
||
279 | * internal error flag |
||
280 | * |
||
281 | * @var bool |
||
282 | */ |
||
283 | private $internalError = false; |
||
284 | |||
285 | /** |
||
286 | * copy of config_overwrite property |
||
287 | * |
||
288 | * @var bool |
||
289 | */ |
||
290 | private $configOverwrite = false; |
||
291 | |||
292 | /** |
||
293 | * copy of config_read_hidden property |
||
294 | * |
||
295 | * @var bool |
||
296 | */ |
||
297 | private $configReadHidden = false; |
||
298 | |||
299 | private $_retvalue; |
||
300 | |||
301 | /** |
||
302 | * constructor |
||
303 | * |
||
304 | * @param Smarty_Internal_Configfilelexer $lex |
||
305 | * @param Smarty_Internal_Config_File_Compiler $compiler |
||
306 | */ |
||
307 | public function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler) |
||
308 | { |
||
309 | $this->lex = $lex; |
||
310 | $this->smarty = $compiler->smarty; |
||
311 | $this->compiler = $compiler; |
||
312 | $this->configOverwrite = $this->smarty->config_overwrite; |
||
313 | $this->configReadHidden = $this->smarty->config_read_hidden; |
||
314 | } |
||
315 | |||
316 | public static function yy_destructor($yymajor, $yypminor) |
||
317 | { |
||
318 | switch ($yymajor) { |
||
319 | default: |
||
320 | break; /* If no destructor action specified: do nothing */ |
||
321 | } |
||
322 | } |
||
323 | |||
324 | /** |
||
325 | * parse single quoted string |
||
326 | * remove outer quotes |
||
327 | * unescape inner quotes |
||
328 | * |
||
329 | * @param string $qstr |
||
330 | * |
||
331 | * @return string |
||
332 | */ |
||
333 | private static function parse_single_quoted_string($qstr) |
||
334 | { |
||
335 | $escaped_string = substr($qstr, 1, strlen($qstr) - 2); //remove outer quotes |
||
336 | $ss = preg_split('/(\\\\.)/', $escaped_string, -1, PREG_SPLIT_DELIM_CAPTURE); |
||
337 | $str = ''; |
||
338 | foreach ($ss as $s) { |
||
339 | if (strlen($s) === 2 && $s[ 0 ] === '\\') { |
||
340 | if (isset(self::$escapes_single[ $s[ 1 ] ])) { |
||
341 | $s = self::$escapes_single[ $s[ 1 ] ]; |
||
342 | } |
||
343 | } |
||
344 | $str .= $s; |
||
345 | } |
||
346 | return $str; |
||
347 | } /* Index of top element in stack */ |
||
348 | /** |
||
349 | * parse double quoted string |
||
350 | * |
||
351 | * @param string $qstr |
||
352 | * |
||
353 | * @return string |
||
354 | */ |
||
355 | private static function parse_double_quoted_string($qstr) |
||
356 | { |
||
357 | $inner_str = substr($qstr, 1, strlen($qstr) - 2); |
||
358 | return stripcslashes($inner_str); |
||
359 | } /* Shifts left before out of the error */ |
||
360 | /** |
||
361 | * parse triple quoted string |
||
362 | * |
||
363 | * @param string $qstr |
||
364 | * |
||
365 | * @return string |
||
366 | */ |
||
367 | private static function parse_tripple_double_quoted_string($qstr) |
||
368 | { |
||
369 | return stripcslashes($qstr); |
||
370 | } /* The parser's stack */ |
||
371 | public function Trace($TraceFILE, $zTracePrompt) |
||
372 | { |
||
373 | if (!$TraceFILE) { |
||
374 | $zTracePrompt = 0; |
||
375 | } elseif (!$zTracePrompt) { |
||
376 | $TraceFILE = 0; |
||
377 | } |
||
378 | $this->yyTraceFILE = $TraceFILE; |
||
379 | $this->yyTracePrompt = $zTracePrompt; |
||
380 | } |
||
381 | |||
382 | public function PrintTrace() |
||
383 | { |
||
384 | $this->yyTraceFILE = fopen('php://output', 'w'); |
||
385 | $this->yyTracePrompt = '<br>'; |
||
386 | } |
||
387 | |||
388 | public function tokenName($tokenType) |
||
389 | { |
||
390 | if ($tokenType === 0) { |
||
391 | return 'End of Input'; |
||
392 | } |
||
393 | if ($tokenType > 0 && $tokenType < count($this->yyTokenName)) { |
||
394 | return $this->yyTokenName[ $tokenType ]; |
||
395 | } else { |
||
396 | return 'Unknown'; |
||
397 | } |
||
398 | } |
||
399 | |||
400 | public function yy_pop_parser_stack() |
||
401 | { |
||
402 | if (empty($this->yystack)) { |
||
403 | return; |
||
404 | } |
||
405 | $yytos = array_pop($this->yystack); |
||
406 | if ($this->yyTraceFILE && $this->yyidx >= 0) { |
||
407 | fwrite( |
||
408 | $this->yyTraceFILE, |
||
409 | $this->yyTracePrompt . 'Popping ' . $this->yyTokenName[ $yytos->major ] . |
||
410 | "\n" |
||
411 | ); |
||
412 | } |
||
413 | $yymajor = $yytos->major; |
||
414 | self::yy_destructor($yymajor, $yytos->minor); |
||
415 | $this->yyidx--; |
||
416 | return $yymajor; |
||
417 | } |
||
418 | |||
419 | public function __destruct() |
||
420 | { |
||
421 | while ($this->yystack !== array()) { |
||
422 | $this->yy_pop_parser_stack(); |
||
423 | } |
||
424 | if (is_resource($this->yyTraceFILE)) { |
||
425 | fclose($this->yyTraceFILE); |
||
426 | } |
||
427 | } |
||
428 | |||
429 | public function yy_get_expected_tokens($token) |
||
430 | { |
||
431 | static $res3 = array(); |
||
432 | static $res4 = array(); |
||
433 | $state = $this->yystack[ $this->yyidx ]->stateno; |
||
434 | $expected = self::$yyExpectedTokens[ $state ]; |
||
435 | if (isset($res3[ $state ][ $token ])) { |
||
436 | if ($res3[ $state ][ $token ]) { |
||
437 | return $expected; |
||
438 | } |
||
439 | } else { |
||
440 | if ($res3[ $state ][ $token ] = in_array($token, self::$yyExpectedTokens[ $state ], true)) { |
||
441 | return $expected; |
||
442 | } |
||
443 | } |
||
444 | $stack = $this->yystack; |
||
445 | $yyidx = $this->yyidx; |
||
446 | do { |
||
447 | $yyact = $this->yy_find_shift_action($token); |
||
448 | if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) { |
||
449 | // reduce action |
||
450 | $done = 0; |
||
451 | do { |
||
452 | if ($done++ === 100) { |
||
453 | $this->yyidx = $yyidx; |
||
454 | $this->yystack = $stack; |
||
455 | // too much recursion prevents proper detection |
||
456 | // so give up |
||
457 | return array_unique($expected); |
||
458 | } |
||
459 | $yyruleno = $yyact - self::YYNSTATE; |
||
460 | $this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ]; |
||
461 | $nextstate = $this->yy_find_reduce_action( |
||
462 | $this->yystack[ $this->yyidx ]->stateno, |
||
463 | self::$yyRuleInfo[ $yyruleno ][ 0 ] |
||
464 | ); |
||
465 | if (isset(self::$yyExpectedTokens[ $nextstate ])) { |
||
466 | $expected = array_merge($expected, self::$yyExpectedTokens[ $nextstate ]); |
||
467 | if (isset($res4[ $nextstate ][ $token ])) { |
||
468 | if ($res4[ $nextstate ][ $token ]) { |
||
469 | $this->yyidx = $yyidx; |
||
470 | $this->yystack = $stack; |
||
471 | return array_unique($expected); |
||
472 | } |
||
473 | } else { |
||
474 | if ($res4[ $nextstate ][ $token ] = |
||
475 | in_array($token, self::$yyExpectedTokens[ $nextstate ], true)) { |
||
476 | $this->yyidx = $yyidx; |
||
477 | $this->yystack = $stack; |
||
478 | return array_unique($expected); |
||
479 | } |
||
480 | } |
||
481 | } |
||
482 | if ($nextstate < self::YYNSTATE) { |
||
483 | // we need to shift a non-terminal |
||
484 | $this->yyidx++; |
||
485 | $x = new TPC_yyStackEntry; |
||
486 | $x->stateno = $nextstate; |
||
487 | $x->major = self::$yyRuleInfo[ $yyruleno ][ 0 ]; |
||
488 | $this->yystack[ $this->yyidx ] = $x; |
||
489 | continue 2; |
||
490 | } elseif ($nextstate === self::YYNSTATE + self::YYNRULE + 1) { |
||
491 | $this->yyidx = $yyidx; |
||
492 | $this->yystack = $stack; |
||
493 | // the last token was just ignored, we can't accept |
||
494 | // by ignoring input, this is in essence ignoring a |
||
495 | // syntax error! |
||
496 | return array_unique($expected); |
||
497 | } elseif ($nextstate === self::YY_NO_ACTION) { |
||
498 | $this->yyidx = $yyidx; |
||
499 | $this->yystack = $stack; |
||
500 | // input accepted, but not shifted (I guess) |
||
501 | return $expected; |
||
502 | } else { |
||
503 | $yyact = $nextstate; |
||
504 | } |
||
505 | } while (true); |
||
506 | } |
||
507 | break; |
||
508 | } while (true); |
||
509 | $this->yyidx = $yyidx; |
||
510 | $this->yystack = $stack; |
||
511 | return array_unique($expected); |
||
512 | } |
||
513 | |||
514 | public function yy_is_expected_token($token) |
||
515 | { |
||
516 | static $res = array(); |
||
517 | static $res2 = array(); |
||
518 | if ($token === 0) { |
||
519 | return true; // 0 is not part of this |
||
520 | } |
||
521 | $state = $this->yystack[ $this->yyidx ]->stateno; |
||
522 | if (isset($res[ $state ][ $token ])) { |
||
523 | if ($res[ $state ][ $token ]) { |
||
524 | return true; |
||
525 | } |
||
526 | } else { |
||
527 | if ($res[ $state ][ $token ] = in_array($token, self::$yyExpectedTokens[ $state ], true)) { |
||
528 | return true; |
||
529 | } |
||
530 | } |
||
531 | $stack = $this->yystack; |
||
532 | $yyidx = $this->yyidx; |
||
533 | do { |
||
534 | $yyact = $this->yy_find_shift_action($token); |
||
535 | if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) { |
||
536 | // reduce action |
||
537 | $done = 0; |
||
538 | do { |
||
539 | if ($done++ === 100) { |
||
540 | $this->yyidx = $yyidx; |
||
541 | $this->yystack = $stack; |
||
542 | // too much recursion prevents proper detection |
||
543 | // so give up |
||
544 | return true; |
||
545 | } |
||
546 | $yyruleno = $yyact - self::YYNSTATE; |
||
547 | $this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ]; |
||
548 | $nextstate = $this->yy_find_reduce_action( |
||
549 | $this->yystack[ $this->yyidx ]->stateno, |
||
550 | self::$yyRuleInfo[ $yyruleno ][ 0 ] |
||
551 | ); |
||
552 | if (isset($res2[ $nextstate ][ $token ])) { |
||
553 | if ($res2[ $nextstate ][ $token ]) { |
||
554 | $this->yyidx = $yyidx; |
||
555 | $this->yystack = $stack; |
||
556 | return true; |
||
557 | } |
||
558 | } else { |
||
559 | if ($res2[ $nextstate ][ $token ] = |
||
560 | (isset(self::$yyExpectedTokens[ $nextstate ]) && |
||
561 | in_array($token, self::$yyExpectedTokens[ $nextstate ], true))) { |
||
562 | $this->yyidx = $yyidx; |
||
563 | $this->yystack = $stack; |
||
564 | return true; |
||
565 | } |
||
566 | } |
||
567 | if ($nextstate < self::YYNSTATE) { |
||
568 | // we need to shift a non-terminal |
||
569 | $this->yyidx++; |
||
570 | $x = new TPC_yyStackEntry; |
||
571 | $x->stateno = $nextstate; |
||
572 | $x->major = self::$yyRuleInfo[ $yyruleno ][ 0 ]; |
||
573 | $this->yystack[ $this->yyidx ] = $x; |
||
574 | continue 2; |
||
575 | } elseif ($nextstate === self::YYNSTATE + self::YYNRULE + 1) { |
||
576 | $this->yyidx = $yyidx; |
||
577 | $this->yystack = $stack; |
||
578 | if (!$token) { |
||
579 | // end of input: this is valid |
||
580 | return true; |
||
581 | } |
||
582 | // the last token was just ignored, we can't accept |
||
583 | // by ignoring input, this is in essence ignoring a |
||
584 | // syntax error! |
||
585 | return false; |
||
586 | } elseif ($nextstate === self::YY_NO_ACTION) { |
||
587 | $this->yyidx = $yyidx; |
||
588 | $this->yystack = $stack; |
||
589 | // input accepted, but not shifted (I guess) |
||
590 | return true; |
||
591 | } else { |
||
592 | $yyact = $nextstate; |
||
593 | } |
||
594 | } while (true); |
||
595 | } |
||
596 | break; |
||
597 | } while (true); |
||
598 | $this->yyidx = $yyidx; |
||
599 | $this->yystack = $stack; |
||
600 | return true; |
||
601 | } |
||
602 | |||
603 | public function yy_find_shift_action($iLookAhead) |
||
604 | { |
||
605 | $stateno = $this->yystack[ $this->yyidx ]->stateno; |
||
606 | /* if ($this->yyidx < 0) return self::YY_NO_ACTION; */ |
||
607 | if (!isset(self::$yy_shift_ofst[ $stateno ])) { |
||
608 | // no shift actions |
||
609 | return self::$yy_default[ $stateno ]; |
||
610 | } |
||
611 | $i = self::$yy_shift_ofst[ $stateno ]; |
||
612 | if ($i === self::YY_SHIFT_USE_DFLT) { |
||
613 | return self::$yy_default[ $stateno ]; |
||
614 | } |
||
615 | if ($iLookAhead === self::YYNOCODE) { |
||
616 | return self::YY_NO_ACTION; |
||
617 | } |
||
618 | $i += $iLookAhead; |
||
619 | if ($i < 0 || $i >= self::YY_SZ_ACTTAB || |
||
620 | self::$yy_lookahead[ $i ] != $iLookAhead) { |
||
621 | if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback) |
||
622 | && ($iFallback = self::$yyFallback[ $iLookAhead ]) != 0) { |
||
623 | if ($this->yyTraceFILE) { |
||
624 | fwrite($this->yyTraceFILE, $this->yyTracePrompt . 'FALLBACK ' . |
||
625 | $this->yyTokenName[ $iLookAhead ] . ' => ' . |
||
626 | $this->yyTokenName[ $iFallback ] . "\n"); |
||
627 | } |
||
628 | return $this->yy_find_shift_action($iFallback); |
||
629 | } |
||
630 | return self::$yy_default[ $stateno ]; |
||
631 | } else { |
||
632 | return self::$yy_action[ $i ]; |
||
633 | } |
||
634 | } |
||
635 | |||
636 | public function yy_find_reduce_action($stateno, $iLookAhead) |
||
637 | { |
||
638 | /* $stateno = $this->yystack[$this->yyidx]->stateno; */ |
||
639 | if (!isset(self::$yy_reduce_ofst[ $stateno ])) { |
||
640 | return self::$yy_default[ $stateno ]; |
||
641 | } |
||
642 | $i = self::$yy_reduce_ofst[ $stateno ]; |
||
643 | if ($i === self::YY_REDUCE_USE_DFLT) { |
||
644 | return self::$yy_default[ $stateno ]; |
||
645 | } |
||
646 | if ($iLookAhead === self::YYNOCODE) { |
||
647 | return self::YY_NO_ACTION; |
||
648 | } |
||
649 | $i += $iLookAhead; |
||
650 | if ($i < 0 || $i >= self::YY_SZ_ACTTAB || |
||
651 | self::$yy_lookahead[ $i ] != $iLookAhead) { |
||
652 | return self::$yy_default[ $stateno ]; |
||
653 | } else { |
||
654 | return self::$yy_action[ $i ]; |
||
655 | } |
||
656 | } |
||
657 | |||
658 | public function yy_shift($yyNewState, $yyMajor, $yypMinor) |
||
659 | { |
||
660 | $this->yyidx++; |
||
661 | if ($this->yyidx >= self::YYSTACKDEPTH) { |
||
662 | $this->yyidx--; |
||
663 | if ($this->yyTraceFILE) { |
||
664 | fprintf($this->yyTraceFILE, "%sStack Overflow!\n", $this->yyTracePrompt); |
||
665 | } |
||
666 | while ($this->yyidx >= 0) { |
||
667 | $this->yy_pop_parser_stack(); |
||
668 | } |
||
669 | // line 239 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
670 | $this->internalError = true; |
||
671 | $this->compiler->trigger_config_file_error('Stack overflow in configfile parser'); |
||
672 | return; |
||
673 | } |
||
674 | $yytos = new TPC_yyStackEntry; |
||
675 | $yytos->stateno = $yyNewState; |
||
676 | $yytos->major = $yyMajor; |
||
677 | $yytos->minor = $yypMinor; |
||
678 | $this->yystack[] = $yytos; |
||
679 | if ($this->yyTraceFILE && $this->yyidx > 0) { |
||
680 | fprintf( |
||
681 | $this->yyTraceFILE, |
||
682 | "%sShift %d\n", |
||
683 | $this->yyTracePrompt, |
||
684 | $yyNewState |
||
685 | ); |
||
686 | fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt); |
||
687 | for ($i = 1; $i <= $this->yyidx; $i++) { |
||
688 | fprintf( |
||
689 | $this->yyTraceFILE, |
||
690 | " %s", |
||
691 | $this->yyTokenName[ $this->yystack[ $i ]->major ] |
||
692 | ); |
||
693 | } |
||
694 | fwrite($this->yyTraceFILE, "\n"); |
||
695 | } |
||
696 | } |
||
697 | |||
698 | public function yy_r0() |
||
699 | { |
||
700 | $this->_retvalue = null; |
||
701 | } |
||
702 | |||
703 | public function yy_r1() |
||
704 | { |
||
705 | $this->add_global_vars($this->yystack[ $this->yyidx + 0 ]->minor); |
||
706 | $this->_retvalue = null; |
||
707 | } |
||
708 | |||
709 | public function yy_r4() |
||
710 | { |
||
711 | $this->add_section_vars($this->yystack[ $this->yyidx + -3 ]->minor, $this->yystack[ $this->yyidx + 0 ]->minor); |
||
712 | $this->_retvalue = null; |
||
713 | } |
||
714 | |||
715 | // line 245 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
716 | public function yy_r5() |
||
717 | { |
||
718 | if ($this->configReadHidden) { |
||
719 | $this->add_section_vars( |
||
720 | $this->yystack[ $this->yyidx + -3 ]->minor, |
||
721 | $this->yystack[ $this->yyidx + 0 ]->minor |
||
722 | ); |
||
723 | } |
||
724 | $this->_retvalue = null; |
||
725 | } |
||
726 | |||
727 | // line 250 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
728 | public function yy_r6() |
||
729 | { |
||
730 | $this->_retvalue = $this->yystack[ $this->yyidx + -1 ]->minor; |
||
731 | } |
||
732 | |||
733 | // line 264 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
734 | public function yy_r7() |
||
735 | { |
||
736 | $this->_retvalue = |
||
737 | array_merge($this->yystack[ $this->yyidx + -1 ]->minor, array($this->yystack[ $this->yyidx + 0 ]->minor)); |
||
738 | } |
||
739 | |||
740 | // line 269 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
741 | public function yy_r8() |
||
742 | { |
||
743 | $this->_retvalue = array(); |
||
744 | } |
||
745 | |||
746 | // line 277 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
747 | public function yy_r9() |
||
748 | { |
||
749 | $this->_retvalue = |
||
750 | array( |
||
751 | 'key' => $this->yystack[ $this->yyidx + -2 ]->minor, |
||
752 | 'value' => $this->yystack[ $this->yyidx + 0 ]->minor |
||
753 | ); |
||
754 | } |
||
755 | |||
756 | // line 281 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
757 | public function yy_r10() |
||
758 | { |
||
759 | $this->_retvalue = (float)$this->yystack[ $this->yyidx + 0 ]->minor; |
||
760 | } |
||
761 | |||
762 | // line 285 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
763 | public function yy_r11() |
||
764 | { |
||
765 | $this->_retvalue = (int)$this->yystack[ $this->yyidx + 0 ]->minor; |
||
766 | } |
||
767 | |||
768 | // line 291 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
769 | public function yy_r12() |
||
770 | { |
||
771 | $this->_retvalue = $this->parse_bool($this->yystack[ $this->yyidx + 0 ]->minor); |
||
772 | } |
||
773 | |||
774 | // line 296 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
775 | public function yy_r13() |
||
776 | { |
||
777 | $this->_retvalue = self::parse_single_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor); |
||
778 | } |
||
779 | |||
780 | // line 300 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
781 | public function yy_r14() |
||
782 | { |
||
783 | $this->_retvalue = self::parse_double_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor); |
||
784 | } |
||
785 | |||
786 | // line 304 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
787 | public function yy_r15() |
||
788 | { |
||
789 | $this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[ $this->yyidx + -1 ]->minor); |
||
790 | } |
||
791 | |||
792 | // line 308 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
793 | public function yy_r16() |
||
794 | { |
||
795 | $this->_retvalue = ''; |
||
796 | } |
||
797 | |||
798 | // line 312 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
799 | public function yy_r17() |
||
800 | { |
||
801 | $this->_retvalue = $this->yystack[ $this->yyidx + 0 ]->minor; |
||
802 | } |
||
803 | |||
804 | // line 316 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
805 | public function yy_reduce($yyruleno) |
||
806 | { |
||
807 | if ($this->yyTraceFILE && $yyruleno >= 0 |
||
808 | && $yyruleno < count(self::$yyRuleName)) { |
||
809 | fprintf( |
||
810 | $this->yyTraceFILE, |
||
811 | "%sReduce (%d) [%s].\n", |
||
812 | $this->yyTracePrompt, |
||
813 | $yyruleno, |
||
814 | self::$yyRuleName[ $yyruleno ] |
||
815 | ); |
||
816 | } |
||
817 | $this->_retvalue = $yy_lefthand_side = null; |
||
818 | if (isset(self::$yyReduceMap[ $yyruleno ])) { |
||
819 | // call the action |
||
820 | $this->_retvalue = null; |
||
821 | $this->{'yy_r' . self::$yyReduceMap[ $yyruleno ]}(); |
||
822 | $yy_lefthand_side = $this->_retvalue; |
||
823 | } |
||
824 | $yygoto = self::$yyRuleInfo[ $yyruleno ][ 0 ]; |
||
825 | $yysize = self::$yyRuleInfo[ $yyruleno ][ 1 ]; |
||
826 | $this->yyidx -= $yysize; |
||
827 | for ($i = $yysize; $i; $i--) { |
||
828 | // pop all of the right-hand side parameters |
||
829 | array_pop($this->yystack); |
||
830 | } |
||
831 | $yyact = $this->yy_find_reduce_action($this->yystack[ $this->yyidx ]->stateno, $yygoto); |
||
832 | if ($yyact < self::YYNSTATE) { |
||
833 | if (!$this->yyTraceFILE && $yysize) { |
||
834 | $this->yyidx++; |
||
835 | $x = new TPC_yyStackEntry; |
||
836 | $x->stateno = $yyact; |
||
837 | $x->major = $yygoto; |
||
838 | $x->minor = $yy_lefthand_side; |
||
839 | $this->yystack[ $this->yyidx ] = $x; |
||
840 | } else { |
||
841 | $this->yy_shift($yyact, $yygoto, $yy_lefthand_side); |
||
842 | } |
||
843 | } elseif ($yyact === self::YYNSTATE + self::YYNRULE + 1) { |
||
844 | $this->yy_accept(); |
||
845 | } |
||
846 | } |
||
847 | |||
848 | // line 320 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
849 | public function yy_parse_failed() |
||
850 | { |
||
851 | if ($this->yyTraceFILE) { |
||
852 | fprintf($this->yyTraceFILE, "%sFail!\n", $this->yyTracePrompt); |
||
853 | } |
||
854 | while ($this->yyidx >= 0) { |
||
855 | $this->yy_pop_parser_stack(); |
||
856 | } |
||
857 | } |
||
858 | |||
859 | // line 324 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
860 | public function yy_syntax_error($yymajor, $TOKEN) |
||
861 | { |
||
862 | // line 232 "../smarty/lexer/smarty_internal_configfileparser.y" |
||
863 | $this->internalError = true; |
||
864 | $this->yymajor = $yymajor; |
||
865 | $this->compiler->trigger_config_file_error(); |
||
866 | } |
||
867 | |||
868 | public function yy_accept() |
||
880 | } |
||
881 | |||
882 | public function doParse($yymajor, $yytokenvalue) |
||
883 | { |
||
884 | $yyerrorhit = 0; /* True if yymajor has invoked an error */ |
||
885 | if ($this->yyidx === null || $this->yyidx < 0) { |
||
886 | $this->yyidx = 0; |
||
887 | $this->yyerrcnt = -1; |
||
888 | $x = new TPC_yyStackEntry; |
||
889 | $x->stateno = 0; |
||
890 | $x->major = 0; |
||
891 | $this->yystack = array(); |
||
892 | $this->yystack[] = $x; |
||
893 | } |
||
894 | $yyendofinput = ($yymajor == 0); |
||
895 | if ($this->yyTraceFILE) { |
||
896 | fprintf( |
||
978 | } |
||
979 | |||
980 | /** |
||
981 | * parse optional boolean keywords |
||
982 | * |
||
983 | * @param string $str |
||
984 | * |
||
985 | * @return bool |
||
986 | */ |
||
987 | private function parse_bool($str) |
||
988 | { |
||
989 | $str = strtolower($str); |
||
990 | if (in_array($str, array('on', 'yes', 'true'))) { |
||
991 | $res = true; |
||
992 | } else { |
||
993 | $res = false; |
||
994 | } |
||
995 | return $res; |
||
996 | } |
||
997 | |||
998 | /** |
||
999 | * set a config variable in target array |
||
1000 | * |
||
1001 | * @param array $var |
||
1002 | * @param array $target_array |
||
1003 | */ |
||
1004 | private function set_var(array $var, array &$target_array) |
||
1005 | { |
||
1006 | $key = $var[ 'key' ]; |
||
1007 | $value = $var[ 'value' ]; |
||
1008 | if ($this->configOverwrite || !isset($target_array[ 'vars' ][ $key ])) { |
||
1009 | $target_array[ 'vars' ][ $key ] = $value; |
||
1010 | } else { |
||
1011 | settype($target_array[ 'vars' ][ $key ], 'array'); |
||
1012 | $target_array[ 'vars' ][ $key ][] = $value; |
||
1013 | } |
||
1014 | } |
||
1015 | |||
1016 | /** |
||
1017 | * add config variable to global vars |
||
1018 | * |
||
1019 | * @param array $vars |
||
1020 | */ |
||
1021 | private function add_global_vars(array $vars) |
||
1028 | } |
||
1029 | } |
||
1030 | |||
1031 | /** |
||
1032 | * add config variable to section |
||
1033 | * |
||
1034 | * @param string $section_name |
||
1035 | * @param array $vars |
||
1036 | */ |
||
1037 | private function add_section_vars($section_name, array $vars) |
||
1044 | } |
||
1045 | } |
||
1046 | } |
||
1047 |