update to smarty v3.1.24
[GitHub/Stricted/Domain-Control-Panel.git] / lib / api / smarty / sysplugins / smarty_internal_configfilelexer.php
1 <?php
2 /**
3 * Smarty Internal Plugin Configfilelexer
4 *
5 * This is the lexer to break the config file source into tokens
6 *
7 * @package Smarty
8 * @subpackage Config
9 * @author Uwe Tews
10 */
11
12 /**
13 * Smarty_Internal_Configfilelexer
14 *
15 * This is the config file lexer.
16 * It is generated from the smarty_internal_configfilelexer.plex file
17 *
18 * @package Smarty
19 * @subpackage Compiler
20 * @author Uwe Tews
21 */
22 class Smarty_Internal_Configfilelexer
23 {
24
25 /**
26 * Source
27 *
28 * @var string
29 */
30 public $data;
31
32 /**
33 * byte counter
34 *
35 * @var int
36 */
37 public $counter;
38
39 /**
40 * token number
41 *
42 * @var int
43 */
44 public $token;
45
46 /**
47 * token value
48 *
49 * @var string
50 */
51 public $value;
52
53 /**
54 * current line
55 *
56 * @var int
57 */
58 public $line;
59
60 /**
61 * state number
62 *
63 * @var int
64 */
65 public $state = 1;
66
67 /**
68 * Smarty object
69 *
70 * @var Smarty
71 */
72 public $smarty = null;
73
74 /**
75 * compiler object
76 *
77 * @var Smarty_Internal_Config_File_Compiler
78 */
79 private $compiler = null;
80
81 /**
82 * copy of config_booleanize
83 *
84 * @var bool
85 */
86 private $configBooleanize = false;
87
88 /**
89 * trace file
90 *
91 * @var resource
92 */
93 public $yyTraceFILE;
94
95 /**
96 * trace prompt
97 *
98 * @var string
99 */
100 public $yyTracePrompt;
101
102 /**
103 * state names
104 *
105 * @var array
106 */
107 public $state_name = array(1 => 'START', 2 => 'VALUE', 3 => 'NAKED_STRING_VALUE', 4 => 'COMMENT', 5 => 'SECTION', 6 => 'TRIPPLE');
108
109 /**
110 * storage for assembled token patterns
111 *
112 * @var sring
113 */
114 private $yy_global_pattern1 = null;
115
116 private $yy_global_pattern2 = null;
117
118 private $yy_global_pattern3 = null;
119
120 private $yy_global_pattern4 = null;
121
122 private $yy_global_pattern5 = null;
123
124 private $yy_global_pattern6 = null;
125
126 /**
127 * token names
128 *
129 * @var array
130 */
131 public $smarty_token_names = array( // Text for parser error messages
132 );
133
134 /**
135 * constructor
136 *
137 * @param string $data template source
138 * @param Smarty_Internal_Config_File_Compiler $compiler
139 */
140 function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
141 {
142 // set instance object
143 self::instance($this);
144 $this->data = $data . "\n"; //now all lines are \n-terminated
145 $this->counter = 0;
146 if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) {
147 $this->counter += strlen($match[0]);
148 }
149 $this->line = 1;
150 $this->compiler = $compiler;
151 $this->smarty = $compiler->smarty;
152 $this->configBooleanize = $this->smarty->config_booleanize;
153 }
154
155 public static function &instance($new_instance = null)
156 {
157 static $instance = null;
158 if (isset($new_instance) && is_object($new_instance)) {
159 $instance = $new_instance;
160 }
161 return $instance;
162 }
163
164 public function PrintTrace()
165 {
166 $this->yyTraceFILE = fopen('php://output', 'w');
167 $this->yyTracePrompt = '<br>';
168 }
169
170 private $_yy_state = 1;
171
172 private $_yy_stack = array();
173
174 public function yylex()
175 {
176 return $this->{'yylex' . $this->_yy_state}();
177 }
178
179 public function yypushstate($state)
180 {
181 if ($this->yyTraceFILE) {
182 fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
183 }
184 array_push($this->_yy_stack, $this->_yy_state);
185 $this->_yy_state = $state;
186 if ($this->yyTraceFILE) {
187 fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
188 }
189 }
190
191 public function yypopstate()
192 {
193 if ($this->yyTraceFILE) {
194 fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
195 }
196 $this->_yy_state = array_pop($this->_yy_stack);
197 if ($this->yyTraceFILE) {
198 fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
199 }
200 }
201
202 public function yybegin($state)
203 {
204 $this->_yy_state = $state;
205 if ($this->yyTraceFILE) {
206 fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
207 }
208 }
209
210 public function yylex1()
211 {
212 if (!isset($this->yy_global_pattern1)) {
213 $this->yy_global_pattern1 = "/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/iS";
214 }
215 if ($this->counter >= strlen($this->data)) {
216 return false; // end of input
217 }
218
219 do {
220 if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) {
221 $yysubmatches = $yymatches;
222 $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
223 if (empty($yymatches)) {
224 throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state START');
225 }
226 next($yymatches); // skip global match
227 $this->token = key($yymatches); // token number
228 $this->value = current($yymatches); // token value
229 $r = $this->{'yy_r1_' . $this->token}();
230 if ($r === null) {
231 $this->counter += strlen($this->value);
232 $this->line += substr_count($this->value, "\n");
233 // accept this token
234 return true;
235 } elseif ($r === true) {
236 // we have changed state
237 // process this token in the new state
238 return $this->yylex();
239 } elseif ($r === false) {
240 $this->counter += strlen($this->value);
241 $this->line += substr_count($this->value, "\n");
242 if ($this->counter >= strlen($this->data)) {
243 return false; // end of input
244 }
245 // skip this token
246 continue;
247 }
248 } else {
249 throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
250 }
251 break;
252 } while (true);
253 } // end function
254
255 const START = 1;
256
257 function yy_r1_1()
258 {
259
260 $this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART;
261 $this->yypushstate(self::COMMENT);
262 }
263
264 function yy_r1_2()
265 {
266
267 $this->token = Smarty_Internal_Configfileparser::TPC_OPENB;
268 $this->yypushstate(self::SECTION);
269 }
270
271 function yy_r1_3()
272 {
273
274 $this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB;
275 }
276
277 function yy_r1_4()
278 {
279
280 $this->token = Smarty_Internal_Configfileparser::TPC_EQUAL;
281 $this->yypushstate(self::VALUE);
282 }
283
284 function yy_r1_5()
285 {
286
287 return false;
288 }
289
290 function yy_r1_6()
291 {
292
293 $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
294 }
295
296 function yy_r1_7()
297 {
298
299 $this->token = Smarty_Internal_Configfileparser::TPC_ID;
300 }
301
302 function yy_r1_8()
303 {
304
305 $this->token = Smarty_Internal_Configfileparser::TPC_OTHER;
306 }
307
308 public function yylex2()
309 {
310 if (!isset($this->yy_global_pattern2)) {
311 $this->yy_global_pattern2 = "/\G([ \t\r]+)|\G(\\d+\\.\\d+(?=[ \t\r]*[\n#;]))|\G(\\d+(?=[ \t\r]*[\n#;]))|\G(\"\"\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#;]))|\G(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#;]))|\G([a-zA-Z]+(?=[ \t\r]*[\n#;]))|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/iS";
312 }
313 if ($this->counter >= strlen($this->data)) {
314 return false; // end of input
315 }
316
317 do {
318 if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) {
319 $yysubmatches = $yymatches;
320 $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
321 if (empty($yymatches)) {
322 throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state VALUE');
323 }
324 next($yymatches); // skip global match
325 $this->token = key($yymatches); // token number
326 $this->value = current($yymatches); // token value
327 $r = $this->{'yy_r2_' . $this->token}();
328 if ($r === null) {
329 $this->counter += strlen($this->value);
330 $this->line += substr_count($this->value, "\n");
331 // accept this token
332 return true;
333 } elseif ($r === true) {
334 // we have changed state
335 // process this token in the new state
336 return $this->yylex();
337 } elseif ($r === false) {
338 $this->counter += strlen($this->value);
339 $this->line += substr_count($this->value, "\n");
340 if ($this->counter >= strlen($this->data)) {
341 return false; // end of input
342 }
343 // skip this token
344 continue;
345 }
346 } else {
347 throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
348 }
349 break;
350 } while (true);
351 } // end function
352
353 const VALUE = 2;
354
355 function yy_r2_1()
356 {
357
358 return false;
359 }
360
361 function yy_r2_2()
362 {
363
364 $this->token = Smarty_Internal_Configfileparser::TPC_FLOAT;
365 $this->yypopstate();
366 }
367
368 function yy_r2_3()
369 {
370
371 $this->token = Smarty_Internal_Configfileparser::TPC_INT;
372 $this->yypopstate();
373 }
374
375 function yy_r2_4()
376 {
377
378 $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES;
379 $this->yypushstate(self::TRIPPLE);
380 }
381
382 function yy_r2_5()
383 {
384
385 $this->token = Smarty_Internal_Configfileparser::TPC_SINGLE_QUOTED_STRING;
386 $this->yypopstate();
387 }
388
389 function yy_r2_6()
390 {
391
392 $this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING;
393 $this->yypopstate();
394 }
395
396 function yy_r2_7()
397 {
398
399 if (!$this->configBooleanize || !in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no"))) {
400 $this->yypopstate();
401 $this->yypushstate(self::NAKED_STRING_VALUE);
402 return true; //reprocess in new state
403 } else {
404 $this->token = Smarty_Internal_Configfileparser::TPC_BOOL;
405 $this->yypopstate();
406 }
407 }
408
409 function yy_r2_8()
410 {
411
412 $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
413 $this->yypopstate();
414 }
415
416 function yy_r2_9()
417 {
418
419 $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
420 $this->value = "";
421 $this->yypopstate();
422 }
423
424 public function yylex3()
425 {
426 if (!isset($this->yy_global_pattern3)) {
427 $this->yy_global_pattern3 = "/\G([^\n]+?(?=[ \t\r]*\n))/iS";
428 }
429 if ($this->counter >= strlen($this->data)) {
430 return false; // end of input
431 }
432
433 do {
434 if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) {
435 $yysubmatches = $yymatches;
436 $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
437 if (empty($yymatches)) {
438 throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state NAKED_STRING_VALUE');
439 }
440 next($yymatches); // skip global match
441 $this->token = key($yymatches); // token number
442 $this->value = current($yymatches); // token value
443 $r = $this->{'yy_r3_' . $this->token}();
444 if ($r === null) {
445 $this->counter += strlen($this->value);
446 $this->line += substr_count($this->value, "\n");
447 // accept this token
448 return true;
449 } elseif ($r === true) {
450 // we have changed state
451 // process this token in the new state
452 return $this->yylex();
453 } elseif ($r === false) {
454 $this->counter += strlen($this->value);
455 $this->line += substr_count($this->value, "\n");
456 if ($this->counter >= strlen($this->data)) {
457 return false; // end of input
458 }
459 // skip this token
460 continue;
461 }
462 } else {
463 throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
464 }
465 break;
466 } while (true);
467 } // end function
468
469 const NAKED_STRING_VALUE = 3;
470
471 function yy_r3_1()
472 {
473
474 $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
475 $this->yypopstate();
476 }
477
478 public function yylex4()
479 {
480 if (!isset($this->yy_global_pattern4)) {
481 $this->yy_global_pattern4 = "/\G([ \t\r]+)|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/iS";
482 }
483 if ($this->counter >= strlen($this->data)) {
484 return false; // end of input
485 }
486
487 do {
488 if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) {
489 $yysubmatches = $yymatches;
490 $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
491 if (empty($yymatches)) {
492 throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state COMMENT');
493 }
494 next($yymatches); // skip global match
495 $this->token = key($yymatches); // token number
496 $this->value = current($yymatches); // token value
497 $r = $this->{'yy_r4_' . $this->token}();
498 if ($r === null) {
499 $this->counter += strlen($this->value);
500 $this->line += substr_count($this->value, "\n");
501 // accept this token
502 return true;
503 } elseif ($r === true) {
504 // we have changed state
505 // process this token in the new state
506 return $this->yylex();
507 } elseif ($r === false) {
508 $this->counter += strlen($this->value);
509 $this->line += substr_count($this->value, "\n");
510 if ($this->counter >= strlen($this->data)) {
511 return false; // end of input
512 }
513 // skip this token
514 continue;
515 }
516 } else {
517 throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
518 }
519 break;
520 } while (true);
521 } // end function
522
523 const COMMENT = 4;
524
525 function yy_r4_1()
526 {
527
528 return false;
529 }
530
531 function yy_r4_2()
532 {
533
534 $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
535 }
536
537 function yy_r4_3()
538 {
539
540 $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
541 $this->yypopstate();
542 }
543
544 public function yylex5()
545 {
546 if (!isset($this->yy_global_pattern5)) {
547 $this->yy_global_pattern5 = "/\G(\\.)|\G(.*?(?=[\.=[\]\r\n]))/iS";
548 }
549 if ($this->counter >= strlen($this->data)) {
550 return false; // end of input
551 }
552
553 do {
554 if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) {
555 $yysubmatches = $yymatches;
556 $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
557 if (empty($yymatches)) {
558 throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state SECTION');
559 }
560 next($yymatches); // skip global match
561 $this->token = key($yymatches); // token number
562 $this->value = current($yymatches); // token value
563 $r = $this->{'yy_r5_' . $this->token}();
564 if ($r === null) {
565 $this->counter += strlen($this->value);
566 $this->line += substr_count($this->value, "\n");
567 // accept this token
568 return true;
569 } elseif ($r === true) {
570 // we have changed state
571 // process this token in the new state
572 return $this->yylex();
573 } elseif ($r === false) {
574 $this->counter += strlen($this->value);
575 $this->line += substr_count($this->value, "\n");
576 if ($this->counter >= strlen($this->data)) {
577 return false; // end of input
578 }
579 // skip this token
580 continue;
581 }
582 } else {
583 throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
584 }
585 break;
586 } while (true);
587 } // end function
588
589 const SECTION = 5;
590
591 function yy_r5_1()
592 {
593
594 $this->token = Smarty_Internal_Configfileparser::TPC_DOT;
595 }
596
597 function yy_r5_2()
598 {
599
600 $this->token = Smarty_Internal_Configfileparser::TPC_SECTION;
601 $this->yypopstate();
602 }
603
604 public function yylex6()
605 {
606 if (!isset($this->yy_global_pattern6)) {
607 $this->yy_global_pattern6 = "/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/iS";
608 }
609 if ($this->counter >= strlen($this->data)) {
610 return false; // end of input
611 }
612
613 do {
614 if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, null, $this->counter)) {
615 $yysubmatches = $yymatches;
616 $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
617 if (empty($yymatches)) {
618 throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TRIPPLE');
619 }
620 next($yymatches); // skip global match
621 $this->token = key($yymatches); // token number
622 $this->value = current($yymatches); // token value
623 $r = $this->{'yy_r6_' . $this->token}();
624 if ($r === null) {
625 $this->counter += strlen($this->value);
626 $this->line += substr_count($this->value, "\n");
627 // accept this token
628 return true;
629 } elseif ($r === true) {
630 // we have changed state
631 // process this token in the new state
632 return $this->yylex();
633 } elseif ($r === false) {
634 $this->counter += strlen($this->value);
635 $this->line += substr_count($this->value, "\n");
636 if ($this->counter >= strlen($this->data)) {
637 return false; // end of input
638 }
639 // skip this token
640 continue;
641 }
642 } else {
643 throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
644 }
645 break;
646 } while (true);
647 } // end function
648
649 const TRIPPLE = 6;
650
651 function yy_r6_1()
652 {
653
654 $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES_END;
655 $this->yypopstate();
656 $this->yypushstate(self::START);
657 }
658
659 function yy_r6_2()
660 {
661
662 $to = strlen($this->data);
663 preg_match("/\"\"\"[ \t\r]*[\n#;]/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
664 if (isset($match[0][1])) {
665 $to = $match[0][1];
666 } else {
667 $this->compiler->trigger_template_error("missing or misspelled literal closing tag");
668 }
669 $this->value = substr($this->data, $this->counter, $to - $this->counter);
670 $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT;
671 }
672 }