home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / uccs / root.13 / udk / usr / ccs / lib / lex / ncform
Text File  |  1998-08-19  |  5KB  |  222 lines

  1. #ident    "@(#)libl:lib/ncform    1.7"
  2. int yylineno =1;
  3. # define YYU(x) x
  4. # define NLSTATE yyprevious=YYNEWLINE
  5. char yytext[YYLMAX];
  6. struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
  7. char yysbuf[YYLMAX];
  8. char *yysptr = yysbuf;
  9. int *yyfnd;
  10. extern struct yysvf *yyestate;
  11. int yyprevious = YYNEWLINE;
  12. #if defined(__cplusplus) || defined(__STDC__)
  13. int yylook(void)
  14. #else
  15. yylook()
  16. #endif
  17. {
  18.     register struct yysvf *yystate, **lsp;
  19.     register struct yywork *yyt;
  20.     struct yysvf *yyz;
  21.     int yych, yyfirst;
  22.     struct yywork *yyr;
  23. # ifdef LEXDEBUG
  24.     int debug;
  25. # endif
  26.     char *yylastch;
  27.     /* start off machines */
  28. # ifdef LEXDEBUG
  29.     debug = 0;
  30. # endif
  31.     yyfirst=1;
  32.     if (!yymorfg)
  33.         yylastch = yytext;
  34.     else {
  35.         yymorfg=0;
  36.         yylastch = yytext+yyleng;
  37.         }
  38.     for(;;){
  39.         lsp = yylstate;
  40.         yyestate = yystate = yybgin;
  41.         if (yyprevious==YYNEWLINE) yystate++;
  42.         for (;;){
  43. # ifdef LEXDEBUG
  44.             if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
  45. # endif
  46.             yyt = yystate->yystoff;
  47.             if(yyt == yycrank && !yyfirst){  /* may not be any transitions */
  48.                 yyz = yystate->yyother;
  49.                 if(yyz == 0)break;
  50.                 if(yyz->yystoff == yycrank)break;
  51.                 }
  52.             *yylastch++ = yych = input();
  53.             if(yylastch > &yytext[YYLMAX]) {
  54.                 fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
  55.                 exit(1);
  56.             }
  57.             yyfirst=0;
  58.         tryagain:
  59. # ifdef LEXDEBUG
  60.             if(debug){
  61.                 fprintf(yyout,"char ");
  62.                 allprint(yych);
  63.                 putchar('\n');
  64.                 }
  65. # endif
  66.             yyr = yyt;
  67.             if ( (int)yyt > (int)yycrank){
  68.                 yyt = yyr + yych;
  69.                 if (yyt <= yytop && yyt->verify+yysvec == yystate){
  70.                     if(yyt->advance+yysvec == YYLERR)    /* error transitions */
  71.                         {unput(*--yylastch);break;}
  72.                     *lsp++ = yystate = yyt->advance+yysvec;
  73.                     if(lsp > &yylstate[YYLMAX]) {
  74.                         fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
  75.                         exit(1);
  76.                     }
  77.                     goto contin;
  78.                     }
  79.                 }
  80. # ifdef YYOPTIM
  81.             else if((int)yyt < (int)yycrank) {        /* r < yycrank */
  82.                 yyt = yyr = yycrank+(yycrank-yyt);
  83. # ifdef LEXDEBUG
  84.                 if(debug)fprintf(yyout,"compressed state\n");
  85. # endif
  86.                 yyt = yyt + yych;
  87.                 if(yyt <= yytop && yyt->verify+yysvec == yystate){
  88.                     if(yyt->advance+yysvec == YYLERR)    /* error transitions */
  89.                         {unput(*--yylastch);break;}
  90.                     *lsp++ = yystate = yyt->advance+yysvec;
  91.                     if(lsp > &yylstate[YYLMAX]) {
  92.                         fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
  93.                         exit(1);
  94.                     }
  95.                     goto contin;
  96.                     }
  97.                 yyt = yyr + YYU(yymatch[yych]);
  98. # ifdef LEXDEBUG
  99.                 if(debug){
  100.                     fprintf(yyout,"try fall back character ");
  101.                     allprint(YYU(yymatch[yych]));
  102.                     putchar('\n');
  103.                     }
  104. # endif
  105.                 if(yyt <= yytop && yyt->verify+yysvec == yystate){
  106.                     if(yyt->advance+yysvec == YYLERR)    /* error transition */
  107.                         {unput(*--yylastch);break;}
  108.                     *lsp++ = yystate = yyt->advance+yysvec;
  109.                     if(lsp > &yylstate[YYLMAX]) {
  110.                         fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
  111.                         exit(1);
  112.                     }
  113.                     goto contin;
  114.                     }
  115.                 }
  116.             if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
  117. # ifdef LEXDEBUG
  118.                 if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
  119. # endif
  120.                 goto tryagain;
  121.                 }
  122. # endif
  123.             else
  124.                 {unput(*--yylastch);break;}
  125.         contin:
  126. # ifdef LEXDEBUG
  127.             if(debug){
  128.                 fprintf(yyout,"state %d char ",yystate-yysvec-1);
  129.                 allprint(yych);
  130.                 putchar('\n');
  131.                 }
  132. # endif
  133.             ;
  134.             }
  135. # ifdef LEXDEBUG
  136.         if(debug){
  137.             fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
  138.             allprint(yych);
  139.             putchar('\n');
  140.             }
  141. # endif
  142.         while (lsp-- > yylstate){
  143.             *yylastch-- = 0;
  144.             if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
  145.                 yyolsp = lsp;
  146.                 if(yyextra[*yyfnd]){        /* must backup */
  147.                     while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
  148.                         lsp--;
  149.                         unput(*yylastch--);
  150.                         }
  151.                     }
  152.                 yyprevious = YYU(*yylastch);
  153.                 yylsp = lsp;
  154.                 yyleng = yylastch-yytext+1;
  155.                 yytext[yyleng] = 0;
  156. # ifdef LEXDEBUG
  157.                 if(debug){
  158.                     fprintf(yyout,"\nmatch ");
  159.                     sprint(yytext);
  160.                     fprintf(yyout," action %d\n",*yyfnd);
  161.                     }
  162. # endif
  163.                 return(*yyfnd++);
  164.                 }
  165.             unput(*yylastch);
  166.             }
  167.         if (yytext[0] == 0  /* && feof(yyin) */)
  168.             {
  169.             yysptr=yysbuf;
  170.             return(0);
  171.             }
  172.         yyprevious = yytext[0] = input();
  173.         if (yyprevious>0)
  174.             output(yyprevious);
  175.         yylastch=yytext;
  176. # ifdef LEXDEBUG
  177.         if(debug)putchar('\n');
  178. # endif
  179.         }
  180.     }
  181. #if defined(__cplusplus) || defined(__STDC__)
  182. int yyback(int *p, int m)
  183. #else
  184. yyback(p, m)
  185.     int *p;
  186. #endif
  187. {
  188.     if (p==0) return(0);
  189.     while (*p) {
  190.         if (*p++ == m)
  191.             return(1);
  192.     }
  193.     return(0);
  194. }
  195.     /* the following are only used in the lex library */
  196. #if defined(__cplusplus) || defined(__STDC__)
  197. int yyinput(void)
  198. #else
  199. yyinput()
  200. #endif
  201. {
  202.     return(input());
  203.     }
  204. #if defined(__cplusplus) || defined(__STDC__)
  205. void yyoutput(int c)
  206. #else
  207. yyoutput(c)
  208.   int c; 
  209. #endif
  210. {
  211.     output(c);
  212.     }
  213. #if defined(__cplusplus) || defined(__STDC__)
  214. void yyunput(int c)
  215. #else
  216. yyunput(c)
  217.    int c; 
  218. #endif
  219. {
  220.     unput(c);
  221.     }
  222.