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

reidr reid at speakeasy.org
Mon Aug 19 10:30:27 PDT 2002


[I recently posted this to comp.compilers.tools.pccts, but that group
looks somewhat dead, and this is an ANTLR question, so....]

Hi,

I recently wrote a parser using Bison/Flex, but it seems kludgey in
ways and kind of awkward to integrate with our other C++ code, so I
thought I'd take a look at ANTLR.  What we're trying to do is parse a
binary input stream, looking for specific marker bytes.  When a marker
token is found, the flex action uses yyin to do some extra parsing of
that particular section, like so:

   short lsiz = readShort(*yyin); // Calls readShort utility function.

FYI, each marker section type is a different length, and the length
can also vary within a type.

My question is whether ANTLR supports something like yyin or yyinput()
to manually read more chars from the input stream.  It looks powerful,
but I can't find anything quite like that (sorry if it's there and I
just missed it).  Maybe I'm still thinking in an incorrect lex
mindset.  (If it's not obvious, I'm somewhat new to parsing concepts
in general.)

Thanks for any info....

Reid

[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.]


 

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



More information about the antlr-interest mailing list