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_templatelexer.php 34KB

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