comp.lang.ada
 help / color / mirror / Atom feed
[parent not found: <mailman.980516658.10759.comp.lang.ada@ada.eu.org>]
* RE: very specific question on Ada syntax
@ 2001-01-30  6:28 Christoph Grein
  2001-01-30  7:16 ` Jean-Pierre Rosen
  2001-01-30 18:41 ` Robert Dewar
  0 siblings, 2 replies; 48+ messages in thread
From: Christoph Grein @ 2001-01-30  6:28 UTC (permalink / raw)
  To: comp.lang.ada

Ted Dennison wrote:

> A'L'M;
> 
> and got:
> 
> Found IDENTIFIER_T A
> Found CHARACTER_T 'L'
> Found IDENTIFIER_T M
> Found SEMICOLON_T ;
> Found END_OF_FILE_T *
> 
> I suppose the original author of the Ada syntax (Christop, I think) was

Ted, you're doing me too much favour, I'm definitely NOT the author of the Ada 
syntax ;>) only of the syntax analyser.

> more or less forced to do it that way because the OpenToken lexical
> analyzer keeps no record of what the last token was. That can certainly
> be fixed. It will add a bit of processing time on each token. But

I think this isn't worth it as long as we do not definitely know of a compiler 
having a one letter attribute that also can appear as an attribute prefix (since 
A'L is correctly lexed).

And as long as there are no such compilers, A'L'M is just a syntax error because 
it should perhaps be A & 'L' & M. So, as Robert Dewar said, Ada lexing is not so 
simple as it might look.

BTW: I'm a physicist and have never studied (computer) language theory. I 
assumed that lexical analysis need not care for the previous token. Now I stand 
corrected. [OK, I already knew about the difference of access and 'Access, but I 
ignored this deliberately. Also here OpenToken will fail.]

I'm more worried about how to lex wide characters. I gather the best way in 
OpenToken would be to leave the character recognizer alone and create a new 
wide_character recognizer, which then could handle the different encodings. We 
can postpone this until the need arises.


Christoph Grein





^ permalink raw reply	[flat|nested] 48+ messages in thread
* Re: very specific question on Ada syntax
@ 2001-01-30  7:19 Jean-Pierre Rosen
  0 siblings, 0 replies; 48+ messages in thread
From: Jean-Pierre Rosen @ 2001-01-30  7:19 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 718 bytes --]


"Jean-Pierre Rosen" <rosen.adalog@wanadoo.fr> a �crit dans le message news: ...
>
> "Christoph Grein" <christoph.grein@eurocopter.de> a �crit dans le message news: mailman.980836879.792.comp.lang.ada@ada.eu.org...
> > I think this isn't worth it as long as we do not definitely know of a compiler
> > having a one letter attribute that also can appear as an attribute prefix (since
> > A'L is correctly lexed).
> >
> Also try this one:
> Character'('a')
>
Well, to make things more interesting, this should be:
subtype S is character;
S'('a')

--
---------------------------------------------------------
           J-P. Rosen (Rosen.Adalog@wanadoo.fr)
Visit Adalog's web site at http://pro.wanadoo.fr/adalog





^ permalink raw reply	[flat|nested] 48+ messages in thread
* Re: very specific question on Ada syntax
@ 2001-01-30  9:30 Christoph Grein
  0 siblings, 0 replies; 48+ messages in thread
From: Christoph Grein @ 2001-01-30  9:30 UTC (permalink / raw)
  To: comp.lang.ada

Jean-Pierre Rosen wrote:
> Also try this one:
> Character'('a')
> 
> It's: Identifier-Apostrophe-Left par-character litteral-Right par
> and not: Identifier-character litteral-Apostrophe-left par

Thanks for the hint. I have to change my mind.

Christoph Grein
--





^ permalink raw reply	[flat|nested] 48+ messages in thread
[parent not found: <B6A1A9B09E52D31183ED00A0C9E0888C4699C9@nctswashxchg.nctswash.navy.mil>]
* RE: very specific question on Ada syntax
@ 2001-01-31  5:01 Christoph Grein
  2001-01-31  6:02 ` Robert Dewar
  0 siblings, 1 reply; 48+ messages in thread
From: Christoph Grein @ 2001-01-31  5:01 UTC (permalink / raw)
  To: comp.lang.ada

Robert Dewar Wrote:

>> OK, I already knew about the difference of access and
>> 'Access, but I  ignored this deliberately.
>
>You may be confused here, when the 'Access attribute is used,
>the word access here is the reserved keyword access, not an
>identifier (go look at the grammar in the RM).
>

OK, you are right, but also the RM does not print these attributes in bold lower 
case.

So if a lexer returns them as reserved words when used as attributes, it 
complicates (hm, "complicates" seems too strong) the job of analysing source 
code. IMHO it's rather irrelevant for lexical analysis if an attribute is 
treated as a reserved word or an identifier.

So please what is the most appropriate treatment (i.e. preventing extra checks 
AFTER lexical analysis in most cases) for 'Access, 'Delta, 'Digits, 'Range? Tick 
Identifier or Tick Reserved_Word?

I would tend to say, it's better to put the extra check for these four into the 
lexer and treat them as identifiers afterwards.

>> Also here OpenToken will fail.]
>
>How? It should return access as a reserved keyword, surely
>it does ...>

Of course is does. So in the light of the above, it does not fail.





^ permalink raw reply	[flat|nested] 48+ messages in thread
* Re: very specific question on Ada syntax
@ 2001-02-01  5:52 Christoph Grein
  2001-02-01  6:25 ` Robert Dewar
  0 siblings, 1 reply; 48+ messages in thread
From: Christoph Grein @ 2001-02-01  5:52 UTC (permalink / raw)
  To: comp.lang.ada

Florian Weimer wrote:

> A character literal is a prefix, taking attributes is allowed.  In
> contrast, a string literal is not a prefix, see RM 4.1(2) and 4.1.4.

Compiling the following with Gnat 3.13p gives:


package P is

  type  T  is ('a', None, 'Z');
  type F_T is access function return T;

  X: F_T := 'a''Access;
  Y: F_T := None'Access;

end P;

     6.   X: F_T := 'a''Access;
                    |
        >>> prefix of "Access" attribute must be aliased

Is this then a bug?





^ permalink raw reply	[flat|nested] 48+ messages in thread
* Re: very specific question on Ada syntax
@ 2001-02-01  7:14 Christoph Grein
  0 siblings, 0 replies; 48+ messages in thread
From: Christoph Grein @ 2001-02-01  7:14 UTC (permalink / raw)
  To: comp.lang.ada

Robert Dewar wrote:

> > package P is
> >
> >   type  T  is ('a', None, 'Z');
> >   type F_T is access function return T;
> >
> >   X: F_T := 'a''Access;
> >   Y: F_T := None'Access;
> >
> > end P;
> >
> >      6.   X: F_T := 'a''Access;
> >                     |
> >         >>> prefix of "Access" attribute must be aliased
> >
> > Is this then a bug?
> 
> No, this is obviously a correct error message. What would
> make you think that this particular usage was legal?

A prefix is a name, and a character literal is a name. So taking an attribute is 
legal. An enumeration literal is a parameterless function, its convention is 
intrinsic. The Access attribute is not allowed for intrinsic subprograms.

So I see two bugs (the second being a misleading error message :-).

Christoph Grein





^ permalink raw reply	[flat|nested] 48+ messages in thread
* Re: very specific question on Ada syntax
@ 2001-02-01 11:10 Christoph Grein
  2001-02-01 17:58 ` Robert Dewar
  0 siblings, 1 reply; 48+ messages in thread
From: Christoph Grein @ 2001-02-01 11:10 UTC (permalink / raw)
  To: comp.lang.ada

''''A'B => character literal '''
           'A attribute
           'B attribute
and not character literal '''
        character literal 'A'
        identifier        B

And I always thought Ada is not cryptic :-)





^ permalink raw reply	[flat|nested] 48+ messages in thread
* Re: very specific question on Ada syntax
@ 2001-02-02  5:53 Christoph Grein
  0 siblings, 0 replies; 48+ messages in thread
From: Christoph Grein @ 2001-02-02  5:53 UTC (permalink / raw)
  To: comp.lang.ada

Robert Dewar wrote:
> 
> In practice of course it is very unlikely that any
> implementation would introduce a single character attribute,
> it would be very unada to do so.
> 
> Furthermore there are almost no attributes that can apply to
> a character literal anyway.

OK, I know that, but if I have learnt anything valuable from this, it's that 
from a syntax point of view, it's irrelevant whether such an attribute exists or 
not.

It's just fun to see something like (C'('C')'C) :-)
which is an illegal expression, whereas (C'('(')) is legal.

Christoph Grein





^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2001-02-04 14:24 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200101261211.NAA13016@bulgaria.otn.eurocopter.de>
2001-01-26 17:17 ` very specific question on Ada syntax Mario Amado Alves
2001-01-28  0:36   ` Robert Dewar
2001-01-29 11:11     ` Mario Amado Alves
2001-01-29 15:55       ` Ted Dennison
2001-01-29 16:41         ` Ted Dennison
2001-01-29 17:52         ` Mario Amado Alves
2001-01-30  6:26         ` Robert Dewar
     [not found] <mailman.980516658.10759.comp.lang.ada@ada.eu.org>
     [not found] ` <94s4vm$qr4$1@nnrp1.deja.com>
2001-01-26 20:26   ` Florian Weimer
2001-01-28  0:28     ` Robert Dewar
2001-01-30  8:47       ` Florian Weimer
2001-01-30 18:35         ` Robert Dewar
2001-01-30 22:16           ` Florian Weimer
2001-01-31  6:10             ` Robert Dewar
2001-01-31 13:29               ` Florian Weimer
2001-01-31 14:40                 ` Marc A. Criley
2001-01-26 22:43 ` Paul Graham
2001-01-28  0:32   ` Robert Dewar
2001-01-30  6:28 Christoph Grein
2001-01-30  7:16 ` Jean-Pierre Rosen
2001-01-30 16:25   ` Mario Amado Alves
2001-01-30 17:57     ` Robert Dewar
2001-01-30 19:16       ` Ted Dennison
2001-01-31  6:16         ` Robert Dewar
2001-01-31 11:40       ` Mario Amado Alves
2001-01-31 22:09         ` Florian Weimer
2001-02-01  5:39           ` Robert Dewar
2001-02-01  5:39           ` Robert Dewar
2001-02-04 14:24             ` Florian Weimer
2001-02-01  5:38         ` Robert Dewar
2001-02-01 18:24           ` Mario Amado Alves
2001-02-02  3:52             ` Robert Dewar
2001-01-30 19:06     ` Ted Dennison
2001-01-31  6:18       ` Robert Dewar
2001-01-30 18:41 ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
2001-01-30  7:19 Jean-Pierre Rosen
2001-01-30  9:30 Christoph Grein
     [not found] <B6A1A9B09E52D31183ED00A0C9E0888C4699C9@nctswashxchg.nctswash.navy.mil>
     [not found] ` <mailman.980504596.2748.comp.lang.ada@ada.eu.org>
2001-01-26 16:17   ` Paul Graham
2001-01-26 16:38   ` Robert Dewar
2001-01-30 16:45   ` Tucker Taft
2001-01-31  5:01 Christoph Grein
2001-01-31  6:02 ` Robert Dewar
2001-02-01  5:52 Christoph Grein
2001-02-01  6:25 ` Robert Dewar
2001-02-01  9:21   ` Keith Thompson
2001-02-01  7:14 Christoph Grein
2001-02-01 11:10 Christoph Grein
2001-02-01 17:58 ` Robert Dewar
2001-02-02  5:53 Christoph Grein

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