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!postnews.google.com!i36g2000prf.googlegroups.com!not-for-mail From: usenet@leapheap.co.uk Newsgroups: comp.lang.ada Subject: Re: Lack of formal syntax undermines Ada Date: Tue, 15 Apr 2008 05:57:42 -0700 (PDT) Organization: http://groups.google.com Message-ID: <0d5b2ee5-56e7-446f-b29c-564580263c3e@i36g2000prf.googlegroups.com> References: <47ff4970$0$19809$4d3efbfe@news.sover.net> NNTP-Posting-Host: 32.58.34.227 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1208264263 9656 127.0.0.1 (15 Apr 2008 12:57:43 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 15 Apr 2008 12:57:43 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i36g2000prf.googlegroups.com; posting-host=32.58.34.227; posting-account=QVLfzAkAAAA63KKDMkjz_X5cKx2FC2Nc User-Agent: G2/1.0 X-HTTP-Via: 1.0 KNDPXS01 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20954 Date: 2008-04-15T05:57:42-07:00 List-Id: Peter C. Chapin wrote: > use...@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. > [snip] > 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). The one true grammar would be the one that the language designers developed ("our DO ... UNLESS construct should look something like...") and committed to in the LRM. > 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. The syntax rules in the LRM cannot be non-normative. It is not possible to deduce the structure of Ada from a version of the LRM with the syntax rules and examples (also non-normative) stripped. I was surprised to see Annex P marked as "informative". I took this as shorthand for a statement of the form: "This Annex is a collection of the syntax rules presented in other sections of the document. Because of the dangers of a transcription error, it is informative only. The syntax rules as they appear in the other sections are normative" Long familiarity with Ada may lead to underestimating the difficulty of interpreting the descriptive rules. Try this one: >From 2.8 Pragmas (BTW I am using the 'consolidated' version of the Ada95 RM) [start of quote] Pragmas are only allowed at the following places in a program: After a semicolon delimiter, but not within a formal_part or discriminant_part. At any place where the syntax rules allow a construct defined by a syntactic category whose name ends with "declaration", "statement", "clause", or "alternative", or one of the syntactic categories variant or exception_handler; but not in place of such a construct. Also at any place where a compilation_unit would be allowed. Additional syntax rules and placement restrictions exist for specific pragmas. [end of quote] Question: Can a sequence of pragmas (as opposed to a single pragma) appear at one of the allowed program locations? Answer 1: Yes, the text implies this by saying "Pragmas are only allowed..."; if only a single pragma could appear, it would say "A pragma is only allowed..." Answer 2: Yes, because the expansion of the syntactic construct pragma ends in a semicolon. You are then free to reapply the rule and use the first limb to add a second pragma. And so on. Answer 3: No, there is no provision in the text for inserting more than one pragma at each allowed location. Is it obvious to anyone which answer is correct? Regards, Chris Noonan