PageRenderTime 38ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/core/Associates/Smarty/sysplugins/smarty_internal_templatelexer.php

https://gitlab.com/fiesta-framework/Documentation
PHP | 1399 lines | 1378 code | 9 blank | 12 comment | 7 complexity | 2afc7bc5e979ef79b566e942849e316a MD5 | raw file
  1. <?php
  2. /**
  3. * Smarty Internal Plugin Templatelexer
  4. * This is the lexer to break the template source into tokens
  5. *
  6. * @package Smarty
  7. * @subpackage Compiler
  8. * @author Uwe Tews
  9. */
  10. /**
  11. * Smarty Internal Plugin Templatelexer
  12. */
  13. class Smarty_Internal_Templatelexer
  14. {
  15. public $data;
  16. public $counter;
  17. public $token;
  18. public $value;
  19. public $node;
  20. public $line;
  21. public $taglineno;
  22. public $is_phpScript = false;
  23. public $state = 1;
  24. public $smarty;
  25. public $literal_cnt = 0;
  26. private $heredoc_id_stack = Array();
  27. public $yyTraceFILE;
  28. public $yyTracePrompt;
  29. public $state_name = array(1 => 'TEXT', 2 => 'SMARTY', 3 => 'LITERAL', 4 => 'DOUBLEQUOTEDSTRING', 5 => 'CHILDBODY');
  30. public $smarty_token_names = array( // Text for parser error messages
  31. 'IDENTITY' => '===',
  32. 'NONEIDENTITY' => '!==',
  33. 'EQUALS' => '==',
  34. 'NOTEQUALS' => '!=',
  35. 'GREATEREQUAL' => '(>=,ge)',
  36. 'LESSEQUAL' => '(<=,le)',
  37. 'GREATERTHAN' => '(>,gt)',
  38. 'LESSTHAN' => '(<,lt)',
  39. 'MOD' => '(%,mod)',
  40. 'NOT' => '(!,not)',
  41. 'LAND' => '(&&,and)',
  42. 'LOR' => '(||,or)',
  43. 'LXOR' => 'xor',
  44. 'OPENP' => '(',
  45. 'CLOSEP' => ')',
  46. 'OPENB' => '[',
  47. 'CLOSEB' => ']',
  48. 'PTR' => '->',
  49. 'APTR' => '=>',
  50. 'EQUAL' => '=',
  51. 'NUMBER' => 'number',
  52. 'UNIMATH' => '+" , "-',
  53. 'MATH' => '*" , "/" , "%',
  54. 'INCDEC' => '++" , "--',
  55. 'SPACE' => ' ',
  56. 'DOLLAR' => '$',
  57. 'SEMICOLON' => ';',
  58. 'COLON' => ':',
  59. 'DOUBLECOLON' => '::',
  60. 'AT' => '@',
  61. 'HATCH' => '#',
  62. 'QUOTE' => '"',
  63. 'BACKTICK' => '`',
  64. 'VERT' => '|',
  65. 'DOT' => '.',
  66. 'COMMA' => '","',
  67. 'ANDSYM' => '"&"',
  68. 'QMARK' => '"?"',
  69. 'ID' => 'identifier',
  70. 'TEXT' => 'text',
  71. 'FAKEPHPSTARTTAG' => 'Fake PHP start tag',
  72. 'PHPSTARTTAG' => 'PHP start tag',
  73. 'PHPENDTAG' => 'PHP end tag',
  74. 'LITERALSTART' => 'Literal start',
  75. 'LITERALEND' => 'Literal end',
  76. 'LDELSLASH' => 'closing tag',
  77. 'COMMENT' => 'comment',
  78. 'AS' => 'as',
  79. 'TO' => 'to',
  80. );
  81. function __construct($data, $compiler)
  82. {
  83. // $this->data = preg_replace("/(\r\n|\r|\n)/", "\n", $data);
  84. $this->data = $data;
  85. $this->counter = 0;
  86. if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) {
  87. $this->counter += strlen($match[0]);
  88. }
  89. $this->line = 1;
  90. $this->smarty = $compiler->smarty;
  91. $this->compiler = $compiler;
  92. $this->ldel = preg_quote($this->smarty->left_delimiter, '/');
  93. $this->ldel_length = strlen($this->smarty->left_delimiter);
  94. $this->rdel = preg_quote($this->smarty->right_delimiter, '/');
  95. $this->rdel_length = strlen($this->smarty->right_delimiter);
  96. $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
  97. $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
  98. }
  99. public function PrintTrace()
  100. {
  101. $this->yyTraceFILE = fopen('php://output', 'w');
  102. $this->yyTracePrompt = '<br>';
  103. }
  104. private $_yy_state = 1;
  105. private $_yy_stack = array();
  106. public function yylex()
  107. {
  108. return $this->{'yylex' . $this->_yy_state}();
  109. }
  110. public function yypushstate($state)
  111. {
  112. if ($this->yyTraceFILE) {
  113. fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
  114. }
  115. array_push($this->_yy_stack, $this->_yy_state);
  116. $this->_yy_state = $state;
  117. if ($this->yyTraceFILE) {
  118. fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
  119. }
  120. }
  121. public function yypopstate()
  122. {
  123. if ($this->yyTraceFILE) {
  124. fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
  125. }
  126. $this->_yy_state = array_pop($this->_yy_stack);
  127. if ($this->yyTraceFILE) {
  128. fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
  129. }
  130. }
  131. public function yybegin($state)
  132. {
  133. $this->_yy_state = $state;
  134. if ($this->yyTraceFILE) {
  135. fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
  136. }
  137. }
  138. public function yylex1()
  139. {
  140. $tokenMap = array(
  141. 1 => 0,
  142. 2 => 1,
  143. 4 => 0,
  144. 5 => 0,
  145. 6 => 0,
  146. 7 => 1,
  147. 9 => 0,
  148. 10 => 0,
  149. 11 => 0,
  150. 12 => 0,
  151. 13 => 0,
  152. 14 => 2,
  153. 17 => 0,
  154. 18 => 0,
  155. 19 => 0,
  156. 20 => 0,
  157. 21 => 0,
  158. 22 => 0,
  159. );
  160. if ($this->counter >= strlen($this->data)) {
  161. return false; // end of input
  162. }
  163. $yy_global_pattern = "/\G(\\{\\})|\G(" . $this->ldel . "\\*([\S\s]*?)\\*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*)|\G((<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|(<\\?(?:php\\w+|=|[a-zA-Z]+)?))|\G(\\?>)|\G(<\/script>)|\G(\\s*" . $this->rdel . ")|\G(<%)|\G(%>)|\G([\S\s])/iS";
  164. do {
  165. if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
  166. $yysubmatches = $yymatches;
  167. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  168. if (!count($yymatches)) {
  169. throw new Exception('Error: lexing failed because a rule matched' .
  170. ' an empty string. Input "' . substr($this->data,
  171. $this->counter, 5) . '... state TEXT');
  172. }
  173. next($yymatches); // skip global match
  174. $this->token = key($yymatches); // token number
  175. if ($tokenMap[$this->token]) {
  176. // extract sub-patterns for passing to lex function
  177. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  178. $tokenMap[$this->token]);
  179. } else {
  180. $yysubmatches = array();
  181. }
  182. $this->value = current($yymatches); // token value
  183. $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
  184. if ($r === null) {
  185. $this->counter += strlen($this->value);
  186. $this->line += substr_count($this->value, "\n");
  187. // accept this token
  188. return true;
  189. } elseif ($r === true) {
  190. // we have changed state
  191. // process this token in the new state
  192. return $this->yylex();
  193. } elseif ($r === false) {
  194. $this->counter += strlen($this->value);
  195. $this->line += substr_count($this->value, "\n");
  196. if ($this->counter >= strlen($this->data)) {
  197. return false; // end of input
  198. }
  199. // skip this token
  200. continue;
  201. }
  202. } else {
  203. throw new Exception('Unexpected input at line' . $this->line .
  204. ': ' . $this->data[$this->counter]);
  205. }
  206. break;
  207. } while (true);
  208. } // end function
  209. const TEXT = 1;
  210. function yy_r1_1($yy_subpatterns)
  211. {
  212. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  213. }
  214. function yy_r1_2($yy_subpatterns)
  215. {
  216. $this->token = Smarty_Internal_Templateparser::TP_COMMENT;
  217. }
  218. function yy_r1_4($yy_subpatterns)
  219. {
  220. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  221. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  222. } else {
  223. $this->token = Smarty_Internal_Templateparser::TP_STRIPON;
  224. }
  225. }
  226. function yy_r1_5($yy_subpatterns)
  227. {
  228. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  229. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  230. } else {
  231. $this->token = Smarty_Internal_Templateparser::TP_STRIPOFF;
  232. }
  233. }
  234. function yy_r1_6($yy_subpatterns)
  235. {
  236. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  237. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  238. } else {
  239. $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
  240. $this->yypushstate(self::LITERAL);
  241. }
  242. }
  243. function yy_r1_7($yy_subpatterns)
  244. {
  245. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  246. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  247. } else {
  248. $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
  249. $this->yypushstate(self::SMARTY);
  250. $this->taglineno = $this->line;
  251. }
  252. }
  253. function yy_r1_9($yy_subpatterns)
  254. {
  255. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  256. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  257. } else {
  258. $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
  259. $this->yypushstate(self::SMARTY);
  260. $this->taglineno = $this->line;
  261. }
  262. }
  263. function yy_r1_10($yy_subpatterns)
  264. {
  265. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  266. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  267. } else {
  268. $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
  269. $this->yypushstate(self::SMARTY);
  270. $this->taglineno = $this->line;
  271. }
  272. }
  273. function yy_r1_11($yy_subpatterns)
  274. {
  275. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  276. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  277. } else {
  278. $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
  279. $this->yypushstate(self::SMARTY);
  280. $this->taglineno = $this->line;
  281. }
  282. }
  283. function yy_r1_12($yy_subpatterns)
  284. {
  285. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  286. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  287. } else {
  288. $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
  289. $this->yypushstate(self::SMARTY);
  290. $this->taglineno = $this->line;
  291. }
  292. }
  293. function yy_r1_13($yy_subpatterns)
  294. {
  295. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  296. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  297. } else {
  298. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  299. $this->yypushstate(self::SMARTY);
  300. $this->taglineno = $this->line;
  301. }
  302. }
  303. function yy_r1_14($yy_subpatterns)
  304. {
  305. if (($script = strpos($this->value, '<s') === 0) || in_array($this->value, Array('<?', '<?=', '<?php'))) {
  306. if ($script) {
  307. $this->is_phpScript = true;
  308. }
  309. $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
  310. } elseif ($this->value == '<?xml') {
  311. $this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
  312. } else {
  313. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  314. //$this->value = substr($this->value, 0, 2);
  315. }
  316. }
  317. function yy_r1_17($yy_subpatterns)
  318. {
  319. $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
  320. }
  321. function yy_r1_18($yy_subpatterns)
  322. {
  323. $this->token = Smarty_Internal_Templateparser::TP_PHPENDSCRIPT;
  324. }
  325. function yy_r1_19($yy_subpatterns)
  326. {
  327. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  328. }
  329. function yy_r1_20($yy_subpatterns)
  330. {
  331. $this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
  332. }
  333. function yy_r1_21($yy_subpatterns)
  334. {
  335. $this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
  336. }
  337. function yy_r1_22($yy_subpatterns)
  338. {
  339. $phpEndScript = $this->is_phpScript ? '|<\\/script>' : '';
  340. $to = strlen($this->data);
  341. preg_match("/{$this->ldel}|<\?|<%|\?>|%>|<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>{$phpEndScript}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
  342. if (isset($match[0][1])) {
  343. $to = $match[0][1];
  344. }
  345. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  346. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  347. }
  348. public function yylex2()
  349. {
  350. $tokenMap = array(
  351. 1 => 0,
  352. 2 => 0,
  353. 3 => 1,
  354. 5 => 0,
  355. 6 => 0,
  356. 7 => 0,
  357. 8 => 0,
  358. 9 => 0,
  359. 10 => 0,
  360. 11 => 0,
  361. 12 => 0,
  362. 13 => 0,
  363. 14 => 0,
  364. 15 => 1,
  365. 17 => 1,
  366. 19 => 1,
  367. 21 => 0,
  368. 22 => 0,
  369. 23 => 0,
  370. 24 => 0,
  371. 25 => 0,
  372. 26 => 0,
  373. 27 => 0,
  374. 28 => 0,
  375. 29 => 0,
  376. 30 => 0,
  377. 31 => 0,
  378. 32 => 0,
  379. 33 => 0,
  380. 34 => 0,
  381. 35 => 0,
  382. 36 => 0,
  383. 37 => 0,
  384. 38 => 3,
  385. 42 => 0,
  386. 43 => 0,
  387. 44 => 0,
  388. 45 => 0,
  389. 46 => 0,
  390. 47 => 0,
  391. 48 => 0,
  392. 49 => 0,
  393. 50 => 1,
  394. 52 => 1,
  395. 54 => 0,
  396. 55 => 0,
  397. 56 => 0,
  398. 57 => 0,
  399. 58 => 0,
  400. 59 => 0,
  401. 60 => 0,
  402. 61 => 0,
  403. 62 => 0,
  404. 63 => 0,
  405. 64 => 0,
  406. 65 => 0,
  407. 66 => 0,
  408. 67 => 0,
  409. 68 => 0,
  410. 69 => 0,
  411. 70 => 1,
  412. 72 => 0,
  413. 73 => 0,
  414. 74 => 0,
  415. 75 => 0,
  416. 76 => 0,
  417. );
  418. if ($this->counter >= strlen($this->data)) {
  419. return false; // end of input
  420. }
  421. $yy_global_pattern = "/\G(\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$]smarty\\.block\\.(child|parent))|\G(\\$)|\G(\\s*" . $this->rdel . ")|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*===\\s*)|\G(\\s*!==\\s*)|\G(\\s*==\\s*|\\s+eq\\s+)|\G(\\s*!=\\s*|\\s*<>\\s*|\\s+(ne|neq)\\s+)|\G(\\s*>=\\s*|\\s+(ge|gte)\\s+)|\G(\\s*<=\\s*|\\s+(le|lte)\\s+)|\G(\\s*>\\s*|\\s+gt\\s+)|\G(\\s*<\\s*|\\s+lt\\s+)|\G(\\s+mod\\s+)|\G(!\\s*|not\\s+)|\G(\\s*&&\\s*|\\s*and\\s+)|\G(\\s*\\|\\|\\s*|\\s*or\\s+)|\G(\\s*xor\\s+)|\G(\\s+is\\s+odd\\s+by\\s+)|\G(\\s+is\\s+not\\s+odd\\s+by\\s+)|\G(\\s+is\\s+odd)|\G(\\s+is\\s+not\\s+odd)|\G(\\s+is\\s+even\\s+by\\s+)|\G(\\s+is\\s+not\\s+even\\s+by\\s+)|\G(\\s+is\\s+even)|\G(\\s+is\\s+not\\s+even)|\G(\\s+is\\s+div\\s+by\\s+)|\G(\\s+is\\s+not\\s+div\\s+by\\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(\\+\\+|--)|\G(\\s*(\\+|-)\\s*)|\G(\\s*(\\*|\/|%)\\s*)|\G(@)|\G(#)|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*=\\s*)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G(`)|\G(\\|)|\G(\\.)|\G(\\s*,\\s*)|\G(\\s*;)|\G(::)|\G(\\s*:\\s*)|\G(\\s*&\\s*)|\G(\\s*\\?\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*)|\G([\S\s])/iS";
  422. do {
  423. if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
  424. $yysubmatches = $yymatches;
  425. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  426. if (!count($yymatches)) {
  427. throw new Exception('Error: lexing failed because a rule matched' .
  428. ' an empty string. Input "' . substr($this->data,
  429. $this->counter, 5) . '... state SMARTY');
  430. }
  431. next($yymatches); // skip global match
  432. $this->token = key($yymatches); // token number
  433. if ($tokenMap[$this->token]) {
  434. // extract sub-patterns for passing to lex function
  435. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  436. $tokenMap[$this->token]);
  437. } else {
  438. $yysubmatches = array();
  439. }
  440. $this->value = current($yymatches); // token value
  441. $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
  442. if ($r === null) {
  443. $this->counter += strlen($this->value);
  444. $this->line += substr_count($this->value, "\n");
  445. // accept this token
  446. return true;
  447. } elseif ($r === true) {
  448. // we have changed state
  449. // process this token in the new state
  450. return $this->yylex();
  451. } elseif ($r === false) {
  452. $this->counter += strlen($this->value);
  453. $this->line += substr_count($this->value, "\n");
  454. if ($this->counter >= strlen($this->data)) {
  455. return false; // end of input
  456. }
  457. // skip this token
  458. continue;
  459. }
  460. } else {
  461. throw new Exception('Unexpected input at line' . $this->line .
  462. ': ' . $this->data[$this->counter]);
  463. }
  464. break;
  465. } while (true);
  466. } // end function
  467. const SMARTY = 2;
  468. function yy_r2_1($yy_subpatterns)
  469. {
  470. $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
  471. $this->yypushstate(self::DOUBLEQUOTEDSTRING);
  472. }
  473. function yy_r2_2($yy_subpatterns)
  474. {
  475. $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
  476. }
  477. function yy_r2_3($yy_subpatterns)
  478. {
  479. $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
  480. $this->taglineno = $this->line;
  481. }
  482. function yy_r2_5($yy_subpatterns)
  483. {
  484. $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
  485. }
  486. function yy_r2_6($yy_subpatterns)
  487. {
  488. $this->token = Smarty_Internal_Templateparser::TP_RDEL;
  489. $this->yypopstate();
  490. }
  491. function yy_r2_7($yy_subpatterns)
  492. {
  493. $this->token = Smarty_Internal_Templateparser::TP_ISIN;
  494. }
  495. function yy_r2_8($yy_subpatterns)
  496. {
  497. $this->token = Smarty_Internal_Templateparser::TP_AS;
  498. }
  499. function yy_r2_9($yy_subpatterns)
  500. {
  501. $this->token = Smarty_Internal_Templateparser::TP_TO;
  502. }
  503. function yy_r2_10($yy_subpatterns)
  504. {
  505. $this->token = Smarty_Internal_Templateparser::TP_STEP;
  506. }
  507. function yy_r2_11($yy_subpatterns)
  508. {
  509. $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
  510. }
  511. function yy_r2_12($yy_subpatterns)
  512. {
  513. $this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
  514. }
  515. function yy_r2_13($yy_subpatterns)
  516. {
  517. $this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
  518. }
  519. function yy_r2_14($yy_subpatterns)
  520. {
  521. $this->token = Smarty_Internal_Templateparser::TP_EQUALS;
  522. }
  523. function yy_r2_15($yy_subpatterns)
  524. {
  525. $this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
  526. }
  527. function yy_r2_17($yy_subpatterns)
  528. {
  529. $this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
  530. }
  531. function yy_r2_19($yy_subpatterns)
  532. {
  533. $this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
  534. }
  535. function yy_r2_21($yy_subpatterns)
  536. {
  537. $this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
  538. }
  539. function yy_r2_22($yy_subpatterns)
  540. {
  541. $this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
  542. }
  543. function yy_r2_23($yy_subpatterns)
  544. {
  545. $this->token = Smarty_Internal_Templateparser::TP_MOD;
  546. }
  547. function yy_r2_24($yy_subpatterns)
  548. {
  549. $this->token = Smarty_Internal_Templateparser::TP_NOT;
  550. }
  551. function yy_r2_25($yy_subpatterns)
  552. {
  553. $this->token = Smarty_Internal_Templateparser::TP_LAND;
  554. }
  555. function yy_r2_26($yy_subpatterns)
  556. {
  557. $this->token = Smarty_Internal_Templateparser::TP_LOR;
  558. }
  559. function yy_r2_27($yy_subpatterns)
  560. {
  561. $this->token = Smarty_Internal_Templateparser::TP_LXOR;
  562. }
  563. function yy_r2_28($yy_subpatterns)
  564. {
  565. $this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
  566. }
  567. function yy_r2_29($yy_subpatterns)
  568. {
  569. $this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
  570. }
  571. function yy_r2_30($yy_subpatterns)
  572. {
  573. $this->token = Smarty_Internal_Templateparser::TP_ISODD;
  574. }
  575. function yy_r2_31($yy_subpatterns)
  576. {
  577. $this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
  578. }
  579. function yy_r2_32($yy_subpatterns)
  580. {
  581. $this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
  582. }
  583. function yy_r2_33($yy_subpatterns)
  584. {
  585. $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
  586. }
  587. function yy_r2_34($yy_subpatterns)
  588. {
  589. $this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
  590. }
  591. function yy_r2_35($yy_subpatterns)
  592. {
  593. $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
  594. }
  595. function yy_r2_36($yy_subpatterns)
  596. {
  597. $this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
  598. }
  599. function yy_r2_37($yy_subpatterns)
  600. {
  601. $this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
  602. }
  603. function yy_r2_38($yy_subpatterns)
  604. {
  605. $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
  606. }
  607. function yy_r2_42($yy_subpatterns)
  608. {
  609. $this->token = Smarty_Internal_Templateparser::TP_OPENP;
  610. }
  611. function yy_r2_43($yy_subpatterns)
  612. {
  613. $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
  614. }
  615. function yy_r2_44($yy_subpatterns)
  616. {
  617. $this->token = Smarty_Internal_Templateparser::TP_OPENB;
  618. }
  619. function yy_r2_45($yy_subpatterns)
  620. {
  621. $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
  622. }
  623. function yy_r2_46($yy_subpatterns)
  624. {
  625. $this->token = Smarty_Internal_Templateparser::TP_PTR;
  626. }
  627. function yy_r2_47($yy_subpatterns)
  628. {
  629. $this->token = Smarty_Internal_Templateparser::TP_APTR;
  630. }
  631. function yy_r2_48($yy_subpatterns)
  632. {
  633. $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
  634. }
  635. function yy_r2_49($yy_subpatterns)
  636. {
  637. $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
  638. }
  639. function yy_r2_50($yy_subpatterns)
  640. {
  641. $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
  642. }
  643. function yy_r2_52($yy_subpatterns)
  644. {
  645. $this->token = Smarty_Internal_Templateparser::TP_MATH;
  646. }
  647. function yy_r2_54($yy_subpatterns)
  648. {
  649. $this->token = Smarty_Internal_Templateparser::TP_AT;
  650. }
  651. function yy_r2_55($yy_subpatterns)
  652. {
  653. $this->token = Smarty_Internal_Templateparser::TP_HATCH;
  654. }
  655. function yy_r2_56($yy_subpatterns)
  656. {
  657. // resolve conflicts with shorttag and right_delimiter starting with '='
  658. if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter) {
  659. preg_match("/\s+/", $this->value, $match);
  660. $this->value = $match[0];
  661. $this->token = Smarty_Internal_Templateparser::TP_SPACE;
  662. } else {
  663. $this->token = Smarty_Internal_Templateparser::TP_ATTR;
  664. }
  665. }
  666. function yy_r2_57($yy_subpatterns)
  667. {
  668. $this->token = Smarty_Internal_Templateparser::TP_ID;
  669. }
  670. function yy_r2_58($yy_subpatterns)
  671. {
  672. $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
  673. }
  674. function yy_r2_59($yy_subpatterns)
  675. {
  676. $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
  677. $this->yypopstate();
  678. }
  679. function yy_r2_60($yy_subpatterns)
  680. {
  681. $this->token = Smarty_Internal_Templateparser::TP_VERT;
  682. }
  683. function yy_r2_61($yy_subpatterns)
  684. {
  685. $this->token = Smarty_Internal_Templateparser::TP_DOT;
  686. }
  687. function yy_r2_62($yy_subpatterns)
  688. {
  689. $this->token = Smarty_Internal_Templateparser::TP_COMMA;
  690. }
  691. function yy_r2_63($yy_subpatterns)
  692. {
  693. $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
  694. }
  695. function yy_r2_64($yy_subpatterns)
  696. {
  697. $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
  698. }
  699. function yy_r2_65($yy_subpatterns)
  700. {
  701. $this->token = Smarty_Internal_Templateparser::TP_COLON;
  702. }
  703. function yy_r2_66($yy_subpatterns)
  704. {
  705. $this->token = Smarty_Internal_Templateparser::TP_ANDSYM;
  706. }
  707. function yy_r2_67($yy_subpatterns)
  708. {
  709. $this->token = Smarty_Internal_Templateparser::TP_QMARK;
  710. }
  711. function yy_r2_68($yy_subpatterns)
  712. {
  713. $this->token = Smarty_Internal_Templateparser::TP_HEX;
  714. }
  715. function yy_r2_69($yy_subpatterns)
  716. {
  717. $this->token = Smarty_Internal_Templateparser::TP_SPACE;
  718. }
  719. function yy_r2_70($yy_subpatterns)
  720. {
  721. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  722. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  723. } else {
  724. $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
  725. $this->yypushstate(self::SMARTY);
  726. $this->taglineno = $this->line;
  727. }
  728. }
  729. function yy_r2_72($yy_subpatterns)
  730. {
  731. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  732. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  733. } else {
  734. $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
  735. $this->yypushstate(self::SMARTY);
  736. $this->taglineno = $this->line;
  737. }
  738. }
  739. function yy_r2_73($yy_subpatterns)
  740. {
  741. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  742. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  743. } else {
  744. $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
  745. $this->yypushstate(self::SMARTY);
  746. $this->taglineno = $this->line;
  747. }
  748. }
  749. function yy_r2_74($yy_subpatterns)
  750. {
  751. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  752. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  753. } else {
  754. $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
  755. $this->yypushstate(self::SMARTY);
  756. $this->taglineno = $this->line;
  757. }
  758. }
  759. function yy_r2_75($yy_subpatterns)
  760. {
  761. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  762. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  763. } else {
  764. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  765. $this->yypushstate(self::SMARTY);
  766. $this->taglineno = $this->line;
  767. }
  768. }
  769. function yy_r2_76($yy_subpatterns)
  770. {
  771. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  772. }
  773. public function yylex3()
  774. {
  775. $tokenMap = array(
  776. 1 => 0,
  777. 2 => 0,
  778. 3 => 0,
  779. );
  780. if ($this->counter >= strlen($this->data)) {
  781. return false; // end of input
  782. }
  783. $yy_global_pattern = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G([\S\s])/iS";
  784. do {
  785. if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
  786. $yysubmatches = $yymatches;
  787. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  788. if (!count($yymatches)) {
  789. throw new Exception('Error: lexing failed because a rule matched' .
  790. ' an empty string. Input "' . substr($this->data,
  791. $this->counter, 5) . '... state LITERAL');
  792. }
  793. next($yymatches); // skip global match
  794. $this->token = key($yymatches); // token number
  795. if ($tokenMap[$this->token]) {
  796. // extract sub-patterns for passing to lex function
  797. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  798. $tokenMap[$this->token]);
  799. } else {
  800. $yysubmatches = array();
  801. }
  802. $this->value = current($yymatches); // token value
  803. $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
  804. if ($r === null) {
  805. $this->counter += strlen($this->value);
  806. $this->line += substr_count($this->value, "\n");
  807. // accept this token
  808. return true;
  809. } elseif ($r === true) {
  810. // we have changed state
  811. // process this token in the new state
  812. return $this->yylex();
  813. } elseif ($r === false) {
  814. $this->counter += strlen($this->value);
  815. $this->line += substr_count($this->value, "\n");
  816. if ($this->counter >= strlen($this->data)) {
  817. return false; // end of input
  818. }
  819. // skip this token
  820. continue;
  821. }
  822. } else {
  823. throw new Exception('Unexpected input at line' . $this->line .
  824. ': ' . $this->data[$this->counter]);
  825. }
  826. break;
  827. } while (true);
  828. } // end function
  829. const LITERAL = 3;
  830. function yy_r3_1($yy_subpatterns)
  831. {
  832. $this->literal_cnt ++;
  833. $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
  834. }
  835. function yy_r3_2($yy_subpatterns)
  836. {
  837. if ($this->literal_cnt) {
  838. $this->literal_cnt --;
  839. $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
  840. } else {
  841. $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
  842. $this->yypopstate();
  843. }
  844. }
  845. function yy_r3_3($yy_subpatterns)
  846. {
  847. $to = strlen($this->data);
  848. preg_match("/{$this->ldel}\/?literal{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
  849. if (isset($match[0][1])) {
  850. $to = $match[0][1];
  851. } else {
  852. $this->compiler->trigger_template_error("missing or misspelled literal closing tag");
  853. }
  854. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  855. $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
  856. }
  857. public function yylex4()
  858. {
  859. $tokenMap = array(
  860. 1 => 1,
  861. 3 => 0,
  862. 4 => 0,
  863. 5 => 0,
  864. 6 => 0,
  865. 7 => 0,
  866. 8 => 0,
  867. 9 => 0,
  868. 10 => 0,
  869. 11 => 0,
  870. 12 => 0,
  871. 13 => 3,
  872. 17 => 0,
  873. );
  874. if ($this->counter >= strlen($this->data)) {
  875. return false; // end of input
  876. }
  877. $yy_global_pattern = "/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*)|\G(\")|\G(`\\$)|\G(\\$[0-9]*[a-zA-Z_]\\w*)|\G(\\$)|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" . $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/iS";
  878. do {
  879. if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
  880. $yysubmatches = $yymatches;
  881. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  882. if (!count($yymatches)) {
  883. throw new Exception('Error: lexing failed because a rule matched' .
  884. ' an empty string. Input "' . substr($this->data,
  885. $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
  886. }
  887. next($yymatches); // skip global match
  888. $this->token = key($yymatches); // token number
  889. if ($tokenMap[$this->token]) {
  890. // extract sub-patterns for passing to lex function
  891. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  892. $tokenMap[$this->token]);
  893. } else {
  894. $yysubmatches = array();
  895. }
  896. $this->value = current($yymatches); // token value
  897. $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
  898. if ($r === null) {
  899. $this->counter += strlen($this->value);
  900. $this->line += substr_count($this->value, "\n");
  901. // accept this token
  902. return true;
  903. } elseif ($r === true) {
  904. // we have changed state
  905. // process this token in the new state
  906. return $this->yylex();
  907. } elseif ($r === false) {
  908. $this->counter += strlen($this->value);
  909. $this->line += substr_count($this->value, "\n");
  910. if ($this->counter >= strlen($this->data)) {
  911. return false; // end of input
  912. }
  913. // skip this token
  914. continue;
  915. }
  916. } else {
  917. throw new Exception('Unexpected input at line' . $this->line .
  918. ': ' . $this->data[$this->counter]);
  919. }
  920. break;
  921. } while (true);
  922. } // end function
  923. const DOUBLEQUOTEDSTRING = 4;
  924. function yy_r4_1($yy_subpatterns)
  925. {
  926. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  927. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  928. } else {
  929. $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
  930. $this->yypushstate(self::SMARTY);
  931. $this->taglineno = $this->line;
  932. }
  933. }
  934. function yy_r4_3($yy_subpatterns)
  935. {
  936. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  937. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  938. } else {
  939. $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
  940. $this->yypushstate(self::SMARTY);
  941. $this->taglineno = $this->line;
  942. }
  943. }
  944. function yy_r4_4($yy_subpatterns)
  945. {
  946. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  947. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  948. } else {
  949. $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
  950. $this->yypushstate(self::SMARTY);
  951. $this->taglineno = $this->line;
  952. }
  953. }
  954. function yy_r4_5($yy_subpatterns)
  955. {
  956. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  957. }
  958. function yy_r4_6($yy_subpatterns)
  959. {
  960. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  961. }
  962. function yy_r4_7($yy_subpatterns)
  963. {
  964. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  965. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  966. } else {
  967. $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
  968. $this->yypushstate(self::SMARTY);
  969. $this->taglineno = $this->line;
  970. }
  971. }
  972. function yy_r4_8($yy_subpatterns)
  973. {
  974. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  975. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  976. } else {
  977. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  978. $this->yypushstate(self::SMARTY);
  979. $this->taglineno = $this->line;
  980. }
  981. }
  982. function yy_r4_9($yy_subpatterns)
  983. {
  984. $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
  985. $this->yypopstate();
  986. }
  987. function yy_r4_10($yy_subpatterns)
  988. {
  989. $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
  990. $this->value = substr($this->value, 0, - 1);
  991. $this->yypushstate(self::SMARTY);
  992. $this->taglineno = $this->line;
  993. }
  994. function yy_r4_11($yy_subpatterns)
  995. {
  996. $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
  997. }
  998. function yy_r4_12($yy_subpatterns)
  999. {
  1000. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  1001. }
  1002. function yy_r4_13($yy_subpatterns)
  1003. {
  1004. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  1005. }
  1006. function yy_r4_17($yy_subpatterns)
  1007. {
  1008. $to = strlen($this->data);
  1009. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  1010. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  1011. }
  1012. public function yylex5()
  1013. {
  1014. $tokenMap = array(
  1015. 1 => 0,
  1016. 2 => 0,
  1017. 3 => 0,
  1018. 4 => 0,
  1019. );
  1020. if ($this->counter >= strlen($this->data)) {
  1021. return false; // end of input
  1022. }
  1023. $yy_global_pattern = "/\G(" . $this->ldel . "\\s*strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G([\S\s])/iS";
  1024. do {
  1025. if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
  1026. $yysubmatches = $yymatches;
  1027. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  1028. if (!count($yymatches)) {
  1029. throw new Exception('Error: lexing failed because a rule matched' .
  1030. ' an empty string. Input "' . substr($this->data,
  1031. $this->counter, 5) . '... state CHILDBODY');
  1032. }
  1033. next($yymatches); // skip global match
  1034. $this->token = key($yymatches); // token number
  1035. if ($tokenMap[$this->token]) {
  1036. // extract sub-patterns for passing to lex function
  1037. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  1038. $tokenMap[$this->token]);
  1039. } else {
  1040. $yysubmatches = array();
  1041. }
  1042. $this->value = current($yymatches); // token value
  1043. $r = $this->{'yy_r5_' . $this->token}($yysubmatches);
  1044. if ($r === null) {
  1045. $this->counter += strlen($this->value);
  1046. $this->line += substr_count($this->value, "\n");
  1047. // accept this token
  1048. return true;
  1049. } elseif ($r === true) {
  1050. // we have changed state
  1051. // process this token in the new state
  1052. return $this->yylex();
  1053. } elseif ($r === false) {
  1054. $this->counter += strlen($this->value);
  1055. $this->line += substr_count($this->value, "\n");
  1056. if ($this->counter >= strlen($this->data)) {
  1057. return false; // end of input
  1058. }
  1059. // skip this token
  1060. continue;
  1061. }
  1062. } else {
  1063. throw new Exception('Unexpected input at line' . $this->line .
  1064. ': ' . $this->data[$this->counter]);
  1065. }
  1066. break;
  1067. } while (true);
  1068. } // end function
  1069. const CHILDBODY = 5;
  1070. function yy_r5_1($yy_subpatterns)
  1071. {
  1072. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  1073. return false;
  1074. } else {
  1075. $this->token = Smarty_Internal_Templateparser::TP_STRIPON;
  1076. }
  1077. }
  1078. function yy_r5_2($yy_subpatterns)
  1079. {
  1080. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  1081. return false;
  1082. } else {
  1083. $this->token = Smarty_Internal_Templateparser::TP_STRIPOFF;
  1084. }
  1085. }
  1086. function yy_r5_3($yy_subpatterns)
  1087. {
  1088. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  1089. return false;
  1090. } else {
  1091. $this->yypopstate();
  1092. return true;
  1093. }
  1094. }
  1095. function yy_r5_4($yy_subpatterns)
  1096. {
  1097. $to = strlen($this->data);
  1098. preg_match("/" . $this->ldel . "\s*((\/)?strip\s*" . $this->rdel . "|block\s+)/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
  1099. if (isset($match[0][1])) {
  1100. $to = $match[0][1];
  1101. }
  1102. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  1103. return false;
  1104. }
  1105. public function yylex6()
  1106. {
  1107. $tokenMap = array(
  1108. 1 => 0,
  1109. 2 => 0,
  1110. 3 => 0,
  1111. 4 => 1,
  1112. 6 => 0,
  1113. );
  1114. if ($this->counter >= strlen($this->data)) {
  1115. return false; // end of input
  1116. }
  1117. $yy_global_pattern = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G(" . $this->ldel . "\\s*\/block)|\G(" . $this->ldel . "\\s*[$]smarty\\.block\\.(child|parent))|\G([\S\s])/iS";
  1118. do {
  1119. if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
  1120. $yysubmatches = $yymatches;
  1121. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  1122. if (!count($yymatches)) {
  1123. throw new Exception('Error: lexing failed because a rule matched' .
  1124. ' an empty string. Input "' . substr($this->data,
  1125. $this->counter, 5) . '... state CHILDBLOCK');
  1126. }
  1127. next($yymatches); // skip global match
  1128. $this->token = key($yymatches); // token number
  1129. if ($tokenMap[$this->token]) {
  1130. // extract sub-patterns for passing to lex function
  1131. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  1132. $tokenMap[$this->token]);
  1133. } else {
  1134. $yysubmatches = array();
  1135. }
  1136. $this->value = current($yymatches); // token value
  1137. $r = $this->{'yy_r6_' . $this->token}($yysubmatches);
  1138. if ($r === null) {
  1139. $this->counter += strlen($this->value);
  1140. $this->line += substr_count($this->value, "\n");
  1141. // accept this token
  1142. return true;
  1143. } elseif ($r === true) {
  1144. // we have changed state
  1145. // process this token in the new state
  1146. return $this->yylex();
  1147. } elseif ($r === false) {
  1148. $this->counter += strlen($this->value);
  1149. $this->line += substr_count($this->value, "\n");
  1150. if ($this->counter >= strlen($this->data)) {
  1151. return false; // end of input
  1152. }
  1153. // skip this token
  1154. continue;
  1155. }
  1156. } else {
  1157. throw new Exception('Unexpected input at line' . $this->line .
  1158. ': ' . $this->data[$this->counter]);
  1159. }
  1160. break;
  1161. } while (true);
  1162. } // end function
  1163. const CHILDBLOCK = 6;
  1164. function yy_r6_1($yy_subpa