ConfigfileParser   F
last analyzed

Complexity

Total Complexity 155

Size/Duplication

Total Lines 950
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 564
dl 0
loc 950
rs 2
c 1
b 0
f 0
wmc 155

40 Methods

Rating   Name   Duplication   Size   Complexity  
D yy_is_expected_token() 0 85 18
A parse_bool() 0 9 2
A yy_r12() 0 2 1
A yy_r6() 0 2 1
B yy_reduce() 0 37 10
C yy_get_expected_tokens() 0 82 16
A yy_r8() 0 2 1
A parse_single_quoted_string() 0 16 5
A __construct() 0 7 1
A yy_r4() 0 3 1
A yy_r14() 0 2 1
A Trace() 0 9 3
A yy_r17() 0 2 1
A yy_r16() 0 2 1
A yy_r13() 0 2 1
A parse_tripple_double_quoted_string() 0 3 1
A parse_double_quoted_string() 0 4 1
A yy_syntax_error() 0 7 1
A set_var() 0 10 3
F doParse() 0 88 27
A yy_destructor() 0 4 1
A yy_r5() 0 5 2
A yy_parse_failed() 0 6 3
A yy_r15() 0 2 1
A yy_r10() 0 2 1
B yy_find_reduce_action() 0 20 7
B yy_shift() 0 32 7
A yy_r0() 0 2 1
A yy_r1() 0 3 1
A add_global_vars() 0 7 3
A yy_r9() 0 2 1
B yy_find_shift_action() 0 33 11
A yy_pop_parser_stack() 0 16 4
A PrintTrace() 0 4 1
A yy_r11() 0 2 1
A add_section_vars() 0 7 3
A yy_accept() 0 12 3
A tokenName() 0 9 4
A yy_r7() 0 2 1
A __destruct() 0 7 3

How to fix   Complexity   

Complex Class

Complex classes like 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 ConfigfileParser, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
// line 12 "src/Parser/ConfigfileParser.y"
4
5
6
namespace Smarty\Parser;
7
8
use \Smarty\Lexer\ConfigfileLexer as Lexer;
0 ignored issues
show
Bug introduced by
The type \Smarty\Lexer\ConfigfileLexer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use \Smarty\Compiler\Configfile as Configfile;
0 ignored issues
show
Bug introduced by
The type \Smarty\Compiler\Configfile was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
/**
12
* Smarty Internal Plugin Configfileparse
13
*
14
* This is the config file parser.
15
* It is generated from the ConfigfileParser.y file
16
* @package Smarty
17
* @subpackage Compiler
18
* @author Uwe Tews
19
*/
20
class ConfigfileParser
21
{
22
// line 31 "src/Parser/ConfigfileParser.y"
23
24
    /**
25
     * result status
26
     *
27
     * @var bool
28
     */
29
    public $successful = true;
30
    /**
31
     * return value
32
     *
33
     * @var mixed
34
     */
35
    public $retvalue = 0;
36
    /**
37
     * @var
38
     */
39
    public $yymajor;
40
    /**
41
     * lexer object
42
     *
43
     * @var Lexer
44
     */
45
    private $lex;
46
    /**
47
     * internal error flag
48
     *
49
     * @var bool
50
     */
51
    private $internalError = false;
52
    /**
53
     * compiler object
54
     *
55
     * @var Configfile
56
     */
57
    public $compiler = null;
58
    /**
59
     * smarty object
60
     *
61
     * @var Smarty
0 ignored issues
show
Bug introduced by
The type Smarty\Parser\Smarty was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

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