qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 3/9] qapi.py: Restructure lexer and parser


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 3/9] qapi.py: Restructure lexer and parser
Date: Fri, 26 Jul 2013 07:54:24 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

On 07/26/2013 06:39 AM, Markus Armbruster wrote:
> The parser has a rather unorthodox structure:
> 

> 
> Replace this piece of original art by a thoroughly unoriginal design.

I sense a bit of tongue-in-cheek urge to use more colorful language at
this point, describing the horrors of the old implementation.  Thank you
for thinking of the children :)

> Takes care of (1), (2), (5), (6) and (7), and lays the groundwork for
> addressing the others.  Generated source files remain unchanged.
> 
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
>  scripts/qapi.py                                | 163 
> +++++++++++++------------
>  tests/qapi-schema/indented-expr.out            |   2 +-
>  tests/qapi-schema/missing-colon.out            |   4 +-
>  tests/qapi-schema/quoted-structural-chars.err  |   1 +
>  tests/qapi-schema/quoted-structural-chars.exit |   2 +-
>  tests/qapi-schema/quoted-structural-chars.out  |   3 -
>  6 files changed, 88 insertions(+), 87 deletions(-)

My python review skills are weak, so take this review with a grain of salt.

> +
> +    def get_members(self):
> +        expr = OrderedDict()
> +        while self.tok != '}':
> +            key = self.val
> +            self.accept()
> +            self.accept()        # :
> +            expr[key] = self.get_expr()
> +            if self.tok == ',':
> +                self.accept()

My comments in 1/9 about a test of trailing comma behavior may impact
this code.

> +        self.accept()
> +        return expr
> +
> +    def get_values(self):
> +        expr = []
> +        while self.tok != ']':
> +            expr.append(self.get_expr())
> +            if self.tok == ',':
> +                self.accept()

and this code.

Reviewed-by: Eric Blake <address@hidden>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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