RE: IfExpr has a mandatory else clause

"Bas de Bakker" <[email protected]>
Newsgroups gmane.comp.web.query-languages
Message-ID <[email protected]>
You could simply use parentheses to tie the 'else' to the outer 'if':

if (expr) then (if (expr) A) else B

Bas de Bakker
X-Hive Corporation

> -----Original Message-----
> From: [email protected] [mailto:[email protected]]On Behalf Of
> TAN Kuan Hui
> Sent: Monday, January 26, 2004 10:14
> To: Michael Dyck; [email protected]
> Subject: Re: IfExpr has a mandatory else clause
> 
> 
> 
> From: "Michael Dyck" <[email protected]>
> >
> > How would you resolve the ambiguity?
> >
> I would bias towards interpreting "else" rather than reducing
> (<"if" "("> Expr ")" "then" ExprSingle) to IfExpr in the presence
> of "else". This is the "classic" approach isn't it ?
> 
> This however implicitly ties the else clause to the innermost 
> if clause.
> The lack of explicit statement block markers in the grammar
> however makes the coding of nested conditional expressions
> with optional "else" tricky; but this is not due to the
> introduction of an optional else clause but the lack of
> block structure in the grammar. I would propose the IfExpr 
> to be re-written as,
> 
> [54]    IfExpr    ::=    <"if" "("> Expr ")" "then" "{" ExprSingle "}"
> (<"else" "{"> ExprSingle "}")?
> 
> where 
>     <"else" "{"> calls pushState(DEFAULT);
> 
> Note :
> 1. There is no ambiguity with the optional "else" clause; however
> note that introducing statement blocks elsewhere in ExprSingle may
> bring back the ambiguity but it can be distinguished.
> 2. The statement block delimited by {} removes ambiguity 
> for nested if-else expressions and makes the logical 
> structure much cleaner and is consistent with the usage
> of {} for the grouping of functionalities (as with function 
> declaration). Thus I think the introduction of {} in the
> IfExpr should be fairly intuitive.
> 3. There is no impact on the rest of the XQuery grammar.
> 4. There is also no conflict with NCName.
> 
> Are there other ambiguities that I have not considered ?
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.