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

elias_biris user_sofia at biris.freeserve.co.uk
Wed Nov 6 21:28:19 PST 2002


--- In antlr-interest at y..., Tom Moog <tmoog at p...> wrote:
> 
> Are you talking about antlr 2 or antlr 1 (aka pccts) ?

antlr 2 (I got 2.7.2a4)

also let me try to make the description a bit clearer: I am not
interested in how I can combine (multiplex) 2 antlr-generated lexers
(this is documented and exemplified in the current versions of antlr
2.7.2aX). I have to have the lexers coming from flex, and if possible
I'd like to have them in separate files  (not combined within 1 lexer
specification, using states). 

Theoretically, I should be able to:

-Create a selector
-Create the 2 lexer wrappers (TokenStreams) and attach them to the
selector
-Select a lexer (token stream) to begin with
-upon hitting a specific set of Tokens, the 1st lexer pushes the
wrapper for the 2nd lexer on the selector stack, and the parser
instantiates the sub-parser and calls the sub-parser's top method
- upon hitting a separate set of tokens, the 2nd lexer pops the
selector stack, and the 1st parser continues


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?

It's the 1st time I am doing this sort of thing, and the constraint to
avoid lexer states (I want to see if it is possible to do so) makes
things a bit awkward for all I know.

kind regards

Elias Biris


 

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



More information about the antlr-interest mailing list