comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Help parsing the language manual on Get'ing integers from Strings
Date: Mon, 21 Dec 2020 09:44:30 +0200	[thread overview]
Message-ID: <i4b22uF79iqU1@mid.individual.net> (raw)
In-Reply-To: <75fbea31-93f7-4b0d-bd73-34c4beefff44n@googlegroups.com>

On 2020-12-21 2:11, John Perry wrote:
> Hello all
> 
> Sorry if the subject is unclear. I recently tried to use
> 
>     Get(S, Value, Last);
> 
> ...in a program where Value was a Natural and S has the value "29:
> 116 82 | 119 24". GNAT gave me a Data_Error.

I get the same.

I'm using GNATLS Community 2019 (20190517-83) on a Mac.


> I've used this procedure before, and as far as I can tell:
> 
>     - GNAT is fine with "29:"
>     - GNAT is NOT fine with "29: " or any larger substring of S


I get the same. However, I also see:

    "12:      44   "  works, Value = 12 and Last = 2
    "18:      44   "  fails with Data_Error.

Very weird.

    "12: 116 82 | 119 24" works, Value = 12 and Last = 2
    "18: 116 82 | 119 24" fails with Data_Error.

Also:

    "18:44:" fails with Data_Error
    "12:44:" works, Value = 52, Last = 6.

Note (44 base 12) = 56 decimal!


> 1) Apparently GNAT thinks the colon is a character that matches the
> syntax of a numeric literal; do I interpret this correctly?

It seems that the Get procedure understands ':' as a base indicator, as in

    "12#44#" works, Value = 52, Last = 6.
    "12#44"  fails with Data_Error.

"29:..." and "18:..." fail because 18 and 29 are too large to be bases; 
the max is 16.

"12:..." works because 12 is an acceptable base.


> 2) Where does the language manual say this? I didn't see it in
> Section 3.5.4 ("Integer Types").


I don't think the manual says this anywhere. RM 2.4.2 "Based Literals" 
shows only '#' as the base indicator.


> 3) or is this a bug?


I think it is.

  reply	other threads:[~2020-12-21  7:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-21  0:11 Help parsing the language manual on Get'ing integers from Strings John Perry
2020-12-21  7:44 ` Niklas Holsti [this message]
2020-12-21  9:33   ` AdaMagica
2020-12-21  7:57 ` Dmitry A. Kazakov
2020-12-21  8:06   ` Niklas Holsti
2020-12-21  9:40     ` Jeffrey R. Carter
2020-12-22  1:11       ` Randy Brukardt
2020-12-21  8:16   ` Dmitry A. Kazakov
2020-12-21 11:30 ` John Perry
2020-12-21 23:25   ` John Perry
2020-12-22  1:19     ` Randy Brukardt
replies disabled

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