Subject: Re: {} in if/else

From: "Chris Bartram" <[email-masked]>
Date: Wed, 5 Nov 1997 21:02:26 -0500

In <[email-masked]> [email-masked] writes:

> So can I change the grammar to require the braces around commands in an
> if/else?
>
> That is,
>         if true keep;
>
> wouldn't be legal; you'd need
>         if true { keep; }

Why???

      -Chris Bartram
       3k Associates, Inc.

---

From: Tim Showalter <[email-masked]>
Date: Thu, 6 Nov 1997 01:29:12 -0500 (EST)

> > wouldn't be legal; you'd need

Because it's slightly easier to parse.

Actually, I need to deal with an ambiguity in the grammar with regards to
this.  What happens in this script --

if false keep; else if false fileinto "foo"; else trash

Also, there are two similar looking lists -- a list of tests, which is
comma-seperated like "(true, false)" and a list of strings, which looks like
("a string" "another string" "yet another string").  I had been told to get
rid of one of them.  Any opinions on this?

-- 
                                           Tim Showalter [email-masked]

---

From: Rob Earhart <[email-masked]>
Date: Thu, 6 Nov 1997 12:19:03 -0500 (EST)

Tim Showalter <[email-masked]> writes:
> What happens in this script --
> 

  trash.  You only run into ambiguities if you can write things like

    if false if false fileinto "foo"; else trash

  where it's not clear which "if" the else belongs to.

  (The problem is that if-then-else is hard to specify unambiguously
in a context-free grammar (although it's certainly possible).  In
practice, though, it tends to work fine - yacc, for instance, will
complain about the shift/reduce conflict, but will default to shifting
the else token, which is exactly what should happen.)

  )Rob