ncform 4.0 KB

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