blob: fc7db48872e4ed3918c5ccca93314c2aae92de3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
%{
#include <stdio.h>
#include <stdlib.h>
#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;
}
|