[PHP-DEV] Re: Bug #838 Updated: Parser error in nested if From: Antonio Garcia Mari (agarcia <email protected>)
Date: 10/09/98

> How is it clear? Because you've indented it that way? :)
> It's not clear at all, and in fact, the solution for the dangling else
> shift/reduce problem clearly states that the else belongs to the closest
> IF.

It's clear because gramatically speaking, its clear that a colon elseif
must belong to a colon if and a non colon elseif cannot belong to a
colon if. The parser is applying this last rule when it doesn't accept
this:
if ($b==2): print "a=2 b=2<br>";
else print "a=3";
endif;
(note that i left identing :-)
> PHP makes no distinction between if's with braces, no braces, or colons,
> and it doesn't pay attention to your indentation either. As soon as it
> sees the elseif, it expects it to match the inner IF sentence, and since
> it doesn't, it fails.

In my point of view, PHP it's making distinction between colon if's and non
colon if's all the time when validating the sintaxis.
The only moment when it isn't is when it expects an else to match the
inner IF sentence.

A colon else must match the inner block if sentence.

Ok, you can say that's difficult to implement, but it's clear.

Antonio Garcia Mari
AT4.net Internet y Comunicación
http://www.at4.net/

--
PHP Development Mailing List   http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe <email protected>
For help: php-dev-help <email protected>