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

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