Hi, newbie alert - this is my first grammar so bare with me!
opt_parameter_list: /* EMPTY */ { $$ = new IdentifierListNode( NULL, NULL ); } | parameter_list { $$ = $1; } parameter_list: IDENTIFIER { $$ = new IdentifierListNode( new IdentifierNode( $1 ), NULL ); } | IDENTIFIER COMMA parameter_list { $$ = new IdentifierListNode( new IdentifierNode( $1 ), $3 ); } ; I'm trying to think how best deal with lists of things when using bison to generate C++. I have come up with an approach that seems to work but feels like too much work. Are there simpler patterns for this? Above example is how I handle zero or more parameters passed to a function. My class takes two pointers, one to an IDENTIFIER ( my parameter type ) and one to the next parameter_list. When I get to evaluating the function definition, I need to walk along the ( effectively linked ) list of IdentifierListNode object gathering up the IDENTIFIERS into a list. Should I be looking at mid-rule actions or some other such construct to simplify this? Best. _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison