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!postnews.google.com!d21g2000prf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ? Date: Wed, 20 Feb 2008 08:43:49 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <4a448c5c-a4ed-446f-bb8b-67c5ba99927a@f47g2000hsd.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1203525830 17351 127.0.0.1 (20 Feb 2008 16:43:50 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 20 Feb 2008 16:43:50 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d21g2000prf.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19912 Date: 2008-02-20T08:43:49-08:00 List-Id: On Feb 19, 4:47 pm, Hibou57 wrote: > Hi peoples living here :p > > I got a doubt about [ARM 1.1.4-1] > > > The form of an Ada program is described by means of a context-free syntax together with context-dependent requirements expressed by narrative rules. > > But as pointed by someone, the grammar is not LR(1), due to the fact > (which is common to many other languages), that as an exemple X(Y) can > stand for a type cast, a function call, an array access, or even an > array slice, and this cannot be decided without knowlegde of the > context. > > Am I wrong or is there really a so big mistake in the ARM ? Well, if this is a mistake, it is a very, very tiny one, not a big one. As both a user and an implementor of Ada, about the last thing I care about is whether it fits into the definition of an LR(1) or an LL(17) or an RLRQ(3.14159) or whatever grammar. I just want to know what the rules are and what my program is going to do. As for your specific example: it's true that an ( ) could be interpreted as an , , or according to the language rules. Actually, a compiler can't even necessarily tell which one it is even if it knows the identifier and the expression, since the identifier could be an overloaded function with one possibility being a parameterless function (or a function with defaults for all its parameters) that returns an array access. But in the grand scheme of things, that's irrelevant, because no knowledgeable implementor will expect to just plug the grammar rules into some black box and have a compiler automatically come out. In practice, this probably means that if we really wanted an LR(1) grammar, some modifications would have to be made to the syntax rules as they're written. But since nobody really cares, the syntax rules as written are fine because they're more helpful to a user of Ada than a more formally written grammar would be. -- Adam