I'm watching ANSI C YACC grammar. And there is something that I don't understand. http://www.lysator.liu.se/c/ANSI-C-grammar-y.html#expression
assignment_expression
: conditional_expression
| unary_expression assignment_operator assignment_expression
;
constant_expression
: conditional_expression
;
Here are the rules for assignment expression and constant expression.
My question is that how can they both use conditional_expression
to reduce?
If there is a token reduced to a conditional_expression, after the token reduced how does YACC parser know how to reduce the token next between assignment_expression
and constant_expression
?
I think I'm missing something huge but I can't find that by myself.
Thank you