1
0

ncform 3.9 KB

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