I'm wanting to add objects to a vector representing an argument list in Yacc/Bison. I have the following grammar rule:
argument_list: expression
{
//push back object representing expression onto arglist vector
}
|
expression ',' argument_list
{
//same here
};
I'm not sure how to go about this, since you can't declare argument_list as a vector in type declarations. I want to pass this vector into a method which creates an AST node representing a method, via a rule such as this:
arg_method_invocation: IDENT PERIOD IDENT LPAR argument_list RPAR
{
$$=new MethodCallStatement(yylineno,new MethodCallExpression(yylineno,$1,$3, $5 ));
if ($$==NULL)
fatal("method stmt: ", "error method stmt call");
}
Is this even possible? I'm new to compiler design and this approach may not be do-able. Any suggestions are welcome.