[antlr-interest] How to parse a file of some "language 1" with embedded strings of another "language 2"?

Ralf Cremerius ralf_c at web.de
Wed Dec 5 08:11:41 PST 2007


Hello,

I'm rather new to ANTLR and trying my best to fight with v3.  :-)

Though I consulted the official book and looked it up in the documentation, I can't figure out so far, if some feature I need can be realized with ANTLR v3:
Is it possible to tell ANTLR, that the content of some rule or token in my grammar has to be handled by another grammar file?
What I like to accomplish is that I parse some input file according to grammar 1 and defer handling of certain delimited strings inside the input to grammar 2. If I mixed up both grammars, I guess there would be a lot of difficult lexing issues - and of course the grammar file would be rather large.

The only topic roughly connected to my needs seems to be "grammar inheritance" - but as far as I understand it, it's still on the ToDo-list of ANTLR v3.1 and (even if available) wouldn't allow me to have two different lexers for my two distinct grammars.
Any comments, ideas, ... or better solutions than my "naive approach" would of course be highly appreciated.

Thanks in advance,
  Ralf Cremerius

PS:  Thanks for providing this great tool, that ANTLR is. I'll never wish myself being back in university, when we had to struggle with LEX & Co. ... :-)
_______________________________________________________________________
Jetzt neu! Schützen Sie Ihren PC mit McAfee und WEB.DE. 3 Monate
kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=022220



More information about the antlr-interest mailing list