RE: [PHP] comment followed by ?> fails to parse
| From: | Jonathan Rosenberg | Date: | Wed, 29 May 2002 18:10:52 +0000 |
| Subject: | RE: [PHP] comment followed by ?> fails to parse | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-99784@lists.php.net to get a copy of this message | ||
-----Original Message-----
> From: Thalis A. Kalfigopoulos [mailto:thalis@cs.pitt.edu]
> Sent: Wednesday, May 29, 2002 1:40 PM
> To: Jonathan Rosenberg
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] comment followed by ?> fails to parse
> On Wed, 29 May 2002, Jonathan Rosenberg wrote:
> > 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).
If I remember correctly, scanning typically uses a finite state
machine (equivalent to regular expressions), while parsing using
a pushdown automaton (or equivalent).
You are also correct that many (most?) compilers throw out
comments during scanning.
> Of course you could keep comments
> around and do the "balanced parenthesis matching" in
> the parsing phase.
Some languages support nested comments & do just this.
> Any fallacies in my memory recollection?
Nope. I think you're correct & I retract my previous criticism.
> cheers,
> thalis