%{ #include "symtab.h" int lineno=1; int row=0; int col=0; #define MAXROW 2000 #define MAXCOL 10 node *collabel[MAXCOL]={0}; node *rowlabel[MAXROW]={0}; int cycles[MAXROW][MAXCOL] = {{0}}; int c,r; int yyerror(char *msg) { fprintf(stderr,"ERROR (%d): %s\n",lineno,msg); exit(1); } int id_node(char *str, int *count, int max, node *label[]) { node *p = lookup(str); if (p==NULL) { if (*count>=max) yyerror("Table too big"); p=insert(str); label[*count]=p; p->i=(*count)++; } return p->i; } %} %% \n lineno++; ^[^,]* c=id_node(yytext,&col,MAXCOL,collabel); ,.*, r=id_node(yytext+1,&row,MAXROW,rowlabel); [0-9]*$ cycles[r][c]=atoi(yytext); . yyerror("Illegal sysmbol"); %% int main(void) { int i,j; yylex(); printf("DIR,NAME,PROGRAM,DATA"); for (j=0;jsymbol); printf("\n"); for (i=0;isymbol); for (j=0;j0) printf(","); printf("%d",cycles[i][j]); } printf("\n"); } return 0; }