[antlr-interest] Accessing input stream object with ANTLR and C++?

Reid Rivenburgh reidr at bigfoot.com
Tue Aug 27 13:47:22 PDT 2002


Thanks for the reply.  I'm just now getting back into this....

 Ric Klaren writes:

 >> [Since I posted this to the newsgroup, I discovered
 >> getInputBuffer().getChar(), which appears to get me the next char
 >> in the stream.  It'd still be useful to get an associated istream,
 >> though, because we have existing functions to do extra parsing on
 >> an istream.]

 RK> You most probably don't want to use getChar() since it bypasses
 RK> all antlr's mechanics. You really have to know what you are doing
 RK> if you use it. Same by accessing the stream directly. Because
 RK> antlr can do backtracking to solve things it could have read the
 RK> way beyond where you think the stream should be.

So there's no good way to do my own reading of the input a la flex?
The multiplexing idea you suggested looks interesting and sort of
helps solve my problem, but in a sense it just pushes the problem down
the line.  With flex, I was able to do my own reading of binary data
using yyin after finding a token in the grammar.  Your suggestion
seems to still imply that all of the input must match tokens in the
grammar, whichever tokenstream they may be coming in on, but this
extra data is outside the grammar in my (possibly wrong!) way of
thinking about it.  (Bear in mind the length of this extra data can
vary a great deal.)  Perhaps some trick of finding a token, marking
the location, finding the next token, and processing the data between
the two as a string...?

These input streams could be quite large, so I need to aim for some
semblance of efficiency, too.

Thanks,
Reid

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list