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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ae5e339df4dff313 X-Google-Attributes: gid103376,public From: "Robert I. Eachus" Subject: Re: Language Lawyer question Date: 2000/06/04 Message-ID: <3939E449.EF7DE629@earthlink.net>#1/1 X-Deja-AN: 630810361 Content-Transfer-Encoding: 7bit References: <39380CEB.2CC4682E@ftw.rsc.raytheon.com> <8h97q3$68b$1@hobbes2.crc.com> X-Accept-Language: en,pdf Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 960095214 63.24.55.119 (Sat, 03 Jun 2000 22:06:54 PDT) Organization: The MITRE Corporation MIME-Version: 1.0 NNTP-Posting-Date: Sat, 03 Jun 2000 22:06:54 PDT Newsgroups: comp.lang.ada Date: 2000-06-04T00:00:00+00:00 List-Id: Keith Thompson wrote: > The grammar for an attribute reference is > attribute_reference ::= prefix'attribute_designator > where > prefix ::= name | implicit_dereference > > Of course, that doesn't really answer the question; the grammar could > have been defined to allow an arbitrary expression as a prefix. I > suppose it was defined that way for the sake of clarity, to prevent > expressions from becoming overly complex. Actually, it is a lexical problem, not a parsing issue. In Ada 80, the rule for distinguishing character literals, strings, and the apostrophes in attributes was unnecessarily complex. It wasn't ambiguous, but looking at fragments like Character''''&''''Last or A'('a','b','c')'Range should show you the problem. The lexical analyzer can figure it out, but trying to do sensible error correction is a horror. (Again, it has been a long time since I was working with Ada definitions before Ada 83, so that first example may be preliminary Ada. You can see why the parentheses are now required around qualified expressions.) During the ANSI standardization process, someone suggested the following rule: If the token before the apostrophe is not an identifier or right parenthesis, the apostrophe is the beginning of a literal. If the next token is a left parenthesis, you have a qualified expression. Otherwise, it had better be an attribute. (I think Ted Baker may have been the first to propose this, but it ws one of those rules that gelled. Once there were no exceptions, no one was going to allow any back in the language. The two pass overload resolution algorithm, definitely from Ted, was another similar case.) So in Ada 80, we all basically agreed that any implementor who defined a single character attribute name--especially if it could be used as the prefix oof another attribute--had to be nuts, and left it at that. In what became Ada 83, the rules were tightened up so that there were no violations of the technique possible. Allowing attributes of arbitrary expressions would just take us back to the bad old days, but if you allow attributes of an expression in parentheses, it wouldn't break existing lexical analyzers.