Skip to content
Prev 40359 / 398498 Next

Problem with parser and if/else

On Fri, 14 Nov 2003, Paul Lemmens wrote:

            
The actual rule is given in my reference (the one that Ben Bolker did not 
bother to look up) earlier in this thread.

You need to ensure that the code is syntactically incomplete when `else'
is encountered.  That will always be true inside a braced expression such 
as the bodies of the functions you quote.  But at top-level, you do need
to write

if(condition) something else something_else

or

if(condition) {
} else {
}

since

if(condition) {
} 
else {
}

fails the test.