[antlr-interest] grammar for jdk1.5 parameterized types

Ernest Pasour sasecp at wnt.sas.com
Thu Sep 18 07:16:19 PDT 2003


I'm trying to expand an existing java grammar to handle the parameterized types supported in jdk1.5.  The problem is that a parameterized type like the following:
	"class Seq<Pair<String>>"
introduces an ambiguity in the grammar.  The natural way to write the parser uses ">" to match the closing angle brackets.  However, in this case, SR (">>") is matched by the lexer instead of two GT (">").  What I would like to be able to do is to detect *from the parser* that I need to change to a special parameter lexer when I see the first '<' (LT) symbol.  The examples I've found all seem to switch lexers in the lexer, based on lexer information.  If I use the parser, then I have to push lookahead tokens back onto the token stream so that the parameter lexer can process them (I assume).

	Is token stream multiplexing an appropriate solution to my problem?  There appears to be a way I can rewrite the grammar to avoid this issue, but it's pretty disgusting.

Thanks for any suggestions,
Ernest

 

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




More information about the antlr-interest mailing list