10 int curval,startval,endval,loop_var;
12 int interactive_parser=0;
22 statement: /* empty */
25 | error { if (interactive_parser)
31 dest: value '=' { curval=$1; }
32 | '(' value ':' value ')' '=' { curval=-1; startval=$2 ; endval = $4;
39 if (curval>=0) table[$1]=curval;
40 else {table[$1]=loop_var++;
46 | value ':' value { int i; for(i=$1;i<=$3;i++)
47 if (curval>=0) table[i]=curval;
48 else {table[i]=loop_var++;
54 value: NUMBER {if ($1>65535)
55 { yyerror("Class value out of range\n");
59 map_statement: value ':' value '=' value ':' value {
60 int i,start,stop,startv,stopv;
61 if ($5>$7) {start=$7;startv=$3;stop=$5;stopv=$1;}
62 else {start=$5;startv=$1;stop=$7;stopv=$3;}
63 for (i=start;i<=stop;i++)
64 table[i]=(i-start)*(stopv-startv)/(start-stop)+startv;
71 { int c,numb=0,isnumb=0;
72 static char unget_buf=0;
73 while ((c=unget_buf?unget_buf:(*my_getc)())!=EOF)
86 case '9': {isnumb=1; numb=numb*10+c-'0'; break;}
88 case '\t': {if (isnumb) { yylval=numb; return NUMBER; } break;}
89 default: if (isnumb) { yylval=numb; unget_buf=c; return NUMBER;}
97 { fprintf(stderr,"%s\n",s);
100 RECLASS make_reclass_table(EPP *infile,int (*recl_getc)())
101 { int size=epp_table_size(infile);
103 return parse_statements(size,create_reclass_table(size),recl_getc);
105 RECLASS parse_statements(int size,RECLASS src,int (*recl_getc)())
108 if (size>65535)size=65535;
110 if (yyparse()) { free(table);return NULL;}
113 RECLASS create_reclass_table(size)
116 if (size<=0) return NULL;
117 else if (size>65535) size=65535;
118 table=malloc((size+1)*sizeof(short int));
119 for(i=0;i<=size;i++) table[i]=i;
122 RECLASS wrapped_reclass(EPP *infile,int white)
125 maxclass=epp_table_size(infile);
126 table=malloc(maxclass*sizeof(short int));
128 for(i=1;i<=maxclass;i++) table[i]=(i-1)%(white-1)+1;
129 table[infile->offsite]=white;