[antlr-interest] CharStream for unbounded input stream

Steve Drach drach at itsit.org
Wed Apr 28 16:47:47 PDT 2010


Hmm, I think I've discovered it can't be done since the Lexer apparently reads until it's collected all the tokens and then the parser parses them.  Well now that is a bummer.  Anybody have any clever ideas on how to process variable length messages on unbounded input streams?  They are well formed in the sense that they have matching parenthesis (I think).

On Apr 28, 2010, at 3:47 PM, Steve Drach wrote:

> I'm reading data off a network interface.  Messages are distinct and come in bursts.  I've defined a grammar that can parse a message that doesn't depend on finding an EOF and it works when the messages are in a finite input stream, because eventually the stream is closed, but it doesn't work when I don't close the stream.  
> 
> My data is delivered via a java.io.Reader that returns either 0 characters when read or some finite number of characters that might not comprise a full message.  If the network connection is closed, it will also return -1.  However, in general the network connection is long lived and not closed.
> 
> I looked around in the mailing list for an appropriate CharStream implementation and didn't find one.  I thought I'd ask here before I embark on developing one.  Anybody have a pointer to something I can use?
> 
> Thanks
> Steve
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list