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.

327 lines
6.9 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. #define MAX_RECOVERY_ATTEMPTS (50)
  66. #define MAX_RETRY_COUNT (3)
  67. static short RetryCount = 0;
  68. static short MaxRecoveryAttempts = 0;
  69. static short fJustDiscarded = 0;
  70. YYLOCAL YYNEAR YYPASCAL YYPARSER()
  71. {
  72. register short yyn;
  73. short yystate, *yyps, *yysave_yyps;
  74. YYSTYPE *yypv,*yysave_yypv;
  75. YYSTYPE yysave_yyval;
  76. short yyj, yym;
  77. short fHaveRecoveredChar = 0;
  78. yy_vc_init();
  79. #ifdef YYDEBUG
  80. yydebug = 1;
  81. #endif /* YYDEBUG */
  82. yystate = 0;
  83. yychar = -1;
  84. yynerrs = 0;
  85. yyerrflag = 0;
  86. yyps= &yys[-1];
  87. yypv= &yyv[-1];
  88. yystack: /* put a state and value onto the stack */
  89. RetryCount = 0;
  90. #ifdef YYDEBUG
  91. yyprintf( "[yydebug] state %d, char %d = %c\n", yystate, yychar,yychar, 0 );
  92. #else /* YYDEBUG */
  93. yyprintf( "[yydebug] state %d, char %d\n", yystate, yychar, 0 );
  94. #endif /* YYDEBUG */
  95. if( ++yyps > &yys[YYMAXDEPTH] ) {
  96. /* yyerror( "yacc stack overflow" ); */
  97. ParseError(C_STACK_OVERFLOW, (char *)NULL);
  98. return(1);
  99. }
  100. *yyps = yystate;
  101. ++yypv;
  102. #ifdef UNION
  103. yyunion(yypv, &yyval);
  104. #else
  105. *yypv = yyval;
  106. #endif
  107. yynewstate:
  108. yysavestate = yystate;
  109. yysave_yypv = yypv;
  110. yysave_yyval= yyval;
  111. yysave_yyps = yyps;
  112. yyn = yypact[yystate];
  113. if( yyn <= YYFLAG ) { /* simple state, no lookahead */
  114. goto yydefault;
  115. }
  116. if( ! fHaveRecoveredChar )
  117. {
  118. if( yychar < 0 ) /* need a lookahead */
  119. {
  120. yychar = YYLEX();
  121. }
  122. }
  123. fHaveRecoveredChar = 0;
  124. if( ((yyn += yychar) < 0) || (yyn >= YYLAST) ) {
  125. goto yydefault;
  126. }
  127. if( yychk[ yyn = yyact[ yyn ] ] == yychar ) { /* valid shift */
  128. yychar = -1;
  129. #ifdef UNION
  130. yyunion(&yyval, &yylval);
  131. #else
  132. yyval = yylval;
  133. #endif
  134. yystate = yyn;
  135. if( yyerrflag > 0 ) {
  136. --yyerrflag;
  137. }
  138. goto yystack;
  139. }
  140. yydefault:
  141. /* default state action */
  142. if( (yyn = yydef[yystate]) == -2 ) {
  143. register short *yyxi;
  144. if( yychar < 0 ) {
  145. yychar = YYLEX();
  146. }
  147. /*
  148. ** search exception table, we find a -1 followed by the current state.
  149. ** if we find one, we'll look through terminal,state pairs. if we find
  150. ** a terminal which matches the current one, we have a match.
  151. ** the exception table is when we have a reduce on a terminal.
  152. */
  153. #if YYOPTTIME
  154. yyxi = yyexca + yyexcaind[yystate];
  155. while(( *yyxi != yychar ) && ( *yyxi >= 0 )){
  156. yyxi += 2;
  157. }
  158. #else
  159. for(yyxi = yyexca;
  160. (*yyxi != (-1)) || (yyxi[1] != yystate);
  161. yyxi += 2
  162. ) {
  163. ; /* VOID */
  164. }
  165. while( *(yyxi += 2) >= 0 ){
  166. if( *yyxi == yychar ) {
  167. break;
  168. }
  169. }
  170. #endif
  171. if( (yyn = yyxi[1]) < 0 ) {
  172. return(0); /* accept */
  173. }
  174. }
  175. if( yyn == 0 ) /* error */
  176. {
  177. int yytempchar;
  178. if( (yychar != EOI ) &&
  179. ( RetryCount < MAX_RETRY_COUNT ) &&
  180. ( MaxRecoveryAttempts < MAX_RECOVERY_ATTEMPTS ) )
  181. {
  182. if( RetryCount == 0 )
  183. SyntaxError( BENIGN_SYNTAX_ERROR, yysavestate );
  184. if((( yytempchar = PossibleMissingToken( yysavestate, yychar ) ) != -1 ))
  185. {
  186. char Buf[ 50 ];
  187. fHaveRecoveredChar = 1;
  188. yyunlex( yychar );
  189. yychar = yytempchar;
  190. if( (yytempchar < 128 ) && isprint( yytempchar ) )
  191. {
  192. sprintf( Buf, " %c ", yytempchar );
  193. }
  194. else if( yytempchar == IDENTIFIER )
  195. {
  196. yylval.yy_pSymName = GenTempName();
  197. sprintf( Buf, " identifier %s", yylval.yy_pSymName );
  198. }
  199. else if( (yytempchar == NUMERICCONSTANT ) ||
  200. (yytempchar == NUMERICLONGCONSTANT ) ||
  201. (yytempchar == NUMERICULONGCONSTANT ) ||
  202. (yytempchar == HEXCONSTANT ) ||
  203. (yytempchar == HEXLONGCONSTANT ) ||
  204. (yytempchar == HEXULONGCONSTANT ) )
  205. {
  206. sprintf( Buf, "a number" );
  207. yylval.yy_numeric.Val = 0;
  208. yylval.yy_numeric.pValStr = new char[2];
  209. strcpy( yylval.yy_numeric.pValStr, "0");
  210. }
  211. ParseError( ASSUMING_CHAR, Buf );
  212. RetryCount = 0;
  213. MaxRecoveryAttempts++;
  214. fJustDiscarded = 0;
  215. }
  216. else
  217. {
  218. char buf[ 20 ];
  219. if( (yychar < 128 ) && isprint( yychar ) )
  220. {
  221. sprintf( buf, " %c ", yychar );
  222. }
  223. else
  224. {
  225. sprintf( buf, " the last token " );
  226. }
  227. ParseError( DISCARDING_CHAR, buf );
  228. yychar = -1;
  229. RetryCount++;
  230. MaxRecoveryAttempts++;
  231. fJustDiscarded = 1;
  232. }
  233. yystate = yysavestate;
  234. yypv = yysave_yypv;
  235. yyval = yysave_yyval;
  236. yyps = yysave_yyps;
  237. goto yynewstate;
  238. }
  239. else if( (yychar == EOI ) && (fJustDiscarded == 0 ) )
  240. {
  241. SyntaxError( UNEXPECTED_END_OF_FILE, yysavestate );
  242. return 1;
  243. }
  244. else
  245. {
  246. SyntaxError( SYNTAX_ERROR, yysavestate );
  247. return 1;
  248. }
  249. }
  250. /* reduction by production yyn */
  251. /* yyreduce: */
  252. {
  253. #ifdef YYDEBUG
  254. yyprintf("[yydebug] reduce %d\n",yyn, 0, 0, 0);
  255. #else /* YYDEBUG */
  256. yyprintf("[yydebug] reduce %d\n",yyn, 0, 0);
  257. #endif /* YYDEBUG */
  258. yypvt = yypv;
  259. yyps -= yyr2[yyn];
  260. yypv -= yyr2[yyn];
  261. #ifdef UNION
  262. yyunion(&yyval, &yypv[1]);
  263. #else
  264. yyval = yypv[1];
  265. #endif
  266. yym = yyn;
  267. yyn = yyr1[yyn]; /* consult goto table to find next state */
  268. yyj = yypgo[yyn] + *yyps + 1;
  269. if( (yyj >= YYLAST) || (yychk[ yystate = yyact[yyj] ] != -yyn) ) {
  270. yystate = yyact[yypgo[yyn]];
  271. }
  272. returnflag = 0;
  273. GrammarAct = yym;
  274. (*(pcase_fn_array[ (yym <= yym_vc_max) ? yym : 0 ]))();
  275. if(returnflag != 0)
  276. return returnflag;
  277. }
  278. goto yystack; /* stack new state and value */
  279. }
  280. ___a_r_u_myact
  281. $A
  282. ___a_r_u_end