comp.lang.ada
 help / color / mirror / Atom feed
From: Mark A Biggar <mark.a.biggar@lmco.com>
Subject: Re: Lexical Conundrum
Date: 1998/02/23
Date: 1998-02-23T00:00:00+00:00	[thread overview]
Message-ID: <34F1BC2B.529629AF@lmco.com> (raw)
In-Reply-To: EotBMK.MnK@world.std.com


Robert A Duff wrote:
> 
> In article <01bd3d80$101287c0$LocalHost@xhv46.dial.pipex.com>,
> Nick Roberts <Nick.Roberts@dial.pipex.com> wrote:
> >But, if you look closely at line 6, you will see the sequence
> >
> >   or'a'in
> >
> >in the middle of an expression.
> >
> >Now, from chapter 2 of the RM, one might get the impression that this could
> >be parsed as five lexical elements (three identifiers and two apostrophes).
> 
> I think 2.2(7) makes it clear that the above is three lexical elements,
> not five.

Not really, as section 2.2(7) only talks about cases that require white space
between tokens to be legal.  The real point in this example is the "or" is
a keyword not an identifier, so the following "'" must be the start of
a character literal, not the start of an attribute.  If you look at the 
LM grammar, you will find that there are NO cases where an attribute follows
a key word and also NO cases where a character literal follows an identifier,
so you can always determine the meaning of "'" just by remembering the
classification of the previous token.  This whole problem is one of the
reasons why the Ada95 LM makes such a big deal of the fact
that keywords tokens are NOT a subset of identifier tokens, which was a
problem with the Ada83 LM.  Note that a lexical analyser can fully determine
this on its own with out help from the associated parser.  So any compiler
that doesn't tokenize the above as the 3 tokens "or", "'a'" and "in" is
in violation of the LM.

--
Mark Biggar
mark.a.biggar@lmco.com




  parent reply	other threads:[~1998-02-23  0:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-02-19  0:00 Lexical Conundrum Nick Roberts
     [not found] ` <EotBMK.MnK@world.std.com>
1998-02-22  0:00   ` Robert Dewar
     [not found]     ` <Eou91J.Es9@world.std.com>
1998-02-23  0:00       ` Robert Dewar
1998-02-23  0:00     ` Keith Thompson
1998-02-23  0:00       ` Robert Dewar
1998-02-26  0:00     ` Dr Steve Sangwine
1998-02-23  0:00   ` Mark A Biggar [this message]
1998-02-24  0:00     ` Mats Weber
1998-02-24  0:00       ` Robert Dewar
1998-03-05  0:00         ` Robert I. Eachus
1998-02-23  0:00 ` Jean-Pierre Rosen
1998-02-23  0:00   ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1998-02-22  0:00 Nick Roberts
1998-02-22  0:00 ` Robert Dewar
1998-02-24  0:00   ` John Roberts-Jones
replies disabled

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