Re: BNF notation for Delphi Grammar

Hans-Peter Diettrich <DrDiettrich@compuserve.de>
8 Jun 2005 15:59:36 -0400

          From comp.compilers

Related articles
BNF notation for Delphi Grammar gustgr@gmail.com (2005-05-31)
Re: BNF notation for Delphi Grammar haberg@math.su.se (2005-06-02)
Re: BNF notation for Delphi Grammar gneuner2@comcast.net (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 franck.pissotte@alussinan.org (Franck Pissotte) (2005-06-08)
Re: BNF notation for Delphi Grammar gneuner2@comcast.net (George Neuner) (2005-06-08)
Re: BNF notation for Delphi Grammar frank@g-n-u.de (2005-06-12)
| List of all articles for this month |

From: Hans-Peter Diettrich <DrDiettrich@compuserve.de>
Newsgroups: comp.compilers
Date: 8 Jun 2005 15:59:36 -0400
Organization: Compilers Central
References: 05-05-230 05-06-037
Keywords: Pascal, parse

George Neuner wrote:


> The Borland Pascal's used to contain the language BNF in the manual
> appendixes. Did they discontinue this practice with Delphi?


The practice is continued, but the grammar is neither complete nor valid
nor up-to-date since the introduction of case-else.


I found railroad diagrams supplied with Delphi 2, that already differed
from what the compiler accepts. Later versions come with some kind of
extended BNF syntax, with the same problems and a missing description
for the grammar syntax or semantics.


Some people have tried to construct EBNF grammars for various Delphi
versions in the past, but the results are questionable, for several
reasons:


- "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?
else c
end;


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.


Now try to construct an according context-free grammar :-(


DoDi


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.