PageRenderTime 54ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/source/Smarty/libs/sysplugins/smarty_internal_templatelexer.php

https://github.com/ywl890227/longphp
PHP | 1396 lines | 1343 code | 36 blank | 17 comment | 50 complexity | 9146be7171737908c20668b7cc1fc992 MD5 | raw file
Possible License(s): LGPL-3.0

Large files files are truncated, but you can click here to view the full file

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

Large files files are truncated, but you can click here to view the full file