comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jeffrey.carter@boeing.com>
Subject: Re: A quickie problem with an array and a right hand bracket
Date: Mon, 11 Jun 2001 22:45:36 GMT
Date: 2001-06-11T22:45:36+00:00	[thread overview]
Message-ID: <3B254A10.5CB7796A@boeing.com> (raw)
In-Reply-To: eV6V6.8331$6d5.1657665@news2-win.server.ntlworld.com

"chris.danx" wrote:
> 
> Hello everyone,
> 
> I'm trying to provide an array for quickie conversion between numbers and
> character equivalents like this
> 
>     type array_16 is array (natural range 0..15) of character;
> 
>     basic_16 : constant array_16 := ('0'..'9'|'a'..'f');
> 
> The compiler corrected me on the use of a comma where the dda ("d divides a",
> from math sorry, it's a bar or more symbol) but this doesn't help with
> "unexpected parenthesis error" when it's compiled.  What's the problem?  It
> looks correct to me but clearly i am missing something (very subtle) point.

Your compiler is expecting something like

('0' .. '9' | 'a' .. 'f' => Some_Value)

so hitting that right parenthesis is throwing it off. Later it would
complain that the index type in the aggregate (characters) does not
match the index type of Array_16 (Natural range 0 .. 15), but it's not
getting to that point.

Since Array_16 is a string type, you could simply use a string literal:

Basic_16 : constant Array_16 := "0123456789abcdef";

You can also use a normal aggregate:

Basic_16 : constant Array_16 :=
   (0 => '0', 1 => '1', 2 => '2', 15 => 'f', 14 => 'e', 13 => 'd',
    3 => '3', 4 => '4', 5 => '5', 12 => 'c', 11 => 'b', 10 => 'a',
    6 => '6', 7 => '7', 8 => '8',  9 => '9');

-- 
Jeffrey Carter



  parent reply	other threads:[~2001-06-11 22:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-11 17:08 A quickie problem with an array and a right hand bracket chris.danx
2001-06-11 17:24 ` Ted Dennison
2001-06-11 22:45 ` Jeffrey Carter [this message]
2001-06-12 10:01 ` chris.danx
replies disabled

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