I have a YACC grammar for parsing expressions in C. These are some of it's fragments:
Expr: Expr COMMA Expr
| Assignment
Assignment: IDENTIFIER
| Assignment COMMA Assignment
Function Call: IDENTIFIER PARENOPEN Expr PARENOPEN
What I basically want to be able to is to parse function calls of the form a(p,q,r) and check if the number and type of the the passed arguments matches that specified in the function definition such that they reduce to Expr
at the level of identifier itself.
What ends up happening is that p,q,r
are reduced to Assignment
instead of Expr COMMA Expr
. This is problematic since I need to run some semantic rules that can only be run using Expr COMMA Expr
. Also it is not possible to remove the rule Assignment COMMA Assignment
since it is critical for certain reductions. Is there any way that I can hardcode into YACC what needs to be done in such a case?