You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

smarty_internal_configfileparser.php 34KB

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