If you name the token __HALT_PHP_PARSER__ instead (or something
equally unlikely to be used by accident and unambiguous in meaning),
you'll get a +1 from me :-)

--Wez.


On Fri, 11 Mar 2005 14:36:16 -0500, Ilia Alshanetsky <[EMAIL PROTECTED]> wrote:
> The attach patch implements a special "token" <?php HALT; ?> that can be
> used to stop the Zend lexical parser from parsing any data after this
> token.
> 
> The idea behind this patch is to allow tucking on of any data (binary
> and otherwise) to the PHP script without having to encode it. It also
> saves on memory/cpu that normally be used/needed to parse the data.
> Memory is particularly important point, since many systems run with
> default memory limit (8 megs) and would easily hit it when a script had
> a 2-4 megs of data tacked on.
> 
> The patch would be extremely helpful for application distribution where
> the entire install/upgrade script can be just a single script.
> 
> The syntax chosen for the patch was design specifically in such a way as
> to not cause parser errors in older PHPs without the support for this
> feature.
> 
> Ilia
> 
> 
> Index: Zend/zend_language_scanner.l
> ===================================================================
> RCS file: /repository/ZendEngine2/zend_language_scanner.l,v
> retrieving revision 1.124
> diff -u -a -p -r1.124 zend_language_scanner.l
> --- Zend/zend_language_scanner.l        7 Mar 2005 16:48:49 -0000       1.124
> +++ Zend/zend_language_scanner.l        11 Mar 2005 19:30:47 -0000
> @@ -1342,6 +1342,10 @@ NEWLINE ("\r"|"\n"|"\r\n")
>         return T_INLINE_HTML;
>  }
> 
> +<INITIAL>"<?php"{WHITESPACE}"HALT;"{WHITESPACE}*"?>" {
> +       yyterminate();
> +}
> +
>  
> <INITIAL>"<?"|"<script"{WHITESPACE}+"language"{WHITESPACE}*"="{WHITESPACE}*("php"|"\"php\""|"\'php\'"){WHITESPACE}*">"
>  {
>         HANDLE_NEWLINES(yytext, yyleng);
>         if (CG(short_tags) || yyleng>2) { /* yyleng>2 means it's not <? but 
> <script> */
> 
> 
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to