From: Ian Campbell <ian.campbell@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>, Jim Fehlig <jfehlig@suse.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 0/4] xl: consolidate adhoc parsers
Date: Wed, 17 Feb 2016 10:01:37 +0000 [thread overview]
Message-ID: <1455703297.814.139.camel@citrix.com> (raw)
In-Reply-To: <20160216232043.GA31818@citrix.com>
On Tue, 2016-02-16 at 23:20 +0000, Wei Liu wrote:
> On Tue, Feb 16, 2016 at 03:09:37PM -0700, Jim Fehlig wrote:
> > Wei Liu wrote:
> > > This patch series consolidates adhoc parsers in xl.
> >
> > Hi Wei,
> >
> > I never tested or reviewed this series after seeing Ian's comments. Did
> > you have
> > time to work on a V2? Or did I miss a V2? :-) Let me know if I can
> > help.
> >
>
> Sorry, this series fell through the crack -- it was only the work of
> one afternoon when I had some free cycles. Now I'm busy with other
> stuff and haven't had the time to pick it up again.
>
> One thing I'm not entirely happy with writing this in plain C is that
> there is subtle semantics difference from the ones generated by
> flex/bison even if they expose similar APIs. For example, the
> functions to parse disk spec won't allow you to set same attribute
> twice, while the work present in this function allows you to do
> that. It's cumbersome to implement the same functionality with open
> coding in C IMHO.
Take care -- the xlu disk parser has a lot of additional complexity and
scaffolding to support the "legacy" xm style device specifications with
positional parameters and strange (ignored by xl) prefixes, trying to merge
that with other device types is likely to result in unwanted/unmanageable
complexity IMHO.
I'm also not sure that switching to flex+bison for the rest is going to
solve the problems you mention above (disallowing setting something twice
etc). flex+bison will take care nicely of things like tokenising and
parsing the input (i.e. it is a nice replacement for strtok and friends),
but ultimately the keys and values need to be exposed to the user somehow
i.e. put into some data structure.
That data structure could either be completely abstract (i.e. just provide
"lookup by key" functionality, via some sort of hash or list etc, which is
basically what the xlu cfg stuff does) or device type specific (i.e. fills
in a given struct based on a knowledge of the value keys for that struct,
which is what the disk stuff does) and it's in that code where you would
need to handle things like what to do with repeated keys.
That is essentially just done by the C snippets in the bison rules or the
scaffolding surrounding the bison, it's not something that bison inherently
deals with.
So ultimately you need to deal with the question of what the semantics of
setting a given key a second time are (error, take the first value, take
the last value, per-key settings etc) in C code, even if you are using
bison. That's slightly easier if you have a parser per device type, since
you can just check the specific field in the specific struct for being
unset or not before making a choice, but even in abstract code it's just a
case of checking in the list/table/hash you are constructing during parsing
for the key and reacting accordingly, but in both cases you are doing so in
C not in "bison".
Ian.
next prev parent reply other threads:[~2016-02-17 10:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-22 11:50 [PATCH 0/4] xl: consolidate adhoc parsers Wei Liu
2016-01-22 11:50 ` [PATCH 1/4] xl: remove unused macros Wei Liu
2016-01-25 12:17 ` Ian Campbell
2016-01-22 11:50 ` [PATCH 2/4] xl: wrap long lines where possible Wei Liu
2016-01-25 12:17 ` Ian Campbell
2016-01-22 11:50 ` [PATCH 3/4] xl: rework vif config parsing code Wei Liu
2016-01-22 11:50 ` [PATCH 4/4] xl: rework vtpm " Wei Liu
2016-01-25 12:25 ` [PATCH 0/4] xl: consolidate adhoc parsers Ian Campbell
2016-02-16 22:09 ` Jim Fehlig
2016-02-16 23:20 ` Wei Liu
2016-02-17 10:01 ` Ian Campbell [this message]
2016-02-17 12:00 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455703297.814.139.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=jfehlig@suse.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).