From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1iSX-0004OV-44 for qemu-devel@nongnu.org; Wed, 25 Nov 2015 17:22:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1iSS-0007xX-7M for qemu-devel@nongnu.org; Wed, 25 Nov 2015 17:22:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52500) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1iSS-0007xT-1w for qemu-devel@nongnu.org; Wed, 25 Nov 2015 17:22:36 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 9CF11C0D2222 for ; Wed, 25 Nov 2015 22:22:35 +0000 (UTC) References: <1448486613-17634-1-git-send-email-armbru@redhat.com> <1448486613-17634-10-git-send-email-armbru@redhat.com> From: Eric Blake Message-ID: <565634AA.1040703@redhat.com> Date: Wed, 25 Nov 2015 15:22:34 -0700 MIME-Version: 1.0 In-Reply-To: <1448486613-17634-10-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="musuLuqRDSUJc6legcPGiasxDF4NLhlT8" Subject: Re: [Qemu-devel] [PATCH v3 for-2.5 09/12] qjson: Convert to parser to recursive descent List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: pbonzini@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --musuLuqRDSUJc6legcPGiasxDF4NLhlT8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/25/2015 02:23 PM, Markus Armbruster wrote: > We backtrack in parse_value(), even though JSON is LL(1) and thus can > be parsed by straightforward recursive descent. Do exactly that. >=20 > Based on an almost-correct patch from Paolo Bonzini. >=20 > Signed-off-by: Markus Armbruster > --- > qobject/json-parser.c | 165 ++++++++++++++----------------------------= -------- > 1 file changed, 47 insertions(+), 118 deletions(-) >=20 > static QObject *parse_value(JSONParserContext *ctxt, va_list *ap) > { > - QObject *obj; > + QObject *token; > =20 > - obj =3D parse_object(ctxt, ap); > - if (obj =3D=3D NULL) { > - obj =3D parse_array(ctxt, ap); > - } > - if (obj =3D=3D NULL) { > - obj =3D parse_escape(ctxt, ap); > - } > - if (obj =3D=3D NULL) { > - obj =3D parse_keyword(ctxt); > - }=20 > - if (obj =3D=3D NULL) { > - obj =3D parse_literal(ctxt); > + token =3D parser_context_peek_token(ctxt); > + if (token =3D=3D NULL) { > + parse_error(ctxt, NULL, "premature EOI"); Should we spell that out as 'end of input'? But that's cosmetic, and doesn't affect correctness of the conversion. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --musuLuqRDSUJc6legcPGiasxDF4NLhlT8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWVjSqAAoJEKeha0olJ0NqQDgH/iDbYogrL4y17qy7C3QpwdRl tRT5VTeTz4we6OeeEgKgJkiZqneiIBPuJqirMcNTsCOFOZY9EzYihsBy7wdU8DBW uOM1F0aRp3u64jFOWUdJMhYuBl6yy0KSpNrj/f2bzx3YfpVQYkhlT7K82OslHwXd 9Y8mwDOjAimalF4uhmCrYnGwh4x0cnBfHYDTANwl1AJiXyLhyEWkCuqYPk2TZ8v+ 7N4Cz5niwiQxbeKSNezMVrF33FP6V1hDTWqaTFRUjBWbV4RQ9DLU64sxUGziy50d c51/Nnj6FwveIRy/TX+/Q/y633Df1YVX9XWWUHdqA1Zf4PjsAmObVxmDly+9aEo= =6A3+ -----END PGP SIGNATURE----- --musuLuqRDSUJc6legcPGiasxDF4NLhlT8--