【php开源代码栏目提醒】:网学会员--在 php开源代码编辑为广大网友搜集整理了:class.compiler.php绩等信息,祝愿广大网友取得需要的信息,参考学习。
<?php
/*
* Project: Smarty-Light, a smarter template engine
* File: class.compiler.php
* Author: Paul Lockaby <paul@paullockaby.com>
* Version: 2.2.8
* Copyright: 2003,2004,2005 by Paul Lockaby
* Credit: This work is a light version of Smarty: the
PHP compiling
* template engine, v2.5.0-CVS. Smarty was originally
* programmed by Monte Ohrt and Andrei Zmievski and can be
* found at http://smarty.php.net
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* You may contact the author of Smarty-Light by e-mail at:
* paul@paullockaby.com
*
* The latest version of Smarty-Light can be obtained from:
* http://www.paullockaby.com/projects/smarty-light
*
*/
class compiler extends template {
// public configuration variables
var $left_tag = "";
var $right_tag = "";
var $plugin_dir = "";
var $template_dir = "";
// private internal variables
var $_vars = array(); // stores all internal assigned variables
var $_confs = array(); // stores all internal config variables
var $_plugins = array(); // stores all internal plugins
var $_linenum = 0; // the current line number in the file we are processing
var $_file = ""; // the current file we are processing
var $_literal = array(); // stores all literal blocks
var $_foreachelse_stack = array();
var $_for_stack = 0;
var $_switch_stack = array();
var $_tag_stack = array();
var $_require_stack = array(); // stores all files that are "required" inside of the template
var $_error_level = null;
var $_sl_md5 = '39fc70570b8b60cbc1b85839bf242aff';
var $_db_qstr_regexp = null; // regexps are setup in the constructor
var $_si_qstr_regexp = null;
var $_qstr_regexp = null;
var $_func_regexp = null;
var $_var_bracket_regexp = null;
var $_dvar_regexp = null;
var $_cvar_regexp = null;
var $_mod_regexp = null;
var $_var_regexp = null;
function compiler() {
// matches double quoted strings:
// "foobar"
// "foo\"bar"
// "foobar" . "foo\"bar"
$this->_db_qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"';
// matches single quoted strings:
// 'foobar'
// 'foo\'bar'
$this->_si_qstr_regexp = '\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
// matches single or double quoted strings
$this->_qstr_regexp = '(?:' . $this->_db_qstr_regexp . '|' . $this->_si_qstr_regexp . ')';
// matches bracket portion of vars
// [0]
// [foo]
// [$bar]
// [#bar#]
$this->_var_bracket_regexp = '\[[\$|\#]?\w+\#?\]';
// matches $ vars (not objects):
// $foo
// $foo[0]
// $foo[$bar]
// $foo[5][blah]
$this->_dvar_regexp = '\$[a-zA-Z0-9_]{1,}(?:' . $this->_var_bracket_regexp . ')*(?:' . $this->_var_bracket_regexp . ')*';
// matches config vars:
// #foo#
// #foobar123_foo#
$this->_cvar_regexp = '\#[a-zA-Z0-9_]{1,}(?:' . $this->_var_bracket_regexp . ')*(?:' . $this->_var_bracket_regexp . ')*\#';
// matches valid variable syntax:
// $foo
// 'text'
// "text"
$this->_var_regexp = '(?:(?:' . $this->_dvar_regexp . '|' . $this->_cvar_regexp . ')|' . $this->_qstr_regexp . ')';
// matches valid modifier syntax:
// |foo
// |@foo
// |foo:"bar"
// |foo:$bar
// |foo:"bar":$foobar
// |foo|bar
$this->_mod_regexp = '(?:\|@?[0-9a-zA-Z_]+(?::(?>-?\w+|' . $this->_dvar_regexp . '|' . $this->_qstr_regexp .'))*)';
// matches valid function name:
// foo123
// _foo_bar
$this->_func_regexp = '[a-zA-Z0-9_]+';
}
function _compile_file($file_contents) {
$ldq = preg_quote($this->left_tag);
$rdq = preg_quote($this->right_tag);
$_match = array(); // a temp variable for the current regex match
$tags = array(); // all original tags
$text = array(); // all original text
$compiled_text = ""; // stores the compiled result
$compiled_tags = array(); // all tags and stuff
/