home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / linuxdoc-sgml-1.1 / html-fix / fixref.c next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  7.6 KB  |  368 lines

  1. # include "stdio.h"
  2. # define U(x) x
  3. # define NLSTATE yyprevious=YYNEWLINE
  4. # define BEGIN yybgin = yysvec + 1 +
  5. # define INITIAL 0
  6. # define YYLERR yysvec
  7. # define YYSTATE (yyestate-yysvec-1)
  8. # define YYOPTIM 1
  9. # define YYLMAX BUFSIZ
  10. # define output(c) putc(c,yyout)
  11. # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
  12. # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
  13. # define yymore() (yymorfg=1)
  14. # define ECHO fprintf(yyout, "%s",yytext)
  15. # define REJECT { nstr = yyreject(); goto yyfussy;}
  16. int yyleng; extern char yytext[];
  17. int yymorfg;
  18. extern char *yysptr, yysbuf[];
  19. int yytchar;
  20. FILE *yyin = {stdin}, *yyout = {stdout};
  21. extern int yylineno;
  22. struct yysvf { 
  23.     struct yywork *yystoff;
  24.     struct yysvf *yyother;
  25.     int *yystops;};
  26. struct yysvf *yyestate;
  27. extern struct yysvf yysvec[], *yybgin;
  28.  
  29. #include <stdio.h>
  30. #include <string.h>
  31.  
  32. #define DEBUG
  33.  
  34. char sectname[256];
  35.  
  36. int filenum = 0;
  37. int homefile = 1;
  38.  
  39. # define YYNEWLINE 10
  40. yylex(){
  41. int nstr; extern int yyprevious;
  42. while((nstr = yylook()) >= 0)
  43. yyfussy: switch(nstr){
  44. case 0:
  45. if(yywrap()) return(0); break;
  46. case 1:
  47.     { filenum++; homefile=0; }
  48. break;
  49. case 2:
  50. { homefile=1; }
  51. break;
  52. case 3:
  53.     {
  54.  
  55. strcpy( sectname, yytext+9 );
  56. printf( "<@@labelp>%s#%d\n", sectname, homefile?0:filenum );
  57.  
  58. }
  59. break;
  60. case 4:
  61.         ;
  62. break;
  63. case -1:
  64. break;
  65. default:
  66. fprintf(yyout,"bad switch yylook %d",nstr);
  67. } return(0); }
  68. /* end of yylex */
  69. int yyvstop[] = {
  70. 0,
  71.  
  72. 4,
  73. 0,
  74.  
  75. 4,
  76. 0,
  77.  
  78. -1,
  79. 0,
  80.  
  81. -3,
  82. 0,
  83.  
  84. 1,
  85. 0,
  86.  
  87. 3,
  88. 0,
  89.  
  90. -2,
  91. 0,
  92.  
  93. 2,
  94. 0,
  95. 0};
  96. # define YYTYPE char
  97. struct yywork { YYTYPE verify, advance; } yycrank[] = {
  98. 0,0,    0,0,    1,3,    21,21,    
  99. 23,23,    27,27,    0,0,    0,0,    
  100. 0,0,    0,0,    0,0,    1,3,    
  101. 21,24,    23,26,    27,28,    0,0,    
  102. 0,0,    0,0,    0,0,    0,0,    
  103. 0,0,    0,0,    0,0,    0,0,    
  104. 0,0,    0,0,    0,0,    0,0,    
  105. 0,0,    0,0,    0,0,    0,0,    
  106. 0,0,    0,0,    0,0,    0,0,    
  107. 0,0,    0,0,    0,0,    0,0,    
  108. 0,0,    0,0,    0,0,    0,0,    
  109. 0,0,    0,0,    0,0,    0,0,    
  110. 0,0,    0,0,    0,0,    0,0,    
  111. 0,0,    0,0,    0,0,    0,0,    
  112. 0,0,    0,0,    0,0,    0,0,    
  113. 0,0,    2,4,    0,0,    18,21,    
  114. 20,23,    4,5,    5,6,    25,27,    
  115. 0,0,    0,0,    0,0,    0,0,    
  116. 0,0,    0,0,    0,0,    0,0,    
  117. 0,0,    0,0,    0,0,    0,0,    
  118. 0,0,    0,0,    0,0,    0,0,    
  119. 0,0,    0,0,    0,0,    0,0,    
  120. 0,0,    0,0,    0,0,    0,0,    
  121. 0,0,    0,0,    0,0,    0,0,    
  122. 0,0,    0,0,    8,11,    11,14,    
  123. 12,15,    10,13,    6,7,    9,12,    
  124. 14,17,    16,19,    19,22,    0,0,    
  125. 0,0,    6,8,    17,20,    7,10,    
  126. 0,0,    0,0,    0,0,    0,0,    
  127. 6,9,    13,16,    15,18,    22,25,    
  128. 0,0};
  129. struct yysvf yysvec[] = {
  130. 0,    0,    0,
  131. yycrank+-1,    0,        0,    
  132. yycrank+-1,    yysvec+1,    0,    
  133. yycrank+0,    0,        yyvstop+1,
  134. yycrank+1,    0,        yyvstop+3,
  135. yycrank+2,    0,        0,    
  136. yycrank+1,    0,        0,    
  137. yycrank+1,    0,        0,    
  138. yycrank+1,    0,        0,    
  139. yycrank+2,    0,        0,    
  140. yycrank+1,    0,        0,    
  141. yycrank+1,    0,        0,    
  142. yycrank+1,    0,        0,    
  143. yycrank+2,    0,        0,    
  144. yycrank+3,    0,        0,    
  145. yycrank+2,    0,        0,    
  146. yycrank+4,    0,        0,    
  147. yycrank+2,    0,        0,    
  148. yycrank+1,    0,        0,    
  149. yycrank+7,    0,        0,    
  150. yycrank+2,    0,        0,    
  151. yycrank+-2,    0,        yyvstop+5,
  152. yycrank+3,    0,        0,    
  153. yycrank+-3,    0,        yyvstop+7,
  154. yycrank+0,    0,        yyvstop+9,
  155. yycrank+5,    0,        0,    
  156. yycrank+0,    0,        yyvstop+11,
  157. yycrank+-4,    0,        yyvstop+13,
  158. yycrank+0,    0,        yyvstop+15,
  159. 0,    0,    0};
  160. struct yywork *yytop = yycrank+119;
  161. struct yysvf *yybgin = yysvec+1;
  162. char yymatch[] = {
  163. 00  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  164. 01  ,01  ,012 ,01  ,01  ,01  ,01  ,01  ,
  165. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  166. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  167. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  168. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  169. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  170. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  171. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  172. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  173. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  174. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  175. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  176. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  177. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  178. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  179. 0};
  180. char yyextra[] = {
  181. 0,1,1,1,0,0,0,0,
  182. 0};
  183. #ifndef lint
  184. static    char ncform_sccsid[] = "@(#)ncform 1.6 88/02/08 SMI"; /* from S5R2 1.2 */
  185. #endif
  186.  
  187. int yylineno =1;
  188. # define YYU(x) x
  189. # define NLSTATE yyprevious=YYNEWLINE
  190. char yytext[YYLMAX];
  191. struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
  192. char yysbuf[YYLMAX];
  193. char *yysptr = yysbuf;
  194. int *yyfnd;
  195. extern struct yysvf *yyestate;
  196. int yyprevious = YYNEWLINE;
  197. yylook(){
  198.     register struct yysvf *yystate, **lsp;
  199.     register struct yywork *yyt;
  200.     struct yysvf *yyz;
  201.     int yych, yyfirst;
  202.     struct yywork *yyr;
  203. # ifdef LEXDEBUG
  204.     int debug;
  205. # endif
  206.     char *yylastch;
  207.     /* start off machines */
  208. # ifdef LEXDEBUG
  209.     debug = 0;
  210. # endif
  211.     yyfirst=1;
  212.     if (!yymorfg)
  213.         yylastch = yytext;
  214.     else {
  215.         yymorfg=0;
  216.         yylastch = yytext+yyleng;
  217.         }
  218.     for(;;){
  219.         lsp = yylstate;
  220.         yyestate = yystate = yybgin;
  221.         if (yyprevious==YYNEWLINE) yystate++;
  222.         for (;;){
  223. # ifdef LEXDEBUG
  224.             if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
  225. # endif
  226.             yyt = yystate->yystoff;
  227.             if(yyt == yycrank && !yyfirst){  /* may not be any transitions */
  228.                 yyz = yystate->yyother;
  229.                 if(yyz == 0)break;
  230.                 if(yyz->yystoff == yycrank)break;
  231.                 }
  232.             *yylastch++ = yych = input();
  233.             yyfirst=0;
  234.         tryagain:
  235. # ifdef LEXDEBUG
  236.             if(debug){
  237.                 fprintf(yyout,"char ");
  238.                 allprint(yych);
  239.                 putchar('\n');
  240.                 }
  241. # endif
  242.             yyr = yyt;
  243.             if ( (int)yyt > (int)yycrank){
  244.                 yyt = yyr + yych;
  245.                 if (yyt <= yytop && yyt->verify+yysvec == yystate){
  246.                     if(yyt->advance+yysvec == YYLERR)    /* error transitions */
  247.                         {unput(*--yylastch);break;}
  248.                     *lsp++ = yystate = yyt->advance+yysvec;
  249.                     goto contin;
  250.                     }
  251.                 }
  252. # ifdef YYOPTIM
  253.             else if((int)yyt < (int)yycrank) {        /* r < yycrank */
  254.                 yyt = yyr = yycrank+(yycrank-yyt);
  255. # ifdef LEXDEBUG
  256.                 if(debug)fprintf(yyout,"compressed state\n");
  257. # endif
  258.                 yyt = yyt + yych;
  259.                 if(yyt <= yytop && yyt->verify+yysvec == yystate){
  260.                     if(yyt->advance+yysvec == YYLERR)    /* error transitions */
  261.                         {unput(*--yylastch);break;}
  262.                     *lsp++ = yystate = yyt->advance+yysvec;
  263.                     goto contin;
  264.                     }
  265.                 yyt = yyr + YYU(yymatch[yych]);
  266. # ifdef LEXDEBUG
  267.                 if(debug){
  268.                     fprintf(yyout,"try fall back character ");
  269.                     allprint(YYU(yymatch[yych]));
  270.                     putchar('\n');
  271.                     }
  272. # endif
  273.                 if(yyt <= yytop && yyt->verify+yysvec == yystate){
  274.                     if(yyt->advance+yysvec == YYLERR)    /* error transition */
  275.                         {unput(*--yylastch);break;}
  276.                     *lsp++ = yystate = yyt->advance+yysvec;
  277.                     goto contin;
  278.                     }
  279.                 }
  280.             if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
  281. # ifdef LEXDEBUG
  282.                 if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
  283. # endif
  284.                 goto tryagain;
  285.                 }
  286. # endif
  287.             else
  288.                 {unput(*--yylastch);break;}
  289.         contin:
  290. # ifdef LEXDEBUG
  291.             if(debug){
  292.                 fprintf(yyout,"state %d char ",yystate-yysvec-1);
  293.                 allprint(yych);
  294.                 putchar('\n');
  295.                 }
  296. # endif
  297.             ;
  298.             }
  299. # ifdef LEXDEBUG
  300.         if(debug){
  301.             fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
  302.             allprint(yych);
  303.             putchar('\n');
  304.             }
  305. # endif
  306.         while (lsp-- > yylstate){
  307.             *yylastch-- = 0;
  308.             if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
  309.                 yyolsp = lsp;
  310.                 if(yyextra[*yyfnd]){        /* must backup */
  311.                     while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
  312.                         lsp--;
  313.                         unput(*yylastch--);
  314.                         }
  315.                     }
  316.                 yyprevious = YYU(*yylastch);
  317.                 yylsp = lsp;
  318.                 yyleng = yylastch-yytext+1;
  319.                 yytext[yyleng] = 0;
  320. # ifdef LEXDEBUG
  321.                 if(debug){
  322.                     fprintf(yyout,"\nmatch ");
  323.                     sprint(yytext);
  324.                     fprintf(yyout," action %d\n",*yyfnd);
  325.                     }
  326. # endif
  327.                 return(*yyfnd++);
  328.                 }
  329.             unput(*yylastch);
  330.             }
  331.         if (yytext[0] == 0  /* && feof(yyin) */)
  332.             {
  333.             yysptr=yysbuf;
  334.             return(0);
  335.             }
  336.         yyprevious = yytext[0] = input();
  337.         if (yyprevious>0)
  338.             output(yyprevious);
  339.         yylastch=yytext;
  340. # ifdef LEXDEBUG
  341.         if(debug)putchar('\n');
  342. # endif
  343.         }
  344.     }
  345. yyback(p, m)
  346.     int *p;
  347. {
  348. if (p==0) return(0);
  349. while (*p)
  350.     {
  351.     if (*p++ == m)
  352.         return(1);
  353.     }
  354. return(0);
  355. }
  356.     /* the following are only used in the lex library */
  357. yyinput(){
  358.     return(input());
  359.     }
  360. yyoutput(c)
  361.   int c; {
  362.     output(c);
  363.     }
  364. yyunput(c)
  365.    int c; {
  366.     unput(c);
  367.     }
  368.