home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / DOS / Programa / CCDL122.ZIP / SOURCE / GETSYM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-06  |  23.7 KB  |  792 lines

  1. /*
  2.  * 68K/386 32-bit C compiler.
  3.  *
  4.  * copyright (c) 1996, David Lindauer
  5.  * 
  6.  * This compiler is intended for educational use.  It may not be used
  7.  * for profit without the express written consent of the author.
  8.  *
  9.  * It may be freely redistributed, as long as this notice remains intact
  10.  * and sources are distributed along with any executables derived from them.
  11.  *
  12.  * The author is not responsible for damages, either direct or consequential,
  13.  * that may arise from use of this software.
  14.  *
  15.  * v1.5 August 1996
  16.  * David Lindauer, gclind01@starbase.spd.louisville.edu
  17.  *
  18.  * Credits to Mathew Brandt for original K&R C compiler
  19.  *
  20.  */
  21. /* Trigraphs implemented, won't work for token pasting though */
  22. #include        <stdio.h>
  23. #include        "expr.h"
  24. #include        "c.h"
  25. #include        "gen.h"
  26. #include        "cglbdec.h"
  27. #include "utype.h"
  28. #include "interp.h"
  29.  
  30. extern int prm_cplusplus,prm_cmangle;
  31. extern int ifskip,elsetaken;
  32. extern IFSTRUCT *ifs;
  33. extern int phiused;
  34.  
  35. int     inline[4096];
  36. extern char *infile;
  37. extern short            *lptr;          /* shared with preproc */
  38. extern FILE            *inclfile[10];  /* shared with preproc */
  39. extern char            *inclfname[10];  /* shared with preproc */
  40. extern IFSTRUCT                 *ifshold[10];
  41. extern int             inclline[10];   /* shared with preproc */
  42. extern int             incldepth;      /* shared with preproc */
  43. extern int                        prm_listfile;
  44. char            *linstack[20];  /* stack for substitutions */
  45. char            chstack[20];    /* place to save lastch */
  46. int             lstackptr = 0;  /* substitution stack pointer */
  47. int cantnewline = FALSE;
  48. int incconst = FALSE;
  49.  
  50. int backupchar = -1;
  51.  
  52. static int phiputcpp,phiputlist;
  53. int     isalnum(char c)
  54. {       return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
  55.                 (c >= '0' && c <= '9');
  56. }
  57.  
  58. int     isdigit(char c)
  59. {       return (c >= '0' && c <= '9');
  60. }
  61. int       isxdigit(char c)
  62. {                return(isdigit(c) || (c >='A' && c <='Z') || (c >='a' && c <= 'z'));
  63. }
  64. void initsym(void)
  65. {       lptr = inline;
  66.         inline[0] = 0;
  67.         lineno = 0;
  68.                 cantnewline=FALSE;
  69.                 incconst = FALSE;
  70.                 backupchar = -1;
  71.                 phiputcpp=phiputlist = FALSE;
  72. }
  73.  
  74. int     getline(int listflag)
  75. {       int     rv,rvc,i,prepping,temp;
  76.  
  77.         char ibuf[4096];
  78.         int *ptr = ibuf;
  79.         if (cantnewline) {
  80.             lptr = inline+1;
  81.             return(0);
  82.         }
  83.         do {
  84.                 rv = FALSE;
  85.                 prepping = FALSE;
  86.                 rvc = 0;
  87.         if( lineno > 0 && listflag && prm_listfile) {
  88.                     if (phiused && !phiputlist) {
  89.                         phiputlist = TRUE;
  90.                         fputc('\x1f',listFile);
  91.                     }
  92.                     lferror();
  93.         }
  94.                 while(rvc +131 < 4096 && !rv) {
  95.             ++lineno;
  96.             rv = (philine(ibuf+rvc,200,inputFile) == NULL);
  97.                     if (rv)
  98.                         break;
  99.                     rvc = strlen(ibuf);
  100.                     if (ibuf[rvc-1] != '\n') {
  101.                         ibuf[rvc++] = '\n';
  102.                         ibuf[rvc] = 0;
  103.                     }
  104.                     rvc-=2;
  105.                     while (ibuf[rvc]==' ')
  106.                         rvc--;
  107.                     if (ibuf[rvc] != '\\')
  108.                         break;
  109.                 }
  110.                 if (rvc)
  111.                     rv = FALSE;
  112.                 if (prm_listfile) {
  113.                     if (phiused && !phiputlist) {
  114.                         phiputlist = TRUE;
  115.                         fputc('\x1f',listFile);
  116.                     }
  117.                     fprintf(listFile,"%3d: %s",lineno, ibuf);
  118.                 }
  119.         if( rv && incldepth > 0 ) {
  120.                 fclose(inputFile);
  121.                 inputFile = inclfile[--incldepth];
  122.                 lineno = inclline[incldepth];
  123.                                 infile = inclfname[incldepth];
  124.                                 if (ifs)
  125.                                     generror(ERR_PREPROCMATCH,0,0);
  126.                                 ifs = ifshold[incldepth];
  127.                                 popif();
  128.                 return getline(0);
  129.                 }
  130.         if( rv )
  131.                 return 1;
  132.                 lptr = inline;
  133.                 ptr = ibuf;
  134.                 while((temp = parsechar(&ptr)) != 0)
  135.                     *lptr++ = temp;
  136.                 *lptr = 0;
  137.         lptr = inline;
  138.         if(inline[0] == '#' || (inline[0] == '?' && inline[1] == '?' && inline[2] == '=')) {
  139.                     rv = pstrlen(inline);
  140.                     for (i=0; i < rv; i++)
  141.                         if (inline[i] == '/' && inline[i+1] == '/') {
  142.                             inline[i] = '\n';
  143.                             inline[i+1] = 0;
  144.                             break;
  145.                         }
  146.           listflag = preprocess();
  147.                     prepping = TRUE;
  148.                 }
  149.         } while (ifskip || prepping);
  150.         defcheck(inline);
  151.         rv = pstrlen(inline);
  152.         for (i=0; i < rv; i++)
  153.             if (inline[i] == '/' && inline[i+1] == '/') {
  154.                 inline[i] = '\n';
  155.                 inline[i+1] = 0;
  156.                 break;
  157.             }
  158.         if (cppFile) {
  159.             char buf[20],*q=buf;
  160.             short *p = inline;
  161.             *q = 0;
  162.             if (phiused && !phiputcpp) {
  163.                 phiputcpp = TRUE;
  164.                 fputc('\x1f',cppFile);
  165.             }
  166.             while (*p) {
  167.                 if (*q) {
  168.                     buf[0] = *q;
  169.                     i = 1;
  170.                 }
  171.                 else
  172.                     i = 0;
  173.                 i+=installphichar(*p++,buf,i);
  174.                 buf[i] = 0;
  175.                 q = buf;
  176.                 while (*q && (*(q+1) || ((*q &0xf0) != 0x90)))
  177.                     fputc(*q++,cppFile);
  178.             }
  179.         }                
  180.     return 0;
  181. }
  182.  
  183. /*
  184.  *      getch - basic get character routine.
  185.  */
  186. int     getch(void)
  187. {       while( (lastch = *lptr++) == '\0') {
  188.                 if( lstackptr > 0 ) {
  189.                         lptr = linstack[--lstackptr];
  190.                         lastch = chstack[lstackptr];
  191.                         return lastch;
  192.                         }
  193.                 if(getline(incldepth == 0))
  194.                         return lastch = -1;
  195.                 }
  196.         return lastch;
  197. }
  198.  
  199. /*
  200.  
  201. /*
  202.  *      getid - get an identifier.
  203.  *
  204.  *      identifiers are any isidch conglomerate
  205.  *      that doesn't start with a numeric character.
  206.  *      this set INCLUDES keywords.
  207.  */
  208. void     getid()
  209. {       register int    i;
  210.         i = 0;
  211.                 if (prm_cmangle)
  212.                     lastid[i++] = '_';        /* Mangling */
  213.                 while(issymchar(lastch)) {
  214.                     if (i < 19)
  215.                         i+=installphichar(lastch,lastid,i);
  216.                     getch();
  217.         }
  218.                 if ((lastid[i-1] & 0xf0) == 0x90)
  219.                     lastid[i-1] = 0x90;
  220.         lastid[i] = '\0';
  221.         lastst = id;
  222. }
  223.  
  224. /*
  225.  *      getsch - get a character in a quoted string.
  226.  *
  227.  *      this routine handles all of the escape mechanisms
  228.  *      for characters in strings and character constants.
  229.  */
  230. int     getsch(void)        /* return an in-quote character */
  231. {       register int    i, j;
  232.         if(lastch == '\n')
  233.                 return -1;
  234.         if(lastch != '\\') {
  235.                 i = lastch;
  236.                 getch();
  237.                 return i;
  238.                 }
  239.         getch();        /* get an escaped character */
  240.         if(isdigit(lastch)) {
  241.                 for(i = 0,j=0;j < 3;++j) {
  242.                         if(lastch <= '7' && lastch >= '0')
  243.                                 i = (i << 3) + lastch - '0';
  244.                         else
  245.                                 break;
  246.                         getch();
  247.                         }
  248.                 return i;
  249.                 }
  250.         i = lastch;
  251.         getch();
  252.         switch(i) {
  253.                 case '\n':
  254.                         getch();
  255.                         return getsch();
  256.                 case 'b':
  257.                         return '\b';
  258.                 case 'f':
  259.                         return '\f';
  260.                 case 'n':
  261.                         return '\n';
  262.                 case 'r':
  263.                         return '\r';
  264.                 case 't':
  265.                         return '\t';
  266.                 default:
  267.                         return i;
  268.                 }
  269. }
  270.  
  271. int     radix36(char c)
  272. {       if(isdigit(c))
  273.                 return c - '0';
  274.         if(c >= 'a' && c <= 'z')
  275.                 return c - 'a' + 10;
  276.         if(c >= 'A' && c <= 'Z')
  277.                 return c - 'A' + 10;
  278.         return -1;
  279. }
  280.  
  281. /*
  282.  *      getbase - get an integer in any base.
  283.  */
  284. void getbase(int b,char **ptr)
  285. {       register long    i, j;
  286.         i = 0;
  287.         while(isalnum(**ptr)) {
  288.                 if((j = radix36(*(*ptr)++)) < b) {
  289.                         i = i * b + j;
  290.                         }
  291.                 else break;
  292.                 }
  293.         ival = i;
  294.         lastst = iconst;
  295. }
  296.  
  297. /*
  298.  *      getfrac - get fraction part of a floating number.
  299.  */
  300. void getfrac(char **ptr)
  301. {       double  frmul;
  302.         frmul = 0.1;
  303.         while(isdigit(**ptr)) {
  304.                 rval += frmul * (*(*ptr)++ - '0');
  305.                 frmul *= 0.1;
  306.                 }
  307. }
  308.  
  309. /*
  310.  *      getexp - get exponent part of floating number.
  311.  *
  312.  *      this algorithm is primative but usefull.  Floating
  313.  *      exponents are limited to +/-255 but most hardware
  314.  *      won't support more anyway.
  315.  */
  316. void getexp(char **ptr)
  317. {       double  expo, exmul;
  318.         expo = 1.0;
  319.         if(lastst != rconst)
  320.                 rval = ival;
  321.         if(**ptr = '-') {
  322.                 exmul = 0.1;
  323.                 (*ptr)++;
  324.                 }
  325.         else {
  326.                 exmul = 10.0;
  327.                                 if (**ptr == '+')
  328.                                     (*ptr)++;
  329.                 }
  330.         getbase(10,ptr);
  331.         if(ival > 255)
  332.                 generror(ERR_FPCON,0,0);
  333.         else
  334.                 while(ival--)
  335.                         expo *= exmul;
  336.         rval *= expo;
  337.                 lastst = rconst;
  338. }
  339.  
  340. /*
  341.  *      getnum - get a number from input.
  342.  *
  343.  *      getnum handles all of the numeric input. it accepts
  344.  *      decimal, octal, hexidecimal, and floating point numbers.
  345.  */
  346. void getnum(void)
  347. {
  348.     int isfloat=FALSE;
  349.     char buf[50],*ptr = buf;
  350.     while (isxdigit(lastch) || lastch == 'x' || lastch == 'X') {
  351.         *ptr++ = lastch;
  352.         getch();
  353.     }
  354.     if (lastch == '.') {
  355.         isfloat = TRUE;
  356.         *ptr++=lastch;
  357.         getch();
  358.         while (isdigit(lastch)) {
  359.             *ptr++ = lastch;
  360.             getch();
  361.         }
  362.     }
  363.     if (lastch == 'e' || lastch == 'E') {
  364.         isfloat = TRUE;
  365.         *ptr++ = lastch;
  366.         getch();
  367.         if (lastch == '+' || lastch == '-') {
  368.             *ptr++=lastch;
  369.             getch();
  370.         }
  371.         while (isdigit(lastch)) {
  372.             *ptr++ = lastch;
  373.             getch();
  374.         }
  375.     }
  376.     if (lastch == 'F') {
  377.         *ptr++ = 'F';
  378.         getch();
  379.         isfloat = TRUE;
  380.     }
  381.     *ptr = 0;
  382.     ptr = buf;
  383.     if (!isfloat) {
  384.         if (*ptr == '0') {
  385.             ptr++;
  386.       if(*ptr == 'x' || *ptr == 'X') {
  387.           ptr++;
  388.           getbase(16,&ptr);
  389.         }
  390.         else getbase(8,&ptr);
  391.        }
  392.         else
  393.             getbase(10,&ptr);
  394.         if (lastch == 'L')
  395.             getch();
  396.     }
  397.   else    {
  398.                 getbase(10,&ptr);
  399.                     if(*ptr == '.') {
  400.                                             ptr++;
  401.                         rval = ival;    /* float the integer part */
  402.                         getfrac(&ptr);      /* add the fractional part */
  403.                         lastst = rconst;
  404.                             }
  405.                     if(*ptr == 'e' || *ptr == 'E') {
  406.                         ptr++;
  407.                         getexp(&ptr);       /* get the exponent */
  408.                         }
  409.                                     if (*ptr == 'F') {
  410.                                             ptr++;
  411.                                             if (lastst != rconst) {
  412.                                                 rval = ival;
  413.                                                 lastst = rconst;
  414.                                             }
  415.                                     }
  416.                                 }
  417. }
  418.  
  419. int getsym2(void) 
  420. {       register int    i, j;
  421.                 int size;
  422. swlp:
  423.                          switch(lastch) {
  424.                 case '+':
  425.                         getch();
  426.                         if(lastch == '+') {
  427.                                 getch();
  428.                                 lastst = autoinc;
  429.                                 }
  430.                         else if(lastch == '=') {
  431.                                 getch();
  432.                                 lastst = asplus;
  433.                                 }
  434.                         else lastst = plus;
  435.                         break;
  436.                 case '-':
  437.                         getch();
  438.                         if(lastch == '-') {
  439.                                 getch();
  440.                                 lastst = autodec;
  441.                                 }
  442.                         else if(lastch == '=') {
  443.                                 getch();
  444.                                 lastst = asminus;
  445.                                 }
  446.                         else if(lastch == '>') {
  447.                                 getch();
  448.                                                                 if (prm_cplusplus && lastch == '*') {
  449.                                                                     getch();
  450.                                                                     lastst = pointstar;
  451.                                                                 }
  452.                                                                 else
  453.                                     lastst = pointsto;
  454.                                 }
  455.                         else lastst = minus;
  456.                         break;
  457.                 case '*':
  458.                         getch();
  459.                         if(lastch == '=') {
  460.                                 getch();
  461.                                 lastst = astimes;
  462.                                 }
  463.                         else lastst = star;
  464.                         break;
  465.                 case '/':
  466.                         getch();
  467.                         if(lastch == '=') {
  468.                                 getch();
  469.                                 lastst = asdivide;
  470.                                 }
  471.                         else if(lastch == '*') {
  472.                                 getch();
  473.                                 for(;;) {
  474.                                         if(lastch == '*') {
  475.                                                 getch();
  476.                                                 if(lastch == '/') {
  477.                                                         getch();
  478.                                                         return 1;
  479.                                                         }
  480.                                                 }
  481.                                         else
  482.                                                 getch();
  483.                                         }
  484.                                 }
  485.                         else lastst = divide;
  486.                         break;
  487.                 case '^':
  488.                         getch();
  489.                         lastst = uparrow;
  490.                         break;
  491.                 case ';':
  492.                         getch();
  493.                         lastst = semicolon;
  494.                         break;
  495.                 case ':':
  496.                         getch();
  497.                                                 if (prm_cplusplus && lastch == ':') {
  498.                                                     lastst = classsel;
  499.                                                     getch();
  500.                                                 }
  501.                                                 else
  502.                             lastst = colon;
  503.                         break;
  504.                 case '=':
  505.                         getch();
  506.                         if(lastch == '=') {
  507.                                 getch();
  508.                                 lastst = eq;
  509.                                 }
  510.                         else lastst = assign;
  511.                         break;
  512.                 case '>':
  513.                         getch();
  514.                         if(lastch == '=') {
  515.                                 getch();
  516.                                 lastst = geq;
  517.                                 }
  518.                         else if(lastch == '>') {
  519.                                 getch();
  520.                                 if(lastch == '=') {
  521.                                         getch();
  522.                                         lastst = asrshift;
  523.                                         }
  524.                                 else lastst = rshift;
  525.                                 }
  526.                         else lastst = gt;
  527.                         break;
  528.                 case '<':
  529.                         getch();
  530.                                                 if (incconst) {
  531.                             for(i = 0;i < MAX_STRLEN;++i) {
  532.                                 if(lastch == '>')
  533.                                         break;
  534.                                 if((j = getsch()) == -1)
  535.                                         break;
  536.                                 else
  537.                                         laststr[i] = j;
  538.                                   }
  539.                             laststr[i] = 0;
  540.                             lastst = sconst;
  541.                             if(lastch != '>')
  542.                                     generror(ERR_NEEDCHAR,'>',0);
  543.                             else
  544.                                     getch();
  545.                                                 } else
  546.                             if(lastch == '=') {
  547.                                 getch();
  548.                                 lastst = leq;
  549.                                 }
  550.                             else if(lastch == '<') {
  551.                                 getch();
  552.                                 if(lastch == '=') {
  553.                                         getch();
  554.                                         lastst = aslshift;
  555.                                         }
  556.                                 else lastst = lshift;
  557.                                 }
  558.                             else lastst = lt;
  559.                         break;
  560.                 case '\'':
  561.                         getch();
  562.                         ival = getsch();        /* get a string char */
  563.                         if(lastch != '\'')
  564.                                 generror(ERR_NEEDCHAR,'\'',0);
  565.                         else
  566.                                 getch();
  567.                         lastst = iconst;
  568.                         break;
  569.                                 case 0x2d4:
  570.                                                 getch();
  571.                                                 i=0;
  572.                                                 while (lastch != '\"' && lastch)
  573.                                                     i=installphichar(lastch,laststr,i);
  574.                                                 if ((lastch & 0x7f) != '\"')
  575.                                     generror(ERR_NEEDCHAR,'\"',0);
  576.                             else
  577.                                     getch();
  578.                                                 size = strlen(laststr);
  579.                                                 lastst = sconst;
  580.                                                 break;
  581.                 case '\"':
  582.                                                  size = 0;
  583.                                                 while (lastch == '\"') {
  584.                             getch();
  585.                             for(i = size;i < MAX_STRLEN;++i) {
  586.                                 if(lastch == '\"')
  587.                                         break;
  588.                                 if((j = getsch()) == -1)
  589.                                         break;
  590.                                 else
  591.                                         laststr[i] = j;
  592.                                 }
  593.                             laststr[i] = 0;
  594.                                                     size = i;
  595.                             lastst = sconst;
  596.                             if(lastch != '\"')
  597.                                     generror(ERR_NEEDCHAR,'\"',0);
  598.                             else
  599.                                     getch();
  600.                                                 }
  601.                         break;
  602.                 case '!':
  603.                         getch();
  604.                         if(lastch == '=') {
  605.                                 getch();
  606.                                 lastst = neq;
  607.                                 }
  608.                         else lastst = not;
  609.                         break;
  610.                 case '%':
  611.                         getch();
  612.                         if(lastch == '=') {
  613.                                 getch();
  614.                                 lastst = asmodop;
  615.                                 }
  616.                         else lastst = modop;
  617.                         break;
  618.                 case '~':
  619.                         getch();
  620.                         lastst = compl;
  621.                         break;
  622.                 case '.':
  623.                                                 if (isdigit(*lptr))
  624.                                                     getnum();
  625.                                                 else {    
  626.                             getch();
  627.                                                     if (prm_cplusplus && lastch == '*') {
  628.                                                         getch();
  629.                                                         lastst = dotstar;
  630.                                                     }
  631.                                                     else if (lastch == '.') {
  632.                                                         getch();
  633.                                                         if (lastch == '.') {
  634.                                                             getch();
  635.                                                             lastst = ellipse;
  636.                                                             break;
  637.                                                         }
  638.                                                         else {
  639.                                   generror(ERR_ILLCHAR,lastch,0);
  640.                                                         }
  641.                                                     }
  642.                             lastst = dot;
  643.                                                 }
  644.                         break;
  645.                 case ',':
  646.                         getch();
  647.                         lastst = comma;
  648.                         break;
  649.                 case '&':
  650.                         getch();
  651.                         if( lastch == '&') {
  652.                                 lastst = land;
  653.                                 getch();
  654.                                 }
  655.                         else if( lastch == '=') {
  656.                                 lastst = asand;
  657.                                 getch();
  658.                                 }
  659.                         else
  660.                                 lastst = and;
  661.                         break;
  662.                 case '|':
  663.                         getch();
  664.                         if(lastch == '|') {
  665.                                 lastst = lor;
  666.                                 getch();
  667.                                 }
  668.                         else if( lastch == '=') {
  669.                                 lastst = asor;
  670.                                 getch();
  671.                                 }
  672.                         else
  673.                                 lastst = or;
  674.                         break;
  675.                 case '(':
  676.                         getch();
  677.                         lastst = openpa;
  678.                         break;
  679.                 case ')':
  680.                         getch();
  681.                         lastst = closepa;
  682.                         break;
  683.                 case '[':
  684.                         getch();
  685.                         lastst = openbr;
  686.                         break;
  687.                 case ']':
  688.                         getch();
  689.                         lastst = closebr;
  690.                         break;
  691.                 case '{':
  692.                         getch();
  693.                         lastst = begin;
  694.                         break;
  695.                 case '}':
  696.                         getch();
  697.                         lastst = end;
  698.                         break;
  699.                 case '?':
  700.                         getch();
  701.                                                 if (lastch != '?')
  702.                             lastst = hook;
  703.                                                 else {
  704.                                                     getch();
  705.                                                     switch(lastch) {
  706.                                                         case '(': lastch = '['; break;
  707.                                                         case '/': lastch = '\\'; break;
  708.                                                         case ')': lastch = ']'; break;
  709.                                                         case '\'': lastch = '^'; break;
  710.                                                         case '<': lastch = '{'; break;
  711.                                                         case '!': lastch = '|'; break;
  712.                                                         case '>': lastch = '}'; break;
  713.                                                         case '-': lastch = '~'; break;
  714.                                                     }
  715.                                                     goto swlp;
  716.                                               }
  717.                         break;
  718.                 default:
  719.                                                 if (iscommentchar(lastch)) {
  720.                                                     do {
  721.                                                         getch();
  722.                                                     } while (!iscommentchar(lastch) && lastch != '\n');
  723.                                                 }
  724.                                                 else
  725.                             generror(ERR_ILLCHAR,lastch,0);
  726.                         getch();
  727.                                                 return 1;
  728.                 }
  729.     return 0;
  730. }
  731. /*
  732.  *      getsym - get next symbol from input stream.
  733.  *
  734.  *      getsym is the basic lexical analyzer.  It builds
  735.  *      basic tokens out of the characters on the input
  736.  *      stream and sets the following global variables:
  737.  *
  738.  *      lastch:         A look behind buffer.
  739.  *      lastst:         type of last symbol read.
  740.  *      laststr:        last string constant read.
  741.  *      lastid:         last identifier read.
  742.  *      ival:           last integer constant read.
  743.  *      rval:           last real constant read.
  744.  *
  745.  *      getsym should be called for all your input needs...
  746.  */
  747. void     getsym(void)
  748. {
  749.  
  750.                 if (backupchar != -1) {
  751.                     lastst = backupchar;
  752.                     backupchar = -1;
  753.                     return;
  754.                 }
  755. restart:        /* we come back here after comments */
  756.         while(iswhitespacechar(lastch))
  757.                 getch();
  758.         if( lastch == -1)
  759.                 lastst = eof;
  760.         else if(isdigit(lastch))
  761.                 getnum();
  762.         else if(isstartchar(lastch)) {
  763.                 getid();
  764.                 searchkw();
  765.                 }
  766.         else if (getsym2())
  767.                     goto restart;
  768. }
  769.  
  770. int needpunc(enum e_sym p, int *skimlist)
  771. {       if( lastst == p) {
  772.                 getsym();
  773.                                 return(TRUE);
  774.                 }
  775.         else
  776.                 expecttoken(p,skimlist);
  777.     return(FALSE);
  778. }
  779. int needpuncexp(enum e_sym p, int *skimlist)
  780. {       if( lastst == p) {
  781.                 getsym();
  782.                                 return(TRUE);
  783.                 }
  784.         else
  785.                 expecttokenexp(p,skimlist);
  786.     return(FALSE);
  787. }
  788. void backup(int st)
  789. {
  790.   backupchar = lastst;
  791.   lastst = st;
  792. }