But in C, you can #if 0 whole blocks out regardless. I'm in favour of a
change like this (if not this specific one) in 4.2.

adamw

----- Original Message -----
From: "Andi Gutmans" <[EMAIL PROTECTED]>
To: "Anders Johannsen" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, November 27, 2001 5:21 PM
Subject: Re: [PHP-DEV] Patch: Nested comments


> I don't think this should be changed and we should stick to the way it is
> in C. (It is also not BC and even if I thought it's a good idea, which I
> don't, I don't think it's worth it).
>
> Andi
>
> At 11:48 AM 11/27/2001 +0100, Anders Johannsen wrote:
> >This patch allows for nested 'C-style' comments, which can be useful
> >especially while debugging.
> >
> >     <?php
> >         /* comments
> >             /* now /* nest */ */
> >
> >             /*/*/*/*
> >             */*/*/*/
> >         */
> >     ?>
> >
> >Since comments are handled purely lexical, there should be virtually no
> >performance hit.
> >
> >The following two examples show how errors are handled:
> >
> >1)
> >     <?php
> >         /*
> >             */
> >         */
> >     ?>
> >
> >2)
> >     <?php
> >         /*
> >             /*
> >         */
> >     ?>
> >
> >Ad 1) This will yield a zend_error(E_COMPILE_ERROR,"Invalid nesting of
> >comments") on the
> >last line. Unpatched, a parse error is the most likely result.
> >
> >Ad 2) A zend_error(E_COMPILE_WARNING, "unterminated comment starting line
> >%d", CG(comment_start_line)) is raised.
> >
> >The attached patch is against latest CVS
> >
> >Best regards,
> >Anders Johannsen
> >--
> >[EMAIL PROTECTED]
> >
> >Index: zend_globals.h
> >===================================================================
> >RCS file: /repository/Zend/zend_globals.h,v
> >retrieving revision 1.80
> >diff -u -r1.80 zend_globals.h
> >--- zend_globals.h      2001/10/23 01:19:16     1.80
> >+++ zend_globals.h      2001/11/27 10:08:06
> >@@ -82,6 +82,7 @@
> >         int comment_start_line;
> >         char *heredoc;
> >         int heredoc_len;
> >+        unsigned int comment_nest_level;
> >
> >         zend_op_array *active_op_array;
> >
> >Index: zend_language_scanner.l
> >===================================================================
> >RCS file: /repository/Zend/zend_language_scanner.l,v
> >retrieving revision 1.40
> >diff -u -r1.40 zend_language_scanner.l
> >--- zend_language_scanner.l     2001/09/22 00:06:27     1.40
> >+++ zend_language_scanner.l     2001/11/27 10:08:07
> >@@ -1,5 +1,4 @@
> >  %{
> >-
> >  /*
> >
> >+----------------------------------------------------------------------+
> >     | Zend
> >Engine                                                          |
> >@@ -125,6 +124,7 @@
> >  {
> >         CG(heredoc) = NULL;
> >         CG(heredoc_len)=0;
> >+       CG(comment_nest_level)=0;
> >  }
> >
> >
> >@@ -1057,24 +1057,39 @@
> >         }
> >  }
> >
> >+<ST_IN_SCRIPTING>"*/" {
> >+       zend_error(E_COMPILE_ERROR,"Invalid nesting of comments");
> >+}
> >+
> >  <ST_IN_SCRIPTING>"/*" {
> >         CG(comment_start_line) = CG(zend_lineno);
> >         BEGIN(ST_COMMENT);
> >+        CG(comment_nest_level) = 1;
> >         yymore();
> >  }
> >
> >-
> >-<ST_COMMENT>[^*]+ {
> >+<ST_COMMENT>[^/*]+ {
> >         yymore();
> >  }
> >
> >+<ST_COMMENT>"/*" {
> >+        CG(comment_nest_level)++;
> >+        yymore();
> >+}
> >+
> >  <ST_COMMENT>"*/" {
> >-       HANDLE_NEWLINES(yytext, yyleng);
> >-       BEGIN(ST_IN_SCRIPTING);
> >-       return T_COMMENT;
> >+        CG(comment_nest_level)--;
> >+
> >+        if (CG(comment_nest_level) == 0) {
> >+                HANDLE_NEWLINES(yytext, yyleng);
> >+               BEGIN(ST_IN_SCRIPTING);
> >+               return T_COMMENT;
> >+        } else {
> >+             yymore();
> >+        }
> >  }
> >
> >-<ST_COMMENT>"*" {
> >+<ST_COMMENT>"*"|"/" {
> >         yymore();
> >  }
> >
> >
> >
> >
> >
> >--
> >PHP Development Mailing List <http://www.php.net/>
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to