cwcaceres wrote:
But I'm not trying to list. I'm trying to do the add operation. So the
expression "5 6 +4" wouldn't be valid. An example of a valid operation would
be "+5 + -6 - -2" which should have an output of 1. My grammar file
currently outputs the correct result.
I agree with trying to remove the conflict but I'm putting that on hold for
now since I can't think of how to remove it.
I'm writing this with the benefit of 10 minutes exposure to your
problem, so I may well be wrong. However, I think you need to stop and
think a bit more.
The expression "5 6 +4" *is* valid according to the grammar; try it. It
may not be valid according to your intent, which is a rather different
matter.
Read the debug output, and walk through a scan of "5 6 +4". After
scanning '6', the parser has to decide whether the '+' marks the start
of a new unary expression, or is an addition operator. If it's the
former, then it has to reduce a summation expression; if the latter, it
has to shift for the addition. That's your conflict. The default is to
reduce, ie. to push onto the expression list, which I don't think is
what you want.
You say that you're "not trying to list". But that's exactly what
expression_list
: /* empty */
| expression_list summation_expression
;
does; it parses a list of summation expressions. What is the intent of
expression_list?
Evan
_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison