10 int curval,startval,endval,loop_var;
12 int interactive_parser=0;
21 statement: /* empty */
24 | error { if (interactive_parser)
30 dest: value '=' { curval=$1; }
31 | '(' value ':' value ')' '=' { curval=-1; startval=$2 ; endval = $4;
38 if (curval>=0) table[$1]=curval;
39 else {table[$1]=loop_var++;
45 | value ':' value { int i; for(i=$1;i<=$3;i++)
46 if (curval>=0) table[i]=curval;
47 else {table[i]=loop_var++;
53 value: NUMBER {if ($1>65535)
54 { yyerror("Class value out of range\n");
58 map_statement: value ':' value '=' value ':' value {
59 int i,start,stop,startv,stopv;
60 if ($5>$7) {start=$7;startv=$3;stop=$5;stopv=$1;}
61 else {start=$5;startv=$1;stop=$7;stopv=$3;}
62 for (i=start;i<=stop;i++)
63 table[i]=(i-start)*(stopv-startv)/(start-stop)+startv;
70 { int c,numb=0,isnumb=0;
71 static char unget_buf=0;
72 while ((c=unget_buf?unget_buf:(*my_getc)())!=EOF)
85 case '9': {isnumb=1; numb=numb*10+c-'0'; break;}
87 case '\t': {if (isnumb) { yylval=numb; return NUMBER; } break;}
88 default: if (isnumb) { yylval=numb; unget_buf=c; return NUMBER;}
96 { fprintf(stderr,"%s\n",s);
99 RECLASS make_reclass_table(EPP *infile,int (*recl_getc)())
100 { int size=epp_table_size(infile);
102 return parse_statements(size,create_reclass_table(size),recl_getc);
104 RECLASS parse_statements(int size,RECLASS src,int (*recl_getc)())
107 if (size>65535)size=65535;
109 if (yyparse()) { free(table);return NULL;}
112 RECLASS create_reclass_table(size)
115 if (size<=0) return NULL;
116 else if (size>65535) size=65535;
117 table=malloc((size+1)*sizeof(short int));
118 for(i=0;i<=size;i++) table[i]=i;
121 RECLASS wrapped_reclass(EPP *infile,int white)
124 maxclass=epp_table_size(infile);
125 table=malloc(maxclass*sizeof(short int));
127 for(i=1;i<=maxclass;i++) table[i]=(i-1)%(white-1)+1;
128 table[infile->offsite]=white;