comp.lang.ada
 help / color / mirror / Atom feed
From: "Peter C. Chapin" <pchapin@sover.net>
Subject: Re: Lack of formal syntax undermines Ada
Date: Fri, 11 Apr 2008 07:20:15 -0400
Date: 2008-04-11T07:20:15-04:00	[thread overview]
Message-ID: <47ff4970$0$19809$4d3efbfe@news.sover.net> (raw)
In-Reply-To: <e99fb94d-da10-41d2-9f20-7a6ce78d4613@p25g2000hsf.googlegroups.com>

usenet@leapheap.co.uk wrote:

> Ada does not have a formal syntax. The LRM provides "syntax rules"
> section by section, then collectively in Annex P. The resulting
> woolly grammar is well-known to be ambiguous (e.g. is X:=Y(Z) an
> assignment from a function call, array indexing or something
> else?). It mixes lexical and syntactical information. It cannot
> be used as the input to a parser generator.

Formally the grammar defines a particular language---the language of all 
strings generated by the grammar. Using the grammar in the LRM, the 
generated language is a superset of Ada (I hope that the grammar in the 
LRM at least generates all legal Ada programs... is that true?). 
Compiler writers have to add additional checks to remove strings allowed 
by the grammar being used and yet illegal according to the rules of the 
language. This is very standard, meaning that pretty much all compilers 
are created in this way.

It is sometimes possible to express a language restriction by creating a 
suitably elaborate grammar that enforces that restriction syntactically. 
On the other hand it is sometimes easier to just use a grammar that 
allows illegal programs and then enforce the restriction in the semantic 
analysis phase of the compiler. Thus there is no "one true grammar" for 
Ada or indeed any full scale programming language (as far as I know, 
anyway). Instead the grammar used is an implementation detail, defined 
at the option of the compiler vendor as part of that vendor's overall 
strategy for handling the language. Grammars that appear in language 
standards are generally non-normative for precisely this reason. They 
exist only to clarify, for the human reader, the descriptive rules 
written in the document.

That said, I appreciate your comments about Ada being used in high 
integrity applications. It would thus benefiting from a higher degree of 
formality than enjoyed by most languages. However, in that case you'd 
really like a formal semantics as well as a formal syntax and that is 
hard to obtain for a language as complex as Ada. I believe Spark has a 
formal semantics (true?) but that is made possible, in part, by reducing 
the size of the language considerably.

Peter

P.S. Just because a grammar is ambiguous or not suitable for a 
particular parser generator does not make it informal.



  reply	other threads:[~2008-04-11 11:20 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-11  9:41 Lack of formal syntax undermines Ada usenet
2008-04-11 11:20 ` Peter C. Chapin [this message]
2008-04-15 12:57   ` usenet
2008-04-16  2:26     ` Peter C. Chapin
2008-04-16  3:14       ` Eric Hughes
2008-04-17  6:37     ` Randy Brukardt
2008-04-11 17:27 ` Georg Bauhaus
2008-04-11 18:13   ` Adam Beneschan
2008-04-11 21:25 ` John McCabe
2008-04-11 21:45   ` Robert A Duff
2008-04-11 22:37     ` John McCabe
2008-04-11 23:08       ` Adam Beneschan
2008-04-12  7:16         ` Dirk Craeynest
2008-04-14  7:23         ` Jean-Pierre Rosen
2008-04-12 12:57       ` Robert A Duff
2008-04-12 15:06         ` (see below)
2008-04-12 16:25           ` John McCabe
2008-04-12 17:55             ` (see below)
2008-04-12 22:19               ` John McCabe
2008-04-13  1:13                 ` (see below)
2008-04-13 11:51                   ` John McCabe
2008-04-13 14:13                     ` (see below)
2008-04-13 19:34                       ` John McCabe
2008-04-13 20:51                         ` (see below)
2008-04-13 21:06                           ` John McCabe
2008-04-12 17:16         ` Gary Scott
2008-04-12 18:43           ` Peter C. Chapin
2008-04-12 19:16             ` Gary Scott
2008-04-12 20:04               ` Robert A Duff
2008-04-12 23:32                 ` Gary Scott
2008-04-13  1:16                   ` Robert A Duff
2008-04-12 20:02           ` Robert A Duff
2008-04-12 20:52             ` Pascal Obry
2008-04-13 22:01       ` Florian Weimer
2008-04-13  9:46 ` anon
2008-04-15 13:22   ` usenet
2008-04-15 16:08     ` Adam Beneschan
2008-04-13 22:04 ` Florian Weimer
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox