From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3a1c64628a09855b X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!198.186.190.247.MISMATCH!news-xxxfer.readnews.com!news-out.readnews.com!postnews3.readnews.com!not-for-mail Date: Fri, 11 Apr 2008 07:20:15 -0400 From: "Peter C. Chapin" User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Lack of formal syntax undermines Ada References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <47ff4970$0$19809$4d3efbfe@news.sover.net> Organization: SoVerNet (sover.net) NNTP-Posting-Host: 659beb99.news.sover.net X-Trace: DXC=kY7ZiQj_F2FP7I;=`^Ef6@K6_LM2JZB_C]4G6lg>[<=E3?@`i3kGa5KlIiLaf9HFV@16?M:C2OJGF X-Complaints-To: abuse@sover.net Xref: g2news1.google.com comp.lang.ada:20878 Date: 2008-04-11T07:20:15-04:00 List-Id: 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.