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