In Yacc / Bison, how do I know the parent rules so I can take actions accordingly?
For example:
Module
:ModuleName "=" Functions
Functions
:Functions Function
| Function
Function
: DEF ID ARGS BODY
{
/* here, I would like to identify the parent rule and do something like this*/
if ($parent_rule == "Module") {
/* take some actions */
} else {
/* this means the Function is matched recursively from the Functions rule. */
}
}