[antlr-interest] Is the -1 bug in .NET ANTLR 3.0.1 runtime's ANTLRReaderStream fixed or not? (was: Antlr and Visual Studio)

Johannes Luber jaluber at gmx.de
Fri Dec 21 15:49:52 PST 2007


Harald M. Müller schrieb:
> Hi ANTLR maintainers (Kunle?!?) -
> 
> In ANTLRReaderStream (in the C# runtime), there is or was a bug in
> method Load(...): The condition of the do-while loop is in some sources
> 
>         while (num != -1);
> 
> whereas in other sources (interim builds) it is
> 
>         while (numRead != 0);
> 
> The latter is correct, the former is wrong and leads to an endless loop.
> 
> However, when I download the current source 3.0.1 from the ANTLR page
> (ANTLR.Tool.zip from the link "Binary of ANTLR tool"; with
> runtime\CSharp\bin\net-2.0\Antlr3.Runtime.dll with Version 0.3.0.37313
> and file date Aug. 13th, 2007, 11:40pm - i.e., the "latest ANTLR
> version") and look into ANTLRReaderStream.Load() with Reflector, I still
> see the first - wrong - condition!!
> 
> It seems something got mixed up here ...
> 
> Will/might this be repaired in some official 3.0.x release, or so we
> have to wait for an official 3.1 for this?

There won't be another 3.0.x release. I've checked in the repos and the
source is correct there already. Not sure why you have a differing
result here. Looking at the title of this thread - was this the bug the
one mentioned in the first email? Before I work through that issue, I
ask. :)
> 
> BTW, array doubling is a somewhat slow algorithm for very long files - I
> have input files with more than 100MB, which yields about 10 doublings
> and hence copies around 1 GB of data. Below is a (not really beautified;
> and intentionally .Net 1.1) variant which does only one copying over and
> hence is faster (but requires twice the final memory instead of only 1.5
> for the original algorithm).

Looking through the code, I see you mention the variable p in the first
for-loop (I would have used a do-while loop instead), but don't declare
it. Shouldn't it replaced by 0 then? You always get a fresh chunk
anyway. The next setting of p to 0 should declare then p, too.

Regarding the memory footprint - do you believe that this may be a
problem for large files? Is this speed-memory trade-off worth it (for
smaller files it looks like yes)? And how do you get C# source files
that long?

Johannes


More information about the antlr-interest mailing list