[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 10/22] qapi: qapi.py, make json parser more robu

From: Michael Roth
Subject: Re: [Qemu-devel] [PATCH 10/22] qapi: qapi.py, make json parser more robust
Date: Tue, 24 Jul 2012 17:59:45 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Jul 24, 2012 at 05:23:33PM -0500, Anthony Liguori wrote:
> Michael Roth <address@hidden> 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:

    address@hidden:~/w/qemu3.git$ cat example.json 
        'a': 'test'
    address@hidden:~/w/qemu3.git$ python scripts/qapi-types.py -o /tmp 
    Traceback (most recent call last):
      File "scripts/qapi-types.py", line 260, in <module>
        exprs = parse_schema(sys.stdin)
      File "/home/mdroth/dev/kvm/qemu3.git/scripts/qapi.py", line 76, in 
        expr_eval = evaluate(expr)
      File "/home/mdroth/dev/kvm/qemu3.git/scripts/qapi.py", line 62, in 
        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

> Regards,
> Anthony Liguori
> [...]

reply via email to

[Prev in Thread] Current Thread [Next in Thread]