[antlr-interest] Re: Parse only <n> bytes from InputStream
andreasharth
aharth at gmx.de
Fri Jul 9 03:42:57 PDT 2004
Hi Ric,
I was able to achieve the functionality I needed.
Just counting the number of char.append()s in CharBuffer.fill()
and appending a (char)-1 when the content length has been
reached did the trick.
Again, thanks for your help!
Andreas.
--- In antlr-interest at yahoogroups.com, Ric Klaren <klaren at c...> wrote:
> On Wed, Jul 07, 2004 at 04:30:15PM -0000, andreasharth wrote:
> > thanks for your reply. I tried to extend CharBuffer.fill() with
> >
> > // n bytes are read (for http content-length)
> > _read += amount;
> >
> > // read enough? close input
> > if (_read >= _contentLength) {
> > input.close();
> > }
> >
> > but that didn't do the trick, the connection is closed way to early.
> > I presume that fill() is called more than once for every chunk of
> > input?
>
> Yup it is. Try inserting a fake EOF in the queue in fill. You
probably also
> need something to remove a fake EOF from this queue again to be able to
> restart the parser.
>
> > A related question: when does the lexer stop reading in new characters
> > in the general case?
>
> Upon end of file.
>
> Cheers,
>
> Ric
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list