[antlr-interest] Re: 2 flex lexers 2 antlr parsers -> 1 simple solution?

elias_biris user_sofia at biris.freeserve.co.uk
Thu Nov 7 22:30:59 PST 2002


> I have verified that the swapping of the lexers and the activation of
> the sub-parser occurs fine. But, the yylex function of the 2nd lexer
> returns immediately EOF causing an early exit of the 2nd parser. I am
> not sure why the yylex returns so quickly. Also I have noticed that if
> antlr-generated lexers are used their state can be shared using the
> provided LexerSharedInputState class ... How can one share states like
> that between flex - lexers?
> 


I must be stupid or forgetting the basics in flex:

Flex reads the entire input file, storing it in its internal buffers,
in one go at the beginning of scanning. So, even if the 2 TokenStream
wrappers around the 2 flex lexers are initialized with the same file
pointer (input file), it is the 1st lexer only that reads all the
input leaving nothing for the 2nd lexer (and thus the early EOF and
exit). Using ftell is useless as the position will be always the same
after the 1st lexer reads the input: mthe end of the input file :-)

Are you aware of any file-position tracking facilities in flex? This
way I could reposition the 2nd lexer when it starts reading ... I
cannot find any such thing in the flex docs. I know this is not a flex
list, but I was hoping someone has hit against this wall before (and
if you ever had to browse through the flex mailing list you'd
appreciate the fuss ... it has no searching facilities - unlike the
slick antlr list ;-)

Kind regards,

Elias


 

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



More information about the antlr-interest mailing list