With Bison, I figured out how to get everything into one long string as follows:
arg_list:
WORD arg_list { strcat( $1, "IFS" ); $$ = strcat($1, $2); } |
WORD
;
and:
WORD arg_list { printf("%s, %s\n", $1, $2); }
But the problem is that I will then have to split up $2 in the second rule again to parse it. Is there a way to populate an array instead of just using concatenation? Am I going about this the wrong way?
If I need to build something like a linked list that could make sense, just not sure what would be the proper way to bind to arg_list, and then clean up the memory.