From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,64d33c985c8959f0 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.42.176.130 with SMTP id be2mr5999058icb.3.1320485556617; Sat, 05 Nov 2011 02:32:36 -0700 (PDT) Path: p6ni73527pbn.0!nntp.google.com!news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!news-transit.tcx.org.uk!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: How does Ada.Text_IO.Enumeration_IO work? Date: Sat, 5 Nov 2011 10:32:35 +0100 Organization: cbb software GmbH Message-ID: <16pu39ybbo1e0$.1iiitzyoxl0h4$.dlg@40tude.net> References: <865d6298-5a0b-45c5-b0fc-372d6222752f@z22g2000prd.googlegroups.com> <7223b173-df96-4a12-82c0-268b7512e958@j36g2000prh.googlegroups.com> <67163342-cdc1-427d-9267-c41b51c9e08f@a12g2000vbz.googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: P1jRfN0Vv/MItvjfwams/Q.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news1.google.com comp.lang.ada:18835 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Date: 2011-11-05T10:32:35+01:00 List-Id: On Fri, 4 Nov 2011 16:31:33 -0700 (PDT), Adam Beneschan wrote: > On Nov 4, 3:46�pm, Jerry wrote: > >>> 'Cuz the rules say so. �A.10.6(5) is the important one here: "Next, >>> characters are input only so long as the sequence input is an initial >>> sequence of an identifier or of a character literal (in particular, >>> input ceases when a line terminator is encountered). The character or >>> line terminator that causes input to cease remains available for >>> subsequent input." �A.10.6(10): "The exception Data_Error is >>> propagated by a Get procedure if the sequence finally input is not a >>> lexical element corresponding to the type, in particular if no >>> characters were input ...". �That's the case when your input (skipping >>> leading blanks) starts with an invalid character like a comma. �Since >>> the comma can't be the first character of an enumeration literal, the >>> comma "remains available for subsequent input", and thus "no >>> characters are input" and Data_Error is raised. >> >> Thanks, Adam. I believe that the clue for me is that "remains >> available for subsequent input" means that it is available only to non- >> enumeration input, characters excepted. > > I'm not sure what you mean by this. If the first character in the > input (other than space) cannot be the start of an enumeration > literal, the input will stop right there; and that character remains > available in the input. If you then try to perform input using > Enumeration_IO (without any other input routines in between), that > same character is "available" in the input but causes Enumeration_IO > to fail again for the same reason. Perhaps there's some confusion > about what the RM means by "available". "The character remains > available for subsequent input" means that *any* input routine will > see that character first (and could raise an exception if that > character is not legal). It doesn't mean that the input routine will > succeed. But you could suck the character up with Text_IO.Get (to get > one character), and then the character isn't available for input any > more. I hope this doesn't confuse you more, but I couldn't tell from > your comment whether things were clear to you; and if not, I was > hoping to try to make it clearer. For what it is worth. Any scanner when detects an error has only two options: 1. Consume input and then raise an exception 2. Leave input as is and raise As a side note, it is unfortunate that Enumeration_IO uses the same exception (Data_Error) in both cases. The behavior 1 means: input recognized but illegal. The behavior 2 means: nothing there, repeat. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de