[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/libraries/Smarty/libs/sysplugins/ -> smarty_internal_templatelexer.php (source)

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


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1