[antlr-interest] non-LL(*) grammar question
Andrew Bradnan
andrew.bradnan at gmail.com
Fri Jun 11 11:52:10 PDT 2010
I'm lost on how to correctly write my grammar with backtracking off. It
seems relatively simple but I didn't find anything in the archive, or in
TDAR.
This is C#/Java grammar and I'm stuck on the relational_expression which
conflicts with the syntax for generics.
Valid input can be *a < b;* or *a<T> < b;*
So at the '<' it doesn't know if it should look for a generic type (and
types don't have to be defined ahead of time) or look for the right hand
side of the expression. I basically want to know if there's a matching '>'
in the future or not.
Here's the simplified grammar sans the lexer bits.
relational_expression: // non-LL(*) decision blah blah blah
type ('<' type)* ;
// type ('@' type)* ; // works fine
generic_argument_list:
'<' type '>' ;
type:
identifier generic_argument_list? ;
How should I fix this?
Thanks,
--
/Andrew
More information about the antlr-interest
mailing list