smarty_internal_templatelexer.php 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557
  1. <?php
  2. /**
  3. * Smarty Internal Plugin Templatelexer
  4. * This is the lexer to break the template source into tokens
  5. *
  6. * @package Smarty
  7. * @subpackage Compiler
  8. * @author Uwe Tews
  9. */
  10. /**
  11. * Smarty Internal Plugin Templatelexer
  12. */
  13. class Smarty_Internal_Templatelexer
  14. {
  15. public $data;
  16. public $counter;
  17. public $token;
  18. public $value;
  19. public $node;
  20. public $line;
  21. public $taglineno;
  22. public $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. }
  93. public function PrintTrace()
  94. {
  95. $this->yyTraceFILE = fopen('php://output', 'w');
  96. $this->yyTracePrompt = '<br>';
  97. }
  98. private $_yy_state = 1;
  99. private $_yy_stack = array();
  100. public function yylex()
  101. {
  102. return $this->{'yylex' . $this->_yy_state}();
  103. }
  104. public function yypushstate($state)
  105. {
  106. if ($this->yyTraceFILE) {
  107. 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);
  108. }
  109. array_push($this->_yy_stack, $this->_yy_state);
  110. $this->_yy_state = $state;
  111. if ($this->yyTraceFILE) {
  112. 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);
  113. }
  114. }
  115. public function yypopstate()
  116. {
  117. if ($this->yyTraceFILE) {
  118. 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);
  119. }
  120. $this->_yy_state = array_pop($this->_yy_stack);
  121. if ($this->yyTraceFILE) {
  122. 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);
  123. }
  124. }
  125. public function yybegin($state)
  126. {
  127. $this->_yy_state = $state;
  128. if ($this->yyTraceFILE) {
  129. 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);
  130. }
  131. }
  132. public function yylex1()
  133. {
  134. $tokenMap = array(
  135. 1 => 0,
  136. 2 => 1,
  137. 4 => 0,
  138. 5 => 0,
  139. 6 => 0,
  140. 7 => 1,
  141. 9 => 0,
  142. 10 => 0,
  143. 11 => 0,
  144. 12 => 0,
  145. 13 => 0,
  146. 14 => 0,
  147. 15 => 0,
  148. 16 => 0,
  149. 17 => 0,
  150. 18 => 0,
  151. 19 => 0,
  152. );
  153. if ($this->counter >= strlen($this->data)) {
  154. return false; // end of input
  155. }
  156. $yy_global_pattern = "/\G(\\{\\})|\G(" . $this->ldel . "\\*([\S\s]*?)\\*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*)|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(\\s*" . $this->rdel . ")|\G(<%)|\G(%>)|\G([\S\s])/iS";
  157. do {
  158. if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
  159. $yysubmatches = $yymatches;
  160. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  161. if (!count($yymatches)) {
  162. throw new Exception('Error: lexing failed because a rule matched' .
  163. ' an empty string. Input "' . substr($this->data,
  164. $this->counter, 5) . '... state TEXT');
  165. }
  166. next($yymatches); // skip global match
  167. $this->token = key($yymatches); // token number
  168. if ($tokenMap[$this->token]) {
  169. // extract sub-patterns for passing to lex function
  170. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  171. $tokenMap[$this->token]);
  172. } else {
  173. $yysubmatches = array();
  174. }
  175. $this->value = current($yymatches); // token value
  176. $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
  177. if ($r === null) {
  178. $this->counter += strlen($this->value);
  179. $this->line += substr_count($this->value, "\n");
  180. // accept this token
  181. return true;
  182. } elseif ($r === true) {
  183. // we have changed state
  184. // process this token in the new state
  185. return $this->yylex();
  186. } elseif ($r === false) {
  187. $this->counter += strlen($this->value);
  188. $this->line += substr_count($this->value, "\n");
  189. if ($this->counter >= strlen($this->data)) {
  190. return false; // end of input
  191. }
  192. // skip this token
  193. continue;
  194. }
  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 && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : 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 && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : 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 && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : 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 && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : 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 && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : 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 && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : 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 && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : 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 && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : 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 && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : 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. $to = strlen($this->data);
  326. preg_match("/{$this->ldel}|<\?|\?>|<%|%>/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
  327. if (isset($match[0][1])) {
  328. $to = $match[0][1];
  329. }
  330. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  331. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  332. }
  333. public function yylex2()
  334. {
  335. $tokenMap = array(
  336. 1 => 0,
  337. 2 => 0,
  338. 3 => 1,
  339. 5 => 0,
  340. 6 => 0,
  341. 7 => 0,
  342. 8 => 0,
  343. 9 => 0,
  344. 10 => 0,
  345. 11 => 0,
  346. 12 => 0,
  347. 13 => 0,
  348. 14 => 0,
  349. 15 => 1,
  350. 17 => 1,
  351. 19 => 1,
  352. 21 => 0,
  353. 22 => 0,
  354. 23 => 0,
  355. 24 => 0,
  356. 25 => 0,
  357. 26 => 0,
  358. 27 => 0,
  359. 28 => 0,
  360. 29 => 0,
  361. 30 => 0,
  362. 31 => 0,
  363. 32 => 0,
  364. 33 => 0,
  365. 34 => 0,
  366. 35 => 0,
  367. 36 => 0,
  368. 37 => 0,
  369. 38 => 3,
  370. 42 => 0,
  371. 43 => 0,
  372. 44 => 0,
  373. 45 => 0,
  374. 46 => 0,
  375. 47 => 0,
  376. 48 => 0,
  377. 49 => 0,
  378. 50 => 1,
  379. 52 => 1,
  380. 54 => 0,
  381. 55 => 0,
  382. 56 => 0,
  383. 57 => 0,
  384. 58 => 0,
  385. 59 => 0,
  386. 60 => 0,
  387. 61 => 0,
  388. 62 => 0,
  389. 63 => 0,
  390. 64 => 0,
  391. 65 => 0,
  392. 66 => 0,
  393. 67 => 0,
  394. 68 => 0,
  395. 69 => 0,
  396. 70 => 1,
  397. 72 => 0,
  398. 73 => 0,
  399. 74 => 0,
  400. 75 => 0,
  401. 76 => 0,
  402. );
  403. if ($this->counter >= strlen($this->data)) {
  404. return false; // end of input
  405. }
  406. $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";
  407. do {
  408. if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
  409. $yysubmatches = $yymatches;
  410. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  411. if (!count($yymatches)) {
  412. throw new Exception('Error: lexing failed because a rule matched' .
  413. ' an empty string. Input "' . substr($this->data,
  414. $this->counter, 5) . '... state SMARTY');
  415. }
  416. next($yymatches); // skip global match
  417. $this->token = key($yymatches); // token number
  418. if ($tokenMap[$this->token]) {
  419. // extract sub-patterns for passing to lex function
  420. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  421. $tokenMap[$this->token]);
  422. } else {
  423. $yysubmatches = array();
  424. }
  425. $this->value = current($yymatches); // token value
  426. $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
  427. if ($r === null) {
  428. $this->counter += strlen($this->value);
  429. $this->line += substr_count($this->value, "\n");
  430. // accept this token
  431. return true;
  432. } elseif ($r === true) {
  433. // we have changed state
  434. // process this token in the new state
  435. return $this->yylex();
  436. } elseif ($r === false) {
  437. $this->counter += strlen($this->value);
  438. $this->line += substr_count($this->value, "\n");
  439. if ($this->counter >= strlen($this->data)) {
  440. return false; // end of input
  441. }
  442. // skip this token
  443. continue;
  444. }
  445. } else {
  446. throw new Exception('Unexpected input at line' . $this->line .
  447. ': ' . $this->data[$this->counter]);
  448. }
  449. break;
  450. } while (true);
  451. } // end function
  452. const SMARTY = 2;
  453. function yy_r2_1($yy_subpatterns)
  454. {
  455. $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
  456. $this->yypushstate(self::DOUBLEQUOTEDSTRING);
  457. }
  458. function yy_r2_2($yy_subpatterns)
  459. {
  460. $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
  461. }
  462. function yy_r2_3($yy_subpatterns)
  463. {
  464. $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
  465. $this->taglineno = $this->line;
  466. }
  467. function yy_r2_5($yy_subpatterns)
  468. {
  469. $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
  470. }
  471. function yy_r2_6($yy_subpatterns)
  472. {
  473. $this->token = Smarty_Internal_Templateparser::TP_RDEL;
  474. $this->yypopstate();
  475. }
  476. function yy_r2_7($yy_subpatterns)
  477. {
  478. $this->token = Smarty_Internal_Templateparser::TP_ISIN;
  479. }
  480. function yy_r2_8($yy_subpatterns)
  481. {
  482. $this->token = Smarty_Internal_Templateparser::TP_AS;
  483. }
  484. function yy_r2_9($yy_subpatterns)
  485. {
  486. $this->token = Smarty_Internal_Templateparser::TP_TO;
  487. }
  488. function yy_r2_10($yy_subpatterns)
  489. {
  490. $this->token = Smarty_Internal_Templateparser::TP_STEP;
  491. }
  492. function yy_r2_11($yy_subpatterns)
  493. {
  494. $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
  495. }
  496. function yy_r2_12($yy_subpatterns)
  497. {
  498. $this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
  499. }
  500. function yy_r2_13($yy_subpatterns)
  501. {
  502. $this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
  503. }
  504. function yy_r2_14($yy_subpatterns)
  505. {
  506. $this->token = Smarty_Internal_Templateparser::TP_EQUALS;
  507. }
  508. function yy_r2_15($yy_subpatterns)
  509. {
  510. $this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
  511. }
  512. function yy_r2_17($yy_subpatterns)
  513. {
  514. $this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
  515. }
  516. function yy_r2_19($yy_subpatterns)
  517. {
  518. $this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
  519. }
  520. function yy_r2_21($yy_subpatterns)
  521. {
  522. $this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
  523. }
  524. function yy_r2_22($yy_subpatterns)
  525. {
  526. $this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
  527. }
  528. function yy_r2_23($yy_subpatterns)
  529. {
  530. $this->token = Smarty_Internal_Templateparser::TP_MOD;
  531. }
  532. function yy_r2_24($yy_subpatterns)
  533. {
  534. $this->token = Smarty_Internal_Templateparser::TP_NOT;
  535. }
  536. function yy_r2_25($yy_subpatterns)
  537. {
  538. $this->token = Smarty_Internal_Templateparser::TP_LAND;
  539. }
  540. function yy_r2_26($yy_subpatterns)
  541. {
  542. $this->token = Smarty_Internal_Templateparser::TP_LOR;
  543. }
  544. function yy_r2_27($yy_subpatterns)
  545. {
  546. $this->token = Smarty_Internal_Templateparser::TP_LXOR;
  547. }
  548. function yy_r2_28($yy_subpatterns)
  549. {
  550. $this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
  551. }
  552. function yy_r2_29($yy_subpatterns)
  553. {
  554. $this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
  555. }
  556. function yy_r2_30($yy_subpatterns)
  557. {
  558. $this->token = Smarty_Internal_Templateparser::TP_ISODD;
  559. }
  560. function yy_r2_31($yy_subpatterns)
  561. {
  562. $this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
  563. }
  564. function yy_r2_32($yy_subpatterns)
  565. {
  566. $this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
  567. }
  568. function yy_r2_33($yy_subpatterns)
  569. {
  570. $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
  571. }
  572. function yy_r2_34($yy_subpatterns)
  573. {
  574. $this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
  575. }
  576. function yy_r2_35($yy_subpatterns)
  577. {
  578. $this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
  579. }
  580. function yy_r2_36($yy_subpatterns)
  581. {
  582. $this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
  583. }
  584. function yy_r2_37($yy_subpatterns)
  585. {
  586. $this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
  587. }
  588. function yy_r2_38($yy_subpatterns)
  589. {
  590. $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
  591. }
  592. function yy_r2_42($yy_subpatterns)
  593. {
  594. $this->token = Smarty_Internal_Templateparser::TP_OPENP;
  595. }
  596. function yy_r2_43($yy_subpatterns)
  597. {
  598. $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
  599. }
  600. function yy_r2_44($yy_subpatterns)
  601. {
  602. $this->token = Smarty_Internal_Templateparser::TP_OPENB;
  603. }
  604. function yy_r2_45($yy_subpatterns)
  605. {
  606. $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
  607. }
  608. function yy_r2_46($yy_subpatterns)
  609. {
  610. $this->token = Smarty_Internal_Templateparser::TP_PTR;
  611. }
  612. function yy_r2_47($yy_subpatterns)
  613. {
  614. $this->token = Smarty_Internal_Templateparser::TP_APTR;
  615. }
  616. function yy_r2_48($yy_subpatterns)
  617. {
  618. $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
  619. }
  620. function yy_r2_49($yy_subpatterns)
  621. {
  622. $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
  623. }
  624. function yy_r2_50($yy_subpatterns)
  625. {
  626. $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
  627. }
  628. function yy_r2_52($yy_subpatterns)
  629. {
  630. $this->token = Smarty_Internal_Templateparser::TP_MATH;
  631. }
  632. function yy_r2_54($yy_subpatterns)
  633. {
  634. $this->token = Smarty_Internal_Templateparser::TP_AT;
  635. }
  636. function yy_r2_55($yy_subpatterns)
  637. {
  638. $this->token = Smarty_Internal_Templateparser::TP_HATCH;
  639. }
  640. function yy_r2_56($yy_subpatterns)
  641. {
  642. // resolve conflicts with shorttag and right_delimiter starting with '='
  643. if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter) {
  644. preg_match("/\s+/", $this->value, $match);
  645. $this->value = $match[0];
  646. $this->token = Smarty_Internal_Templateparser::TP_SPACE;
  647. } else {
  648. $this->token = Smarty_Internal_Templateparser::TP_ATTR;
  649. }
  650. }
  651. function yy_r2_57($yy_subpatterns)
  652. {
  653. $this->token = Smarty_Internal_Templateparser::TP_ID;
  654. }
  655. function yy_r2_58($yy_subpatterns)
  656. {
  657. $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
  658. }
  659. function yy_r2_59($yy_subpatterns)
  660. {
  661. $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
  662. $this->yypopstate();
  663. }
  664. function yy_r2_60($yy_subpatterns)
  665. {
  666. $this->token = Smarty_Internal_Templateparser::TP_VERT;
  667. }
  668. function yy_r2_61($yy_subpatterns)
  669. {
  670. $this->token = Smarty_Internal_Templateparser::TP_DOT;
  671. }
  672. function yy_r2_62($yy_subpatterns)
  673. {
  674. $this->token = Smarty_Internal_Templateparser::TP_COMMA;
  675. }
  676. function yy_r2_63($yy_subpatterns)
  677. {
  678. $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
  679. }
  680. function yy_r2_64($yy_subpatterns)
  681. {
  682. $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
  683. }
  684. function yy_r2_65($yy_subpatterns)
  685. {
  686. $this->token = Smarty_Internal_Templateparser::TP_COLON;
  687. }
  688. function yy_r2_66($yy_subpatterns)
  689. {
  690. $this->token = Smarty_Internal_Templateparser::TP_ANDSYM;
  691. }
  692. function yy_r2_67($yy_subpatterns)
  693. {
  694. $this->token = Smarty_Internal_Templateparser::TP_QMARK;
  695. }
  696. function yy_r2_68($yy_subpatterns)
  697. {
  698. $this->token = Smarty_Internal_Templateparser::TP_HEX;
  699. }
  700. function yy_r2_69($yy_subpatterns)
  701. {
  702. $this->token = Smarty_Internal_Templateparser::TP_SPACE;
  703. }
  704. function yy_r2_70($yy_subpatterns)
  705. {
  706. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  707. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  708. } else {
  709. $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
  710. $this->yypushstate(self::SMARTY);
  711. $this->taglineno = $this->line;
  712. }
  713. }
  714. function yy_r2_72($yy_subpatterns)
  715. {
  716. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  717. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  718. } else {
  719. $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
  720. $this->yypushstate(self::SMARTY);
  721. $this->taglineno = $this->line;
  722. }
  723. }
  724. function yy_r2_73($yy_subpatterns)
  725. {
  726. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  727. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  728. } else {
  729. $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
  730. $this->yypushstate(self::SMARTY);
  731. $this->taglineno = $this->line;
  732. }
  733. }
  734. function yy_r2_74($yy_subpatterns)
  735. {
  736. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  737. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  738. } else {
  739. $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
  740. $this->yypushstate(self::SMARTY);
  741. $this->taglineno = $this->line;
  742. }
  743. }
  744. function yy_r2_75($yy_subpatterns)
  745. {
  746. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  747. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  748. } else {
  749. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  750. $this->yypushstate(self::SMARTY);
  751. $this->taglineno = $this->line;
  752. }
  753. }
  754. function yy_r2_76($yy_subpatterns)
  755. {
  756. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  757. }
  758. public function yylex3()
  759. {
  760. $tokenMap = array(
  761. 1 => 0,
  762. 2 => 0,
  763. 3 => 0,
  764. 4 => 0,
  765. 5 => 0,
  766. 6 => 0,
  767. 7 => 0,
  768. );
  769. if ($this->counter >= strlen($this->data)) {
  770. return false; // end of input
  771. }
  772. $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";
  773. do {
  774. if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
  775. $yysubmatches = $yymatches;
  776. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  777. if (!count($yymatches)) {
  778. throw new Exception('Error: lexing failed because a rule matched' .
  779. ' an empty string. Input "' . substr($this->data,
  780. $this->counter, 5) . '... state LITERAL');
  781. }
  782. next($yymatches); // skip global match
  783. $this->token = key($yymatches); // token number
  784. if ($tokenMap[$this->token]) {
  785. // extract sub-patterns for passing to lex function
  786. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  787. $tokenMap[$this->token]);
  788. } else {
  789. $yysubmatches = array();
  790. }
  791. $this->value = current($yymatches); // token value
  792. $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
  793. if ($r === null) {
  794. $this->counter += strlen($this->value);
  795. $this->line += substr_count($this->value, "\n");
  796. // accept this token
  797. return true;
  798. } elseif ($r === true) {
  799. // we have changed state
  800. // process this token in the new state
  801. return $this->yylex();
  802. } elseif ($r === false) {
  803. $this->counter += strlen($this->value);
  804. $this->line += substr_count($this->value, "\n");
  805. if ($this->counter >= strlen($this->data)) {
  806. return false; // end of input
  807. }
  808. // skip this token
  809. continue;
  810. }
  811. } else {
  812. throw new Exception('Unexpected input at line' . $this->line .
  813. ': ' . $this->data[$this->counter]);
  814. }
  815. break;
  816. } while (true);
  817. } // end function
  818. const LITERAL = 3;
  819. function yy_r3_1($yy_subpatterns)
  820. {
  821. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  822. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  823. } else {
  824. $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
  825. $this->yypushstate(self::LITERAL);
  826. }
  827. }
  828. function yy_r3_2($yy_subpatterns)
  829. {
  830. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  831. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  832. } else {
  833. $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
  834. $this->yypopstate();
  835. }
  836. }
  837. function yy_r3_3($yy_subpatterns)
  838. {
  839. if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
  840. $this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
  841. } else {
  842. $this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
  843. $this->value = substr($this->value, 0, 2);
  844. }
  845. }
  846. function yy_r3_4($yy_subpatterns)
  847. {
  848. $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
  849. }
  850. function yy_r3_5($yy_subpatterns)
  851. {
  852. $this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
  853. }
  854. function yy_r3_6($yy_subpatterns)
  855. {
  856. $this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
  857. }
  858. function yy_r3_7($yy_subpatterns)
  859. {
  860. $to = strlen($this->data);
  861. preg_match("/{$this->ldel}\/?literal{$this->rdel}|<\?|<%|\?>|%>/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
  862. if (isset($match[0][1])) {
  863. $to = $match[0][1];
  864. } else {
  865. $this->compiler->trigger_template_error("missing or misspelled literal closing tag");
  866. }
  867. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  868. $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
  869. }
  870. public function yylex4()
  871. {
  872. $tokenMap = array(
  873. 1 => 1,
  874. 3 => 0,
  875. 4 => 0,
  876. 5 => 0,
  877. 6 => 0,
  878. 7 => 0,
  879. 8 => 0,
  880. 9 => 0,
  881. 10 => 0,
  882. 11 => 3,
  883. 15 => 0,
  884. );
  885. if ($this->counter >= strlen($this->data)) {
  886. return false; // end of input
  887. }
  888. $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";
  889. do {
  890. if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
  891. $yysubmatches = $yymatches;
  892. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  893. if (!count($yymatches)) {
  894. throw new Exception('Error: lexing failed because a rule matched' .
  895. ' an empty string. Input "' . substr($this->data,
  896. $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
  897. }
  898. next($yymatches); // skip global match
  899. $this->token = key($yymatches); // token number
  900. if ($tokenMap[$this->token]) {
  901. // extract sub-patterns for passing to lex function
  902. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  903. $tokenMap[$this->token]);
  904. } else {
  905. $yysubmatches = array();
  906. }
  907. $this->value = current($yymatches); // token value
  908. $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
  909. if ($r === null) {
  910. $this->counter += strlen($this->value);
  911. $this->line += substr_count($this->value, "\n");
  912. // accept this token
  913. return true;
  914. } elseif ($r === true) {
  915. // we have changed state
  916. // process this token in the new state
  917. return $this->yylex();
  918. } elseif ($r === false) {
  919. $this->counter += strlen($this->value);
  920. $this->line += substr_count($this->value, "\n");
  921. if ($this->counter >= strlen($this->data)) {
  922. return false; // end of input
  923. }
  924. // skip this token
  925. continue;
  926. }
  927. } else {
  928. throw new Exception('Unexpected input at line' . $this->line .
  929. ': ' . $this->data[$this->counter]);
  930. }
  931. break;
  932. } while (true);
  933. } // end function
  934. const DOUBLEQUOTEDSTRING = 4;
  935. function yy_r4_1($yy_subpatterns)
  936. {
  937. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  938. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  939. } else {
  940. $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
  941. $this->yypushstate(self::SMARTY);
  942. $this->taglineno = $this->line;
  943. }
  944. }
  945. function yy_r4_3($yy_subpatterns)
  946. {
  947. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  948. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  949. } else {
  950. $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
  951. $this->yypushstate(self::SMARTY);
  952. $this->taglineno = $this->line;
  953. }
  954. }
  955. function yy_r4_4($yy_subpatterns)
  956. {
  957. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  958. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  959. } else {
  960. $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
  961. $this->yypushstate(self::SMARTY);
  962. $this->taglineno = $this->line;
  963. }
  964. }
  965. function yy_r4_5($yy_subpatterns)
  966. {
  967. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  968. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  969. } else {
  970. $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
  971. $this->yypushstate(self::SMARTY);
  972. $this->taglineno = $this->line;
  973. }
  974. }
  975. function yy_r4_6($yy_subpatterns)
  976. {
  977. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  978. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  979. } else {
  980. $this->token = Smarty_Internal_Templateparser::TP_LDEL;
  981. $this->yypushstate(self::SMARTY);
  982. $this->taglineno = $this->line;
  983. }
  984. }
  985. function yy_r4_7($yy_subpatterns)
  986. {
  987. $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
  988. $this->yypopstate();
  989. }
  990. function yy_r4_8($yy_subpatterns)
  991. {
  992. $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
  993. $this->value = substr($this->value, 0, - 1);
  994. $this->yypushstate(self::SMARTY);
  995. $this->taglineno = $this->line;
  996. }
  997. function yy_r4_9($yy_subpatterns)
  998. {
  999. $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
  1000. }
  1001. function yy_r4_10($yy_subpatterns)
  1002. {
  1003. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  1004. }
  1005. function yy_r4_11($yy_subpatterns)
  1006. {
  1007. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  1008. }
  1009. function yy_r4_15($yy_subpatterns)
  1010. {
  1011. $to = strlen($this->data);
  1012. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  1013. $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  1014. }
  1015. public function yylex5()
  1016. {
  1017. $tokenMap = array(
  1018. 1 => 0,
  1019. 2 => 0,
  1020. 3 => 0,
  1021. 4 => 0,
  1022. );
  1023. if ($this->counter >= strlen($this->data)) {
  1024. return false; // end of input
  1025. }
  1026. $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";
  1027. do {
  1028. if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
  1029. $yysubmatches = $yymatches;
  1030. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  1031. if (!count($yymatches)) {
  1032. throw new Exception('Error: lexing failed because a rule matched' .
  1033. ' an empty string. Input "' . substr($this->data,
  1034. $this->counter, 5) . '... state CHILDBODY');
  1035. }
  1036. next($yymatches); // skip global match
  1037. $this->token = key($yymatches); // token number
  1038. if ($tokenMap[$this->token]) {
  1039. // extract sub-patterns for passing to lex function
  1040. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  1041. $tokenMap[$this->token]);
  1042. } else {
  1043. $yysubmatches = array();
  1044. }
  1045. $this->value = current($yymatches); // token value
  1046. $r = $this->{'yy_r5_' . $this->token}($yysubmatches);
  1047. if ($r === null) {
  1048. $this->counter += strlen($this->value);
  1049. $this->line += substr_count($this->value, "\n");
  1050. // accept this token
  1051. return true;
  1052. } elseif ($r === true) {
  1053. // we have changed state
  1054. // process this token in the new state
  1055. return $this->yylex();
  1056. } elseif ($r === false) {
  1057. $this->counter += strlen($this->value);
  1058. $this->line += substr_count($this->value, "\n");
  1059. if ($this->counter >= strlen($this->data)) {
  1060. return false; // end of input
  1061. }
  1062. // skip this token
  1063. continue;
  1064. }
  1065. } else {
  1066. throw new Exception('Unexpected input at line' . $this->line .
  1067. ': ' . $this->data[$this->counter]);
  1068. }
  1069. break;
  1070. } while (true);
  1071. } // end function
  1072. const CHILDBODY = 5;
  1073. function yy_r5_1($yy_subpatterns)
  1074. {
  1075. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  1076. return false;
  1077. } else {
  1078. $this->token = Smarty_Internal_Templateparser::TP_STRIPON;
  1079. }
  1080. }
  1081. function yy_r5_2($yy_subpatterns)
  1082. {
  1083. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  1084. return false;
  1085. } else {
  1086. $this->token = Smarty_Internal_Templateparser::TP_STRIPOFF;
  1087. }
  1088. }
  1089. function yy_r5_3($yy_subpatterns)
  1090. {
  1091. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  1092. return false;
  1093. } else {
  1094. $this->yypopstate();
  1095. return true;
  1096. }
  1097. }
  1098. function yy_r5_4($yy_subpatterns)
  1099. {
  1100. $to = strlen($this->data);
  1101. preg_match("/" . $this->ldel . "\s*((\/)?strip\s*" . $this->rdel . "|block\s+)/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
  1102. if (isset($match[0][1])) {
  1103. $to = $match[0][1];
  1104. }
  1105. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  1106. return false;
  1107. }
  1108. public function yylex6()
  1109. {
  1110. $tokenMap = array(
  1111. 1 => 0,
  1112. 2 => 0,
  1113. 3 => 0,
  1114. 4 => 1,
  1115. 6 => 0,
  1116. );
  1117. if ($this->counter >= strlen($this->data)) {
  1118. return false; // end of input
  1119. }
  1120. $yy_global_pattern = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G(" . $this->ldel . "\\s*\/block)|\G(" . $this->ldel . "\\s*[$]smarty\\.block\\.(child|parent))|\G([\S\s])/iS";
  1121. do {
  1122. if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
  1123. $yysubmatches = $yymatches;
  1124. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  1125. if (!count($yymatches)) {
  1126. throw new Exception('Error: lexing failed because a rule matched' .
  1127. ' an empty string. Input "' . substr($this->data,
  1128. $this->counter, 5) . '... state CHILDBLOCK');
  1129. }
  1130. next($yymatches); // skip global match
  1131. $this->token = key($yymatches); // token number
  1132. if ($tokenMap[$this->token]) {
  1133. // extract sub-patterns for passing to lex function
  1134. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  1135. $tokenMap[$this->token]);
  1136. } else {
  1137. $yysubmatches = array();
  1138. }
  1139. $this->value = current($yymatches); // token value
  1140. $r = $this->{'yy_r6_' . $this->token}($yysubmatches);
  1141. if ($r === null) {
  1142. $this->counter += strlen($this->value);
  1143. $this->line += substr_count($this->value, "\n");
  1144. // accept this token
  1145. return true;
  1146. } elseif ($r === true) {
  1147. // we have changed state
  1148. // process this token in the new state
  1149. return $this->yylex();
  1150. } elseif ($r === false) {
  1151. $this->counter += strlen($this->value);
  1152. $this->line += substr_count($this->value, "\n");
  1153. if ($this->counter >= strlen($this->data)) {
  1154. return false; // end of input
  1155. }
  1156. // skip this token
  1157. continue;
  1158. }
  1159. } else {
  1160. throw new Exception('Unexpected input at line' . $this->line .
  1161. ': ' . $this->data[$this->counter]);
  1162. }
  1163. break;
  1164. } while (true);
  1165. } // end function
  1166. const CHILDBLOCK = 6;
  1167. function yy_r6_1($yy_subpatterns)
  1168. {
  1169. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  1170. $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
  1171. } else {
  1172. $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
  1173. $this->yypushstate(self::CHILDLITERAL);
  1174. }
  1175. }
  1176. function yy_r6_2($yy_subpatterns)
  1177. {
  1178. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  1179. $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
  1180. } else {
  1181. $this->yypopstate();
  1182. return true;
  1183. }
  1184. }
  1185. function yy_r6_3($yy_subpatterns)
  1186. {
  1187. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  1188. $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
  1189. } else {
  1190. $this->yypopstate();
  1191. return true;
  1192. }
  1193. }
  1194. function yy_r6_4($yy_subpatterns)
  1195. {
  1196. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  1197. $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
  1198. } else {
  1199. $this->yypopstate();
  1200. return true;
  1201. }
  1202. }
  1203. function yy_r6_6($yy_subpatterns)
  1204. {
  1205. $to = strlen($this->data);
  1206. preg_match("/" . $this->ldel . "\s*(literal\s*" . $this->rdel . "|(\/)?block(\s|" . $this->rdel . ")|[\$]smarty\.block\.(child|parent))/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
  1207. if (isset($match[0][1])) {
  1208. $to = $match[0][1];
  1209. }
  1210. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  1211. $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
  1212. }
  1213. public function yylex7()
  1214. {
  1215. $tokenMap = array(
  1216. 1 => 0,
  1217. 2 => 0,
  1218. 3 => 0,
  1219. );
  1220. if ($this->counter >= strlen($this->data)) {
  1221. return false; // end of input
  1222. }
  1223. $yy_global_pattern = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G([\S\s])/iS";
  1224. do {
  1225. if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
  1226. $yysubmatches = $yymatches;
  1227. $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
  1228. if (!count($yymatches)) {
  1229. throw new Exception('Error: lexing failed because a rule matched' .
  1230. ' an empty string. Input "' . substr($this->data,
  1231. $this->counter, 5) . '... state CHILDLITERAL');
  1232. }
  1233. next($yymatches); // skip global match
  1234. $this->token = key($yymatches); // token number
  1235. if ($tokenMap[$this->token]) {
  1236. // extract sub-patterns for passing to lex function
  1237. $yysubmatches = array_slice($yysubmatches, $this->token + 1,
  1238. $tokenMap[$this->token]);
  1239. } else {
  1240. $yysubmatches = array();
  1241. }
  1242. $this->value = current($yymatches); // token value
  1243. $r = $this->{'yy_r7_' . $this->token}($yysubmatches);
  1244. if ($r === null) {
  1245. $this->counter += strlen($this->value);
  1246. $this->line += substr_count($this->value, "\n");
  1247. // accept this token
  1248. return true;
  1249. } elseif ($r === true) {
  1250. // we have changed state
  1251. // process this token in the new state
  1252. return $this->yylex();
  1253. } elseif ($r === false) {
  1254. $this->counter += strlen($this->value);
  1255. $this->line += substr_count($this->value, "\n");
  1256. if ($this->counter >= strlen($this->data)) {
  1257. return false; // end of input
  1258. }
  1259. // skip this token
  1260. continue;
  1261. }
  1262. } else {
  1263. throw new Exception('Unexpected input at line' . $this->line .
  1264. ': ' . $this->data[$this->counter]);
  1265. }
  1266. break;
  1267. } while (true);
  1268. } // end function
  1269. const CHILDLITERAL = 7;
  1270. function yy_r7_1($yy_subpatterns)
  1271. {
  1272. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  1273. $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
  1274. } else {
  1275. $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
  1276. $this->yypushstate(self::CHILDLITERAL);
  1277. }
  1278. }
  1279. function yy_r7_2($yy_subpatterns)
  1280. {
  1281. if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
  1282. $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
  1283. } else {
  1284. $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
  1285. $this->yypopstate();
  1286. }
  1287. }
  1288. function yy_r7_3($yy_subpatterns)
  1289. {
  1290. $to = strlen($this->data);
  1291. preg_match("/{$this->ldel}\/?literal\s*{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
  1292. if (isset($match[0][1])) {
  1293. $to = $match[0][1];
  1294. } else {
  1295. $this->compiler->trigger_template_error("missing or misspelled literal closing tag");
  1296. }
  1297. $this->value = substr($this->data, $this->counter, $to - $this->counter);
  1298. $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
  1299. }
  1300. }