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