smarty_internal_configfileparser.php 33 KB

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