Received: from eggs.gnu.org ([2001:4830:134:3::10]:41947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOA0S-0006wn-RY for qemu-devel@nongnu.org; Thu, 13 Mar 2014 14:05:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOA0L-0006LP-UC for qemu-devel@nongnu.org; Thu, 13 Mar 2014 14:05:24 -0400 Received: from roura.ac.upc.edu ([147.83.33.10]:53147 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOA0L-0006L7-Iv for qemu-devel@nongnu.org; Thu, 13 Mar 2014 14:05:17 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <20140228155309.28087.96600.stgit@fimbulvetr.bsc.es> <20140228155321.28087.44860.stgit@fimbulvetr.bsc.es> <87eh2mgusw.fsf@blackfin.pond.sub.org> <87d2i3z7l0.fsf@fimbulvetr.bsc.es> <8738izxpyb.fsf@blackfin.pond.sub.org> <5314C244.5070805@redhat.com> <87y50qs85q.fsf@blackfin.pond.sub.org> <20140313153355.GA5294@irqsave.net> <5321D4A7.7000007@redhat.com> Date: Thu, 13 Mar 2014 19:05:12 +0100 In-Reply-To: <5321D4A7.7000007@redhat.com> (Eric Blake's message of "Thu, 13 Mar 2014 09:54:15 -0600") Message-ID: <87wqfy2cvb.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 2/3] qapi: Add a primitive to include other files from a QAPI schema file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: =?utf-8?Q?Beno=C3=AEt?= Canet , Markus Armbruster , qemu-devel@nongnu.org Eric Blake writes: > On 03/13/2014 09:33 AM, Beno=C3=AEt Canet wrote: >>> We certainly can't do without comments. >>>=20 >>> JSON is designed for easy data exchange, but we use it as programming >>> language syntax. Its restrictions make sense for easy data exchange, >>> but hurt our use. We're not the first ones experiencing that pain: >>> http://json5.org/ >>>=20 >>> No idea how much momentum this JSON5 thingy has... > If we 's,#,//,', our comments magically fall in line with JSON5 syntax; > everything else in our files is already compliant with JSON5. >>>=20 >>> Switch to JSON5 and call it qapi-schema.json5? > This actually seems like a rather nice idea - but due to our choice of > comments, it means rewriting the bulk of the file and tweaking our parser. >>>=20 >>=20 >> Hmm don't we want something that python and other language know how to p= arse out >> of the box ? Or will we write yet another delicate work of art to parse = it ? > Our existing parser would only need to learn a new comment syntax to > parse the subset of JSON5 that we currently actually use. Parsing FULL > JSON5 would mean also learning about trailing commas, unquoted names in > name:value pairs, multiline strings, and alternative numeric > representations. But a point made on the JSON5 page is that ES5 > JavaScript already parses JSON5, just as it already parses original JSON. Another option is to bump QEMU requirements to python 2.6 or later. Then we= can use the json parser that comes with python. A simple pre-processing could eliminate the comments before passing them to the json package for loading = into python structures. The commands/enums/etc should also be elements of a list= for it to work (that must be either changed on the qapi files, or hackishly "injected" before parsing). Lluis --=20 "And it's much the same thing with knowledge, for whenever you learn something new, the whole world becomes that much richer." -- The Princess of Pure Reason, as told by Norton Juster in The Phantom Tollbooth