PageRenderTime 57ms CodeModel.GetById 3ms app.highlight 45ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://zoop.googlecode.com/
PHP | 1803 lines | 1673 code | 107 blank | 23 comment | 38 complexity | a3b2793c254c2e2146fbe0a1ced6384b MD5 | raw file

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

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