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

At 18:55 09/10/98 +0200, Antonio Garcia Mari wrote:
> | IF '(' expr ')' { cs_start_if (&$3 _INLINE_TLS); } statement
elseif_list else_single {
>cs_end_if ( _INLINE_TLS_VOID); }
> | IF '(' expr ')' ':' { cs_start_if (&$3 _INLINE_TLS); } statement_list
new_elseif_list
>new_else_single { cs_end_if ( _INLINE_TLS_VOID); } ENDIF ';'
>
>So, rules for colon if's and non colon if's are completely different.
except for the
>cs_start_if, cs_end_if. I deduce (correct me if i'm wrong) that theese
functions
>register the nesting if's.

Two different rules for two identical constructs.

>What i'm saying is that a colon if is a different instruction (a different
language construct ) that a non
>colon if. If i'm right, the register functions must be different.

No, you're wrong - they're the same construct, with two flavors for the
syntax. It uses the same tokens.

>Considere the language construct AF like the colon IF:
>
>AF '(' expr ')' ':' { cs_start_af (&$3 _INLINE_TLS); } statement_list
new_elseaf_list new_elsea_single {
>cs_end_af ( _INLINE_TLS_VOID); } ENDAF ';'
>
>Then if i've understood the semmantics, this construction is correct:
>AF ($a==1):
> if ($b==2) echo "hello world";
>ELSEAF ($a==2):
> echo "hello world";
>ENDAF;
>
>Can you do that without changing IF by AF or am i completely obfuscated?

No, you can't do it without changing the tokens. That's why I say that the
colon and non-colon if's are two flavors of the very same construct.

Zeev

--
Zeev Suraski   <zeev <email protected>>
For a PGP public key, finger bourbon <email protected>

-- 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>