%{ #include #include #include "ast.h" AstVec numbers; %} Numberlist = ( n:NUMBER { astvec_append(&numbers, astnode_new_num(n)); } )+ NUMBER = < [0-9]+ > [ \t]* { $$ = atoi(yytext); } %% int main() { printf("len %ld cap %ld vals %p\n", numbers.len, numbers.cap, numbers.vals); while (yyparse()) ; printf("len %ld cap %ld vals %p\n", numbers.len, numbers.cap, numbers.vals); for (int i = 0; i < numbers.len; i++) { printf("[%d] ",numbers.vals[i].as.num); } return 0; }