Received: from eggs.gnu.org ([2001:4830:134:3::10]:38478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2nlO-0005yx-Hz for qemu-devel@nongnu.org; Fri, 26 Jul 2013 15:33:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2nlN-0007au-LI for qemu-devel@nongnu.org; Fri, 26 Jul 2013 15:33:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56522) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2nlN-0007ao-E6 for qemu-devel@nongnu.org; Fri, 26 Jul 2013 15:33:17 -0400 From: Markus Armbruster References: <1374842387-17146-1-git-send-email-armbru@redhat.com> <1374842387-17146-5-git-send-email-armbru@redhat.com> <51F29620.9090108@redhat.com> Date: Fri, 26 Jul 2013 21:33:13 +0200 In-Reply-To: <51F29620.9090108@redhat.com> (Eric Blake's message of "Fri, 26 Jul 2013 09:30:40 -0600") Message-ID: <87ob9pqfpi.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 4/9] qapi.py: Decent syntax error reporting 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: >> Signed-off-by: Markus Armbruster >> --- >> scripts/qapi.py | 29 +++++++++++++++++++++++++++-- >> tests/qapi-schema/test-qapi.py | 2 ++ >> tests/qapi-schema/unclosed-string.err | 2 +- >> 3 files changed, 30 insertions(+), 3 deletions(-) > >> >> +class QAPISchemaError(Exception): >> + def __init__(self, schema, msg): >> + self.fp = schema.fp >> + self.msg = msg >> + self.line = self.col = 1 >> + for ch in schema.src[0:schema.pos]: >> + if ch == '\n': >> + self.line += 1 >> + self.col = 1 >> + elif ch == '\t': >> + self.col = (self.col + 7) % 8 + 1 > > Do we even want to allow TABs in the schema files? Right now, they are > tab-free; if you error out here instead of futzing with tab width, we > could forcefully maintain that property. I'm not volunteering for the TAB police, but if y'all want the parser to reject TABs, I can do that. >> + else: >> + self.col += 1 > > Does python support ++ as shorthand for += 1? It doesn't, sadly. > Reviewed-by: Eric Blake