smarty_internal_smartytemplatecompiler.php
Current file: C:\DATA\Viktor\Diplomka\XSLT-Benchmarking/Libs/Smarty/sysplugins/smarty_internal_smartytemplatecompiler.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00% 0 / 1
0.00% 0 / 2 CRAP
0.00% 0 / 25
Smarty_Internal_SmartyTemplateCompiler
0.00% 0 / 1
0.00% 0 / 2 72
0.00% 0 / 24
 __construct($lexer_class, $parser_class, $smarty)
0.00% 0 / 1 2
0.00% 0 / 5
 doCompile($_content)
0.00% 0 / 1 56
0.00% 0 / 19



       1                 : <?php                                                                                                                
       2                 : /**                                                                                                                  
       3                 :  * Smarty Internal Plugin Smarty Template Compiler Base                                                              
       4                 :  *                                                                                                                   
       5                 :  * This file contains the basic classes and methodes for compiling Smarty templates with lexer/parser                
       6                 :  *                                                                                                                   
       7                 :  * @package Smarty                                                                                                   
       8                 :  * @subpackage Compiler                                                                                              
       9                 :  * @author Uwe Tews                                                                                                  
      10                 :  */                                                                                                                  
      11                 :                                                                                                                      
      12                 : /**                                                                                                                  
      13                 :  * @ignore                                                                                                           
      14                 :  */                                                                                                                  
      15               0 : include ("smarty_internal_parsetree.php");                                                                           
      16                 :                                                                                                                      
      17                 : /**                                                                                                                  
      18                 :  * Class SmartyTemplateCompiler                                                                                      
      19                 :  *                                                                                                                   
      20                 :  * @package Smarty                                                                                                   
      21                 :  * @subpackage Compiler                                                                                              
      22                 :  */                                                                                                                  
      23                 : class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCompilerBase {                          
      24                 :                                                                                                                      
      25                 :     /**                                                                                                              
      26                 :      * Lexer class name                                                                                              
      27                 :      *                                                                                                               
      28                 :      * @var string                                                                                                   
      29                 :      */                                                                                                              
      30                 :     public $lexer_class;                                                                                             
      31                 :                                                                                                                      
      32                 :     /**                                                                                                              
      33                 :      * Parser class name                                                                                             
      34                 :      *                                                                                                               
      35                 :      * @var string                                                                                                   
      36                 :      */                                                                                                              
      37                 :     public $parser_class;                                                                                            
      38                 :                                                                                                                      
      39                 :     /**                                                                                                              
      40                 :      * Lexer object                                                                                                  
      41                 :      *                                                                                                               
      42                 :      * @var object                                                                                                   
      43                 :      */                                                                                                              
      44                 :     public $lex;                                                                                                     
      45                 :                                                                                                                      
      46                 :     /**                                                                                                              
      47                 :      * Parser object                                                                                                 
      48                 :      *                                                                                                               
      49                 :      * @var object                                                                                                   
      50                 :      */                                                                                                              
      51                 :     public $parser;                                                                                                  
      52                 :                                                                                                                      
      53                 :     /**                                                                                                              
      54                 :      * Smarty object                                                                                                 
      55                 :      *                                                                                                               
      56                 :      * @var object                                                                                                   
      57                 :      */                                                                                                              
      58                 :     public $smarty;                                                                                                  
      59                 :                                                                                                                      
      60                 :     /**                                                                                                              
      61                 :      * array of vars which can be compiled in local scope                                                            
      62                 :      *                                                                                                               
      63                 :      * @var array                                                                                                    
      64                 :      */                                                                                                              
      65                 :     public $local_var = array();                                                                                     
      66                 :                                                                                                                      
      67                 :     /**                                                                                                              
      68                 :      * Initialize compiler                                                                                           
      69                 :      *                                                                                                               
      70                 :      * @param string $lexer_class  class name                                                                        
      71                 :      * @param string $parser_class class name                                                                        
      72                 :      * @param Smarty $smarty       global instance                                                                   
      73                 :      */                                                                                                              
      74                 :     public function __construct($lexer_class, $parser_class, $smarty)                                                
      75                 :     {                                                                                                                
      76               0 :         $this->smarty = $smarty;                                                                                     
      77               0 :         parent::__construct();                                                                                       
      78                 :         // get required plugins                                                                                      
      79               0 :         $this->lexer_class = $lexer_class;                                                                           
      80               0 :         $this->parser_class = $parser_class;                                                                         
      81               0 :     }                                                                                                                
      82                 :                                                                                                                      
      83                 :     /**                                                                                                              
      84                 :      * Methode to compile a Smarty template                                                                          
      85                 :      *                                                                                                               
      86                 :      * @param  mixed $_content template source                                                                       
      87                 :      * @return bool true if compiling succeeded, false if it failed                                                  
      88                 :      */                                                                                                              
      89                 :     protected function doCompile($_content)                                                                          
      90                 :     {                                                                                                                
      91                 :         /* here is where the compiling takes place. Smarty                                                           
      92                 :           tags in the templates are replaces with PHP code,                                                          
      93                 :           then written to compiled files. */                                                                         
      94                 :         // init the lexer/parser to compile the template                                                             
      95               0 :         $this->lex = new $this->lexer_class($_content, $this);                                                       
      96               0 :         $this->parser = new $this->parser_class($this->lex, $this);                                                  
      97               0 :         if ($this->smarty->_parserdebug)                                                                             
      98               0 :             $this->parser->PrintTrace();                                                                             
      99                 :         // get tokens from lexer and parse them                                                                      
     100               0 :         while ($this->lex->yylex() && !$this->abort_and_recompile) {                                                 
     101               0 :             if ($this->smarty->_parserdebug) {                                                                       
     102               0 :                 echo "<pre>Line {$this->lex->line} Parsing  {$this->parser->yyTokenName[$this->lex->token]} Token " .
     103               0 :                     htmlentities($this->lex->value) . "</pre>";                                                      
     104               0 :             }                                                                                                        
     105               0 :             $this->parser->doParse($this->lex->token, $this->lex->value);                                            
     106               0 :         }                                                                                                            
     107                 :                                                                                                                      
     108               0 :         if ($this->abort_and_recompile) {                                                                            
     109                 :             // exit here on abort                                                                                    
     110               0 :             return false;                                                                                            
     111                 :         }                                                                                                            
     112                 :         // finish parsing process                                                                                    
     113               0 :         $this->parser->doParse(0, 0);                                                                                
     114                 :         // check for unclosed tags                                                                                   
     115               0 :         if (count($this->_tag_stack) > 0) {                                                                          
     116                 :             // get stacked info                                                                                      
     117               0 :             list($openTag, $_data) = array_pop($this->_tag_stack);                                                   
     118               0 :             $this->trigger_template_error("unclosed {" . $openTag . "} tag");                                        
     119               0 :         }                                                                                                            
     120                 :         // return compiled code                                                                                      
     121                 :         // return str_replace(array("? >\n<?php","? ><?php"), array('',''), $this->parser->retvalue);                
     122               0 :         return $this->parser->retvalue;                                                                              
     123                 :     }                                                                                                                
     124                 :                                                                                                                      
     125                 : }                                                                                                                    
     126                 :                                                                                                                      


Generated by PHP_CodeCoverage @package_version@ using PHP 5.3.6 and PHPUnit @package_version@ at Tue Jun 26 15:06:55 CEST 2012.