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 33KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  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,), array(1,), array(), array(), array(),
  313. array(2, 4,), array(15, 17,), array(13, 14,), array(14,), array(17,), array(3,), array(3,), array(2,),
  314. array(6,), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(),
  315. array(), array(), array(), array(), array(),);
  316. 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,
  317. 55, 54, 57, 56, 50, 45, 43, 42, 38, 46, 47, 52, 51, 49, 48, 53,);
  318. const YYNOCODE = 29;
  319. const YYSTACKDEPTH = 100;
  320. const YYNSTATE = 36;
  321. const YYNRULE = 22;
  322. const YYERRORSYMBOL = 19;
  323. const YYERRSYMDT = 'yy0';
  324. const YYFALLBACK = 0;
  325. public static $yyFallback = array();
  326. public function Trace($TraceFILE, $zTracePrompt)
  327. {
  328. if (!$TraceFILE) {
  329. $zTracePrompt = 0;
  330. } elseif (!$zTracePrompt) {
  331. $TraceFILE = 0;
  332. }
  333. $this->yyTraceFILE = $TraceFILE;
  334. $this->yyTracePrompt = $zTracePrompt;
  335. }
  336. public function PrintTrace()
  337. {
  338. $this->yyTraceFILE = fopen('php://output', 'w');
  339. $this->yyTracePrompt = '<br>';
  340. }
  341. public $yyTraceFILE;
  342. public $yyTracePrompt;
  343. public $yyidx; /* Index of top element in stack */
  344. public $yyerrcnt; /* Shifts left before out of the error */
  345. public $yystack = array(); /* The parser's stack */
  346. public $yyTokenName = array('$', 'OPENB', 'SECTION', 'CLOSEB', 'DOT', 'ID', 'EQUAL', 'FLOAT', 'INT', 'BOOL',
  347. 'SINGLE_QUOTED_STRING', 'DOUBLE_QUOTED_STRING', 'TRIPPLE_QUOTES', 'TRIPPLE_TEXT', 'TRIPPLE_QUOTES_END',
  348. 'NAKED_STRING', 'OTHER', 'NEWLINE', 'COMMENTSTART', 'error', 'start', 'global_vars', 'sections', 'var_list',
  349. 'section', 'newline', 'var', 'value',);
  350. public static $yyRuleName = array('start ::= global_vars sections', 'global_vars ::= var_list',
  351. 'sections ::= sections section', 'sections ::=', 'section ::= OPENB SECTION CLOSEB newline var_list',
  352. 'section ::= OPENB DOT SECTION CLOSEB newline var_list', 'var_list ::= var_list newline',
  353. 'var_list ::= var_list var', 'var_list ::=', 'var ::= ID EQUAL value', 'value ::= FLOAT', 'value ::= INT',
  354. 'value ::= BOOL', 'value ::= SINGLE_QUOTED_STRING', 'value ::= DOUBLE_QUOTED_STRING',
  355. 'value ::= TRIPPLE_QUOTES TRIPPLE_TEXT TRIPPLE_QUOTES_END', 'value ::= TRIPPLE_QUOTES TRIPPLE_QUOTES_END',
  356. 'value ::= NAKED_STRING', 'value ::= OTHER', 'newline ::= NEWLINE', 'newline ::= COMMENTSTART NEWLINE',
  357. 'newline ::= COMMENTSTART NAKED_STRING NEWLINE',);
  358. public function tokenName($tokenType)
  359. {
  360. if ($tokenType === 0) {
  361. return 'End of Input';
  362. }
  363. if ($tokenType > 0 && $tokenType < count($this->yyTokenName)) {
  364. return $this->yyTokenName[$tokenType];
  365. } else {
  366. return "Unknown";
  367. }
  368. }
  369. public static function yy_destructor($yymajor, $yypminor)
  370. {
  371. switch ($yymajor) {
  372. default:
  373. break; /* If no destructor action specified: do nothing */
  374. }
  375. }
  376. public function yy_pop_parser_stack()
  377. {
  378. if (empty($this->yystack)) {
  379. return;
  380. }
  381. $yytos = array_pop($this->yystack);
  382. if ($this->yyTraceFILE && $this->yyidx >= 0) {
  383. fwrite($this->yyTraceFILE, $this->yyTracePrompt . 'Popping ' . $this->yyTokenName[$yytos->major] . "\n");
  384. }
  385. $yymajor = $yytos->major;
  386. self::yy_destructor($yymajor, $yytos->minor);
  387. $this->yyidx --;
  388. return $yymajor;
  389. }
  390. public function __destruct()
  391. {
  392. while ($this->yystack !== Array()) {
  393. $this->yy_pop_parser_stack();
  394. }
  395. if (is_resource($this->yyTraceFILE)) {
  396. fclose($this->yyTraceFILE);
  397. }
  398. }
  399. public function yy_get_expected_tokens($token)
  400. {
  401. static $res3 = array();
  402. static $res4 = array();
  403. $state = $this->yystack[$this->yyidx]->stateno;
  404. $expected = self::$yyExpectedTokens[$state];
  405. if (isset($res3[$state][$token])) {
  406. if ($res3[$state][$token]) {
  407. return $expected;
  408. }
  409. } else {
  410. if ($res3[$state][$token] = in_array($token, self::$yyExpectedTokens[$state], true)) {
  411. return $expected;
  412. }
  413. }
  414. $stack = $this->yystack;
  415. $yyidx = $this->yyidx;
  416. do {
  417. $yyact = $this->yy_find_shift_action($token);
  418. if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) {
  419. // reduce action
  420. $done = 0;
  421. do {
  422. if ($done ++ == 100) {
  423. $this->yyidx = $yyidx;
  424. $this->yystack = $stack;
  425. // too much recursion prevents proper detection
  426. // so give up
  427. return array_unique($expected);
  428. }
  429. $yyruleno = $yyact - self::YYNSTATE;
  430. $this->yyidx -= self::$yyRuleInfo[$yyruleno][1];
  431. $nextstate = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, self::$yyRuleInfo[$yyruleno][0]);
  432. if (isset(self::$yyExpectedTokens[$nextstate])) {
  433. $expected = array_merge($expected, self::$yyExpectedTokens[$nextstate]);
  434. if (isset($res4[$nextstate][$token])) {
  435. if ($res4[$nextstate][$token]) {
  436. $this->yyidx = $yyidx;
  437. $this->yystack = $stack;
  438. return array_unique($expected);
  439. }
  440. } else {
  441. if ($res4[$nextstate][$token] = in_array($token, self::$yyExpectedTokens[$nextstate], true)) {
  442. $this->yyidx = $yyidx;
  443. $this->yystack = $stack;
  444. return array_unique($expected);
  445. }
  446. }
  447. }
  448. if ($nextstate < self::YYNSTATE) {
  449. // we need to shift a non-terminal
  450. $this->yyidx ++;
  451. $x = new TPC_yyStackEntry;
  452. $x->stateno = $nextstate;
  453. $x->major = self::$yyRuleInfo[$yyruleno][0];
  454. $this->yystack[$this->yyidx] = $x;
  455. continue 2;
  456. } elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) {
  457. $this->yyidx = $yyidx;
  458. $this->yystack = $stack;
  459. // the last token was just ignored, we can't accept
  460. // by ignoring input, this is in essence ignoring a
  461. // syntax error!
  462. return array_unique($expected);
  463. } elseif ($nextstate === self::YY_NO_ACTION) {
  464. $this->yyidx = $yyidx;
  465. $this->yystack = $stack;
  466. // input accepted, but not shifted (I guess)
  467. return $expected;
  468. } else {
  469. $yyact = $nextstate;
  470. }
  471. } while (true);
  472. }
  473. break;
  474. } while (true);
  475. $this->yyidx = $yyidx;
  476. $this->yystack = $stack;
  477. return array_unique($expected);
  478. }
  479. public function yy_is_expected_token($token)
  480. {
  481. static $res = array();
  482. static $res2 = array();
  483. if ($token === 0) {
  484. return true; // 0 is not part of this
  485. }
  486. $state = $this->yystack[$this->yyidx]->stateno;
  487. if (isset($res[$state][$token])) {
  488. if ($res[$state][$token]) {
  489. return true;
  490. }
  491. } else {
  492. if ($res[$state][$token] = in_array($token, self::$yyExpectedTokens[$state], true)) {
  493. return true;
  494. }
  495. }
  496. $stack = $this->yystack;
  497. $yyidx = $this->yyidx;
  498. do {
  499. $yyact = $this->yy_find_shift_action($token);
  500. if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) {
  501. // reduce action
  502. $done = 0;
  503. do {
  504. if ($done ++ == 100) {
  505. $this->yyidx = $yyidx;
  506. $this->yystack = $stack;
  507. // too much recursion prevents proper detection
  508. // so give up
  509. return true;
  510. }
  511. $yyruleno = $yyact - self::YYNSTATE;
  512. $this->yyidx -= self::$yyRuleInfo[$yyruleno][1];
  513. $nextstate = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, self::$yyRuleInfo[$yyruleno][0]);
  514. if (isset($res2[$nextstate][$token])) {
  515. if ($res2[$nextstate][$token]) {
  516. $this->yyidx = $yyidx;
  517. $this->yystack = $stack;
  518. return true;
  519. }
  520. } else {
  521. if ($res2[$nextstate][$token] = (isset(self::$yyExpectedTokens[$nextstate]) && in_array($token, self::$yyExpectedTokens[$nextstate], true))) {
  522. $this->yyidx = $yyidx;
  523. $this->yystack = $stack;
  524. return true;
  525. }
  526. }
  527. if ($nextstate < self::YYNSTATE) {
  528. // we need to shift a non-terminal
  529. $this->yyidx ++;
  530. $x = new TPC_yyStackEntry;
  531. $x->stateno = $nextstate;
  532. $x->major = self::$yyRuleInfo[$yyruleno][0];
  533. $this->yystack[$this->yyidx] = $x;
  534. continue 2;
  535. } elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) {
  536. $this->yyidx = $yyidx;
  537. $this->yystack = $stack;
  538. if (!$token) {
  539. // end of input: this is valid
  540. return true;
  541. }
  542. // the last token was just ignored, we can't accept
  543. // by ignoring input, this is in essence ignoring a
  544. // syntax error!
  545. return false;
  546. } elseif ($nextstate === self::YY_NO_ACTION) {
  547. $this->yyidx = $yyidx;
  548. $this->yystack = $stack;
  549. // input accepted, but not shifted (I guess)
  550. return true;
  551. } else {
  552. $yyact = $nextstate;
  553. }
  554. } while (true);
  555. }
  556. break;
  557. } while (true);
  558. $this->yyidx = $yyidx;
  559. $this->yystack = $stack;
  560. return true;
  561. }
  562. public function yy_find_shift_action($iLookAhead)
  563. {
  564. $stateno = $this->yystack[$this->yyidx]->stateno;
  565. /* if ($this->yyidx < 0) return self::YY_NO_ACTION; */
  566. if (!isset(self::$yy_shift_ofst[$stateno])) {
  567. // no shift actions
  568. return self::$yy_default[$stateno];
  569. }
  570. $i = self::$yy_shift_ofst[$stateno];
  571. if ($i === self::YY_SHIFT_USE_DFLT) {
  572. return self::$yy_default[$stateno];
  573. }
  574. if ($iLookAhead == self::YYNOCODE) {
  575. return self::YY_NO_ACTION;
  576. }
  577. $i += $iLookAhead;
  578. if ($i < 0 || $i >= self::YY_SZ_ACTTAB || self::$yy_lookahead[$i] != $iLookAhead) {
  579. if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback) && ($iFallback = self::$yyFallback[$iLookAhead]) != 0) {
  580. if ($this->yyTraceFILE) {
  581. fwrite($this->yyTraceFILE, $this->yyTracePrompt . "FALLBACK " . $this->yyTokenName[$iLookAhead] . " => " . $this->yyTokenName[$iFallback] . "\n");
  582. }
  583. return $this->yy_find_shift_action($iFallback);
  584. }
  585. return self::$yy_default[$stateno];
  586. } else {
  587. return self::$yy_action[$i];
  588. }
  589. }
  590. public function yy_find_reduce_action($stateno, $iLookAhead)
  591. {
  592. /* $stateno = $this->yystack[$this->yyidx]->stateno; */
  593. if (!isset(self::$yy_reduce_ofst[$stateno])) {
  594. return self::$yy_default[$stateno];
  595. }
  596. $i = self::$yy_reduce_ofst[$stateno];
  597. if ($i == self::YY_REDUCE_USE_DFLT) {
  598. return self::$yy_default[$stateno];
  599. }
  600. if ($iLookAhead == self::YYNOCODE) {
  601. return self::YY_NO_ACTION;
  602. }
  603. $i += $iLookAhead;
  604. if ($i < 0 || $i >= self::YY_SZ_ACTTAB || self::$yy_lookahead[$i] != $iLookAhead) {
  605. return self::$yy_default[$stateno];
  606. } else {
  607. return self::$yy_action[$i];
  608. }
  609. }
  610. public function yy_shift($yyNewState, $yyMajor, $yypMinor)
  611. {
  612. $this->yyidx ++;
  613. if ($this->yyidx >= self::YYSTACKDEPTH) {
  614. $this->yyidx --;
  615. if ($this->yyTraceFILE) {
  616. fprintf($this->yyTraceFILE, "%sStack Overflow!\n", $this->yyTracePrompt);
  617. }
  618. while ($this->yyidx >= 0) {
  619. $this->yy_pop_parser_stack();
  620. }
  621. #line 255 "../smarty/lexer/smarty_internal_configfileparser.y"
  622. $this->internalError = true;
  623. $this->compiler->trigger_config_file_error("Stack overflow in configfile parser");
  624. return;
  625. }
  626. $yytos = new TPC_yyStackEntry;
  627. $yytos->stateno = $yyNewState;
  628. $yytos->major = $yyMajor;
  629. $yytos->minor = $yypMinor;
  630. $this->yystack[] = $yytos;
  631. if ($this->yyTraceFILE && $this->yyidx > 0) {
  632. fprintf($this->yyTraceFILE, "%sShift %d\n", $this->yyTracePrompt, $yyNewState);
  633. fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt);
  634. for ($i = 1; $i <= $this->yyidx; $i ++) {
  635. fprintf($this->yyTraceFILE, " %s", $this->yyTokenName[$this->yystack[$i]->major]);
  636. }
  637. fwrite($this->yyTraceFILE, "\n");
  638. }
  639. }
  640. public static $yyRuleInfo = array(array(0 => 20, 1 => 2), array(0 => 21, 1 => 1), array(0 => 22, 1 => 2),
  641. array(0 => 22, 1 => 0), array(0 => 24, 1 => 5), array(0 => 24, 1 => 6), array(0 => 23, 1 => 2),
  642. array(0 => 23, 1 => 2), array(0 => 23, 1 => 0), array(0 => 26, 1 => 3), array(0 => 27, 1 => 1),
  643. array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1),
  644. array(0 => 27, 1 => 3), array(0 => 27, 1 => 2), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1),
  645. array(0 => 25, 1 => 1), array(0 => 25, 1 => 2), array(0 => 25, 1 => 3),);
  646. public static $yyReduceMap = array(0 => 0, 2 => 0, 3 => 0, 19 => 0, 20 => 0, 21 => 0, 1 => 1, 4 => 4, 5 => 5,
  647. 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13,
  648. 14 => 14, 15 => 15, 16 => 16, 17 => 17, 18 => 17,);
  649. #line 261 "../smarty/lexer/smarty_internal_configfileparser.y"
  650. function yy_r0()
  651. {
  652. $this->_retvalue = null;
  653. }
  654. #line 266 "../smarty/lexer/smarty_internal_configfileparser.y"
  655. function yy_r1()
  656. {
  657. $this->add_global_vars($this->yystack[$this->yyidx + 0]->minor);
  658. $this->_retvalue = null;
  659. }
  660. #line 280 "../smarty/lexer/smarty_internal_configfileparser.y"
  661. function yy_r4()
  662. {
  663. $this->add_section_vars($this->yystack[$this->yyidx + - 3]->minor, $this->yystack[$this->yyidx + 0]->minor);
  664. $this->_retvalue = null;
  665. }
  666. #line 285 "../smarty/lexer/smarty_internal_configfileparser.y"
  667. function yy_r5()
  668. {
  669. if ($this->configReadHidden) {
  670. $this->add_section_vars($this->yystack[$this->yyidx + - 3]->minor, $this->yystack[$this->yyidx + 0]->minor);
  671. }
  672. $this->_retvalue = null;
  673. }
  674. #line 293 "../smarty/lexer/smarty_internal_configfileparser.y"
  675. function yy_r6()
  676. {
  677. $this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor;
  678. }
  679. #line 297 "../smarty/lexer/smarty_internal_configfileparser.y"
  680. function yy_r7()
  681. {
  682. $this->_retvalue = array_merge($this->yystack[$this->yyidx + - 1]->minor, Array($this->yystack[$this->yyidx + 0]->minor));
  683. }
  684. #line 301 "../smarty/lexer/smarty_internal_configfileparser.y"
  685. function yy_r8()
  686. {
  687. $this->_retvalue = Array();
  688. }
  689. #line 307 "../smarty/lexer/smarty_internal_configfileparser.y"
  690. function yy_r9()
  691. {
  692. $this->_retvalue = Array("key" => $this->yystack[$this->yyidx + - 2]->minor,
  693. "value" => $this->yystack[$this->yyidx + 0]->minor);
  694. }
  695. #line 312 "../smarty/lexer/smarty_internal_configfileparser.y"
  696. function yy_r10()
  697. {
  698. $this->_retvalue = (float) $this->yystack[$this->yyidx + 0]->minor;
  699. }
  700. #line 316 "../smarty/lexer/smarty_internal_configfileparser.y"
  701. function yy_r11()
  702. {
  703. $this->_retvalue = (int) $this->yystack[$this->yyidx + 0]->minor;
  704. }
  705. #line 320 "../smarty/lexer/smarty_internal_configfileparser.y"
  706. function yy_r12()
  707. {
  708. $this->_retvalue = $this->parse_bool($this->yystack[$this->yyidx + 0]->minor);
  709. }
  710. #line 324 "../smarty/lexer/smarty_internal_configfileparser.y"
  711. function yy_r13()
  712. {
  713. $this->_retvalue = self::parse_single_quoted_string($this->yystack[$this->yyidx + 0]->minor);
  714. }
  715. #line 328 "../smarty/lexer/smarty_internal_configfileparser.y"
  716. function yy_r14()
  717. {
  718. $this->_retvalue = self::parse_double_quoted_string($this->yystack[$this->yyidx + 0]->minor);
  719. }
  720. #line 332 "../smarty/lexer/smarty_internal_configfileparser.y"
  721. function yy_r15()
  722. {
  723. $this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[$this->yyidx + - 1]->minor);
  724. }
  725. #line 336 "../smarty/lexer/smarty_internal_configfileparser.y"
  726. function yy_r16()
  727. {
  728. $this->_retvalue = '';
  729. }
  730. #line 340 "../smarty/lexer/smarty_internal_configfileparser.y"
  731. function yy_r17()
  732. {
  733. $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
  734. }
  735. private $_retvalue;
  736. public function yy_reduce($yyruleno)
  737. {
  738. if ($this->yyTraceFILE && $yyruleno >= 0 && $yyruleno < count(self::$yyRuleName)) {
  739. fprintf($this->yyTraceFILE, "%sReduce (%d) [%s].\n", $this->yyTracePrompt, $yyruleno, self::$yyRuleName[$yyruleno]);
  740. }
  741. $this->_retvalue = $yy_lefthand_side = null;
  742. if (isset(self::$yyReduceMap[$yyruleno])) {
  743. // call the action
  744. $this->_retvalue = null;
  745. $this->{'yy_r' . self::$yyReduceMap[$yyruleno]}();
  746. $yy_lefthand_side = $this->_retvalue;
  747. }
  748. $yygoto = self::$yyRuleInfo[$yyruleno][0];
  749. $yysize = self::$yyRuleInfo[$yyruleno][1];
  750. $this->yyidx -= $yysize;
  751. for ($i = $yysize; $i; $i --) {
  752. // pop all of the right-hand side parameters
  753. array_pop($this->yystack);
  754. }
  755. $yyact = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, $yygoto);
  756. if ($yyact < self::YYNSTATE) {
  757. if (!$this->yyTraceFILE && $yysize) {
  758. $this->yyidx ++;
  759. $x = new TPC_yyStackEntry;
  760. $x->stateno = $yyact;
  761. $x->major = $yygoto;
  762. $x->minor = $yy_lefthand_side;
  763. $this->yystack[$this->yyidx] = $x;
  764. } else {
  765. $this->yy_shift($yyact, $yygoto, $yy_lefthand_side);
  766. }
  767. } elseif ($yyact == self::YYNSTATE + self::YYNRULE + 1) {
  768. $this->yy_accept();
  769. }
  770. }
  771. public function yy_parse_failed()
  772. {
  773. if ($this->yyTraceFILE) {
  774. fprintf($this->yyTraceFILE, "%sFail!\n", $this->yyTracePrompt);
  775. }
  776. while ($this->yyidx >= 0) {
  777. $this->yy_pop_parser_stack();
  778. }
  779. }
  780. public function yy_syntax_error($yymajor, $TOKEN)
  781. {
  782. #line 248 "../smarty/lexer/smarty_internal_configfileparser.y"
  783. $this->internalError = true;
  784. $this->yymajor = $yymajor;
  785. $this->compiler->trigger_config_file_error();
  786. }
  787. public function yy_accept()
  788. {
  789. if ($this->yyTraceFILE) {
  790. fprintf($this->yyTraceFILE, "%sAccept!\n", $this->yyTracePrompt);
  791. }
  792. while ($this->yyidx >= 0) {
  793. $this->yy_pop_parser_stack();
  794. }
  795. #line 241 "../smarty/lexer/smarty_internal_configfileparser.y"
  796. $this->successful = !$this->internalError;
  797. $this->internalError = false;
  798. $this->retvalue = $this->_retvalue;
  799. }
  800. public function doParse($yymajor, $yytokenvalue)
  801. {
  802. $yyerrorhit = 0; /* True if yymajor has invoked an error */
  803. if ($this->yyidx === null || $this->yyidx < 0) {
  804. $this->yyidx = 0;
  805. $this->yyerrcnt = - 1;
  806. $x = new TPC_yyStackEntry;
  807. $x->stateno = 0;
  808. $x->major = 0;
  809. $this->yystack = array();
  810. $this->yystack[] = $x;
  811. }
  812. $yyendofinput = ($yymajor == 0);
  813. if ($this->yyTraceFILE) {
  814. fprintf($this->yyTraceFILE, "%sInput %s\n", $this->yyTracePrompt, $this->yyTokenName[$yymajor]);
  815. }
  816. do {
  817. $yyact = $this->yy_find_shift_action($yymajor);
  818. if ($yymajor < self::YYERRORSYMBOL && !$this->yy_is_expected_token($yymajor)) {
  819. // force a syntax error
  820. $yyact = self::YY_ERROR_ACTION;
  821. }
  822. if ($yyact < self::YYNSTATE) {
  823. $this->yy_shift($yyact, $yymajor, $yytokenvalue);
  824. $this->yyerrcnt --;
  825. if ($yyendofinput && $this->yyidx >= 0) {
  826. $yymajor = 0;
  827. } else {
  828. $yymajor = self::YYNOCODE;
  829. }
  830. } elseif ($yyact < self::YYNSTATE + self::YYNRULE) {
  831. $this->yy_reduce($yyact - self::YYNSTATE);
  832. } elseif ($yyact == self::YY_ERROR_ACTION) {
  833. if ($this->yyTraceFILE) {
  834. fprintf($this->yyTraceFILE, "%sSyntax Error!\n", $this->yyTracePrompt);
  835. }
  836. if (self::YYERRORSYMBOL) {
  837. if ($this->yyerrcnt < 0) {
  838. $this->yy_syntax_error($yymajor, $yytokenvalue);
  839. }
  840. $yymx = $this->yystack[$this->yyidx]->major;
  841. if ($yymx == self::YYERRORSYMBOL || $yyerrorhit) {
  842. if ($this->yyTraceFILE) {
  843. fprintf($this->yyTraceFILE, "%sDiscard input token %s\n", $this->yyTracePrompt, $this->yyTokenName[$yymajor]);
  844. }
  845. $this->yy_destructor($yymajor, $yytokenvalue);
  846. $yymajor = self::YYNOCODE;
  847. } else {
  848. while ($this->yyidx >= 0 && $yymx != self::YYERRORSYMBOL && ($yyact = $this->yy_find_shift_action(self::YYERRORSYMBOL)) >= self::YYNSTATE) {
  849. $this->yy_pop_parser_stack();
  850. }
  851. if ($this->yyidx < 0 || $yymajor == 0) {
  852. $this->yy_destructor($yymajor, $yytokenvalue);
  853. $this->yy_parse_failed();
  854. $yymajor = self::YYNOCODE;
  855. } elseif ($yymx != self::YYERRORSYMBOL) {
  856. $u2 = 0;
  857. $this->yy_shift($yyact, self::YYERRORSYMBOL, $u2);
  858. }
  859. }
  860. $this->yyerrcnt = 3;
  861. $yyerrorhit = 1;
  862. } else {
  863. if ($this->yyerrcnt <= 0) {
  864. $this->yy_syntax_error($yymajor, $yytokenvalue);
  865. }
  866. $this->yyerrcnt = 3;
  867. $this->yy_destructor($yymajor, $yytokenvalue);
  868. if ($yyendofinput) {
  869. $this->yy_parse_failed();
  870. }
  871. $yymajor = self::YYNOCODE;
  872. }
  873. } else {
  874. $this->yy_accept();
  875. $yymajor = self::YYNOCODE;
  876. }
  877. } while ($yymajor != self::YYNOCODE && $this->yyidx >= 0);
  878. }
  879. }