New syntax allowed for the compiler
| From: | Renaud Binse | Date: | Tue, 04 Feb 2003 11:16:32 +0000 |
| Subject: | New syntax allowed for the compiler | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-661@lists.php.net to get a copy of this message | ||
Hi,
Here is a little patch to allow the compiler to recognize the following
syntax :
$foo->bar[$foo]
$foo->bar[$foo]->bar
$foo->bar[$bar]->foo->bar()
$foo->bar[$foo]->foo[$bar]->bar()
etc
These modifications recognize all the standard samples given in the file
Smarty_Compiler.class.php
If anyone see a wrong recognized syntax
Renaud
57a58
> var $_arvar_regexp = null;
96c97,98
< $this->_dvar_regexp =
'\$\w+(?:\[\$?[\w\.]+\])*(?:\.\$?\w+(?:\[\$?[\w\.]+\])*)*';
---
> $this->_arvar_regexp =
'\w+(?:\[\$?[\w\.]+\])*(?:\.\$?\w+(?:\[\$?[\w\.]+\])*)*';
> $this->_dvar_regexp = '\$'.$this->_arvar_regexp;
132a135,136
> // $foo->bar[$foo]
> // $foo->bar[$foo]->bar
139,140c143,146
< $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp .
'(?:\->\w+)+)';
< $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp .
'(?:\((?:\w+|'
---
> // $foo->bar[$bar]->foo->bar()
> // $foo->bar[$foo]->foo[$bar]->bar()
> $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp .
'(?:\->'.$this->_arvar_regexp.')*)';
> $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp .
'(?:\w+\((?:\w+|'