comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@earthlink.net>
Subject: Re: Language Lawyer question
Date: 2000/06/04
Date: 2000-06-04T00:00:00+00:00	[thread overview]
Message-ID: <3939E449.EF7DE629@earthlink.net> (raw)
In-Reply-To: yec1z2fr6zs.fsf@king.cts.com

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.




  reply	other threads:[~2000-06-04  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-02  0:00 Language Lawyer question Wes Groleau
2000-06-02  0:00 ` David C. Hoos, Sr.
2000-06-02  0:00   ` Keith Thompson
2000-06-04  0:00     ` Robert I. Eachus [this message]
2000-06-05  0:00       ` Robert A Duff
2000-06-05  0:00     ` Robert Dewar
2000-06-05  0:00   ` Robert A Duff
2000-06-02  0:00 ` Paul Graham
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox