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,c89a4b067758a6e1 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.ision.net!newsfeed2.easynews.net!ision!citadel.nobulus.com!fi.sn.net!newsfeed1.fi.sn.net!news.song.fi!not-for-mail Date: Wed, 20 Feb 2008 17:19:25 +0200 From: Niklas Holsti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060628 Debian/1.7.8-1sarge7.1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ? References: <4a448c5c-a4ed-446f-bb8b-67c5ba99927a@f47g2000hsd.googlegroups.com> <47bbfb5b$1@news.post.ch> <37b7e369-01c8-4adf-8d1e-c40fa7e51cea@f47g2000hsd.googlegroups.com> <9012d70c-8d61-4e2e-9eda-c12d48f1d9e1@s19g2000prg.googlegroups.com> In-Reply-To: <9012d70c-8d61-4e2e-9eda-c12d48f1d9e1@s19g2000prg.googlegroups.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <47bc40e7$0$21890$4f793bc4@news.tdc.fi> Organization: TDC Internet Services NNTP-Posting-Host: laku61.adsl.netsonic.fi X-Trace: 1203519719 news.tdc.fi 21890 81.17.205.61:32973 X-Complaints-To: abuse@tdcnet.fi Xref: g2news1.google.com comp.lang.ada:19911 Date: 2008-02-20T17:19:25+02:00 List-Id: Hibou57 wrote: > But I'm still not sure about the assertion that it is context free > (while, Ok, the AEM does not tell it is LR(1)) > > If it need name resolution to figure out what means the construct, > this is not a context-free grammar. The *grammar* in the ARM is surely context-free. In each production, there is only one non-terminal symbol on the left-hand side, for example 6.4(3): function_call ::= prefix actual_parameter_part In a context-dependent grammar, there would be several symbols on the left-hand side, before the "::=" sign. The *Ada language* is not context-free, in the sense that the set of legal Ada programs cannot be defined by a context-free grammar. The same is true for all practical programming languages that allow user-defined identifiers with different properties, for example type identifiers and procedure identifiers, and that allow only some kinds of identifiers in some constructs. For example, you cannot "call" a type, but you can "call" a procedure. The grammar in the ARM generates or accepts many strings that are not legal Ada programs. The "context-dependent narrative rules" are there to say which of these strings are legal Ada programs. This same definition method is used for most programming languages. > Is this construct the only one of the grammar which is not context- > free, or is there some others ? Your are using the term "context-free" in some peculiar way, not in its usual meaning, I think. It seems to me that you are really asking this question: given a *fragment* of an Ada program, for example "X(Y)", can this fragment be produced from more than one non-terminal grammar symbol? I don't think that this has much to do with the context-freeness of the grammar, and I don't understand why you feel so strongly that there should be only one grammar symbol for each fragment. For another example, consider the fragment delay 0.3 The way the grammar is now written, this fragment can (I think) be produced only from the non-terminal symbol delay_statement, by the rule in ARM 9.6(4). Does that make you happy? But look, the *meaning* of this fragment depends strongly on the context of this delay_statement: is it used as a simple_statement (5.1(4)) or a delay_alternative (9.7.1(6)) or a triggering_statement (9.7.4(4)) ? These grammar rules could also be written without using the non-terminal symbol delay_statement, replacing it by the sequence consisting of the terminal symbol "delay" and the non-terminal symbol "expression". Then the fragment "delay 0.3" could be produced directly by any one of the three different non-terminal symbols (simple_statement, delay_alternative, triggering_statement). I don't think that change in the grammar would make any significant difference to the readability or parsability of Ada, so I don't see what your problem is. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .