comp.lang.ada
 help / color / mirror / Atom feed
* Help parsing the language manual on Get'ing integers from Strings
@ 2020-12-21  0:11 John Perry
  2020-12-21  7:44 ` Niklas Holsti
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: John Perry @ 2020-12-21  0:11 UTC (permalink / raw)


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 don't understand why. Here's what the language manual says:

"Reads an integer value from the beginning of the given string, following the same rules as the Get procedure that reads an integer value from a file, but treating the end of the string as a file terminator. ...The exception Data_Error is propagated if the sequence input does not have the required syntax or if the value obtained is not of the subtype Num."

The referenced Get procedure says, (some irrelevant (?) parts omitted)

"...skips any leading blanks, line terminators, or page terminators, then ...reads the longest possible sequence of characters matching the syntax of a numeric literal without a point."

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

So:

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

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

3) or is this a bug?

4) or do I misinterpret the language manual?

sincere thanks
john perry

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

end of thread, other threads:[~2020-12-22  1:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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