Initial repo created
[timetracker.git] / WEB-INF / lib / 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 * @package Smarty
7 * @subpackage Config
8 * @author Uwe Tews 
9 */
10 /**
11 * Smarty Internal Plugin Configfilelexer
12 */
13 class Smarty_Internal_Configfilelexer
14 {
15
16     public $data;
17     public $counter;
18     public $token;
19     public $value;
20     public $node;
21     public $line;
22     private $state = 1;
23     public $smarty_token_names = array (                // Text for parser error messages
24                                 );
25                                 
26                                 
27     function __construct($data, $smarty)
28     {
29         // set instance object
30         self::instance($this); 
31         $this->data = $data . "\n"; //now all lines are \n-terminated
32         $this->counter = 0;
33         $this->line = 1;
34         $this->smarty = $smarty; 
35      }
36     public static function &instance($new_instance = null)
37     {
38         static $instance = null;
39         if (isset($new_instance) && is_object($new_instance))
40             $instance = $new_instance;
41         return $instance;
42     } 
43
44
45
46     private $_yy_state = 1;
47     private $_yy_stack = array();
48
49     function yylex()
50     {
51         return $this->{'yylex' . $this->_yy_state}();
52     }
53
54     function yypushstate($state)
55     {
56         array_push($this->_yy_stack, $this->_yy_state);
57         $this->_yy_state = $state;
58     }
59
60     function yypopstate()
61     {
62         $this->_yy_state = array_pop($this->_yy_stack);
63     }
64
65     function yybegin($state)
66     {
67         $this->_yy_state = $state;
68     }
69
70
71
72
73     function yylex1()
74     {
75         $tokenMap = array (
76               1 => 0,
77               2 => 0,
78               3 => 0,
79               4 => 0,
80               5 => 0,
81               6 => 0,
82               7 => 0,
83             );
84         if ($this->counter >= strlen($this->data)) {
85             return false; // end of input
86         }
87         $yy_global_pattern = "/^(#)|^(\\[)|^(\\])|^(=)|^([ \t\r]+)|^(\n)|^([0-9]*[a-zA-Z_]\\w*)/iS";
88
89         do {
90             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
91                 $yysubmatches = $yymatches;
92                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
93                 if (!count($yymatches)) {
94                     throw new Exception('Error: lexing failed because a rule matched' .
95                         'an empty string.  Input "' . substr($this->data,
96                         $this->counter, 5) . '... state START');
97                 }
98                 next($yymatches); // skip global match
99                 $this->token = key($yymatches); // token number
100                 if ($tokenMap[$this->token]) {
101                     // extract sub-patterns for passing to lex function
102                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
103                         $tokenMap[$this->token]);
104                 } else {
105                     $yysubmatches = array();
106                 }
107                 $this->value = current($yymatches); // token value
108                 $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
109                 if ($r === null) {
110                     $this->counter += strlen($this->value);
111                     $this->line += substr_count($this->value, "\n");
112                     // accept this token
113                     return true;
114                 } elseif ($r === true) {
115                     // we have changed state
116                     // process this token in the new state
117                     return $this->yylex();
118                 } elseif ($r === false) {
119                     $this->counter += strlen($this->value);
120                     $this->line += substr_count($this->value, "\n");
121                     if ($this->counter >= strlen($this->data)) {
122                         return false; // end of input
123                     }
124                     // skip this token
125                     continue;
126                 }            } else {
127                 throw new Exception('Unexpected input at line' . $this->line .
128                     ': ' . $this->data[$this->counter]);
129             }
130             break;
131         } while (true);
132
133     } // end function
134
135
136     const START = 1;
137     function yy_r1_1($yy_subpatterns)
138     {
139
140     $this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART;
141     $this->yypushstate(self::COMMENT);
142     }
143     function yy_r1_2($yy_subpatterns)
144     {
145
146     $this->token = Smarty_Internal_Configfileparser::TPC_OPENB;
147     $this->yypushstate(self::SECTION);
148     }
149     function yy_r1_3($yy_subpatterns)
150     {
151
152     $this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB;
153     }
154     function yy_r1_4($yy_subpatterns)
155     {
156
157     $this->token = Smarty_Internal_Configfileparser::TPC_EQUAL;
158     $this->yypushstate(self::VALUE);
159     }
160     function yy_r1_5($yy_subpatterns)
161     {
162
163     return false;
164     }
165     function yy_r1_6($yy_subpatterns)
166     {
167
168     $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
169     }
170     function yy_r1_7($yy_subpatterns)
171     {
172
173     $this->token = Smarty_Internal_Configfileparser::TPC_ID;
174     }
175
176
177
178     function yylex2()
179     {
180         $tokenMap = array (
181               1 => 0,
182               2 => 0,
183               3 => 0,
184               4 => 0,
185               5 => 0,
186               6 => 0,
187               7 => 0,
188               8 => 0,
189               9 => 0,
190             );
191         if ($this->counter >= strlen($this->data)) {
192             return false; // end of input
193         }
194         $yy_global_pattern = "/^([ \t\r]+)|^(\\d+\\.\\d+(?=[ \t\r]*[\n#]))|^(\\d+(?=[ \t\r]*[\n#]))|^('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#]))|^(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#]))|^(\"\"\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"\"\"(?=[ \t\r]*[\n#]))|^([a-zA-Z]+(?=[ \t\r]*[\n#]))|^([^\n]+?(?=[ \t\r]*\n))|^(\n)/iS";
195
196         do {
197             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
198                 $yysubmatches = $yymatches;
199                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
200                 if (!count($yymatches)) {
201                     throw new Exception('Error: lexing failed because a rule matched' .
202                         'an empty string.  Input "' . substr($this->data,
203                         $this->counter, 5) . '... state VALUE');
204                 }
205                 next($yymatches); // skip global match
206                 $this->token = key($yymatches); // token number
207                 if ($tokenMap[$this->token]) {
208                     // extract sub-patterns for passing to lex function
209                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
210                         $tokenMap[$this->token]);
211                 } else {
212                     $yysubmatches = array();
213                 }
214                 $this->value = current($yymatches); // token value
215                 $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
216                 if ($r === null) {
217                     $this->counter += strlen($this->value);
218                     $this->line += substr_count($this->value, "\n");
219                     // accept this token
220                     return true;
221                 } elseif ($r === true) {
222                     // we have changed state
223                     // process this token in the new state
224                     return $this->yylex();
225                 } elseif ($r === false) {
226                     $this->counter += strlen($this->value);
227                     $this->line += substr_count($this->value, "\n");
228                     if ($this->counter >= strlen($this->data)) {
229                         return false; // end of input
230                     }
231                     // skip this token
232                     continue;
233                 }            } else {
234                 throw new Exception('Unexpected input at line' . $this->line .
235                     ': ' . $this->data[$this->counter]);
236             }
237             break;
238         } while (true);
239
240     } // end function
241
242
243     const VALUE = 2;
244     function yy_r2_1($yy_subpatterns)
245     {
246
247     return false;
248     }
249     function yy_r2_2($yy_subpatterns)
250     {
251
252     $this->token = Smarty_Internal_Configfileparser::TPC_FLOAT;
253     $this->yypopstate();
254     }
255     function yy_r2_3($yy_subpatterns)
256     {
257
258     $this->token = Smarty_Internal_Configfileparser::TPC_INT;
259     $this->yypopstate();
260     }
261     function yy_r2_4($yy_subpatterns)
262     {
263
264     $this->token = Smarty_Internal_Configfileparser::TPC_SINGLE_QUOTED_STRING;
265     $this->yypopstate();
266     }
267     function yy_r2_5($yy_subpatterns)
268     {
269
270     $this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING;
271     $this->yypopstate();
272     }
273     function yy_r2_6($yy_subpatterns)
274     {
275
276     $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_DOUBLE_QUOTED_STRING;
277     $this->yypopstate();
278     }
279     function yy_r2_7($yy_subpatterns)
280     {
281
282     if (!$this->smarty->config_booleanize || !in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no")) ) {
283         $this->yypopstate();
284         $this->yypushstate(self::NAKED_STRING_VALUE);
285         return true; //reprocess in new state
286     } else {
287         $this->token = Smarty_Internal_Configfileparser::TPC_BOOL;
288         $this->yypopstate();
289     }
290     }
291     function yy_r2_8($yy_subpatterns)
292     {
293
294     $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
295     $this->yypopstate();
296     }
297     function yy_r2_9($yy_subpatterns)
298     {
299
300     $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
301     $this->value = "";
302     $this->yypopstate();
303     }
304
305
306
307     function yylex3()
308     {
309         $tokenMap = array (
310               1 => 0,
311             );
312         if ($this->counter >= strlen($this->data)) {
313             return false; // end of input
314         }
315         $yy_global_pattern = "/^([^\n]+?(?=[ \t\r]*\n))/iS";
316
317         do {
318             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
319                 $yysubmatches = $yymatches;
320                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
321                 if (!count($yymatches)) {
322                     throw new Exception('Error: lexing failed because a rule matched' .
323                         'an empty string.  Input "' . substr($this->data,
324                         $this->counter, 5) . '... state NAKED_STRING_VALUE');
325                 }
326                 next($yymatches); // skip global match
327                 $this->token = key($yymatches); // token number
328                 if ($tokenMap[$this->token]) {
329                     // extract sub-patterns for passing to lex function
330                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
331                         $tokenMap[$this->token]);
332                 } else {
333                     $yysubmatches = array();
334                 }
335                 $this->value = current($yymatches); // token value
336                 $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
337                 if ($r === null) {
338                     $this->counter += strlen($this->value);
339                     $this->line += substr_count($this->value, "\n");
340                     // accept this token
341                     return true;
342                 } elseif ($r === true) {
343                     // we have changed state
344                     // process this token in the new state
345                     return $this->yylex();
346                 } elseif ($r === false) {
347                     $this->counter += strlen($this->value);
348                     $this->line += substr_count($this->value, "\n");
349                     if ($this->counter >= strlen($this->data)) {
350                         return false; // end of input
351                     }
352                     // skip this token
353                     continue;
354                 }            } else {
355                 throw new Exception('Unexpected input at line' . $this->line .
356                     ': ' . $this->data[$this->counter]);
357             }
358             break;
359         } while (true);
360
361     } // end function
362
363
364     const NAKED_STRING_VALUE = 3;
365     function yy_r3_1($yy_subpatterns)
366     {
367
368     $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
369     $this->yypopstate();
370     }
371
372
373
374     function yylex4()
375     {
376         $tokenMap = array (
377               1 => 0,
378               2 => 0,
379               3 => 0,
380             );
381         if ($this->counter >= strlen($this->data)) {
382             return false; // end of input
383         }
384         $yy_global_pattern = "/^([ \t\r]+)|^([^\n]+?(?=[ \t\r]*\n))|^(\n)/iS";
385
386         do {
387             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
388                 $yysubmatches = $yymatches;
389                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
390                 if (!count($yymatches)) {
391                     throw new Exception('Error: lexing failed because a rule matched' .
392                         'an empty string.  Input "' . substr($this->data,
393                         $this->counter, 5) . '... state COMMENT');
394                 }
395                 next($yymatches); // skip global match
396                 $this->token = key($yymatches); // token number
397                 if ($tokenMap[$this->token]) {
398                     // extract sub-patterns for passing to lex function
399                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
400                         $tokenMap[$this->token]);
401                 } else {
402                     $yysubmatches = array();
403                 }
404                 $this->value = current($yymatches); // token value
405                 $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
406                 if ($r === null) {
407                     $this->counter += strlen($this->value);
408                     $this->line += substr_count($this->value, "\n");
409                     // accept this token
410                     return true;
411                 } elseif ($r === true) {
412                     // we have changed state
413                     // process this token in the new state
414                     return $this->yylex();
415                 } elseif ($r === false) {
416                     $this->counter += strlen($this->value);
417                     $this->line += substr_count($this->value, "\n");
418                     if ($this->counter >= strlen($this->data)) {
419                         return false; // end of input
420                     }
421                     // skip this token
422                     continue;
423                 }            } else {
424                 throw new Exception('Unexpected input at line' . $this->line .
425                     ': ' . $this->data[$this->counter]);
426             }
427             break;
428         } while (true);
429
430     } // end function
431
432
433     const COMMENT = 4;
434     function yy_r4_1($yy_subpatterns)
435     {
436
437     return false;
438     }
439     function yy_r4_2($yy_subpatterns)
440     {
441
442     $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
443     }
444     function yy_r4_3($yy_subpatterns)
445     {
446
447     $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
448     $this->yypopstate();
449     }
450
451
452
453     function yylex5()
454     {
455         $tokenMap = array (
456               1 => 0,
457               2 => 0,
458             );
459         if ($this->counter >= strlen($this->data)) {
460             return false; // end of input
461         }
462         $yy_global_pattern = "/^(\\.)|^(.*?(?=[\.=[\]\r\n]))/iS";
463
464         do {
465             if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
466                 $yysubmatches = $yymatches;
467                 $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
468                 if (!count($yymatches)) {
469                     throw new Exception('Error: lexing failed because a rule matched' .
470                         'an empty string.  Input "' . substr($this->data,
471                         $this->counter, 5) . '... state SECTION');
472                 }
473                 next($yymatches); // skip global match
474                 $this->token = key($yymatches); // token number
475                 if ($tokenMap[$this->token]) {
476                     // extract sub-patterns for passing to lex function
477                     $yysubmatches = array_slice($yysubmatches, $this->token + 1,
478                         $tokenMap[$this->token]);
479                 } else {
480                     $yysubmatches = array();
481                 }
482                 $this->value = current($yymatches); // token value
483                 $r = $this->{'yy_r5_' . $this->token}($yysubmatches);
484                 if ($r === null) {
485                     $this->counter += strlen($this->value);
486                     $this->line += substr_count($this->value, "\n");
487                     // accept this token
488                     return true;
489                 } elseif ($r === true) {
490                     // we have changed state
491                     // process this token in the new state
492                     return $this->yylex();
493                 } elseif ($r === false) {
494                     $this->counter += strlen($this->value);
495                     $this->line += substr_count($this->value, "\n");
496                     if ($this->counter >= strlen($this->data)) {
497                         return false; // end of input
498                     }
499                     // skip this token
500                     continue;
501                 }            } else {
502                 throw new Exception('Unexpected input at line' . $this->line .
503                     ': ' . $this->data[$this->counter]);
504             }
505             break;
506         } while (true);
507
508     } // end function
509
510
511     const SECTION = 5;
512     function yy_r5_1($yy_subpatterns)
513     {
514
515     $this->token = Smarty_Internal_Configfileparser::TPC_DOT;
516     }
517     function yy_r5_2($yy_subpatterns)
518     {
519
520     $this->token = Smarty_Internal_Configfileparser::TPC_SECTION;
521     $this->yypopstate();
522     }
523
524
525 }
526 ?>