On Mon, Feb 18, 2013 at 9:54 AM, Iustin Pop <[email protected]> wrote:

> On Fri, Feb 15, 2013 at 09:24:40PM +0100, Michele Tartara wrote:
> > On Fri, Feb 15, 2013 at 10:33 AM, Iustin Pop <[email protected]> wrote:
> >
> > > On Fri, Feb 15, 2013 at 10:21:46AM +0100, Michele Tartara wrote:
> > > > On Thu, Feb 14, 2013 at 2:53 PM, Iustin Pop <[email protected]>
> wrote:
> > > >
> > > > > On Wed, Feb 06, 2013 at 01:09:51PM +0100, Michele Tartara wrote:
> > > > > > In order to fetch precise information about the status of the VMs
> > > > > running in
> > > > > > Xen, we need to analyze the output of the "xm list --long"
> command.
> > > > > >
> > > > > > This commit adds the parser to do that, and its tests.
> > >
> > > OK, thanks for all the acks, LGTM on submitting it with them.
> > >
> > > thanks,
> > > iustin
> > >
> >
> >
> > While switching from my genNonEmptyString to genName, I found out a bug
> in
> > the parser.
> > If a string like "9a" was received, it would have been parsed as LCDouble
> > 9, instead of LCString 9a.
> >
> > In order to fix the bug, I needed to use a lookahead of 1 character to
> > determine if after the number there was an alphabetic caracter or the
> > actual end of the number.
> >
> > This required some non-trivial modifications (especially because
> > Data.Attoparsec.Text does not support lookahead, whereas
> > Data.Attoparsec.ByteString.Char8 does).
>
> Hmm. Can't you fix this without lookahead, by requiring the "leftover"
> string to be empty? IIRC you use that model already in the DRBD parser…
>
>
Yes, but that is just the most simple case. The exact same problem happens
in a configuration like this:
(name 9a (100 foo))
or in a string like this:
(field 40rg)

Not just in the trivial string-only case. A number is actually a number
only if it is followed by a whitespace or a ')'.
The end of input is just a very specific case.

There is probably a way to check this without lookahead, but I haven't
found it yet (and anyway I expect it likely to make the parser quite
unreadable).

Thanks,
Michele

Reply via email to