smarty_internal_templatelexer.php 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  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' => ')', 'OPENB' => '[',
  156. 'CLOSEB' => ']', 'PTR' => '->', 'APTR' => '=>', 'EQUAL' => '=',
  157. 'NUMBER' => 'number', 'UNIMATH' => '+" , "-', 'MATH' => '*" , "/" , "%',
  158. 'INCDEC' => '++" , "--', 'SPACE' => ' ', 'DOLLAR' => '$',
  159. 'SEMICOLON' => ';', 'COLON' => ':', 'DOUBLECOLON' => '::', 'AT' => '@',
  160. 'HATCH' => '#', 'QUOTE' => '"', 'BACKTICK' => '`',
  161. 'VERT' => '"|" modifier', 'DOT' => '.', 'COMMA' => '","',
  162. 'QMARK' => '"?"', 'ID' => 'id, name', 'TEXT' => 'text',
  163. 'LDELSLASH' => '{/..} closing tag', 'LDEL' => '{...} Smarty tag',
  164. 'COMMENT' => 'comment', 'AS' => 'as', 'TO' => 'to',
  165. 'PHP' => '"<?php", "<%", "{php}" tag',
  166. 'LOGOP' => '"<", "==" ... logical operator',
  167. 'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
  168. 'SCOND' => '"is even" ... if condition',);
  169. /**
  170. * constructor
  171. *
  172. * @param string $data template source
  173. * @param Smarty_Internal_TemplateCompilerBase $compiler
  174. */
  175. function __construct($data, Smarty_Internal_TemplateCompilerBase $compiler)
  176. {
  177. $this->data = $data;
  178. $this->counter = 0;
  179. if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) {
  180. $this->counter += strlen($match[ 0 ]);
  181. }
  182. $this->line = 1;
  183. $this->smarty = $compiler->smarty;
  184. $this->compiler = $compiler;
  185. $this->ldel = preg_quote($this->smarty->left_delimiter, '/');
  186. $this->ldel_length = strlen($this->smarty->left_delimiter);
  187. $this->rdel = preg_quote($this->smarty->right_delimiter, '/');
  188. $this->rdel_length = strlen($this->smarty->right_delimiter);
  189. $this->smarty_token_names[ 'LDEL' ] = $this->smarty->left_delimiter;
  190. $this->smarty_token_names[ 'RDEL' ] = $this->smarty->right_delimiter;
  191. }
  192. public function PrintTrace()
  193. {
  194. $this->yyTraceFILE = fopen('php://output', 'w');
  195. $this->yyTracePrompt = '<br>';
  196. }
  197. /*
  198. * Check if this tag is autoliteral
  199. */
  200. public function isAutoLiteral()
  201. {
  202. return $this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
  203. strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false;
  204. }
  205. private $_yy_state = 1;
  206. private $_yy_stack = array();
  207. public function yylex()
  208. {
  209. return $this->{'yylex' . $this->_yy_state}();
  210. }
  211. public function yypushstate($state)
  212. {
  213. if ($this->yyTraceFILE) {
  214. fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt,
  215. isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
  216. $this->_yy_state);
  217. }
  218. array_push($this->_yy_stack, $this->_yy_state);
  219. $this->_yy_state = $state;
  220. if ($this->yyTraceFILE) {
  221. fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
  222. isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
  223. $this->_yy_state);
  224. }
  225. }
  226. public function yypopstate()
  227. {
  228. if ($this->yyTraceFILE) {
  229. fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt,
  230. isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
  231. $this->_yy_state);
  232. }
  233. $this->_yy_state = array_pop($this->_yy_stack);
  234. if ($this->yyTraceFILE) {
  235. fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
  236. isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
  237. $this->_yy_state);
  238. }
  239. }
  240. public function yybegin($state)
  241. {
  242. $this->_yy_state = $state;
  243. if ($this->yyTraceFILE) {
  244. fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt,
  245. isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
  246. $this->_yy_state);
  247. }
  248. }
  249. public function yylex1()
  250. {
  251. if (!isset($this->yy_global_pattern1)) {
  252. $this->yy_global_pattern1 =
  253. "/\G([{][}])|\G(" . $this->ldel . "[*])|\G((" . $this->ldel . "\\s*php([ ].*?)?" . $this->rdel . ")|(" .
  254. $this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel .
  255. ")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel .
  256. ")|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>]))|\G([\S\s])/isS";
  257. }
  258. if ($this->counter >= strlen($this->data)) {
  259. return false; // end of input
  260. }
  261. do {
  262. if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) {
  263. $yysubmatches = $yymatches;
  264. if (strlen($yysubmatches[ 0 ]) < 200) {
  265. $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
  266. } else {
  267. $yymatches = array_filter($yymatches, 'strlen');
  268. }
  269. if (empty($yymatches)) {
  270. throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
  271. substr($this->data, $this->counter, 5) . '... state TEXT');
  272. }
  273. next($yymatches); // skip global match
  274. $this->token = key($yymatches); // token number
  275. $this->value = current($yymatches); // token value
  276. $r = $this->{'yy_r1_' . $this->token}();
  277. if ($r === null) {
  278. $this->counter += strlen($this->value);
  279. $this->line += substr_count($this->value, "\n");
  280. // accept this token
  281. return true;
  282. } elseif ($r === true) {
  283. // we have changed state
  284. // process this token in the new state
  285. return $this->yylex();
  286. } elseif ($r === false) {
  287. $this->counter += strlen($this->value);
  288. $this->line += substr_count($this->value, "\n");
  289. if ($this->counter >= strlen($this->data)) {
  290. return false; // end of input
  291. }
  292. // skip this token
  293. continue;
  294. }
  295. } else {
  296. throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
  297. }
  298. break;
  299. }
  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*make_nocache\\s+)|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel .
  372. ")|\G(" . $this->ldel . "\\s*[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*" . $this->rdel . ")|\G(" .
  373. $this->ldel . "\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel .
  374. "\\s*[\/])|\G(" . $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. }
  418. while (true);
  419. } // end function
  420. const TAG = 2;
  421. function yy_r2_1()
  422. {
  423. $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
  424. $this->yybegin(self::TAGBODY);
  425. $this->taglineno = $this->line;
  426. }
  427. function yy_r2_3()
  428. {
  429. $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
  430. $this->yybegin(self::TAGBODY);
  431. $this->taglineno = $this->line;
  432. }
  433. function yy_r2_4()
  434. {
  435. $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
  436. $this->yybegin(self::TAGBODY);
  437. $this->taglineno = $this->line;
  438. }
  439. function yy_r2_5()
  440. {
  441. $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
  442. $this->yybegin(self::TAGBODY);
  443. $this->taglineno = $this->line;
  444. }
  445. function yy_r2_6()
  446. {
  447. $this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE;
  448. $this->yybegin(self::TAGBODY);
  449. $this->taglineno = $this->line;
  450. }
  451. function yy_r2_7()
  452. {
  453. $this->yypopstate();
  454. $this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG;
  455. $this->taglineno = $this->line;
  456. }
  457. function yy_r2_9()
  458. {
  459. $this->yypopstate();
  460. $this->token = Smarty_Internal_Templateparser::TP_CLOSETAG;
  461. $this->taglineno = $this->line;
  462. }
  463. function yy_r2_10()
  464. {
  465. if ($this->_yy_stack[ count($this->_yy_stack) - 1 ] == self::TEXT) {
  466. $this->yypopstate();
  467. $this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT;
  468. $this->taglineno = $this->line;
  469. } else {
  470. $this->value = $this->smarty->left_delimiter;
  471. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  472. $this->yybegin(self::TAGBODY);
  473. $this->taglineno = $this->line;
  474. }
  475. }
  476. function yy_r2_12()
  477. {
  478. $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
  479. $this->yybegin(self::TAGBODY);
  480. $this->taglineno = $this->line;
  481. }
  482. function yy_r2_13()
  483. {
  484. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  485. $this->yybegin(self::TAGBODY);
  486. $this->taglineno = $this->line;
  487. }
  488. public function yylex3()
  489. {
  490. if (!isset($this->yy_global_pattern3)) {
  491. $this->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\G(" . $this->ldel .
  492. "\\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";
  493. }
  494. if ($this->counter >= strlen($this->data)) {
  495. return false; // end of input
  496. }
  497. do {
  498. if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) {
  499. $yysubmatches = $yymatches;
  500. if (strlen($yysubmatches[ 0 ]) < 200) {
  501. $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
  502. } else {
  503. $yymatches = array_filter($yymatches, 'strlen');
  504. }
  505. if (empty($yymatches)) {
  506. throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
  507. substr($this->data, $this->counter, 5) . '... state TAGBODY');
  508. }
  509. next($yymatches); // skip global match
  510. $this->token = key($yymatches); // token number
  511. $this->value = current($yymatches); // token value
  512. $r = $this->{'yy_r3_' . $this->token}();
  513. if ($r === null) {
  514. $this->counter += strlen($this->value);
  515. $this->line += substr_count($this->value, "\n");
  516. // accept this token
  517. return true;
  518. } elseif ($r === true) {
  519. // we have changed state
  520. // process this token in the new state
  521. return $this->yylex();
  522. } elseif ($r === false) {
  523. $this->counter += strlen($this->value);
  524. $this->line += substr_count($this->value, "\n");
  525. if ($this->counter >= strlen($this->data)) {
  526. return false; // end of input
  527. }
  528. // skip this token
  529. continue;
  530. }
  531. } else {
  532. throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
  533. }
  534. break;
  535. }
  536. while (true);
  537. } // end function
  538. const TAGBODY = 3;
  539. function yy_r3_1()
  540. {
  541. $this->token = Smarty_Internal_Templateparser::TP_RDEL;
  542. $this->yypopstate();
  543. }
  544. function yy_r3_2()
  545. {
  546. if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
  547. strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
  548. ) {
  549. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  550. } else {
  551. $this->yypushstate(self::TAG);
  552. return true;
  553. }
  554. }
  555. function yy_r3_3()
  556. {
  557. $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
  558. $this->yypushstate(self::DOUBLEQUOTEDSTRING);
  559. }
  560. function yy_r3_4()
  561. {
  562. $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
  563. }
  564. function yy_r3_5()
  565. {
  566. $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
  567. $this->taglineno = $this->line;
  568. }
  569. function yy_r3_7()
  570. {
  571. $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
  572. }
  573. function yy_r3_8()
  574. {
  575. $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
  576. }
  577. function yy_r3_9()
  578. {
  579. $this->token = Smarty_Internal_Templateparser::TP_ISIN;
  580. }
  581. function yy_r3_10()
  582. {
  583. $this->token = Smarty_Internal_Templateparser::TP_AS;
  584. }
  585. function yy_r3_11()
  586. {
  587. $this->token = Smarty_Internal_Templateparser::TP_TO;
  588. }
  589. function yy_r3_12()
  590. {
  591. $this->token = Smarty_Internal_Templateparser::TP_STEP;
  592. }
  593. function yy_r3_13()
  594. {
  595. $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
  596. }
  597. function yy_r3_14()
  598. {
  599. $this->token = Smarty_Internal_Templateparser::TP_LOGOP;
  600. }
  601. function yy_r3_19()
  602. {
  603. $this->token = Smarty_Internal_Templateparser::TP_SLOGOP;
  604. }
  605. function yy_r3_21()
  606. {
  607. $this->token = Smarty_Internal_Templateparser::TP_TLOGOP;
  608. }
  609. function yy_r3_25()
  610. {
  611. $this->token = Smarty_Internal_Templateparser::TP_SINGLECOND;
  612. }
  613. function yy_r3_28()
  614. {
  615. $this->token = Smarty_Internal_Templateparser::TP_NOT;
  616. }
  617. function yy_r3_31()
  618. {
  619. $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
  620. }
  621. function yy_r3_35()
  622. {
  623. $this->token = Smarty_Internal_Templateparser::TP_OPENP;
  624. }
  625. function yy_r3_36()
  626. {
  627. $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
  628. }
  629. function yy_r3_37()
  630. {
  631. $this->token = Smarty_Internal_Templateparser::TP_OPENB;
  632. }
  633. function yy_r3_38()
  634. {
  635. $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
  636. }
  637. function yy_r3_39()
  638. {
  639. $this->token = Smarty_Internal_Templateparser::TP_PTR;
  640. }
  641. function yy_r3_40()
  642. {
  643. $this->token = Smarty_Internal_Templateparser::TP_APTR;
  644. }
  645. function yy_r3_41()
  646. {
  647. $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
  648. }
  649. function yy_r3_42()
  650. {
  651. $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
  652. }
  653. function yy_r3_44()
  654. {
  655. $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
  656. }
  657. function yy_r3_46()
  658. {
  659. $this->token = Smarty_Internal_Templateparser::TP_MATH;
  660. }
  661. function yy_r3_48()
  662. {
  663. $this->token = Smarty_Internal_Templateparser::TP_AT;
  664. }
  665. function yy_r3_49()
  666. {
  667. $this->token = Smarty_Internal_Templateparser::TP_HATCH;
  668. }
  669. function yy_r3_50()
  670. {
  671. // resolve conflicts with shorttag and right_delimiter starting with '='
  672. if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) ==
  673. $this->smarty->right_delimiter
  674. ) {
  675. preg_match("/\s+/", $this->value, $match);
  676. $this->value = $match[ 0 ];
  677. $this->token = Smarty_Internal_Templateparser::TP_SPACE;
  678. } else {
  679. $this->token = Smarty_Internal_Templateparser::TP_ATTR;
  680. }
  681. }
  682. function yy_r3_51()
  683. {
  684. $this->token = Smarty_Internal_Templateparser::TP_NAMESPACE;
  685. }
  686. function yy_r3_54()
  687. {
  688. $this->token = Smarty_Internal_Templateparser::TP_ID;
  689. }
  690. function yy_r3_55()
  691. {
  692. $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
  693. }
  694. function yy_r3_56()
  695. {
  696. $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
  697. $this->yypopstate();
  698. }
  699. function yy_r3_57()
  700. {
  701. $this->token = Smarty_Internal_Templateparser::TP_VERT;
  702. }
  703. function yy_r3_58()
  704. {
  705. $this->token = Smarty_Internal_Templateparser::TP_DOT;
  706. }
  707. function yy_r3_59()
  708. {
  709. $this->token = Smarty_Internal_Templateparser::TP_COMMA;
  710. }
  711. function yy_r3_60()
  712. {
  713. $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
  714. }
  715. function yy_r3_61()
  716. {
  717. $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
  718. }
  719. function yy_r3_62()
  720. {
  721. $this->token = Smarty_Internal_Templateparser::TP_COLON;
  722. }
  723. function yy_r3_63()
  724. {
  725. $this->token = Smarty_Internal_Templateparser::TP_QMARK;
  726. }
  727. function yy_r3_64()
  728. {
  729. $this->token = Smarty_Internal_Templateparser::TP_HEX;
  730. }
  731. function yy_r3_65()
  732. {
  733. $this->token = Smarty_Internal_Templateparser::TP_SPACE;
  734. }
  735. function yy_r3_66()
  736. {
  737. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  738. }
  739. public function yylex4()
  740. {
  741. if (!isset($this->yy_global_pattern4)) {
  742. $this->yy_global_pattern4 =
  743. "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" .
  744. $this->rdel . ")|\G([\S\s])/isS";
  745. }
  746. if ($this->counter >= strlen($this->data)) {
  747. return false; // end of input
  748. }
  749. do {
  750. if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) {
  751. $yysubmatches = $yymatches;
  752. if (strlen($yysubmatches[ 0 ]) < 200) {
  753. $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
  754. } else {
  755. $yymatches = array_filter($yymatches, 'strlen');
  756. }
  757. if (empty($yymatches)) {
  758. throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
  759. substr($this->data, $this->counter, 5) . '... state LITERAL');
  760. }
  761. next($yymatches); // skip global match
  762. $this->token = key($yymatches); // token number
  763. $this->value = current($yymatches); // token value
  764. $r = $this->{'yy_r4_' . $this->token}();
  765. if ($r === null) {
  766. $this->counter += strlen($this->value);
  767. $this->line += substr_count($this->value, "\n");
  768. // accept this token
  769. return true;
  770. } elseif ($r === true) {
  771. // we have changed state
  772. // process this token in the new state
  773. return $this->yylex();
  774. } elseif ($r === false) {
  775. $this->counter += strlen($this->value);
  776. $this->line += substr_count($this->value, "\n");
  777. if ($this->counter >= strlen($this->data)) {
  778. return false; // end of input
  779. }
  780. // skip this token
  781. continue;
  782. }
  783. } else {
  784. throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
  785. }
  786. break;
  787. }
  788. while (true);
  789. } // end function
  790. const LITERAL = 4;
  791. function yy_r4_1()
  792. {
  793. $this->literal_cnt ++;
  794. $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
  795. }
  796. function yy_r4_2()
  797. {
  798. if ($this->literal_cnt) {
  799. $this->literal_cnt --;
  800. $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
  801. } else {
  802. $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
  803. $this->yypopstate();
  804. }
  805. }
  806. function yy_r4_3()
  807. {
  808. $to = strlen($this->data);
  809. preg_match("/{$this->ldel}[\/]?literal{$this->rdel}/i", $this->data, $match, PREG_OFFSET_CAPTURE,
  810. $this->counter);
  811. if (isset($match[ 0 ][ 1 ])) {
  812. $to = $match[ 0 ][ 1 ];
  813. } else {
  814. $this->compiler->trigger_template_error("missing or misspelled literal closing tag");
  815. }
  816. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  817. $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
  818. }
  819. public function yylex5()
  820. {
  821. if (!isset($this->yy_global_pattern5)) {
  822. $this->yy_global_pattern5 =
  823. "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" .
  824. $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" .
  825. $this->ldel .
  826. "\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" .
  827. $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS";
  828. }
  829. if ($this->counter >= strlen($this->data)) {
  830. return false; // end of input
  831. }
  832. do {
  833. if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) {
  834. $yysubmatches = $yymatches;
  835. if (strlen($yysubmatches[ 0 ]) < 200) {
  836. $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
  837. } else {
  838. $yymatches = array_filter($yymatches, 'strlen');
  839. }
  840. if (empty($yymatches)) {
  841. throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
  842. substr($this->data, $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
  843. }
  844. next($yymatches); // skip global match
  845. $this->token = key($yymatches); // token number
  846. $this->value = current($yymatches); // token value
  847. $r = $this->{'yy_r5_' . $this->token}();
  848. if ($r === null) {
  849. $this->counter += strlen($this->value);
  850. $this->line += substr_count($this->value, "\n");
  851. // accept this token
  852. return true;
  853. } elseif ($r === true) {
  854. // we have changed state
  855. // process this token in the new state
  856. return $this->yylex();
  857. } elseif ($r === false) {
  858. $this->counter += strlen($this->value);
  859. $this->line += substr_count($this->value, "\n");
  860. if ($this->counter >= strlen($this->data)) {
  861. return false; // end of input
  862. }
  863. // skip this token
  864. continue;
  865. }
  866. } else {
  867. throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
  868. }
  869. break;
  870. }
  871. while (true);
  872. } // end function
  873. const DOUBLEQUOTEDSTRING = 5;
  874. function yy_r5_1()
  875. {
  876. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  877. }
  878. function yy_r5_2()
  879. {
  880. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  881. }
  882. function yy_r5_3()
  883. {
  884. if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
  885. strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
  886. ) {
  887. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  888. } else {
  889. $this->yypushstate(self::TAG);
  890. return true;
  891. }
  892. }
  893. function yy_r5_4()
  894. {
  895. if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
  896. strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
  897. ) {
  898. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  899. } else {
  900. $this->yypushstate(self::TAG);
  901. return true;
  902. }
  903. }
  904. function yy_r5_5()
  905. {
  906. if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
  907. strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
  908. ) {
  909. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  910. } else {
  911. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  912. $this->taglineno = $this->line;
  913. $this->yypushstate(self::TAGBODY);
  914. }
  915. }
  916. function yy_r5_6()
  917. {
  918. $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
  919. $this->yypopstate();
  920. }
  921. function yy_r5_7()
  922. {
  923. $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
  924. $this->value = substr($this->value, 0, - 1);
  925. $this->yypushstate(self::TAGBODY);
  926. $this->taglineno = $this->line;
  927. }
  928. function yy_r5_8()
  929. {
  930. $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
  931. }
  932. function yy_r5_9()
  933. {
  934. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  935. }
  936. function yy_r5_10()
  937. {
  938. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  939. }
  940. function yy_r5_14()
  941. {
  942. $to = strlen($this->data);
  943. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  944. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  945. }
  946. }