[antlr-interest] Actions with multiple lexers

Paul J. Lucas dude at darkfigure.org
Fri Nov 15 17:27:00 PST 2002


	So I have 2 lexers, a main lexer and a second for scanning a
	sub-language within the first (similar to JavaDoc vs. Java).
	For example:

		let $x := (<a/>) return $x

	The sub-language is XML that starts when a '<' is encountered
	and ends when ')' is encountered.

	The main lexer has semantic actions on many of the rules, for
	example on ')'.  The XML-lexer has also has to return ')' just
	like the JavaDoc lexer has to return "*/".

	The problem is that I need to have the semantic actions of the
	main lexer executed as if it has scanned the ')'.  One ugly
	solution is to duplicate all the semantic actions for tokens in
	common.

	Ideally what I would like would be a way to put the ')' from the
	XML lexer back on the token stream and then, once the lexer is
	popped back to the main lexer, let it rescan the same token.

	Is there a way to do this?  (Or other way to solve this
	problem?)

	- Paul


 

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



More information about the antlr-interest mailing list