[antlr-interest] Bug and Fix for Python ANTLR 2.7.6
Gregory W. Bond
bond at research.att.com
Wed May 24 13:06:40 PDT 2006
i encountered a bug related to the implementation of hidden token
streams in the Python implementation of ANTLR 2.7.6 - the bug causes an
exception to be thrown from deep inside antlr.py during parsing - a
search of the antlr-interest email archives revealed that someone else
experienced problems with the 2.7.5 version (see
http://www.antlr.org/pipermail/antlr-interest/2005-May/
012173.html) - the poster included a patch for antlr.py v2.7.5 that
fixed his problems - i applied a variation of his patch to antlr.py
v2.7.6 which has fixed the problem for me - i've notified the PyANTLR
maintainers but i haven't received a response from them - since it's
not clear to me how to formally submit a bug fix i include my patch
here:
--- antlr-2.7.6/lib/python/antlr/antlr.py Wed Dec 7 13:00:36 2005
+++ antlr.py Wed May 24 15:32:47 2006
@@ -1007,7 +1007,7 @@
if isinstance(m,int):
self.hideMask.add(m)
return
- if isinstance(m.BitMask):
+ if isinstance(m,BitMask):
self.hideMask = m
return
@@ -1630,10 +1630,13 @@
self.set(bit,not off)
def at(self,bit):
- i = self.wordNumber(bit)
- v = self.data[i]
- m = self.bitMask(bit)
- return v & m
+ try:
+ i = self.wordNumber(bit)
+ v = self.data[i]
+ m = self.bitMask(bit)
+ return v & m
+ except IndexError:
+ return False
###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
@@ -2553,7 +2556,7 @@
CommonAST.initialize(self,*args)
if args and isinstance(args[0],Token):
assert isinstance(args[0],CommonHiddenStreamToken)
- self.hideenBefore = args[0].getHiddenBefore()
+ self.hiddenBefore = args[0].getHiddenBefore()
self.hiddenAfter = args[0].getHiddenAfter()
###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx###
--
Gregory W. Bond
AT&T Labs - Research
180 Park Avenue, Rm. D273, Bldg. 103
Florham Park, NJ, 07932-0971, USA
tel: 973 360 7216 fax: 973 360 8092
More information about the antlr-interest
mailing list