PageRenderTime 52ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/framework/vendor/smarty3/lib/libs/sysplugins/smarty_internal_templatelexer.php

http://zoop.googlecode.com/
PHP | 1803 lines | 1673 code | 107 blank | 23 comment | 38 complexity | a3b2793c254c2e2146fbe0a1ced6384b MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * Smarty Internal Plugin Templatelexer
  4. *
  5. * This is the lexer to break the template source into tokens
  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 $state = 1;
  23. public $strip = false;
  24. private $heredoc_id_stack = Array();
  25. public $smarty_token_names = array ( // Text for parser error messages
  26. 'IDENTITY' => '===',
  27. 'NONEIDENTITY' => '!==',
  28. 'EQUALS' => '==',
  29. 'NOTEQUALS' => '!=',
  30. 'GREATEREQUAL' => '(>=,ge)',
  31. 'LESSEQUAL' => '(<=,le)',
  32. 'GREATERTHAN' => '(>,gt)',
  33. 'LESSTHAN' => '(<,lt)',
  34. 'MOD' => '(%,mod)',
  35. 'NOT' => '(!,not)',
  36. 'LAND' => '(&&,and)',
  37. 'LOR' => '(||,or)',
  38. 'LXOR' => 'xor',
  39. 'OPENP' => '(',
  40. 'CLOSEP' => ')',
  41. 'OPENB' => '[',
  42. 'CLOSEB' => ']',
  43. 'PTR' => '->',
  44. 'APTR' => '=>',
  45. 'EQUAL' => '=',
  46. 'NUMBER' => 'number',
  47. 'UNIMATH' => '+" , "-',
  48. 'MATH' => '*" , "/" , "%',
  49. 'INCDEC' => '++" , "--',
  50. 'SPACE' => ' ',
  51. 'DOLLAR' => '$',
  52. 'SEMICOLON' => ';',
  53. 'COLON' => ':',
  54. 'DOUBLECOLON' => '::',
  55. 'AT' => '@',
  56. 'HATCH' => '#',
  57. 'QUOTE' => '"',
  58. 'BACKTICK' => '`',
  59. 'VERT' => '|',
  60. 'DOT' => '.',
  61. 'COMMA' => '","',
  62. 'ANDSYM' => '"&"',
  63. 'QMARK' => '"?"',
  64. 'ID' => 'identifier',
  65. 'OTHER' => 'text',
  66. 'FAKEPHPSTARTTAG' => 'Fake PHP start tag',
  67. 'PHPSTARTTAG' => 'PHP start tag',
  68. 'PHPENDTAG' => 'PHP end tag',
  69. 'LITERALSTART' => 'Literal start',
  70. 'LITERALEND' => 'Literal end',
  71. 'LDELSLASH' => 'closing tag',
  72. 'COMMENT' => 'comment',
  73. 'LITERALEND' => 'literal close',
  74. 'AS' => 'as',
  75. 'TO' => 'to',
  76. 'NULL' => 'null',
  77. 'BOOLEAN' => 'boolean'
  78. );
  79. function __construct($data,$compiler)
  80. {
  81. // set instance object
  82. self::instance($this);
  83. // $this->data = preg_replace("/(\r\n|\r|\n)/", "\n", $data);
  84. $this->data = $data;
  85. $this->counter = 0;
  86. $this->line = 1;
  87. $this->smarty = $compiler->smarty;
  88. $this->compiler = $compiler;
  89. $this->ldel = preg_quote($this->smarty->left_delimiter,'/');
  90. $this->rdel = preg_quote($this->smarty->right_delimiter,'/');
  91. $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
  92. $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
  93. }
  94. public static function &instance($new_instance = null)
  95. {
  96. static $instance = null;
  97. if (isset($new_instance) && is_object($new_instance))
  98. $instance = $new_instance;
  99. return $instance;
  100. }
  101. private $_yy_state = 1;
  102. private $_yy_stack = array();
  103. function yylex()
  104. {
  105. return $this->{'yylex' . $this->_yy_state}();
  106. }
  107. function yypushstate($state)
  108. {
  109. array_push($this->_yy_stack, $this->_yy_state);
  110. $this->_yy_state = $state;
  111. }
  112. function yypopstate()
  113. {
  114. $this->_yy_state = array_pop($this->_yy_stack);
  115. }
  116. function yybegin($state)
  117. {
  118. $this->_yy_state = $state;
  119. }
  120. function yylex1()
  121. {
  122. $tokenMap = array (
  123. 1 => 0,
  124. 2 => 1,
  125. 4 => 0,
  126. 5 => 0,
  127. 6 => 0,
  128. 7 => 0,
  129. 8 => 0,
  130. 9 => 0,
  131. 10 => 0,
  132. 11 => 0,
  133. 12 => 0,
  134. 13 => 2,
  135. 16 => 0,
  136. );
  137. if ($this->counter >= strlen($this->data)) {
  138. return false; // end of input
  139. }
  140. $yy_global_pattern = "/^(\\{\\})|^(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^([\t ]*[\r\n]+[\t ]*)|^(".$this->ldel."strip".$this->rdel.")|^(".$this->ldel."\/strip".$this->rdel.")|^(".$this->ldel."literal".$this->rdel.")|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?)))|^([\S\s]+)/";
  141. do {
  142. if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
  143. $yysubmatches = $yymatches;
  144. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  145. if (!count($yymatches)) {
  146. throw new Exception('Error: lexing failed because a rule matched' .
  147. 'an empty string. Input "' . substr($this->data,
  148. $this->counter, 5) . '... state TEXT');
  149. }
  150. next($yymatches); // skip global match
  151. $this->token = key($yymatches); // token number
  152. if ($tokenMap[$this->token]) {
  153. // extract sub-patterns for passing to lex function
  154. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  155. $tokenMap[$this->token]);
  156. } else {
  157. $yysubmatches = array();
  158. }
  159. $this->value = current($yymatches); // token value
  160. $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
  161. if ($r === null) {
  162. $this->counter += strlen($this->value);
  163. $this->line += substr_count($this->value, "\n");
  164. // accept this token
  165. return true;
  166. } elseif ($r === true) {
  167. // we have changed state
  168. // process this token in the new state
  169. return $this->yylex();
  170. } elseif ($r === false) {
  171. $this->counter += strlen($this->value);
  172. $this->line += substr_count($this->value, "\n");
  173. if ($this->counter >= strlen($this->data)) {
  174. return false; // end of input
  175. }
  176. // skip this token
  177. continue;
  178. } } else {
  179. throw new Exception('Unexpected input at line' . $this->line .
  180. ': ' . $this->data[$this->counter]);
  181. }
  182. break;
  183. } while (true);
  184. } // end function
  185. const TEXT = 1;
  186. function yy_r1_1($yy_subpatterns)
  187. {
  188. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  189. }
  190. function yy_r1_2($yy_subpatterns)
  191. {
  192. $this->token = Smarty_Internal_Templateparser::TP_COMMENT;
  193. }
  194. function yy_r1_4($yy_subpatterns)
  195. {
  196. if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
  197. $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
  198. $this->yypushstate(self::PHP);
  199. } elseif ($this->value == '<?xml') {
  200. $this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
  201. } else {
  202. $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
  203. $this->value = substr($this->value, 0, 2);
  204. }
  205. }
  206. function yy_r1_5($yy_subpatterns)
  207. {
  208. if ($this->strip) {
  209. return false;
  210. } else {
  211. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  212. }
  213. }
  214. function yy_r1_6($yy_subpatterns)
  215. {
  216. $this->strip = true;
  217. return false;
  218. }
  219. function yy_r1_7($yy_subpatterns)
  220. {
  221. $this->strip = false;
  222. return false;
  223. }
  224. function yy_r1_8($yy_subpatterns)
  225. {
  226. $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
  227. $this->yypushstate(self::LITERAL);
  228. }
  229. function yy_r1_9($yy_subpatterns)
  230. {
  231. if ($this->smarty->auto_literal) {
  232. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  233. } else {
  234. $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
  235. $this->yypushstate(self::SMARTY);
  236. $this->taglineno = $this->line;
  237. }
  238. }
  239. function yy_r1_10($yy_subpatterns)
  240. {
  241. if ($this->smarty->auto_literal) {
  242. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  243. } else {
  244. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  245. $this->yypushstate(self::SMARTY);
  246. $this->taglineno = $this->line;
  247. }
  248. }
  249. function yy_r1_11($yy_subpatterns)
  250. {
  251. $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
  252. $this->yypushstate(self::SMARTY);
  253. $this->taglineno = $this->line;
  254. }
  255. function yy_r1_12($yy_subpatterns)
  256. {
  257. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  258. $this->yypushstate(self::SMARTY);
  259. $this->taglineno = $this->line;
  260. }
  261. function yy_r1_13($yy_subpatterns)
  262. {
  263. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  264. }
  265. function yy_r1_16($yy_subpatterns)
  266. {
  267. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  268. }
  269. function yylex2()
  270. {
  271. $tokenMap = array (
  272. 1 => 0,
  273. 2 => 0,
  274. 3 => 0,
  275. 4 => 0,
  276. 5 => 0,
  277. 6 => 0,
  278. 7 => 0,
  279. 8 => 0,
  280. 9 => 1,
  281. 11 => 1,
  282. 13 => 1,
  283. 15 => 0,
  284. 16 => 0,
  285. 17 => 0,
  286. 18 => 0,
  287. 19 => 0,
  288. 20 => 1,
  289. 22 => 1,
  290. 24 => 1,
  291. 26 => 1,
  292. 28 => 1,
  293. 30 => 1,
  294. 32 => 1,
  295. 34 => 1,
  296. 36 => 1,
  297. 38 => 1,
  298. 40 => 1,
  299. 42 => 0,
  300. 43 => 0,
  301. 44 => 0,
  302. 45 => 0,
  303. 46 => 0,
  304. 47 => 0,
  305. 48 => 0,
  306. 49 => 0,
  307. 50 => 0,
  308. 51 => 0,
  309. 52 => 3,
  310. 56 => 0,
  311. 57 => 0,
  312. 58 => 0,
  313. 59 => 0,
  314. 60 => 0,
  315. 61 => 0,
  316. 62 => 0,
  317. 63 => 1,
  318. 65 => 1,
  319. 67 => 1,
  320. 69 => 0,
  321. 70 => 0,
  322. 71 => 0,
  323. 72 => 0,
  324. 73 => 0,
  325. 74 => 0,
  326. 75 => 0,
  327. 76 => 0,
  328. 77 => 0,
  329. 78 => 0,
  330. 79 => 0,
  331. 80 => 0,
  332. 81 => 0,
  333. 82 => 1,
  334. 84 => 0,
  335. 85 => 0,
  336. 86 => 0,
  337. 87 => 0,
  338. 88 => 0,
  339. 89 => 0,
  340. );
  341. if ($this->counter >= strlen($this->data)) {
  342. return false; // end of input
  343. }
  344. $yy_global_pattern = "/^('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(".$this->ldel."\/)|^(".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+(to)\\s+)|^(\\s+(step)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|NEQ|ne|neq)\\s+)|^(\\s*>=\\s*|\\s+(GE|GTE|ge|gte)\\s+)|^(\\s*<=\\s*|\\s+(LE|LTE|le|lte)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(\\s+(MOD|mod)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\))|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;)|^(::)|^(\\s*:\\s*)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(\\s*\\?\\s*)|^((if|elseif|else if|while)(?![^\s]))|^(foreach(?![^\s]))|^(for(?![^\s]))|^([0-9]*[a-zA-Z_]\\w*)|^(\\d+)|^(\\s+)|^(.)/";
  345. do {
  346. if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
  347. $yysubmatches = $yymatches;
  348. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  349. if (!count($yymatches)) {
  350. throw new Exception('Error: lexing failed because a rule matched' .
  351. 'an empty string. Input "' . substr($this->data,
  352. $this->counter, 5) . '... state SMARTY');
  353. }
  354. next($yymatches); // skip global match
  355. $this->token = key($yymatches); // token number
  356. if ($tokenMap[$this->token]) {
  357. // extract sub-patterns for passing to lex function
  358. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  359. $tokenMap[$this->token]);
  360. } else {
  361. $yysubmatches = array();
  362. }
  363. $this->value = current($yymatches); // token value
  364. $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
  365. if ($r === null) {
  366. $this->counter += strlen($this->value);
  367. $this->line += substr_count($this->value, "\n");
  368. // accept this token
  369. return true;
  370. } elseif ($r === true) {
  371. // we have changed state
  372. // process this token in the new state
  373. return $this->yylex();
  374. } elseif ($r === false) {
  375. $this->counter += strlen($this->value);
  376. $this->line += substr_count($this->value, "\n");
  377. if ($this->counter >= strlen($this->data)) {
  378. return false; // end of input
  379. }
  380. // skip this token
  381. continue;
  382. } } else {
  383. throw new Exception('Unexpected input at line' . $this->line .
  384. ': ' . $this->data[$this->counter]);
  385. }
  386. break;
  387. } while (true);
  388. } // end function
  389. const SMARTY = 2;
  390. function yy_r2_1($yy_subpatterns)
  391. {
  392. $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
  393. }
  394. function yy_r2_2($yy_subpatterns)
  395. {
  396. if ($this->smarty->auto_literal) {
  397. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  398. } else {
  399. $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
  400. $this->yypushstate(self::SMARTY);
  401. $this->taglineno = $this->line;
  402. }
  403. }
  404. function yy_r2_3($yy_subpatterns)
  405. {
  406. if ($this->smarty->auto_literal) {
  407. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  408. } else {
  409. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  410. $this->yypushstate(self::SMARTY);
  411. $this->taglineno = $this->line;
  412. }
  413. }
  414. function yy_r2_4($yy_subpatterns)
  415. {
  416. if ($this->smarty->auto_literal) {
  417. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  418. } else {
  419. $this->token = Smarty_Internal_Templateparser::TP_RDEL;
  420. $this->yypopstate();
  421. }
  422. }
  423. function yy_r2_5($yy_subpatterns)
  424. {
  425. $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
  426. $this->yypushstate(self::SMARTY);
  427. $this->taglineno = $this->line;
  428. }
  429. function yy_r2_6($yy_subpatterns)
  430. {
  431. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  432. $this->yypushstate(self::SMARTY);
  433. $this->taglineno = $this->line;
  434. }
  435. function yy_r2_7($yy_subpatterns)
  436. {
  437. $this->token = Smarty_Internal_Templateparser::TP_RDEL;
  438. $this->yypopstate();
  439. }
  440. function yy_r2_8($yy_subpatterns)
  441. {
  442. $this->token = Smarty_Internal_Templateparser::TP_ISIN;
  443. }
  444. function yy_r2_9($yy_subpatterns)
  445. {
  446. $this->token = Smarty_Internal_Templateparser::TP_AS;
  447. }
  448. function yy_r2_11($yy_subpatterns)
  449. {
  450. $this->token = Smarty_Internal_Templateparser::TP_TO;
  451. }
  452. function yy_r2_13($yy_subpatterns)
  453. {
  454. $this->token = Smarty_Internal_Templateparser::TP_STEP;
  455. }
  456. function yy_r2_15($yy_subpatterns)
  457. {
  458. $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
  459. }
  460. function yy_r2_16($yy_subpatterns)
  461. {
  462. $this->token = Smarty_Internal_Templateparser::TP_BOOLEAN;
  463. }
  464. function yy_r2_17($yy_subpatterns)
  465. {
  466. $this->token = Smarty_Internal_Templateparser::TP_NULL;
  467. }
  468. function yy_r2_18($yy_subpatterns)
  469. {
  470. $this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
  471. }
  472. function yy_r2_19($yy_subpatterns)
  473. {
  474. $this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
  475. }
  476. function yy_r2_20($yy_subpatterns)
  477. {
  478. $this->token = Smarty_Internal_Templateparser::TP_EQUALS;
  479. }
  480. function yy_r2_22($yy_subpatterns)
  481. {
  482. $this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
  483. }
  484. function yy_r2_24($yy_subpatterns)
  485. {
  486. $this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
  487. }
  488. function yy_r2_26($yy_subpatterns)
  489. {
  490. $this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
  491. }
  492. function yy_r2_28($yy_subpatterns)
  493. {
  494. $this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
  495. }
  496. function yy_r2_30($yy_subpatterns)
  497. {
  498. $this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
  499. }
  500. function yy_r2_32($yy_subpatterns)
  501. {
  502. $this->token = Smarty_Internal_Templateparser::TP_MOD;
  503. }
  504. function yy_r2_34($yy_subpatterns)
  505. {
  506. $this->token = Smarty_Internal_Templateparser::TP_NOT;
  507. }
  508. function yy_r2_36($yy_subpatterns)
  509. {
  510. $this->token = Smarty_Internal_Templateparser::TP_LAND;
  511. }
  512. function yy_r2_38($yy_subpatterns)
  513. {
  514. $this->token = Smarty_Internal_Templateparser::TP_LOR;
  515. }
  516. function yy_r2_40($yy_subpatterns)
  517. {
  518. $this->token = Smarty_Internal_Templateparser::TP_LXOR;
  519. }
  520. function yy_r2_42($yy_subpatterns)
  521. {
  522. $this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
  523. }
  524. function yy_r2_43($yy_subpatterns)
  525. {
  526. $this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
  527. }
  528. function yy_r2_44($yy_subpatterns)
  529. {
  530. $this->token = Smarty_Internal_Templateparser::TP_ISODD;
  531. }
  532. function yy_r2_45($yy_subpatterns)
  533. {
  534. $this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
  535. }
  536. function yy_r2_46($yy_subpatterns)
  537. {
  538. $this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
  539. }
  540. function yy_r2_47($yy_subpatterns)
  541. {
  542. $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
  543. }
  544. function yy_r2_48($yy_subpatterns)
  545. {
  546. $this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
  547. }
  548. function yy_r2_49($yy_subpatterns)
  549. {
  550. $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
  551. }
  552. function yy_r2_50($yy_subpatterns)
  553. {
  554. $this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
  555. }
  556. function yy_r2_51($yy_subpatterns)
  557. {
  558. $this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
  559. }
  560. function yy_r2_52($yy_subpatterns)
  561. {
  562. $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
  563. }
  564. function yy_r2_56($yy_subpatterns)
  565. {
  566. $this->token = Smarty_Internal_Templateparser::TP_OPENP;
  567. }
  568. function yy_r2_57($yy_subpatterns)
  569. {
  570. $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
  571. }
  572. function yy_r2_58($yy_subpatterns)
  573. {
  574. $this->token = Smarty_Internal_Templateparser::TP_OPENB;
  575. }
  576. function yy_r2_59($yy_subpatterns)
  577. {
  578. $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
  579. }
  580. function yy_r2_60($yy_subpatterns)
  581. {
  582. $this->token = Smarty_Internal_Templateparser::TP_PTR;
  583. }
  584. function yy_r2_61($yy_subpatterns)
  585. {
  586. $this->token = Smarty_Internal_Templateparser::TP_APTR;
  587. }
  588. function yy_r2_62($yy_subpatterns)
  589. {
  590. $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
  591. }
  592. function yy_r2_63($yy_subpatterns)
  593. {
  594. $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
  595. }
  596. function yy_r2_65($yy_subpatterns)
  597. {
  598. $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
  599. }
  600. function yy_r2_67($yy_subpatterns)
  601. {
  602. $this->token = Smarty_Internal_Templateparser::TP_MATH;
  603. }
  604. function yy_r2_69($yy_subpatterns)
  605. {
  606. $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
  607. }
  608. function yy_r2_70($yy_subpatterns)
  609. {
  610. $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
  611. }
  612. function yy_r2_71($yy_subpatterns)
  613. {
  614. $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
  615. }
  616. function yy_r2_72($yy_subpatterns)
  617. {
  618. $this->token = Smarty_Internal_Templateparser::TP_COLON;
  619. }
  620. function yy_r2_73($yy_subpatterns)
  621. {
  622. $this->token = Smarty_Internal_Templateparser::TP_AT;
  623. }
  624. function yy_r2_74($yy_subpatterns)
  625. {
  626. $this->token = Smarty_Internal_Templateparser::TP_HATCH;
  627. }
  628. function yy_r2_75($yy_subpatterns)
  629. {
  630. $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
  631. $this->yypushstate(self::DOUBLEQUOTEDSTRING);
  632. }
  633. function yy_r2_76($yy_subpatterns)
  634. {
  635. $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
  636. $this->yypopstate();
  637. }
  638. function yy_r2_77($yy_subpatterns)
  639. {
  640. $this->token = Smarty_Internal_Templateparser::TP_VERT;
  641. }
  642. function yy_r2_78($yy_subpatterns)
  643. {
  644. $this->token = Smarty_Internal_Templateparser::TP_DOT;
  645. }
  646. function yy_r2_79($yy_subpatterns)
  647. {
  648. $this->token = Smarty_Internal_Templateparser::TP_COMMA;
  649. }
  650. function yy_r2_80($yy_subpatterns)
  651. {
  652. $this->token = Smarty_Internal_Templateparser::TP_ANDSYM;
  653. }
  654. function yy_r2_81($yy_subpatterns)
  655. {
  656. $this->token = Smarty_Internal_Templateparser::TP_QMARK;
  657. }
  658. function yy_r2_82($yy_subpatterns)
  659. {
  660. $this->token = Smarty_Internal_Templateparser::TP_IF;
  661. }
  662. function yy_r2_84($yy_subpatterns)
  663. {
  664. $this->token = Smarty_Internal_Templateparser::TP_FOREACH;
  665. }
  666. function yy_r2_85($yy_subpatterns)
  667. {
  668. $this->token = Smarty_Internal_Templateparser::TP_FOR;
  669. }
  670. function yy_r2_86($yy_subpatterns)
  671. {
  672. $this->token = Smarty_Internal_Templateparser::TP_ID;
  673. }
  674. function yy_r2_87($yy_subpatterns)
  675. {
  676. $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
  677. }
  678. function yy_r2_88($yy_subpatterns)
  679. {
  680. $this->token = Smarty_Internal_Templateparser::TP_SPACE;
  681. }
  682. function yy_r2_89($yy_subpatterns)
  683. {
  684. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  685. }
  686. function yylex3()
  687. {
  688. $tokenMap = array (
  689. 1 => 0,
  690. 2 => 1,
  691. 4 => 0,
  692. );
  693. if ($this->counter >= strlen($this->data)) {
  694. return false; // end of input
  695. }
  696. $yy_global_pattern = "/^(\\?>)|^([\s\S]+?(\\?>|\/\\*|'|\"|<<<\\s*'?\\w+'?\r?\n|\/\/|#))|^([\S\s]+)/";
  697. do {
  698. if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
  699. $yysubmatches = $yymatches;
  700. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  701. if (!count($yymatches)) {
  702. throw new Exception('Error: lexing failed because a rule matched' .
  703. 'an empty string. Input "' . substr($this->data,
  704. $this->counter, 5) . '... state PHP');
  705. }
  706. next($yymatches); // skip global match
  707. $this->token = key($yymatches); // token number
  708. if ($tokenMap[$this->token]) {
  709. // extract sub-patterns for passing to lex function
  710. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  711. $tokenMap[$this->token]);
  712. } else {
  713. $yysubmatches = array();
  714. }
  715. $this->value = current($yymatches); // token value
  716. $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
  717. if ($r === null) {
  718. $this->counter += strlen($this->value);
  719. $this->line += substr_count($this->value, "\n");
  720. // accept this token
  721. return true;
  722. } elseif ($r === true) {
  723. // we have changed state
  724. // process this token in the new state
  725. return $this->yylex();
  726. } elseif ($r === false) {
  727. $this->counter += strlen($this->value);
  728. $this->line += substr_count($this->value, "\n");
  729. if ($this->counter >= strlen($this->data)) {
  730. return false; // end of input
  731. }
  732. // skip this token
  733. continue;
  734. } } else {
  735. throw new Exception('Unexpected input at line' . $this->line .
  736. ': ' . $this->data[$this->counter]);
  737. }
  738. break;
  739. } while (true);
  740. } // end function
  741. const PHP = 3;
  742. function yy_r3_1($yy_subpatterns)
  743. {
  744. $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
  745. $this->yypopstate();
  746. }
  747. function yy_r3_2($yy_subpatterns)
  748. {
  749. switch ($yy_subpatterns[0]) {
  750. case '?>':
  751. $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
  752. $this->value = substr($this->value, 0, -2);
  753. break;
  754. case "'":
  755. $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
  756. $this->yypushstate(self::PHP_SINGLE_QUOTED_STRING);
  757. break;
  758. case '"':
  759. $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE_START_DOUBLEQUOTE;
  760. $this->yypushstate(self::PHP_DOUBLE_QUOTED_STRING);
  761. break;
  762. case '/*':
  763. $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
  764. $this->yypushstate(self::PHP_ML_COMMENT);
  765. break;
  766. case '//':
  767. case '#':
  768. $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
  769. $this->yypushstate(self::PHP_SL_COMMENT);
  770. break;
  771. default:
  772. $res = preg_match('/\A<<<\s*\'?(\w+)(\'?)\r?\n\z/', $yy_subpatterns[0], $matches);
  773. assert($res === 1);
  774. $is_nowdoc = $matches[2] === "'";
  775. $this->token = $is_nowdoc
  776. ? Smarty_Internal_Templateparser::TP_PHP_NOWDOC_START
  777. : Smarty_Internal_Templateparser::TP_PHP_HEREDOC_START;
  778. $this->heredoc_id_stack[] = $matches[1];
  779. $this->yypushstate($is_nowdoc ? self::PHP_NOWDOC : self::PHP_HEREDOC);
  780. break;
  781. }
  782. }
  783. function yy_r3_4($yy_subpatterns)
  784. {
  785. $this->compiler->trigger_template_error ("missing PHP end tag");
  786. }
  787. function yylex4()
  788. {
  789. $tokenMap = array (
  790. 1 => 0,
  791. 2 => 0,
  792. );
  793. if ($this->counter >= strlen($this->data)) {
  794. return false; // end of input
  795. }
  796. $yy_global_pattern = "/^([\s\S]*\\*\/)|^([\S\s]+)/";
  797. do {
  798. if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
  799. $yysubmatches = $yymatches;
  800. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  801. if (!count($yymatches)) {
  802. throw new Exception('Error: lexing failed because a rule matched' .
  803. 'an empty string. Input "' . substr($this->data,
  804. $this->counter, 5) . '... state PHP_ML_COMMENT');
  805. }
  806. next($yymatches); // skip global match
  807. $this->token = key($yymatches); // token number
  808. if ($tokenMap[$this->token]) {
  809. // extract sub-patterns for passing to lex function
  810. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  811. $tokenMap[$this->token]);
  812. } else {
  813. $yysubmatches = array();
  814. }
  815. $this->value = current($yymatches); // token value
  816. $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
  817. if ($r === null) {
  818. $this->counter += strlen($this->value);
  819. $this->line += substr_count($this->value, "\n");
  820. // accept this token
  821. return true;
  822. } elseif ($r === true) {
  823. // we have changed state
  824. // process this token in the new state
  825. return $this->yylex();
  826. } elseif ($r === false) {
  827. $this->counter += strlen($this->value);
  828. $this->line += substr_count($this->value, "\n");
  829. if ($this->counter >= strlen($this->data)) {
  830. return false; // end of input
  831. }
  832. // skip this token
  833. continue;
  834. } } else {
  835. throw new Exception('Unexpected input at line' . $this->line .
  836. ': ' . $this->data[$this->counter]);
  837. }
  838. break;
  839. } while (true);
  840. } // end function
  841. const PHP_ML_COMMENT = 4;
  842. function yy_r4_1($yy_subpatterns)
  843. {
  844. $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
  845. $this->yypopstate();
  846. }
  847. function yy_r4_2($yy_subpatterns)
  848. {
  849. $this->compiler->trigger_template_error("missing PHP comment end */");
  850. }
  851. function yylex5()
  852. {
  853. $tokenMap = array (
  854. 1 => 0,
  855. 2 => 0,
  856. );
  857. if ($this->counter >= strlen($this->data)) {
  858. return false; // end of input
  859. }
  860. $yy_global_pattern = "/^(.+?(?=\\?>|\n))|^([\S\s]+)/";
  861. do {
  862. if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
  863. $yysubmatches = $yymatches;
  864. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  865. if (!count($yymatches)) {
  866. throw new Exception('Error: lexing failed because a rule matched' .
  867. 'an empty string. Input "' . substr($this->data,
  868. $this->counter, 5) . '... state PHP_SL_COMMENT');
  869. }
  870. next($yymatches); // skip global match
  871. $this->token = key($yymatches); // token number
  872. if ($tokenMap[$this->token]) {
  873. // extract sub-patterns for passing to lex function
  874. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  875. $tokenMap[$this->token]);
  876. } else {
  877. $yysubmatches = array();
  878. }
  879. $this->value = current($yymatches); // token value
  880. $r = $this->{'yy_r5_' . $this->token}($yysubmatches);
  881. if ($r === null) {
  882. $this->counter += strlen($this->value);
  883. $this->line += substr_count($this->value, "\n");
  884. // accept this token
  885. return true;
  886. } elseif ($r === true) {
  887. // we have changed state
  888. // process this token in the new state
  889. return $this->yylex();
  890. } elseif ($r === false) {
  891. $this->counter += strlen($this->value);
  892. $this->line += substr_count($this->value, "\n");
  893. if ($this->counter >= strlen($this->data)) {
  894. return false; // end of input
  895. }
  896. // skip this token
  897. continue;
  898. } } else {
  899. throw new Exception('Unexpected input at line' . $this->line .
  900. ': ' . $this->data[$this->counter]);
  901. }
  902. break;
  903. } while (true);
  904. } // end function
  905. const PHP_SL_COMMENT = 5;
  906. function yy_r5_1($yy_subpatterns)
  907. {
  908. $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
  909. $this->yypopstate();
  910. }
  911. function yy_r5_2($yy_subpatterns)
  912. {
  913. /* this can happen for "//?>" */
  914. $this->yypopstate();
  915. return true;
  916. }
  917. function yylex6()
  918. {
  919. $tokenMap = array (
  920. 1 => 0,
  921. 2 => 0,
  922. );
  923. if ($this->counter >= strlen($this->data)) {
  924. return false; // end of input
  925. }
  926. $yy_global_pattern = "/^([^\n]*\n)|^([\S\s]+)/";
  927. do {
  928. if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
  929. $yysubmatches = $yymatches;
  930. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  931. if (!count($yymatches)) {
  932. throw new Exception('Error: lexing failed because a rule matched' .
  933. 'an empty string. Input "' . substr($this->data,
  934. $this->counter, 5) . '... state PHP_NOWDOC');
  935. }
  936. next($yymatches); // skip global match
  937. $this->token = key($yymatches); // token number
  938. if ($tokenMap[$this->token]) {
  939. // extract sub-patterns for passing to lex function
  940. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  941. $tokenMap[$this->token]);
  942. } else {
  943. $yysubmatches = array();
  944. }
  945. $this->value = current($yymatches); // token value
  946. $r = $this->{'yy_r6_' . $this->token}($yysubmatches);
  947. if ($r === null) {
  948. $this->counter += strlen($this->value);
  949. $this->line += substr_count($this->value, "\n");
  950. // accept this token
  951. return true;
  952. } elseif ($r === true) {
  953. // we have changed state
  954. // process this token in the new state
  955. return $this->yylex();
  956. } elseif ($r === false) {
  957. $this->counter += strlen($this->value);
  958. $this->line += substr_count($this->value, "\n");
  959. if ($this->counter >= strlen($this->data)) {
  960. return false; // end of input
  961. }
  962. // skip this token
  963. continue;
  964. } } else {
  965. throw new Exception('Unexpected input at line' . $this->line .
  966. ': ' . $this->data[$this->counter]);
  967. }
  968. break;
  969. } while (true);
  970. } // end function
  971. const PHP_NOWDOC = 6;
  972. function yy_r6_1($yy_subpatterns)
  973. {
  974. $heredoc_id = $this->heredoc_id_stack[sizeof($this->heredoc_id_stack)-1];
  975. if ( $this->value === $heredoc_id."\n"
  976. || $this->value === $heredoc_id."\r\n"
  977. || $this->value === $heredoc_id.";\n"
  978. || $this->value === $heredoc_id.";\r\n"
  979. ) {
  980. $this->token = Smarty_Internal_Templateparser::TP_PHP_NOWDOC_END;
  981. array_pop($this->heredoc_id_stack);
  982. $this->yypopstate();
  983. } else {
  984. $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_CONTENT;
  985. }
  986. }
  987. function yy_r6_2($yy_subpatterns)
  988. {
  989. $this->compiler->trigger_template_error("missing PHP NOWDOC end");
  990. }
  991. function yylex7()
  992. {
  993. $tokenMap = array (
  994. 1 => 0,
  995. 2 => 0,
  996. 3 => 0,
  997. );
  998. if ($this->counter >= strlen($this->data)) {
  999. return false; // end of input
  1000. }
  1001. $yy_global_pattern = "/^(\\{\\$|\\{\\$)|^([^\n]*\n)|^([\S\s]+)/";
  1002. do {
  1003. if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
  1004. $yysubmatches = $yymatches;
  1005. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  1006. if (!count($yymatches)) {
  1007. throw new Exception('Error: lexing failed because a rule matched' .
  1008. 'an empty string. Input "' . substr($this->data,
  1009. $this->counter, 5) . '... state PHP_HEREDOC');
  1010. }
  1011. next($yymatches); // skip global match
  1012. $this->token = key($yymatches); // token number
  1013. if ($tokenMap[$this->token]) {
  1014. // extract sub-patterns for passing to lex function
  1015. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  1016. $tokenMap[$this->token]);
  1017. } else {
  1018. $yysubmatches = array();
  1019. }
  1020. $this->value = current($yymatches); // token value
  1021. $r = $this->{'yy_r7_' . $this->token}($yysubmatches);
  1022. if ($r === null) {
  1023. $this->counter += strlen($this->value);
  1024. $this->line += substr_count($this->value, "\n");
  1025. // accept this token
  1026. return true;
  1027. } elseif ($r === true) {
  1028. // we have changed state
  1029. // process this token in the new state
  1030. return $this->yylex();
  1031. } elseif ($r === false) {
  1032. $this->counter += strlen($this->value);
  1033. $this->line += substr_count($this->value, "\n");
  1034. if ($this->counter >= strlen($this->data)) {
  1035. return false; // end of input
  1036. }
  1037. // skip this token
  1038. continue;
  1039. } } else {
  1040. throw new Exception('Unexpected input at line' . $this->line .
  1041. ': ' . $this->data[$this->counter]);
  1042. }
  1043. break;
  1044. } while (true);
  1045. } // end function
  1046. const PHP_HEREDOC = 7;
  1047. function yy_r7_1($yy_subpatterns)
  1048. {
  1049. $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_EMBED_START;
  1050. $this->yypushstate(self::PHP_RETURNING_TO_HEREDOC_FROM_EMBEDDED);
  1051. $this->yypushstate(self::PHP_DOUBLE_QUOTED_STRING_EMBEDDED);
  1052. }
  1053. function yy_r7_2($yy_subpatterns)
  1054. {
  1055. $heredoc_id = $this->heredoc_id_stack[sizeof($this->heredoc_id_stack)-1];
  1056. if ( $this->value === $heredoc_id."\n"
  1057. || $this->value === $heredoc_id."\r\n"
  1058. || $this->value === $heredoc_id.";\n"
  1059. || $this->value === $heredoc_id.";\r\n"
  1060. ) {
  1061. $this->token = Smarty_Internal_Templateparser::TP_PHP_HEREDOC_END;
  1062. array_pop($this->heredoc_id_stack);
  1063. $this->yypopstate();
  1064. } else {
  1065. $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_CONTENT;
  1066. if (preg_match('/(.*?)(\{\$\|\$\{)/', $this->value, $matches)) {
  1067. $this->value = $matches[1];
  1068. }
  1069. }
  1070. }
  1071. function yy_r7_3($yy_subpatterns)
  1072. {
  1073. $this->compiler->trigger_template_error("missing PHP HEREDOC end");
  1074. }
  1075. function yylex8()
  1076. {
  1077. $tokenMap = array (
  1078. 1 => 0,
  1079. );
  1080. if ($this->counter >= strlen($this->data)) {
  1081. return false; // end of input
  1082. }
  1083. $yy_global_pattern = "/^([^\n]*\n)/";
  1084. do {
  1085. if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
  1086. $yysubmatches = $yymatches;
  1087. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  1088. if (!count($yymatches)) {
  1089. throw new Exception('Error: lexing failed because a rule matched' .
  1090. 'an empty string. Input "' . substr($this->data,
  1091. $this->counter, 5) . '... state PHP_RETURNING_TO_HEREDOC_FROM_EMBEDDED');
  1092. }
  1093. next($yymatches); // skip global match
  1094. $this->token = key($yymatches); // token number
  1095. if ($tokenMap[$this->token]) {
  1096. // extract sub-patterns for passing to lex function
  1097. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  1098. $tokenMap[$this->token]);
  1099. } else {
  1100. $yysubmatches = array();
  1101. }
  1102. $this->value = current($yymatches); // token value
  1103. $r = $this->{'yy_r8_' . $this->token}($yysubmatches);
  1104. if ($r === null) {
  1105. $this->counter += strlen($this->value);
  1106. $this->line += substr_count($this->value, "\n");
  1107. // accept this token
  1108. return true;
  1109. } elseif ($r === true) {
  1110. // we have changed state
  1111. // process this token in the new state
  1112. return $this->yylex();
  1113. } elseif ($r === false) {
  1114. $this->counter += strlen($this->value);
  1115. $this->line += substr_count($this->value, "\n");
  1116. if ($this->counter >= strlen($this->data)) {
  1117. return false; // end of input
  1118. }
  1119. // skip this token
  1120. continue;
  1121. } } else {
  1122. throw new Exception('Unexpected input at line' . $this->line .
  1123. ': ' . $this->data[$this->counter]);
  1124. }
  1125. break;
  1126. } while (true);
  1127. } // end function
  1128. const PHP_RETURNING_TO_HEREDOC_FROM_EMBEDDED = 8;
  1129. function yy_r8_1($yy_subpatterns)
  1130. {
  1131. $this->yypopstate();
  1132. $heredoc_id = $this->heredoc_id_stack[sizeof($this->heredoc_id_stack)-1];
  1133. if ( $this->value === $heredoc_id."\n"
  1134. || $this->value === $heredoc_id."\r\n"
  1135. || $this->value === $heredoc_id.";\n"
  1136. || $this->value === $heredoc_id.";\r\n"
  1137. ) {
  1138. //Make sure it isn't interpreted as HEREDOC end.
  1139. $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_CONTENT;
  1140. } else {
  1141. return true; //retry in PHP_HEREDOC state
  1142. }
  1143. }
  1144. function yylex9()
  1145. {
  1146. $tokenMap = array (
  1147. 1 => 0,
  1148. 2 => 0,
  1149. );
  1150. if ($this->counter >= strlen($this->data)) {
  1151. return false; // end of input
  1152. }
  1153. $yy_global_pattern = "/^((?:[^\\\\']|\\\\.)*')|^([\S\s]+)/";
  1154. do {
  1155. if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
  1156. $yysubmatches = $yymatches;
  1157. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  1158. if (!count($yymatches)) {
  1159. throw new Exception('Error: lexing failed because a rule matched' .
  1160. 'an empty string. Input "' . substr($this->data,
  1161. $this->counter, 5) . '... state PHP_SINGLE_QUOTED_STRING');
  1162. }
  1163. next($yymatches); // skip global match
  1164. $this->token = key($yymatches); // token number
  1165. if ($tokenMap[$this->token]) {
  1166. // extract sub-patterns for passing to lex function
  1167. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  1168. $tokenMap[$this->token]);
  1169. } else {
  1170. $yysubmatches = array();
  1171. }
  1172. $this->value = current($yymatches); // token value
  1173. $r = $this->{'yy_r9_' . $this->token}($yysubmatches);
  1174. if ($r === null) {
  1175. $this->counter += strlen($this->value);
  1176. $this->line += substr_count($this->value, "\n");
  1177. // accept this token
  1178. return true;
  1179. } elseif ($r === true) {
  1180. // we have changed state
  1181. // process this token in the new state
  1182. return $this->yylex();
  1183. } elseif ($r === false) {
  1184. $this->counter += strlen($this->value);
  1185. $this->line += substr_count($this->value, "\n");
  1186. if ($this->counter >= strlen($this->data)) {
  1187. return false; // end of input
  1188. }
  1189. // skip this token
  1190. continue;
  1191. } } else {
  1192. throw new Exception('Unexpected input at line' . $this->line .
  1193. ': ' . $this->data[$this->counter]);
  1194. }
  1195. break;
  1196. } while (true);
  1197. } // end function
  1198. const PHP_SINGLE_QUOTED_STRING = 9;
  1199. function yy_r9_1($yy_subpatterns)
  1200. {
  1201. $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
  1202. $this->yypopstate();
  1203. }
  1204. function yy_r9_2($yy_subpatterns)
  1205. {
  1206. $this->compiler->trigger_template_error("missing PHP single quoted string end");
  1207. }
  1208. function yylex10()
  1209. {
  1210. $tokenMap = array (
  1211. 1 => 0,
  1212. 2 => 0,
  1213. 3 => 0,
  1214. 4 => 0,
  1215. );
  1216. if ($this->counter >= strlen($this->data)) {
  1217. return false; // end of input
  1218. }
  1219. $yy_global_pattern = "/^(\\{\\$|\\{\\$)|^(\")|^((?:\\\\.|[^\"\\\\])+?(?=\"|\\{\\$|\\$\\{))|^([\S\s]+)/";
  1220. do {
  1221. if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
  1222. $yysubmatches = $yymatches;
  1223. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  1224. if (!count($yymatches)) {
  1225. throw new Exception('Error: lexing failed because a rule matched' .
  1226. 'an empty string. Input "' . substr($this->data,
  1227. $this->counter, 5) . '... state PHP_DOUBLE_QUOTED_STRING');
  1228. }
  1229. next($yymatches); // skip global match
  1230. $this->token = key($yymatches); // token number
  1231. if ($tokenMap[$this->token]) {
  1232. // extract sub-patterns for passing to lex function
  1233. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  1234. $tokenMap[$this->token]);
  1235. } else {
  1236. $yysubmatches = array();
  1237. }
  1238. $this->value = current($yymatches); // token value
  1239. $r = $this->{'yy_r10_' . $this->token}($yysubmatches);
  1240. if ($r === null) {
  1241. $this->counter += strlen($this->value);
  1242. $this->line += substr_count($this->value, "\n");
  1243. // accept this token
  1244. return true;
  1245. } elseif ($r === true) {
  1246. // we have changed state
  1247. // process this token in the new state
  1248. return $this->yylex();
  1249. } elseif ($r === false) {
  1250. $this->counter += strlen($this->value);
  1251. $this->line += substr_count($this->value, "\n");
  1252. if ($this->counter >= strlen($this->data)) {
  1253. return false; // end of input
  1254. }
  1255. // skip this token
  1256. continue;
  1257. } } else {
  1258. throw new Exception('Unexpected input at line' . $this->line .
  1259. ': ' . $this->data[$this->counter]);
  1260. }
  1261. break;
  1262. } while (true);
  1263. } // end function
  1264. const PHP_DOUBLE_QUOTED_STRING = 10;
  1265. function yy_r10_1($yy_subpatterns)
  1266. {
  1267. $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_EMBED_START;
  1268. $this->yypushstate(self::PHP_DOUBLE_QUOTED_STRING_EMBEDDED);
  1269. }
  1270. function yy_r10_2($yy_subpatterns)
  1271. {
  1272. $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE_DOUBLEQUOTE;
  1273. $this->yypopstate();
  1274. }
  1275. function yy_r10_3($yy_subpatterns)
  1276. {
  1277. $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_CONTENT;
  1278. }
  1279. function yy_r10_4($yy_subpatterns)
  1280. {
  1281. $this->compiler->trigger_template_error("missing PHP double quoted string end");
  1282. }
  1283. function yylex11()
  1284. {
  1285. $tokenMap = array (
  1286. 1 => 0,
  1287. 2 => 0,
  1288. 3 => 0,
  1289. 4 => 0,
  1290. 5 => 0,
  1291. 6 => 0,
  1292. );
  1293. if ($this->counter >= strlen($this->data)) {
  1294. return false; // end of input
  1295. }
  1296. $yy_global_pattern = "/^(\")|^(')|^(<<<\\s*\\w+\r?\n)|^(<<<\\s*'\\w+'\r?\n)|^(\\})|^([^'\"}]+?(?='|\"|\\}|<<<\\s*'?\\w+'?\r?\n))/";
  1297. do {
  1298. if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
  1299. $yysubmatches = $yymatches;
  1300. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  1301. if (!count($yymatches)) {
  1302. throw new Exception('Error: lexing failed because a rule matched' .
  1303. 'an empty string. Input "' . substr($this->data,
  1304. $this->counter, 5) . '... state PHP_DOUBLE_QUOTED_STRING_EMBEDDED');
  1305. }
  1306. next($yymatches); // skip global match
  1307. $this->token = key($yymatches); // token number
  1308. if ($tokenMap[$this->token]) {
  1309. // extract sub-patterns for passing to lex function
  1310. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  1311. $tokenMap[$this->token]);
  1312. } else {
  1313. $yysubmatches = array();
  1314. }
  1315. $this->value = current($yymatches); // token value
  1316. $r = $this->{'yy_r11_' . $this->token}($yysubmatches);
  1317. if ($r === null) {
  1318. $this->counter += strlen($this->value);
  1319. $this->line += substr_count($this->value, "\n");
  1320. // accept this token
  1321. return true;
  1322. } elseif ($r === true) {
  1323. // we have changed state
  1324. // process this token in the new state
  1325. return $this->yylex();
  1326. } elseif ($r === false) {
  1327. $this->counter += strlen($this->value);
  1328. $this->line += substr_count($this->value, "\n");
  1329. if ($this->counter >= strlen($this->data)) {
  1330. return false; // end of input
  1331. }
  1332. // skip this token
  1333. continue;
  1334. } } else {
  1335. throw new Exception('Unexpected input at line' . $this->line .
  1336. ': ' . $this->data[$this->counter]);
  1337. }
  1338. break;
  1339. } while (true);
  1340. } // end function
  1341. const PHP_DOUBLE_QUOTED_STRING_EMBEDDED = 11;
  1342. function yy_r11_1($yy_subpatterns)
  1343. {
  1344. $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE_START_DOUBLEQUOTE;
  1345. $this->yypushstate(self::PHP_DOUBLE_QUOTED_STRING);
  1346. }
  1347. function yy_r11_2($yy_subpatterns)
  1348. {
  1349. $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
  1350. $this->yypushstate(self::PHP_SINGLE_QUOTED_STRING);
  1351. }
  1352. function yy_r11_3($yy_subpatterns)
  1353. {
  1354. $this->token = Smarty_Internal_Templateparser::TP_PHP_HEREDOC_START;
  1355. $res = preg_match('/\A\<\<\<\s*(\w+)\r?\n\z/', $this->value, $matches);
  1356. assert($res === 1);
  1357. $this->heredoc_id_stack[] = $matches[1];
  1358. $this->yypushstate(self::PHP_HEREDOC);
  1359. }
  1360. function yy_r11_4($yy_subpatterns)
  1361. {
  1362. $this->token = Smarty_Internal_Templateparser::TP_PHP_NOWDOC_START;
  1363. $res = preg_match('/\A\<\<\<\s*\'(\w+)\'\r?\n\z/', $this->value, $matches);
  1364. assert($res === 1);
  1365. $this->heredoc_id_stack[] = $matches[1];
  1366. $this->yypushstate(self::PHP_NOWDOC);
  1367. }
  1368. function yy_r11_5($yy_subpatterns)
  1369. {
  1370. $this->token = Smarty_Internal_Templateparser::TP_PHP_DQ_EMBED_END;
  1371. $this->yypopstate();
  1372. }
  1373. function yy_r11_6($yy_subpatterns)
  1374. {
  1375. $this->token = Smarty_Internal_Templateparser::TP_PHP_CODE;
  1376. }
  1377. function yylex12()
  1378. {
  1379. $tokenMap = array (
  1380. 1 => 0,
  1381. 2 => 0,
  1382. 3 => 0,
  1383. 4 => 0,
  1384. 5 => 2,
  1385. 8 => 0,
  1386. );
  1387. if ($this->counter >= strlen($this->data)) {
  1388. return false; // end of input
  1389. }
  1390. $yy_global_pattern = "/^(".$this->ldel."literal".$this->rdel.")|^(".$this->ldel."\/literal".$this->rdel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(([\S\s]*?)(?=(".$this->ldel."\/?literal".$this->rdel."|<\\?)))|^([\S\s]+)/";
  1391. do {
  1392. if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
  1393. $yysubmatches = $yymatches;
  1394. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  1395. if (!count($yymatches)) {
  1396. throw new Exception('Error: lexing failed because a rule matched' .
  1397. 'an empty string. Input "' . substr($this->data,
  1398. $this->counter, 5) . '... state LITERAL');
  1399. }
  1400. next($yymatches); // skip global match
  1401. $this->token = key($yymatches); // token number
  1402. if ($tokenMap[$this->token]) {
  1403. // extract sub-patterns for passing to lex function
  1404. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  1405. $tokenMap[$this->token]);
  1406. } else {
  1407. $yysubmatches = array();
  1408. }
  1409. $this->value = current($yymatches); // token value
  1410. $r = $this->{'yy_r12_' . $this->token}($yysubmatches);
  1411. if ($r === null) {
  1412. $this->counter += strlen($this->value);
  1413. $this->line += substr_count($this->value, "\n");
  1414. // accept this token
  1415. return true;
  1416. } elseif ($r === true) {
  1417. // we have changed state
  1418. // process this token in the new state
  1419. return $this->yylex();
  1420. } elseif ($r === false) {
  1421. $this->counter += strlen($this->value);
  1422. $this->line += substr_count($this->value, "\n");
  1423. if ($this->counter >= strlen($this->data)) {
  1424. return false; // end of input
  1425. }
  1426. // skip this token
  1427. continue;
  1428. } } else {
  1429. throw new Exception('Unexpected input at line' . $this->line .
  1430. ': ' . $this->data[$this->counter]);
  1431. }
  1432. break;
  1433. } while (true);
  1434. } // end function
  1435. const LITERAL = 12;
  1436. function yy_r12_1($yy_subpatterns)
  1437. {
  1438. $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
  1439. $this->yypushstate(self::LITERAL);
  1440. }
  1441. function yy_r12_2($yy_subpatterns)
  1442. {
  1443. $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
  1444. $this->yypopstate();
  1445. }
  1446. function yy_r12_3($yy_subpatterns)
  1447. {
  1448. if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
  1449. $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
  1450. } else {
  1451. $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
  1452. $this->value = substr($this->value, 0, 2);
  1453. }
  1454. }
  1455. function yy_r12_4($yy_subpatterns)
  1456. {
  1457. $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
  1458. }
  1459. function yy_r12_5($yy_subpatterns)
  1460. {
  1461. $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
  1462. }
  1463. function yy_r12_8($yy_subpatterns)
  1464. {
  1465. $this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
  1466. }
  1467. function yylex13()
  1468. {
  1469. $tokenMap = array (
  1470. 1 => 0,
  1471. 2 => 0,
  1472. 3 => 0,
  1473. 4 => 0,
  1474. 5 => 0,
  1475. 6 => 0,
  1476. 7 => 0,
  1477. 8 => 0,
  1478. 9 => 3,
  1479. 13 => 0,
  1480. );
  1481. if ($this->counter >= strlen($this->data)) {
  1482. return false; // end of input
  1483. }
  1484. $yy_global_pattern = "/^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(\")|^(`\\$)|^(\\$[0-9]*[a-zA-Z_]\\w*)|^(\\$)|^(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(".$this->ldel."|\\$|`\\$|\")))|^([\S\s]+)/";
  1485. do {
  1486. if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
  1487. $yysubmatches = $yymatches;
  1488. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  1489. if (!count($yymatches)) {
  1490. throw new Exception('Error: lexing failed because a rule matched' .
  1491. 'an empty string. Input "' . substr($this->data,
  1492. $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
  1493. }
  1494. next($yymatches); // skip global match
  1495. $this->token = key($yymatches); // token number
  1496. if ($tokenMap[$this->token]) {
  1497. // extract sub-patterns for passing to lex function
  1498. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  1499. $tokenMap[$this->token]);
  1500. } else {
  1501. $yysubmatches = array();
  1502. }
  1503. $this->value = current($yymatches); // token value
  1504. $r = $this->{'yy_r13_' . $this->token}($yysubmatches);
  1505. if ($r === null) {
  1506. $this->counter += strlen($this->value);
  1507. $this->line += substr_count($this->value, "\n");
  1508. // accept this token
  1509. return true;
  1510. } elseif ($r === true) {
  1511. // we have changed state
  1512. // process this token in the new state
  1513. return $this->yylex();
  1514. } elseif ($r === false) {
  1515. $this->counter += strlen($this->value);
  1516. $this->line += substr_count($this->value, "\n");
  1517. if ($this->counter >= strlen($this->data)) {
  1518. return false; // end of input
  1519. }
  1520. // skip this token
  1521. continue;
  1522. } } else {
  1523. throw new Exception('Unexpected input at line' . $this->line .
  1524. ': ' . $this->data[$this->counter]);
  1525. }
  1526. break;
  1527. } while (true);
  1528. } // end function
  1529. const DOUBLEQUOTEDSTRING = 13;
  1530. function yy_r13_1($yy_subpatterns)
  1531. {
  1532. if ($this->smarty->auto_literal) {
  1533. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  1534. } else {
  1535. $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
  1536. $this->yypushstate(self::SMARTY);
  1537. $this->taglineno = $this->line;
  1538. }
  1539. }
  1540. function yy_r13_2($yy_subpatterns)
  1541. {
  1542. if ($this->smarty->auto_literal) {
  1543. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  1544. } else {
  1545. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  1546. $this->yypushstate(self::SMARTY);
  1547. $this->taglineno = $this->line;
  1548. }
  1549. }
  1550. function yy_r13_3($yy_subpatterns)
  1551. {
  1552. $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
  1553. $this->yypushstate(self::SMARTY);
  1554. $this->taglineno = $this->line;
  1555. }
  1556. function yy_r13_4($yy_subpatterns)
  1557. {
  1558. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  1559. $this->yypushstate(self::SMARTY);
  1560. $this->taglineno = $this->line;
  1561. }
  1562. function yy_r13_5($yy_subpatterns)
  1563. {
  1564. $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
  1565. $this->yypopstate();
  1566. }
  1567. function yy_r13_6($yy_subpatterns)
  1568. {
  1569. $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
  1570. $this->value = substr($this->value,0,-1);
  1571. $this->yypushstate(self::SMARTY);
  1572. $this->taglineno = $this->line;
  1573. }
  1574. function yy_r13_7($yy_subpatterns)
  1575. {
  1576. $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
  1577. }
  1578. function yy_r13_8($yy_subpatterns)
  1579. {
  1580. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  1581. }
  1582. function yy_r13_9($yy_subpatterns)
  1583. {
  1584. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  1585. }
  1586. function yy_r13_13($yy_subpatterns)
  1587. {
  1588. $this->token = Smarty_Internal_Templateparser::TP_OTHER;
  1589. }
  1590. }
  1591. ?>