smarty_internal_configfileparser.php 34 KB

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