[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grammar questions



> You will have to make a choice.  The best you can do is automatically
> associate an "elseif" with the closest enclosing "if()" or "if():".
> 
> So, in the case of your example, you would get a parsing error, because
> it would be parsed as:
> if (a):
>   if (c)
>     x = y;
>   elseif (b): *** parse error: ":" is invalid in this context.
> ...

In retrospect, I definitely think that this is really how the parser
should behave.  It is easy and intuitive for a PHP programmer to
understand that an "elseif" is associated with the closest enclosing
"if", regardless of the form of the statement block.  So, the above
parsing error would be logical.

Etienne
-- 
----------------------------------------------------------------------
Etienne M. Gagnon, M.Sc.                     e-mail: egagnon@j-meg.com
Author of SableCC:                             http://www.sablecc.org/
and SableVM:                                   http://www.sablevm.org/