comp.lang.ada
 help / color / mirror / Atom feed
From: Jerry <lanceboyle@qwest.net>
Subject: Re: How does Ada.Text_IO.Enumeration_IO work?
Date: Sun, 6 Nov 2011 14:42:11 -0800 (PST)
Date: 2011-11-06T14:42:11-08:00	[thread overview]
Message-ID: <45161063-8da9-4163-8c3c-db469540ace9@j36g2000prh.googlegroups.com> (raw)
In-Reply-To: ee2c351c-8fee-4e58-aaf3-1cfffd4dd311@p16g2000yqd.googlegroups.com

On Nov 4, 4:31 pm, Adam Beneschan <a...@irvine.com> wrote:
> On Nov 4, 3:46 pm, Jerry <lancebo...@qwest.net> 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.
>
>                             -- Adam

The source of confusion here is my poorly worded reply. What I meant
to say (he said, sounding like a politician) is that the character
will be "gotten" only by non-enumeration input attempts, character
types excepted. Both RM and you are clear.

Jerry



      parent reply	other threads:[~2011-11-06 22:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-03  8:52 How does Ada.Text_IO.Enumeration_IO work? Jerry
2011-11-03  9:27 ` AdaMagica
2011-11-03 10:18   ` Jerry
2011-11-03 14:52 ` Adam Beneschan
2011-11-04 22:46   ` Jerry
2011-11-04 23:31     ` Adam Beneschan
2011-11-05  9:32       ` Dmitry A. Kazakov
2011-11-06 22:42       ` Jerry [this message]
replies disabled

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