|BNF notation for Delphi Grammar firstname.lastname@example.org (2005-05-31)|
|Re: BNF notation for Delphi Grammar email@example.com (2005-06-02)|
|Re: BNF notation for Delphi Grammar firstname.lastname@example.org (George Neuner) (2005-06-06)|
|Re: BNF notation for Delphi Grammar DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2005-06-08)|
|Re: BNF notation for Delphi Grammar email@example.com (Franck Pissotte) (2005-06-08)|
|Re: BNF notation for Delphi Grammar firstname.lastname@example.org (George Neuner) (2005-06-08)|
|Re: BNF notation for Delphi Grammar email@example.com (2005-06-12)|
|From:||George Neuner <firstname.lastname@example.org>|
|Date:||8 Jun 2005 22:36:15 -0400|
|References:||05-05-230 05-06-037 05-06-042|
On 8 Jun 2005 15:59:36 -0400, Hans-Peter Diettrich
>Some people have tried to construct EBNF grammars for various Delphi
>versions in the past, but the results are questionable, for several
>- "directives" are reserved words in specific context.
>- the semantics are too far away from the syntax, in detail
>- semicolons can have unexpected (context sensitive) effects.
>My favorite example:
>case i of
>0: if a then b
>; //<----- illegal, optional or required?
>Normally a semicolon is illegal in this place, because it's intended to
>only separate multiple case-labels. In this special case the marked
>semicolon is not optional, in fact it indicates whether the following
>dangling "else" is part of the "if" or of the "case" statement.
I just looked in the manual for TP5 and I agree the your example is
ambiguous wrt the syntax diagrams ... I guess I never noticed it
I don't know Delphi, but assuming that it follows Pascal rules I would
say that in your example the semicolon is required to guarantee
separation of the cases's else clause from the if statement.
When I learned Pascal I somehow got into the habit of always using a
begin-end block within a case clause ... I guess this situation never
bit me because of that.
Return to the
Search the comp.compilers archives again.