Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

321 lines
7.5 KiB

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. /* SCCSWHAT( "@(#)yypars.c 2.4 88/05/09 15:22:59 " ) */
  3. ___a_r_u_start
  4. static char *SCCSID = "@(#)yypars.c:1.3";
  5. # define YYFLAG -1000
  6. # define YYERROR goto yyerrlab
  7. # define YYACCEPT return(0)
  8. # define YYABORT return(1)
  9. #ifdef YYDEBUG /* RRR - 10/9/85 */
  10. #define yyprintf(a, b, c, d, e) printf(a, b, c, d, e)
  11. #else
  12. #define yyprintf(a, b, c, d)
  13. #endif
  14. #ifndef YYPRINT
  15. #define YYPRINT printf
  16. #endif
  17. #if ! defined YYSTATIC
  18. #define YYSTATIC
  19. #endif
  20. /* parser for yacc output */
  21. #ifdef YYDEBUG
  22. YYSTATIC int yydebug = 0; /* 1 for debugging */
  23. #endif
  24. YYSTATIC YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
  25. YYSTATIC short yys[YYMAXDEPTH]; /* the parse stack */
  26. YYSTATIC int yychar = -1; /* current input token number */
  27. YYSTATIC int yynerrs = 0; /* number of errors */
  28. YYSTATIC short yyerrflag = 0; /* error recovery flag */
  29. #ifdef YYRECOVER
  30. /*
  31. ** yyscpy : copy f onto t and return a ptr to the null terminator at the
  32. ** end of t.
  33. */
  34. YYSTATIC char *yyscpy(t,f)
  35. register char *t, *f;
  36. {
  37. while(*t = *f++)
  38. t++;
  39. return(t); /* ptr to the null char */
  40. }
  41. #endif
  42. #ifndef YYNEAR
  43. #define YYNEAR
  44. #endif
  45. #ifndef YYPASCAL
  46. #define YYPASCAL
  47. #endif
  48. #ifndef YYLOCAL
  49. #define YYLOCAL
  50. #endif
  51. #if ! defined YYPARSER
  52. #define YYPARSER yyparse
  53. #endif
  54. #if ! defined YYLEX
  55. #define YYLEX yylex
  56. #endif
  57. static void yy_vc_init();
  58. typedef void (*pfn)();
  59. static pfn *pcase_fn_array;
  60. static int returnflag = 0;
  61. static YYSTYPE *yypvt;
  62. static int yym_vc_max = 0;
  63. extern short GrammarAct;
  64. extern short yysavestate;
  65. YYLOCAL YYNEAR YYPASCAL YYPARSER()
  66. {
  67. register short yyn;
  68. short yystate, *yyps;
  69. YYSTYPE *yypv;
  70. short yyj, yym;
  71. yy_vc_init();
  72. #ifdef YYDEBUG
  73. yydebug = 1;
  74. #endif /* YYDEBUG */
  75. yystate = 0;
  76. yychar = -1;
  77. yynerrs = 0;
  78. yyerrflag = 0;
  79. yyps= &yys[-1];
  80. yypv= &yyv[-1];
  81. yystack: /* put a state and value onto the stack */
  82. #ifdef YYDEBUG
  83. yyprintf( "[yydebug] state %d, char %d = %c\n", yystate, yychar,yychar, 0 );
  84. #else /* YYDEBUG */
  85. yyprintf( "[yydebug] state %d, char %d\n", yystate, yychar, 0 );
  86. #endif /* YYDEBUG */
  87. if( ++yyps > &yys[YYMAXDEPTH] ) {
  88. /* yyerror( "yacc stack overflow" ); */
  89. ParseError(C_STACK_OVERFLOW, (char *)NULL);
  90. return(1);
  91. }
  92. *yyps = yystate;
  93. ++yypv;
  94. #ifdef UNION
  95. yyunion(yypv, &yyval);
  96. #else
  97. *yypv = yyval;
  98. #endif
  99. yynewstate:
  100. yysavestate = yystate;
  101. yyn = yypact[yystate];
  102. if( yyn <= YYFLAG ) { /* simple state, no lookahead */
  103. goto yydefault;
  104. }
  105. if( yychar < 0 ) { /* need a lookahead */
  106. yychar = YYLEX();
  107. }
  108. if( ((yyn += yychar) < 0) || (yyn >= YYLAST) ) {
  109. goto yydefault;
  110. }
  111. if( yychk[ yyn = yyact[ yyn ] ] == yychar ) { /* valid shift */
  112. yychar = -1;
  113. #ifdef UNION
  114. yyunion(&yyval, &yylval);
  115. #else
  116. yyval = yylval;
  117. #endif
  118. yystate = yyn;
  119. if( yyerrflag > 0 ) {
  120. --yyerrflag;
  121. }
  122. goto yystack;
  123. }
  124. yydefault:
  125. /* default state action */
  126. if( (yyn = yydef[yystate]) == -2 ) {
  127. register short *yyxi;
  128. if( yychar < 0 ) {
  129. yychar = YYLEX();
  130. }
  131. /*
  132. ** search exception table, we find a -1 followed by the current state.
  133. ** if we find one, we'll look through terminal,state pairs. if we find
  134. ** a terminal which matches the current one, we have a match.
  135. ** the exception table is when we have a reduce on a terminal.
  136. */
  137. #if YYOPTTIME
  138. yyxi = yyexca + yyexcaind[yystate];
  139. while(( *yyxi != yychar ) && ( *yyxi >= 0 )){
  140. yyxi += 2;
  141. }
  142. #else
  143. for(yyxi = yyexca;
  144. (*yyxi != (-1)) || (yyxi[1] != yystate);
  145. yyxi += 2
  146. ) {
  147. ; /* VOID */
  148. }
  149. while( *(yyxi += 2) >= 0 ){
  150. if( *yyxi == yychar ) {
  151. break;
  152. }
  153. }
  154. #endif
  155. if( (yyn = yyxi[1]) < 0 ) {
  156. return(0); /* accept */
  157. }
  158. }
  159. if( yyn == 0 ){ /* error */
  160. /* error ... attempt to resume parsing */
  161. switch( yyerrflag ){
  162. case 0: /* brand new error */
  163. #ifdef YYRECOVER
  164. {
  165. register int i,j;
  166. for(i = 0;
  167. (yyrecover[i] != -1000) && (yystate > yyrecover[i]);
  168. i += 3
  169. ) {
  170. ;
  171. }
  172. if(yystate == yyrecover[i]) {
  173. #ifdef YYDEBUG
  174. yyprintf("recovered, from state %d to state %d on token %d\n",
  175. yystate,yyrecover[i+2],yyrecover[i+1], 0
  176. );
  177. #else /* YYDEBUG */
  178. yyprintf("recovered, from state %d to state %d on token %d\n",
  179. yystate,yyrecover[i+2],yyrecover[i+1]
  180. );
  181. #endif /* YYDEBUG */
  182. j = yyrecover[i + 1];
  183. if(j < 0) {
  184. /*
  185. ** here we have one of the injection set, so we're not quite
  186. ** sure that the next valid thing will be a shift. so we'll
  187. ** count it as an error and continue.
  188. ** actually we're not absolutely sure that the next token
  189. ** we were supposed to get is the one when j > 0. for example,
  190. ** for(+) {;} error recovery with yyerrflag always set, stops
  191. ** after inserting one ; before the +. at the point of the +,
  192. ** we're pretty sure the guy wants a 'for' loop. without
  193. ** setting the flag, when we're almost absolutely sure, we'll
  194. ** give him one, since the only thing we can shift on this
  195. ** error is after finding an expression followed by a +
  196. */
  197. yyerrflag++;
  198. j = -j;
  199. }
  200. if(yyerrflag <= 1) { /* only on first insertion */
  201. yyrecerr(yychar,j); /* what was, what should be first */
  202. }
  203. yyval = yyeval(j);
  204. yystate = yyrecover[i + 2];
  205. goto yystack;
  206. }
  207. }
  208. #endif
  209. /* yyerror("syntax error"); */
  210. SyntaxError(SYNTAX_ERROR, yysavestate );
  211. /* yyerrlab: */
  212. ++yynerrs;
  213. case 1:
  214. case 2: /* incompletely recovered error ... try again */
  215. yyerrflag = 3;
  216. /* find a state where "error" is a legal shift action */
  217. while ( yyps >= yys ) {
  218. yyn = yypact[*yyps] + YYERRCODE;
  219. if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
  220. yystate = yyact[yyn]; /* simulate a shift of "error" */
  221. goto yystack;
  222. }
  223. yyn = yypact[*yyps];
  224. /* the current yyps has no shift onn "error", pop stack */
  225. #ifdef YYDEBUG
  226. yyprintf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1], 0, 0 );
  227. #else /* YYDEBUG */
  228. yyprintf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1], 0 );
  229. #endif /* YYDEBUG */
  230. --yyps;
  231. --yypv;
  232. }
  233. /* there is no state on the stack with an error shift ... abort */
  234. yyabort:
  235. return(1);
  236. case 3: /* no shift yet; clobber input char */
  237. #ifdef YYDEBUG
  238. yyprintf( "error recovery discards char %d\n", yychar, 0, 0, 0 );
  239. #else /* YYDEBUG */
  240. yyprintf( "error recovery discards char %d\n", yychar, 0, 0 );
  241. #endif /* YYDEBUG */
  242. if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
  243. yychar = -1;
  244. goto yynewstate; /* try again in the same state */
  245. }
  246. }
  247. /* reduction by production yyn */
  248. /* yyreduce: */
  249. {
  250. #ifdef YYDEBUG
  251. yyprintf("[yydebug] reduce %d\n",yyn, 0, 0, 0);
  252. #else /* YYDEBUG */
  253. yyprintf("[yydebug] reduce %d\n",yyn, 0, 0);
  254. #endif /* YYDEBUG */
  255. yypvt = yypv;
  256. yyps -= yyr2[yyn];
  257. yypv -= yyr2[yyn];
  258. #ifdef UNION
  259. yyunion(&yyval, &yypv[1]);
  260. #else
  261. yyval = yypv[1];
  262. #endif
  263. yym = yyn;
  264. yyn = yyr1[yyn]; /* consult goto table to find next state */
  265. yyj = yypgo[yyn] + *yyps + 1;
  266. if( (yyj >= YYLAST) || (yychk[ yystate = yyact[yyj] ] != -yyn) ) {
  267. yystate = yyact[yypgo[yyn]];
  268. }
  269. returnflag = 0;
  270. GrammarAct = yym;
  271. (*(pcase_fn_array[ (yym <= yym_vc_max) ? yym : 0 ]))();
  272. if(returnflag != 0)
  273. return returnflag;
  274. }
  275. goto yystack; /* stack new state and value */
  276. }
  277. ___a_r_u_myact
  278. $A
  279. ___a_r_u_end