From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sto5K-0002zE-Hd for qemu-devel@nongnu.org; Tue, 24 Jul 2012 19:00:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sto5I-0001hG-Cn for qemu-devel@nongnu.org; Tue, 24 Jul 2012 19:00:10 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:62070) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sto5I-0001aU-6C for qemu-devel@nongnu.org; Tue, 24 Jul 2012 19:00:08 -0400 Received: by pbbro12 with SMTP id ro12so322918pbb.4 for ; Tue, 24 Jul 2012 16:00:03 -0700 (PDT) Sender: fluxion Date: Tue, 24 Jul 2012 17:59:45 -0500 From: Michael Roth Message-ID: <20120724225945.GG2880@illuin> References: <1343150454-4677-1-git-send-email-mdroth@linux.vnet.ibm.com> <1343150454-4677-11-git-send-email-mdroth@linux.vnet.ibm.com> <87vchckdcq.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87vchckdcq.fsf@codemonkey.ws> Subject: Re: [Qemu-devel] [PATCH 10/22] qapi: qapi.py, make json parser more robust List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: quintela@redhat.com, owasserm@redhat.com, qemu-devel@nongnu.org, yamahata@valinux.co.jp, pbonzini@redhat.com, akong@redhat.com, afaerber@suse.de On Tue, Jul 24, 2012 at 05:23:33PM -0500, Anthony Liguori wrote: > Michael Roth writes: > > > Currently the QAPI JSON parser expects a very particular style of code > > indentation, the major one being that terminating curly/square brackets are > > not on placed on a seperate line. This is incompatible with most > > pretty-print formats, so make it a little more robust by supporting > > these cases. > > The code was supposed to just expect that all subsequent lines are > indented. This was to simplify the parser. Can you provide an > problematic example? The main one was cases like this: mdroth@loki:~/w/qemu3.git$ cat example.json { 'a': 'test' } mdroth@loki:~/w/qemu3.git$ python scripts/qapi-types.py -o /tmp exprs = parse_schema(sys.stdin) File "/home/mdroth/dev/kvm/qemu3.git/scripts/qapi.py", line 76, in parse_schema expr_eval = evaluate(expr) File "/home/mdroth/dev/kvm/qemu3.git/scripts/qapi.py", line 62, in evaluate return parse(map(lambda x: x, tokenize(string)))[0] File "/home/mdroth/dev/kvm/qemu3.git/scripts/qapi.py", line 42, in parse if tokens[0] == ',': IndexError: list index out of range I had it in my queue because it was what was preventing me from pretty-printing the QIDL-generated schemas in V1, since python's pretty print stuff generally puts the opening/closing braces at the same indent level. But now we store them in the binary, and don't pretty-print those, so I don't think this is an issue WRT this series anymore. Might still make sense to add it for future use-cases though. > > Regards, > > Anthony Liguori > [...] >