Suppose you're designing a protocol, and you're deliberating over whether to use XML, YAML, JSON, s-expressions (!) or some other data representation format for it.
The question you need to ask yourself is, "have I written an
EBNF definition for my protocol yet
(
Read more... )
Designing the grammar first might mean your grammar is less than well suited to the particular data format you then wish to pick or, indeed, illegal in that format.
Or have I completely missed the point?
I guess, I'm just thinking, if I do the EBNF then I can, for example, immediately rule out XML unless I secretly thought "I'll use XML" then did the EBNF and then decided -- in which case the EBNF case was merely a ponderous waste.
What am I not seeing? I think I *AM* intermingling data representation and protocol structure but I cannot see how NOT to do this using EBNF.
Reply
Reply
Reply
I guess my methodology would be to pick (say) XML, design the grammar to work in XML (using one of the XML definition thingums) with an eye on the eventual data structure in the code but not genuinely dictated by that. What do I gain by adding EBNF because it seems there is a lot to lose?
Reply
Reply
Why? XML can itself be defined by an EBNF. I actually think XML is a relatively decent way to represent a parse tree; tags correspond to nonterminals, text elements to terminals. You get a very nice separation between leaves and non-leaves that way. Of course the implementor then has to deal with XML, but that's his problem.
Reply
Reply
Note that I'm not saying that the EBNF should generate XML; it can, though that somewhat defeats the purpose of what I'm asserting. Rather, I submit that any valid EBNF can be rendered as XML (and, for bonus points, you get the parse tree for free).
Reply
Anything can be transformed into valid XML -- but if you're going to do that wouldn't it be better to have started in XML?
Your design process seems to be "design grammar", "pick parsing scheme", "design second grammar to fit parsing scheme".
Now, I think you'll agree (maybe not) that taking, say a JSON way of doing things and moving it directly to XML will result is something "bodgy" and not quite in the spirit of XML.
In other words, the grammar you designed using EBNF would, I submit, spit out the answer as to whether XML or JSON better suits it even though that actually might be the "wrong" choice.
I suspect there is some subtlety to what you are suggesting that I'm not seeing.
Reply
I don't know if that's what Meredith's intended to say. But I would. :)
Reply
Reply
Reply
However I'm reviewing conference papers today and the deadline is tight, so I can't commit as much time to LJ today as I would prefer. I promise I'll come back to this, though.
Reply
Reply
http://jogre.sourceforge.net/protocol.htm
Gives a starting point for discussion without either of you having to make up a protocol.
I'm interested myself, I -feel- that maradydd is giving good advice, but I'm unable to come up with an example to illustrate in my lunch hour.
Reply
Also, the "protocol" is (or should be) your "data format". But not necessarily your data structure. More so in a configuration file than in an inter-process protocol, where your primary concern tends to be communication of state (or remote procedure calls that may or may not involve state). Extra bonus if the protocol is human-readable, makes it that much easier to read (for a hit in processing speed, but if you're using sufficiently loose constraints on hardware, you'll have to accomodate all sorts of things, like non-ocet bytes and a vast variety of bit-orders).
Reply
Leave a comment