Yes you can do this, but it is a little hacky. First you will need to create a token vocab file: X=4 Y=5
etc and import it in to both lexers. Then you will need to embed some java code to hand off the input stream to your second lexer and have it add tokens to the current token stream. You should be able to do that. However, before doing that, take a look at the island grammar examples. This may be more elegant for your needs if the switch over can be lexically detected. Look to that first. Jim > -----Original Message----- > From: [email protected] [mailto:antlr-interest- > [email protected]] On Behalf Of [email protected] > Sent: Sunday, February 27, 2011 6:41 AM > To: [email protected] > Subject: [antlr-interest] Lexical hacks ... again. > > Right. ANTLR != PCCTS. Wow. > > I've written a modest utility to transform CoCo/R grammar specs to > ANTLR 3. CoCo/R allows syntactic predicates (for LL(1) disambiguation) > to be embedded as 'IF' '(' anything ')'. Not wanting to parse all the > code I've dealt with this by having the lexer eat all content after > spotting the 'IF'. > > Question is this: Is there any way to embed a 'sub-lexer' at this > point? > i.e. grab the input stream and point it at a lexer for C#/C code? > > I don't need to evaluate the expression itself but storing lexical > tokens rather than characters would be a plus in later stages of > analysis. > > Thx++ > > Jerry. > > > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your- > email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
