#include "CCG"/* start of cc4 */keepch(c)char c;$(mline[mptr]=c;if(mptr<mpmax)mptr++;return c;$)preprocess()$(int k;char c,sname[namesize];if(cmode==0)return;mptr=lptr=0;while(ch())$(if((ch()==' ')|(ch()==tabchar))$(keepch(' ');while((ch()==' ')|(ch()==tabchar))gch();$)else if(ch()=='"')$(keepch(ch());gch();while(ch()!='"')$(if(ch()==0)  $(error("missing quote");  break;  $)/* keep escaped char */if(ch()==92)keepch(gch());keepch(gch());$)gch();keepch('"');$)else if(ch()==39)$(keepch(39);gch();while(ch()!=39)$(if(ch()==0)$(error("missing apostrophe");break;$)/* keep escaped char */if(ch()==92)keepch(gch());keepch(gch());$)gch();keepch(39);$)else if((ch()=='/')&(nch()=='*'))$(inchar();inchar();while(((ch()=='*')&(nch()=='/'))==0)$(if(ch()==0)inline();else inchar();if(eof)break;$)inchar();inchar();$)else if(an(ch()))$(k=0;while(an(ch()))$(if(k<namemax)sname[k++]=ch();gch();$)sname[k]=0;if(k=findmac(sname))while(c=macq[k++])keepch(c);else$(k=0;while(c=sname[k++])keepch(c);$)$)else keepch(gch());$)keepch(0);if(mptr>=mpmax)error("line too long");lptr=0;mptr=strcpy(line,mline)+2;$)addmac()$(char sname[namesize];int k;if(symname(sname)==0)$(illname();kill();return;$)k=0;while(putmac(sname[k++]));while (ch()==' ' | ch()==tabchar)gch();while(putmac(gch()));if(macptr>=macmax)error("macro table full");$)putmac(c)char c;$(macq[macptr]=c;if(macptr<macmax)macptr++;return c;$)findmac(sname)char *sname;$(int k;k=0;while(k<macptr)$(if(astreq(sname,macq+k,namemax))$(k=k+find(macq+k,macqsize,0)+1;return k;$)k=k+find(macq+k,macqsize,0)+1;k=k+find(macq+k,macqsize,0)+1;$)return 0;$)outbyte(c)char c;$(cputc(c,output);return c;$)error(ptr)char ptr[]; $(int k;putchar(eol);ps(line);putchar(eol);k=0;while(k<lptr)$(if(line[k]==tabchar)putchar(tabchar);else putchar(' ');++k;$)putchar(27); /* escape next char */putchar(28); /* which is up-arrow */putchar(eol);ps(ptr);putchar(eol);/* -- Beep bell if first error -- */if(errcnt++);else putchar(253); $)/* print a string to standard out */ps(str)char *str;$(cprints(str);$)streq(str1,str2)char str1[],str2[]; $(int k;k=0;while (str2[k])$(if((str1[k])!=(str2[k]))return 0;k++;$)return k; $)astreq(str1,str2,len)char str1[],str2[];int len; $(int k;k=0;while (k<len)$(if ((str1[k])!=(str2[k]))break;if(str1[k]==0)break;if(str2[k]==0)break;k++;$)if (an(str1[k]))return 0;if (an(str2[k]))return 0;return k; $)match(lit)char *lit; $(int k;blanks();if (k=streq(line+lptr,lit))$(lptr=lptr+k;return 1;$) return 0;$)amatch(lit,len)char *lit;int len; $(int k;blanks();if (k=astreq(line+lptr,lit,len))$(lptr=lptr+k;while(an(ch())) inbyte();return 1;$)return 0; $)blanks()$(while(1)$(while(ch()==0)$(inline();preprocess();if(eof)break;$)if(ch()==' ')gch();else if(ch()==tabchar)gch();else return;$)$)/* end of cc4 */