smarty_internal_configfileparser.php 35 KB

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