Received: from eggs.gnu.org ([2001:4830:134:3::10]:39296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2nns-0000Er-6C for qemu-devel@nongnu.org; Fri, 26 Jul 2013 15:35:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2nnr-0000dB-7B for qemu-devel@nongnu.org; Fri, 26 Jul 2013 15:35:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8608) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2nnq-0000d0-MH for qemu-devel@nongnu.org; Fri, 26 Jul 2013 15:35:51 -0400 From: Markus Armbruster References: <1374842387-17146-1-git-send-email-armbru@redhat.com> <1374842387-17146-7-git-send-email-armbru@redhat.com> <51F29C20.3020006@redhat.com> Date: Fri, 26 Jul 2013 21:35:46 +0200 In-Reply-To: <51F29C20.3020006@redhat.com> (Eric Blake's message of "Fri, 26 Jul 2013 09:56:16 -0600") Message-ID: <87k3kdqfl9.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 6/9] qapi.py: Fix schema parser to check syntax systematically List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: aliguori@us.ibm.com, akong@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com Eric Blake writes: > On 07/26/2013 06:39 AM, Markus Armbruster wrote: >> Fixes at least the following parser bugs: >> >> * accepts any token in place of a colon >> >> * treats comma as optional >> >> * crashes when closing braces or brackets are missing >> >> Signed-off-by: Markus Armbruster >> --- >> scripts/qapi.py | 40 ++++++++++++++++++++++++++--------- >> tests/qapi-schema/missing-colon.err | 1 + >> tests/qapi-schema/missing-colon.exit | 2 +- >> tests/qapi-schema/missing-colon.out | 3 --- >> tests/qapi-schema/missing-comma.err | 1 + >> tests/qapi-schema/missing-comma.exit | 2 +- >> tests/qapi-schema/missing-comma.out | 3 --- >> tests/qapi-schema/unclosed-object.err | 2 +- >> 8 files changed, 35 insertions(+), 19 deletions(-) >> > >> >> def get_values(self): >> expr = [] >> - while self.tok != ']': >> + if self.tok == ']': >> + self.accept() >> + return expr >> + if not self.tok in [ '{', '[', "'" ]: >> + raise QAPISchemaError(self, 'Expected "{", "[", "]" or string') > > JSON allows primitives here, as in [ 1 ]; but I agree that for the > purposes of our schema we will always be taking a string or complex > object whenever we have a list. The lexer doesn't recognize any atoms but strings. If we change that, the syntax error messages need to be reviewed (not just this one). > Reviewed-by: Eric Blake