[antlr-interest] Nested Generics - Java Grammar

Thomas Brandon tbrandonau at gmail.com
Mon Aug 25 23:13:01 PDT 2008


Which java grammar are you using and which version? Looks like the
Java 1.5 grammar v1.0.6 in the grammars section
(http://antlr.org/grammar/1152141644268/Java.g) might handle this, it
doesn't appear to use a '>>' token.

Tom.
On Tue, Aug 26, 2008 at 3:44 PM, Aravinda Dassanayake
<aravinda777 at gmail.com> wrote:
> Hi all,
>
> I have a little problem with the available Java grammar. It has trouble
> dealing with nested generics.
>
> eg:
>
> HashMap<String, ArrayList<String>> cat_map = new HashMap<String,
> ArrayList<String>>();
>
> It warns about the multiple '>' characters like;
>
> line 72:11 no viable alternative at input 'Element'
> line 74:8 no viable alternative at input 'HashMap'
> line 74:41 mismatched input '>>' expecting '>'
> line 74:52 mismatched input '=' expecting '('
> line 74:52 mismatched input '=' expecting ';'
> line 74:91 mismatched input '>>' expecting '>' etc
>
> Is there a refined version of the grammar to support this type of scenario,
> or what is the possible workaround?
>
> Regards,
>
> Aravinda Dassanayake
>
> +94715320257
>
> aravinda777 at yahoo.com
> aravinda777 at gmail.com
>
> http://aravindad.blogspot.com
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
>


More information about the antlr-interest mailing list