-----Original Message-----
> From: Thalis A. Kalfigopoulos [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 29, 2002 1:40 PM
> To: Jonathan Rosenberg
> Cc: [EMAIL PROTECTED]
> 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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to