RE: [PHP] comment followed by ?> fails to parse

From: Date: Wed, 29 May 2002 17:39:47 +0000
Subject: RE: [PHP] comment followed by ?> fails to parse
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-99780@lists.php.net to get a copy of this message
On Wed, 29 May 2002, Jonathan Rosenberg wrote: > -----Original Message----- > > From: Thalis A. Kalfigopoulos [mailto:thalis@cs.pitt.edu] > > Sent: Wednesday, May 29, 2002 10:27 AM > > To: php-general@lists.php.net > > Subject: Re: [PHP] comment followed by ?> fails to parse > > > On Wed, 29 May 2002, Jason Wong wrote: > > > > Yes this hightlights another shortcoming of PHP in > > > that it cannot have nested multi-line comments. > > > This is not a shortcoming. This is an issue of the > > scanner of the compiler. It is not possible to > > remember the nesting level of the comments because of > > the nature of regular expressions: they lack memory. > > You need to brush up on your parsing theory. If the PHP parser > can balance parentheses, it can balance comments, also. From what I remember from my compilers theory, "regexpr" is one thing, but "grammar" is another. The parsing phase uses a grammar which is more powerful (every regexpr has equivalent grammar but not the other way around). But the comments are usually detected and dropped thereof in the scanning phase (prior to parsing). Of course you could keep comments around and do the "balanced parenthesis matching" in the parsing phase. Any fallacies in my memory recollection? cheers, thalis

« previous php.general (#99780) next »