I've been having some difficulty with a shift/reduce conflict. The
parser I'm woking on has a syntax that is basically the templates
sytnax from C++. Therefore I have the following rules, which result
in a shift/reduce conflict:
expression : expression LESS expression %prec COMPARISON
expression : template
template : NAME
| NAME LESS templates GREATER
templates : template
| templates COMMA template
This basically works for most things, however it fails to parse NAME
LESS expression, for examples "a < 2", I get 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'>
I'm looking for a way to resolve this shift reduce conflict. One
suggestion I've heard is to turn typenames into their own token, which
I might do, but it is nontrivial so i'd like to aoid it. Thanks.
--
You received this message because you are subscribed to the Google Groups
"ply-hack" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/ply-hack?hl=en.