Skip to content
Prev 57355 / 63424 Next

Documenting else's greed

On 16/08/2019 12:36 p.m., Hugh Parsonage wrote:
I agree this is surprising, and should perhaps be pointed out in the 
docs, but I don't think your suggestion is quite right.  { 2 } + 3 is a 
legal expression.  It doesn't have to be the end of a statement that 
limits the alt.expr, e.g. this could be one big statement:


  { if (TRUE) {
       0
     } else {
       2
     } + 3 }

What ends alt.expr is a token that isn't collected as part of alt.expr, 
not just a semicolon (which separates statements) or a newline.  I don't 
know how many of those there are, but the list would include at least
semicolon, newline, }, ), ], and maybe others.

Duncan Murdoch