Just make the actions on .y files to create AST nodes. e.g. from the wiki example (intentionally stripped down for brevity), instead of:
expressao
: expressao '+' termo { $$ := $1 + $3; }
| termo { $$ := $1; }
;
termo
: termo '*' fator { $$ := $1 * $3; }
| fator { $$ := $1; }
;
fator
: NUMBER { $$ := $1; }
;
you can do:
expressao
: expressao '+' termo { Root := BinaryExpressionNode($1,'+',$3); }
| termo { Root := $1; }
;
termo
: termo '*' fator { $$ := BinaryExpressionNode($1,'*',$3); }
| fator { $$ := $1; }
;
fator
: NUMBER { $$ := NumberNode($1); }
;
Now if you pass 1+2*3, you will get Root as if you do:
Root := BinaryExpressionNode(NumberNode(1),'+',BinaryExpressionNode(NumberNode(2),'*',NumberNode(3)));
Certainly the AST structure design is your call. Feel free to figure out the node structure how the above could work.