yacc shift/reduce conflict
From: aegis (aegis_at_mad.scientist.com)
Date: 11/13/05
- Next message: Kasper Dupont: "Re: Abolute path of argv[0]"
- Previous message: Art Werschulz: "Re: Abolute path of argv[0]"
- Next in thread: Måns Rullgård: "Re: yacc shift/reduce conflict"
- Reply: Måns Rullgård: "Re: yacc shift/reduce conflict"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 12 Nov 2005 22:27:39 -0800
list : expr '\n' ;
expr : expr ',' expr | SYMBOL { printf("%s\n", yytext); }
I'm trying to describe the following with the above rules:
identifier [,] ...
in other words, either a single identifier or a list of identifiers
that are comma-separated.
so a; a,b; a,b,c,d,e,f,g,h,i; etc would all be valid.
I would expect my rule to work, but it doesn't.
My expression rule would do the following(to my mind),
if it sees something that qualifies as a SYMBOL, reduce
it to 'expr', if the next token is a comma then shift. Now
if the next token qualifies as a SYMBOL, reduce to 'expr'
then in the case of 'expr , expr' reduce to 'expr' and repeat
recursively until end of input. However, this doesn't seem
to be the case, given the shift/reduce conflict. Could some-
one point this conflict out at least? Because I fail to see it.
- Next message: Kasper Dupont: "Re: Abolute path of argv[0]"
- Previous message: Art Werschulz: "Re: Abolute path of argv[0]"
- Next in thread: Måns Rullgård: "Re: yacc shift/reduce conflict"
- Reply: Måns Rullgård: "Re: yacc shift/reduce conflict"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]