[antlr-interest] Nested structures

Stephanie stephanie.balzer at gmail.com
Mon Mar 22 17:03:02 PDT 2010


Hi,

As I understood, I can use syntactic predicates to deal with non-regular
structures. Unfortunately, I don't get it right. Here is an excerpt of my
grammar (without syntactic predicates):

type
: moldType
| setType
;

moldType
: 'Mold' '<' Identifier '>'
;

setType
: 'Set' '<' Identifier '>'
| 'Set' '<' pairType  '>'
;

pairType
: 'Pair' '<' ( Identifier | pairType ) ',' ( Identifier | pairType ) '>'
;

In my grammar, type is used as part of variable / method declarations. So,
type declarations can be: Mold<X>, Set<X>, Set<Pair<X,X>>,
Set<Pair<X,Pair<X,X>>>, ...

I get an "non-LL(*) decision error" reported. I assume the problem is due to
the recursion in pairType. How can I fix this grammar?

Thanks a lot for your help!

Stephanie


More information about the antlr-interest mailing list