[PATCH] Add a VFSFromYAML class and a parser to create it

Ben Langmuir blangmuir at apple.com
Fri Feb 21 09:55:10 PST 2014


On Feb 21, 2014, at 9:24 AM, Argyrios Kyrtzidis <kyrtzidis at apple.com> wrote:

> 
> On Feb 21, 2014, at 9:09 AM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> 
>> On Fri, Feb 21, 2014 at 5:02 PM, Argyrios Kyrtzidis <kyrtzidis at apple.com> wrote:
>>> The problem with a simple JSON field is that it is not clear that we are depending on the presence of something at the beginning of the file in order to interpret it as JSON.
>>> It is more clear to say
>>>       the file should have this at the top:
>>>               %TAG ! tag:vfs-yaml-file…
>>> vs
>>>       the file should have this at the top:
>>>               {
>>>                       ‘version’: 1
>> 
>> I think it would be easy to do the check the other way.  If we have a
>> signature in the binary file that is not valid JSON, we will be
>> deciding the file format (text/binary) based on that signature.
> 
> So JSON is the default fallback ? I can see benefits both ways, (with default fallback and without), but both should work for allowing switching without any build system changes, leaving the call to Ben.

I don’t think there is a good answer here. %TAG requires two lines, json fields are unordered (so you could have to parse the entire file before seeing the version number), and pretty much anything else we can legally stick at the top is probably not intended to convey semantic information (e.g. comments).

At this point, the solution I hate the least is to use a regular field, and cheat the JSON spec by requiring it to come first.  If no one hates that, I’ll go with it.

Ben

> 
>> 
>> Dmitri
>> 
>> -- 
>> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
>> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
> 





More information about the cfe-commits mailing list