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

mzukowski at yci.com mzukowski at yci.com
Thu Sep 18 11:35:11 PDT 2003

You could use a token stream with a grammar processor on it to recognize the
"class" ID LT as the start of a parameterized type and then change the shift
back into two GTs, etc.  See http://www.codetransform.com/filterexample.html
for an in depth explanation.

Let us know how you solve this, I'm sure we'll need it sooner than later.


-----Original Message-----
From: Ernest Pasour [mailto:sasecp at wnt.sas.com] 
Sent: Thursday, September 18, 2003 7:16 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] grammar for jdk1.5 parameterized types

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

	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,


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


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

More information about the antlr-interest mailing list