I've been using PLY to build up a parser for my language, however I've got a shift/reduce conflict that's causing me some trouble. My language has generic types with a syntax ala C++ templates. So right now I have rules like:
expression : expression LESS expression %prec COMPARISON
expression : template
template : NAME
| NAME LESS templates GREATER
templates : template
| templates COMMA template
However, I've found that it's unable to parse:
a < 2
(which is a problem for obvious reasons). The following is the debug output:
PLY: PARSE DEBUG START
State : 0
Stack : . <Token: 'NAME' 'a'>
Action : Shift and goto state 42
State : 42
Stack : NAME . <Token: 'LESS' '<'>
Action : Shift and goto state 81
State : 81
Stack : NAME LESS . <Token: 'NUMBER' '2'>
ERROR: Error : NAME LESS . <Token: 'NUMBER' '2'>
If more of my parser is needed I can provide it. Thanks.
EDIT: One solution that was suggested to me was to make types their own token. This would require a little bit of work because my language doesn't use a preprocessor include system like C/C++ however I think it would still be possible, I'd prefer a solution restricted to the grammar however.