comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: How does Ada.Text_IO.Enumeration_IO work?
Date: Fri, 4 Nov 2011 16:31:33 -0700 (PDT)
Date: 2011-11-04T16:31:33-07:00	[thread overview]
Message-ID: <ee2c351c-8fee-4e58-aaf3-1cfffd4dd311@p16g2000yqd.googlegroups.com> (raw)
In-Reply-To: 67163342-cdc1-427d-9267-c41b51c9e08f@a12g2000vbz.googlegroups.com

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




  reply	other threads:[~2011-11-04 23:31 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 [this message]
2011-11-05  9:32       ` Dmitry A. Kazakov
2011-11-06 22:42       ` Jerry
replies disabled

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