[antlr-interest] Re: controlled input stream parsing
rbohn777
rbohn777 at yahoo.com
Fri Dec 3 11:25:32 PST 2004
> As a side question, why is it bad to just pull in the whole file?
Too much
> data?
pretty much, i'd rather stream in one record at a time.
--- In antlr-interest at yahoogroups.com, "Bryan Ewbank" <ewbank at s...> wrote:
> > > I'm new to antlr, so I'm writing a simple CSV parser. In
> > my grammar,
> > > each line is referred to as a record. What I want to do is
> > have the
> > > parser and lexer only consume as much needed from the input stream
> > > until it finds a record and then stop until a client
> > requests the next
> > > record at which it will pull from the input stream again until it
> > > finds the next record. Is this possible?
> >
> > Yes, it is possible, but it is not antlr responsibility.
> > You can read a string from input stream on each request and
> > pass it (using StringReader) to antlr to parse.
>
> You can also just have the ANTLR grammar recognize one of your
records; it
> will then stop after reading exactly one of them. The next time you
call
> the parser, it will eat the next one. Just don't put the EOF token
at the
> end of your production.
>
> As a side question, why is it bad to just pull in the whole file?
Too much
> data?
>
> - Bryan
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