Source code of Windows XP (NT5)
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.

154 lines
3.6 KiB

  1. # define YYFLAG -1000
  2. # define YYERROR goto yyerrlab
  3. # define YYACCEPT return(0)
  4. # define YYABORT return(1)
  5. #ifdef YYDEBUG /* RRR - 10/9/85 */
  6. #define yyprintf(a, b, c) printf(a, b, c)
  7. #else
  8. #define yyprintf(a, b, c)
  9. #endif
  10. /* parser for yacc output */
  11. YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
  12. int yychar = -1; /* current input token number */
  13. int yynerrs = 0; /* number of errors */
  14. short yyerrflag = 0; /* error recovery flag */
  15. int NEAR yyparse(void)
  16. {
  17. short yys[YYMAXDEPTH];
  18. short yyj, yym;
  19. register YYSTYPE *yypvt;
  20. register short yystate, *yyps, yyn;
  21. register YYSTYPE *yypv;
  22. register short *yyxi;
  23. yystate = 0;
  24. yychar = -1;
  25. yynerrs = 0;
  26. yyerrflag = 0;
  27. yyps= &yys[-1];
  28. yypv= &yyv[-1];
  29. yystack: /* put a state and value onto the stack */
  30. yyprintf( "state %d, char 0%o\n", yystate, yychar );
  31. if( ++yyps> &yys[YYMAXDEPTH] )
  32. {
  33. yyerror( "yacc stack overflow" );
  34. return(1);
  35. }
  36. *yyps = yystate;
  37. ++yypv;
  38. *yypv = yyval;
  39. yynewstate:
  40. yyn = yypact[yystate];
  41. if( yyn<= YYFLAG ) goto yydefault; /* simple state */
  42. if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
  43. if( (yyn += (short)yychar)<0 || yyn >= YYLAST ) goto yydefault;
  44. if( yychk[ yyn=yyact[ yyn ] ] == yychar )
  45. {
  46. /* valid shift */
  47. yychar = -1;
  48. yyval = yylval;
  49. yystate = yyn;
  50. if( yyerrflag > 0 ) --yyerrflag;
  51. goto yystack;
  52. }
  53. yydefault:
  54. /* default state action */
  55. if( (yyn=yydef[yystate]) == -2 )
  56. {
  57. if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
  58. /* look through exception table */
  59. for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
  60. for(yyxi+=2; *yyxi >= 0; yyxi+=2)
  61. {
  62. if( *yyxi == yychar ) break;
  63. }
  64. if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */
  65. }
  66. if( yyn == 0 )
  67. {
  68. /* error */
  69. /* error ... attempt to resume parsing */
  70. switch( yyerrflag )
  71. {
  72. case 0: /* brand new error */
  73. yyerror( "syntax error" );
  74. ++yynerrs;
  75. case 1:
  76. case 2: /* incompletely recovered error ... try again */
  77. yyerrflag = 3;
  78. /* find a state where "error" is a legal shift action */
  79. while ( yyps >= yys )
  80. {
  81. yyn = yypact[*yyps] + YYERRCODE;
  82. if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE )
  83. {
  84. yystate = yyact[yyn]; /* simulate a shift of "error" */
  85. goto yystack;
  86. }
  87. yyn = yypact[*yyps];
  88. /* the current yyps has no shift onn "error", pop stack */
  89. yyprintf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
  90. --yyps;
  91. --yypv;
  92. }
  93. /* there is no state on the stack with an error shift ... abort */
  94. yyabort:
  95. return(1);
  96. case 3: /* no shift yet; clobber input char */
  97. yyprintf( "error recovery discards char %d\n", yychar, 0 );
  98. if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
  99. yychar = -1;
  100. goto yynewstate; /* try again in the same state */
  101. }
  102. }
  103. /* reduction by production yyn */
  104. yyprintf("reduce %d\n",yyn, 0);
  105. yyps -= yyr2[yyn];
  106. yypvt = yypv;
  107. yypv -= yyr2[yyn];
  108. yyval = yypv[1];
  109. yym=yyn;
  110. /* consult goto table to find next state */
  111. yyn = yyr1[yyn];
  112. yyj = yypgo[yyn] + *yyps + 1;
  113. if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
  114. switch(yym)
  115. {
  116. $A
  117. }
  118. goto yystack; /* stack new state and value */
  119. }