smarty_internal_templatelexer.php 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. <?php
  2. /*
  3. * This file is part of Smarty.
  4. *
  5. * (c) 2015 Uwe Tews
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * Smarty_Internal_Templatelexer
  12. * This is the template file lexer.
  13. * It is generated from the smarty_internal_templatelexer.plex file
  14. *
  15. *
  16. * @author Uwe Tews <uwe.tews@googlemail.com>
  17. */
  18. class Smarty_Internal_Templatelexer
  19. {
  20. /**
  21. * Source
  22. *
  23. * @var string
  24. */
  25. public $data;
  26. /**
  27. * Source length
  28. *
  29. * @var int
  30. */
  31. public $dataLength = null;
  32. /**
  33. * byte counter
  34. *
  35. * @var int
  36. */
  37. public $counter;
  38. /**
  39. * token number
  40. *
  41. * @var int
  42. */
  43. public $token;
  44. /**
  45. * token value
  46. *
  47. * @var string
  48. */
  49. public $value;
  50. /**
  51. * current line
  52. *
  53. * @var int
  54. */
  55. public $line;
  56. /**
  57. * tag start line
  58. *
  59. * @var
  60. */
  61. public $taglineno;
  62. /**
  63. * php code type
  64. *
  65. * @var string
  66. */
  67. public $phpType = '';
  68. /**
  69. * escaped left delimiter
  70. *
  71. * @var string
  72. */
  73. public $ldel = '';
  74. /**
  75. * escaped left delimiter length
  76. *
  77. * @var int
  78. */
  79. public $ldel_length = 0;
  80. /**
  81. * escaped right delimiter
  82. *
  83. * @var string
  84. */
  85. public $rdel = '';
  86. /**
  87. * escaped right delimiter length
  88. *
  89. * @var int
  90. */
  91. public $rdel_length = 0;
  92. /**
  93. * state number
  94. *
  95. * @var int
  96. */
  97. public $state = 1;
  98. /**
  99. * Smarty object
  100. *
  101. * @var Smarty
  102. */
  103. public $smarty = null;
  104. /**
  105. * compiler object
  106. *
  107. * @var Smarty_Internal_TemplateCompilerBase
  108. */
  109. public $compiler = null;
  110. /**
  111. * literal tag nesting level
  112. *
  113. * @var int
  114. */
  115. private $literal_cnt = 0;
  116. /**
  117. * PHP start tag string
  118. *
  119. * @var string
  120. */
  121. /**
  122. * trace file
  123. *
  124. * @var resource
  125. */
  126. public $yyTraceFILE;
  127. /**
  128. * trace prompt
  129. *
  130. * @var string
  131. */
  132. public $yyTracePrompt;
  133. /**
  134. * XML flag true while processing xml
  135. *
  136. * @var bool
  137. */
  138. public $is_xml = false;
  139. /**
  140. * state names
  141. *
  142. * @var array
  143. */
  144. public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',);
  145. /**
  146. * storage for assembled token patterns
  147. *
  148. * @var string
  149. */
  150. private $yy_global_pattern1 = null;
  151. private $yy_global_pattern2 = null;
  152. private $yy_global_pattern3 = null;
  153. private $yy_global_pattern4 = null;
  154. private $yy_global_pattern5 = null;
  155. /**
  156. * token names
  157. *
  158. * @var array
  159. */
  160. public $smarty_token_names = array( // Text for parser error messages
  161. 'NOT' => '(!,not)', 'OPENP' => '(', 'CLOSEP' => ')', 'OPENB' => '[',
  162. 'CLOSEB' => ']', 'PTR' => '->', 'APTR' => '=>', 'EQUAL' => '=',
  163. 'NUMBER' => 'number', 'UNIMATH' => '+" , "-', 'MATH' => '*" , "/" , "%',
  164. 'INCDEC' => '++" , "--', 'SPACE' => ' ', 'DOLLAR' => '$',
  165. 'SEMICOLON' => ';', 'COLON' => ':', 'DOUBLECOLON' => '::', 'AT' => '@',
  166. 'HATCH' => '#', 'QUOTE' => '"', 'BACKTICK' => '`',
  167. 'VERT' => '"|" modifier', 'DOT' => '.', 'COMMA' => '","',
  168. 'QMARK' => '"?"', 'ID' => 'id, name', 'TEXT' => 'text',
  169. 'LDELSLASH' => '{/..} closing tag', 'LDEL' => '{...} Smarty tag',
  170. 'COMMENT' => 'comment', 'AS' => 'as', 'TO' => 'to',
  171. 'PHP' => '"<?php", "<%", "{php}" tag',
  172. 'LOGOP' => '"<", "==" ... logical operator',
  173. 'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
  174. 'SCOND' => '"is even" ... if condition',);
  175. /**
  176. * constructor
  177. *
  178. * @param string $data template source
  179. * @param Smarty_Internal_TemplateCompilerBase $compiler
  180. */
  181. function __construct($data, Smarty_Internal_TemplateCompilerBase $compiler)
  182. {
  183. $this->data = $data;
  184. $this->dataLength = strlen($data);
  185. $this->counter = 0;
  186. if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) {
  187. $this->counter += strlen($match[ 0 ]);
  188. }
  189. $this->line = 1;
  190. $this->smarty = $compiler->smarty;
  191. $this->compiler = $compiler;
  192. $this->ldel = preg_quote($this->smarty->left_delimiter, '/');
  193. $this->ldel_length = strlen($this->smarty->left_delimiter);
  194. $this->rdel = preg_quote($this->smarty->right_delimiter, '/');
  195. $this->rdel_length = strlen($this->smarty->right_delimiter);
  196. $this->smarty_token_names[ 'LDEL' ] = $this->smarty->left_delimiter;
  197. $this->smarty_token_names[ 'RDEL' ] = $this->smarty->right_delimiter;
  198. }
  199. public function PrintTrace()
  200. {
  201. $this->yyTraceFILE = fopen('php://output', 'w');
  202. $this->yyTracePrompt = '<br>';
  203. }
  204. /*
  205. * Check if this tag is autoliteral
  206. */
  207. public function isAutoLiteral()
  208. {
  209. return $this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
  210. strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false;
  211. }
  212. private $_yy_state = 1;
  213. private $_yy_stack = array();
  214. public function yylex()
  215. {
  216. return $this->{'yylex' . $this->_yy_state}();
  217. }
  218. public function yypushstate($state)
  219. {
  220. if ($this->yyTraceFILE) {
  221. fprintf($this->yyTraceFILE, "%sState Push %s\n", $this->yyTracePrompt,
  222. isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
  223. $this->_yy_state);
  224. }
  225. array_push($this->_yy_stack, $this->_yy_state);
  226. $this->_yy_state = $state;
  227. if ($this->yyTraceFILE) {
  228. fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
  229. isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
  230. $this->_yy_state);
  231. }
  232. }
  233. public function yypopstate()
  234. {
  235. if ($this->yyTraceFILE) {
  236. fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt,
  237. isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
  238. $this->_yy_state);
  239. }
  240. $this->_yy_state = array_pop($this->_yy_stack);
  241. if ($this->yyTraceFILE) {
  242. fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
  243. isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
  244. $this->_yy_state);
  245. }
  246. }
  247. public function yybegin($state)
  248. {
  249. $this->_yy_state = $state;
  250. if ($this->yyTraceFILE) {
  251. fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt,
  252. isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
  253. $this->_yy_state);
  254. }
  255. }
  256. public function yylex1()
  257. {
  258. if (!isset($this->yy_global_pattern1)) {
  259. $this->yy_global_pattern1 =
  260. "/\G([{][}])|\G(" . $this->ldel . "[*])|\G((" . $this->ldel . "\\s*php([ ].*?)?" . $this->rdel . ")|(" .
  261. $this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel .
  262. ")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel .
  263. ")|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>]))|\G([\S\s])/isS";
  264. }
  265. if (!isset($this->dataLength)) {
  266. $this->dataLength = strlen($this->data);
  267. }
  268. if ($this->counter >= $this->dataLength) {
  269. return false; // end of input
  270. }
  271. do {
  272. if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) {
  273. if (!isset($yymatches[ 0 ][ 1 ])) {
  274. $yymatches = preg_grep("/(.|\s)+/", $yymatches);
  275. } else {
  276. $yymatches = array_filter($yymatches);
  277. }
  278. if (empty($yymatches)) {
  279. throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
  280. substr($this->data, $this->counter, 5) . '... state TEXT');
  281. }
  282. next($yymatches); // skip global match
  283. $this->token = key($yymatches); // token number
  284. $this->value = current($yymatches); // token value
  285. $r = $this->{'yy_r1_' . $this->token}();
  286. if ($r === null) {
  287. $this->counter += strlen($this->value);
  288. $this->line += substr_count($this->value, "\n");
  289. // accept this token
  290. return true;
  291. } elseif ($r === true) {
  292. // we have changed state
  293. // process this token in the new state
  294. return $this->yylex();
  295. } elseif ($r === false) {
  296. $this->counter += strlen($this->value);
  297. $this->line += substr_count($this->value, "\n");
  298. if ($this->counter >= $this->dataLength) {
  299. return false; // end of input
  300. }
  301. // skip this token
  302. continue;
  303. }
  304. } else {
  305. throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
  306. }
  307. break;
  308. }
  309. while (true);
  310. } // end function
  311. const TEXT = 1;
  312. function yy_r1_1()
  313. {
  314. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  315. }
  316. function yy_r1_2()
  317. {
  318. preg_match("/[*]{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
  319. if (isset($match[ 0 ][ 1 ])) {
  320. $to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]);
  321. } else {
  322. $this->compiler->trigger_template_error("missing or misspelled comment closing tag '*{$this->smarty->right_delimiter}'");
  323. }
  324. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  325. return false;
  326. }
  327. function yy_r1_3()
  328. {
  329. $this->compiler->getTagCompiler('private_php')->parsePhp($this);
  330. }
  331. function yy_r1_7()
  332. {
  333. if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
  334. strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
  335. ) {
  336. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  337. } else {
  338. $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
  339. $this->yypushstate(self::LITERAL);
  340. }
  341. }
  342. function yy_r1_8()
  343. {
  344. if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
  345. strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
  346. ) {
  347. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  348. } else {
  349. $this->yypushstate(self::TAG);
  350. return true;
  351. }
  352. }
  353. function yy_r1_9()
  354. {
  355. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  356. }
  357. function yy_r1_10()
  358. {
  359. $this->compiler->getTagCompiler('private_php')->parsePhp($this);
  360. }
  361. function yy_r1_19()
  362. {
  363. $to = $this->dataLength;
  364. preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])/i",
  365. $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
  366. if (isset($match[ 0 ][ 1 ])) {
  367. $to = $match[ 0 ][ 1 ];
  368. }
  369. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  370. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  371. }
  372. public function yylex2()
  373. {
  374. if (!isset($this->yy_global_pattern2)) {
  375. $this->yy_global_pattern2 =
  376. "/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" .
  377. $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(" . $this->ldel .
  378. "\\s*make_nocache\\s+)|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel .
  379. ")|\G(" . $this->ldel . "\\s*[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*" . $this->rdel . ")|\G(" .
  380. $this->ldel . "\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel .
  381. "\\s*[\/])|\G(" . $this->ldel . "\\s*)/isS";
  382. }
  383. if (!isset($this->dataLength)) {
  384. $this->dataLength = strlen($this->data);
  385. }
  386. if ($this->counter >= $this->dataLength) {
  387. return false; // end of input
  388. }
  389. do {
  390. if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) {
  391. if (!isset($yymatches[ 0 ][ 1 ])) {
  392. $yymatches = preg_grep("/(.|\s)+/", $yymatches);
  393. } else {
  394. $yymatches = array_filter($yymatches);
  395. }
  396. if (empty($yymatches)) {
  397. throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
  398. substr($this->data, $this->counter, 5) . '... state TAG');
  399. }
  400. next($yymatches); // skip global match
  401. $this->token = key($yymatches); // token number
  402. $this->value = current($yymatches); // token value
  403. $r = $this->{'yy_r2_' . $this->token}();
  404. if ($r === null) {
  405. $this->counter += strlen($this->value);
  406. $this->line += substr_count($this->value, "\n");
  407. // accept this token
  408. return true;
  409. } elseif ($r === true) {
  410. // we have changed state
  411. // process this token in the new state
  412. return $this->yylex();
  413. } elseif ($r === false) {
  414. $this->counter += strlen($this->value);
  415. $this->line += substr_count($this->value, "\n");
  416. if ($this->counter >= $this->dataLength) {
  417. return false; // end of input
  418. }
  419. // skip this token
  420. continue;
  421. }
  422. } else {
  423. throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
  424. }
  425. break;
  426. }
  427. while (true);
  428. } // end function
  429. const TAG = 2;
  430. function yy_r2_1()
  431. {
  432. $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
  433. $this->yybegin(self::TAGBODY);
  434. $this->taglineno = $this->line;
  435. }
  436. function yy_r2_3()
  437. {
  438. $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
  439. $this->yybegin(self::TAGBODY);
  440. $this->taglineno = $this->line;
  441. }
  442. function yy_r2_4()
  443. {
  444. $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
  445. $this->yybegin(self::TAGBODY);
  446. $this->taglineno = $this->line;
  447. }
  448. function yy_r2_5()
  449. {
  450. $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
  451. $this->yybegin(self::TAGBODY);
  452. $this->taglineno = $this->line;
  453. }
  454. function yy_r2_6()
  455. {
  456. $this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE;
  457. $this->yybegin(self::TAGBODY);
  458. $this->taglineno = $this->line;
  459. }
  460. function yy_r2_7()
  461. {
  462. $this->yypopstate();
  463. $this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG;
  464. $this->taglineno = $this->line;
  465. }
  466. function yy_r2_9()
  467. {
  468. $this->yypopstate();
  469. $this->token = Smarty_Internal_Templateparser::TP_CLOSETAG;
  470. $this->taglineno = $this->line;
  471. }
  472. function yy_r2_10()
  473. {
  474. if ($this->_yy_stack[ count($this->_yy_stack) - 1 ] == self::TEXT) {
  475. $this->yypopstate();
  476. $this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT;
  477. $this->taglineno = $this->line;
  478. } else {
  479. $this->value = $this->smarty->left_delimiter;
  480. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  481. $this->yybegin(self::TAGBODY);
  482. $this->taglineno = $this->line;
  483. }
  484. }
  485. function yy_r2_12()
  486. {
  487. $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
  488. $this->yybegin(self::TAGBODY);
  489. $this->taglineno = $this->line;
  490. }
  491. function yy_r2_13()
  492. {
  493. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  494. $this->yybegin(self::TAGBODY);
  495. $this->taglineno = $this->line;
  496. }
  497. public function yylex3()
  498. {
  499. if (!isset($this->yy_global_pattern3)) {
  500. $this->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\G(" . $this->ldel .
  501. "\\s*)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$]smarty\\.block\\.(child|parent))|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+(is\\s+(not\\s+)?(odd|even|div)\\s+by)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G(([!]\\s*)|(not\\s+))|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|])|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS";
  502. }
  503. if (!isset($this->dataLength)) {
  504. $this->dataLength = strlen($this->data);
  505. }
  506. if ($this->counter >= $this->dataLength) {
  507. return false; // end of input
  508. }
  509. do {
  510. if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) {
  511. if (!isset($yymatches[ 0 ][ 1 ])) {
  512. $yymatches = preg_grep("/(.|\s)+/", $yymatches);
  513. } else {
  514. $yymatches = array_filter($yymatches);
  515. }
  516. if (empty($yymatches)) {
  517. throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
  518. substr($this->data, $this->counter, 5) . '... state TAGBODY');
  519. }
  520. next($yymatches); // skip global match
  521. $this->token = key($yymatches); // token number
  522. $this->value = current($yymatches); // token value
  523. $r = $this->{'yy_r3_' . $this->token}();
  524. if ($r === null) {
  525. $this->counter += strlen($this->value);
  526. $this->line += substr_count($this->value, "\n");
  527. // accept this token
  528. return true;
  529. } elseif ($r === true) {
  530. // we have changed state
  531. // process this token in the new state
  532. return $this->yylex();
  533. } elseif ($r === false) {
  534. $this->counter += strlen($this->value);
  535. $this->line += substr_count($this->value, "\n");
  536. if ($this->counter >= $this->dataLength) {
  537. return false; // end of input
  538. }
  539. // skip this token
  540. continue;
  541. }
  542. } else {
  543. throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
  544. }
  545. break;
  546. }
  547. while (true);
  548. } // end function
  549. const TAGBODY = 3;
  550. function yy_r3_1()
  551. {
  552. $this->token = Smarty_Internal_Templateparser::TP_RDEL;
  553. $this->yypopstate();
  554. }
  555. function yy_r3_2()
  556. {
  557. if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
  558. strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
  559. ) {
  560. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  561. } else {
  562. $this->yypushstate(self::TAG);
  563. return true;
  564. }
  565. }
  566. function yy_r3_3()
  567. {
  568. $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
  569. $this->yypushstate(self::DOUBLEQUOTEDSTRING);
  570. }
  571. function yy_r3_4()
  572. {
  573. $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
  574. }
  575. function yy_r3_5()
  576. {
  577. $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
  578. $this->taglineno = $this->line;
  579. }
  580. function yy_r3_7()
  581. {
  582. $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
  583. }
  584. function yy_r3_8()
  585. {
  586. $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
  587. }
  588. function yy_r3_9()
  589. {
  590. $this->token = Smarty_Internal_Templateparser::TP_ISIN;
  591. }
  592. function yy_r3_10()
  593. {
  594. $this->token = Smarty_Internal_Templateparser::TP_AS;
  595. }
  596. function yy_r3_11()
  597. {
  598. $this->token = Smarty_Internal_Templateparser::TP_TO;
  599. }
  600. function yy_r3_12()
  601. {
  602. $this->token = Smarty_Internal_Templateparser::TP_STEP;
  603. }
  604. function yy_r3_13()
  605. {
  606. $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
  607. }
  608. function yy_r3_14()
  609. {
  610. $this->token = Smarty_Internal_Templateparser::TP_LOGOP;
  611. }
  612. function yy_r3_19()
  613. {
  614. $this->token = Smarty_Internal_Templateparser::TP_SLOGOP;
  615. }
  616. function yy_r3_21()
  617. {
  618. $this->token = Smarty_Internal_Templateparser::TP_TLOGOP;
  619. }
  620. function yy_r3_25()
  621. {
  622. $this->token = Smarty_Internal_Templateparser::TP_SINGLECOND;
  623. }
  624. function yy_r3_28()
  625. {
  626. $this->token = Smarty_Internal_Templateparser::TP_NOT;
  627. }
  628. function yy_r3_31()
  629. {
  630. $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
  631. }
  632. function yy_r3_35()
  633. {
  634. $this->token = Smarty_Internal_Templateparser::TP_OPENP;
  635. }
  636. function yy_r3_36()
  637. {
  638. $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
  639. }
  640. function yy_r3_37()
  641. {
  642. $this->token = Smarty_Internal_Templateparser::TP_OPENB;
  643. }
  644. function yy_r3_38()
  645. {
  646. $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
  647. }
  648. function yy_r3_39()
  649. {
  650. $this->token = Smarty_Internal_Templateparser::TP_PTR;
  651. }
  652. function yy_r3_40()
  653. {
  654. $this->token = Smarty_Internal_Templateparser::TP_APTR;
  655. }
  656. function yy_r3_41()
  657. {
  658. $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
  659. }
  660. function yy_r3_42()
  661. {
  662. $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
  663. }
  664. function yy_r3_44()
  665. {
  666. $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
  667. }
  668. function yy_r3_46()
  669. {
  670. $this->token = Smarty_Internal_Templateparser::TP_MATH;
  671. }
  672. function yy_r3_48()
  673. {
  674. $this->token = Smarty_Internal_Templateparser::TP_AT;
  675. }
  676. function yy_r3_49()
  677. {
  678. $this->token = Smarty_Internal_Templateparser::TP_HATCH;
  679. }
  680. function yy_r3_50()
  681. {
  682. // resolve conflicts with shorttag and right_delimiter starting with '='
  683. if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) ==
  684. $this->smarty->right_delimiter
  685. ) {
  686. preg_match("/\s+/", $this->value, $match);
  687. $this->value = $match[ 0 ];
  688. $this->token = Smarty_Internal_Templateparser::TP_SPACE;
  689. } else {
  690. $this->token = Smarty_Internal_Templateparser::TP_ATTR;
  691. }
  692. }
  693. function yy_r3_51()
  694. {
  695. $this->token = Smarty_Internal_Templateparser::TP_NAMESPACE;
  696. }
  697. function yy_r3_54()
  698. {
  699. $this->token = Smarty_Internal_Templateparser::TP_ID;
  700. }
  701. function yy_r3_55()
  702. {
  703. $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
  704. }
  705. function yy_r3_56()
  706. {
  707. $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
  708. $this->yypopstate();
  709. }
  710. function yy_r3_57()
  711. {
  712. $this->token = Smarty_Internal_Templateparser::TP_VERT;
  713. }
  714. function yy_r3_58()
  715. {
  716. $this->token = Smarty_Internal_Templateparser::TP_DOT;
  717. }
  718. function yy_r3_59()
  719. {
  720. $this->token = Smarty_Internal_Templateparser::TP_COMMA;
  721. }
  722. function yy_r3_60()
  723. {
  724. $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
  725. }
  726. function yy_r3_61()
  727. {
  728. $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
  729. }
  730. function yy_r3_62()
  731. {
  732. $this->token = Smarty_Internal_Templateparser::TP_COLON;
  733. }
  734. function yy_r3_63()
  735. {
  736. $this->token = Smarty_Internal_Templateparser::TP_QMARK;
  737. }
  738. function yy_r3_64()
  739. {
  740. $this->token = Smarty_Internal_Templateparser::TP_HEX;
  741. }
  742. function yy_r3_65()
  743. {
  744. $this->token = Smarty_Internal_Templateparser::TP_SPACE;
  745. }
  746. function yy_r3_66()
  747. {
  748. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  749. }
  750. public function yylex4()
  751. {
  752. if (!isset($this->yy_global_pattern4)) {
  753. $this->yy_global_pattern4 =
  754. "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" .
  755. $this->rdel . ")|\G([\S\s])/isS";
  756. }
  757. if (!isset($this->dataLength)) {
  758. $this->dataLength = strlen($this->data);
  759. }
  760. if ($this->counter >= $this->dataLength) {
  761. return false; // end of input
  762. }
  763. do {
  764. if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) {
  765. if (!isset($yymatches[ 0 ][ 1 ])) {
  766. $yymatches = preg_grep("/(.|\s)+/", $yymatches);
  767. } else {
  768. $yymatches = array_filter($yymatches);
  769. }
  770. if (empty($yymatches)) {
  771. throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
  772. substr($this->data, $this->counter, 5) . '... state LITERAL');
  773. }
  774. next($yymatches); // skip global match
  775. $this->token = key($yymatches); // token number
  776. $this->value = current($yymatches); // token value
  777. $r = $this->{'yy_r4_' . $this->token}();
  778. if ($r === null) {
  779. $this->counter += strlen($this->value);
  780. $this->line += substr_count($this->value, "\n");
  781. // accept this token
  782. return true;
  783. } elseif ($r === true) {
  784. // we have changed state
  785. // process this token in the new state
  786. return $this->yylex();
  787. } elseif ($r === false) {
  788. $this->counter += strlen($this->value);
  789. $this->line += substr_count($this->value, "\n");
  790. if ($this->counter >= $this->dataLength) {
  791. return false; // end of input
  792. }
  793. // skip this token
  794. continue;
  795. }
  796. } else {
  797. throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
  798. }
  799. break;
  800. }
  801. while (true);
  802. } // end function
  803. const LITERAL = 4;
  804. function yy_r4_1()
  805. {
  806. $this->literal_cnt ++;
  807. $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
  808. }
  809. function yy_r4_2()
  810. {
  811. if ($this->literal_cnt) {
  812. $this->literal_cnt --;
  813. $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
  814. } else {
  815. $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
  816. $this->yypopstate();
  817. }
  818. }
  819. function yy_r4_3()
  820. {
  821. $to = $this->dataLength;
  822. preg_match("/{$this->ldel}[\/]?literal{$this->rdel}/i", $this->data, $match, PREG_OFFSET_CAPTURE,
  823. $this->counter);
  824. if (isset($match[ 0 ][ 1 ])) {
  825. $to = $match[ 0 ][ 1 ];
  826. } else {
  827. $this->compiler->trigger_template_error("missing or misspelled literal closing tag");
  828. }
  829. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  830. $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
  831. }
  832. public function yylex5()
  833. {
  834. if (!isset($this->yy_global_pattern5)) {
  835. $this->yy_global_pattern5 =
  836. "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" .
  837. $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" .
  838. $this->ldel .
  839. "\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" .
  840. $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS";
  841. }
  842. if (!isset($this->dataLength)) {
  843. $this->dataLength = strlen($this->data);
  844. }
  845. if ($this->counter >= $this->dataLength) {
  846. return false; // end of input
  847. }
  848. do {
  849. if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) {
  850. if (!isset($yymatches[ 0 ][ 1 ])) {
  851. $yymatches = preg_grep("/(.|\s)+/", $yymatches);
  852. } else {
  853. $yymatches = array_filter($yymatches);
  854. }
  855. if (empty($yymatches)) {
  856. throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
  857. substr($this->data, $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
  858. }
  859. next($yymatches); // skip global match
  860. $this->token = key($yymatches); // token number
  861. $this->value = current($yymatches); // token value
  862. $r = $this->{'yy_r5_' . $this->token}();
  863. if ($r === null) {
  864. $this->counter += strlen($this->value);
  865. $this->line += substr_count($this->value, "\n");
  866. // accept this token
  867. return true;
  868. } elseif ($r === true) {
  869. // we have changed state
  870. // process this token in the new state
  871. return $this->yylex();
  872. } elseif ($r === false) {
  873. $this->counter += strlen($this->value);
  874. $this->line += substr_count($this->value, "\n");
  875. if ($this->counter >= $this->dataLength) {
  876. return false; // end of input
  877. }
  878. // skip this token
  879. continue;
  880. }
  881. } else {
  882. throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
  883. }
  884. break;
  885. }
  886. while (true);
  887. } // end function
  888. const DOUBLEQUOTEDSTRING = 5;
  889. function yy_r5_1()
  890. {
  891. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  892. }
  893. function yy_r5_2()
  894. {
  895. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  896. }
  897. function yy_r5_3()
  898. {
  899. if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
  900. strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
  901. ) {
  902. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  903. } else {
  904. $this->yypushstate(self::TAG);
  905. return true;
  906. }
  907. }
  908. function yy_r5_4()
  909. {
  910. if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
  911. strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
  912. ) {
  913. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  914. } else {
  915. $this->yypushstate(self::TAG);
  916. return true;
  917. }
  918. }
  919. function yy_r5_5()
  920. {
  921. if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
  922. strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
  923. ) {
  924. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  925. } else {
  926. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  927. $this->taglineno = $this->line;
  928. $this->yypushstate(self::TAGBODY);
  929. }
  930. }
  931. function yy_r5_6()
  932. {
  933. $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
  934. $this->yypopstate();
  935. }
  936. function yy_r5_7()
  937. {
  938. $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
  939. $this->value = substr($this->value, 0, - 1);
  940. $this->yypushstate(self::TAGBODY);
  941. $this->taglineno = $this->line;
  942. }
  943. function yy_r5_8()
  944. {
  945. $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
  946. }
  947. function yy_r5_9()
  948. {
  949. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  950. }
  951. function yy_r5_10()
  952. {
  953. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  954. }
  955. function yy_r5_14()
  956. {
  957. $to = $this->dataLength;
  958. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  959. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  960. }
  961. }