📄 parser.cpp
字号:
}
else
{
yytoken = YYTRANSLATE (yychar);
YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */
yyn += yytoken;
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0)
{
if (yyn == 0 || yyn == YYTABLE_NINF)
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
if (yyn == YYFINAL)
YYACCEPT;
/* Shift the lookahead token. */
YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
yychar = YYEMPTY;
*++yyvsp = yylval;
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
yystate = yyn;
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- Do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
`$$ = $1'.
Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison
users should not rely upon it. Assigning to YYVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 2:
{
ParsedSearchExpression(yyvsp[0].pexpr);
delete yyvsp[0].pexpr;
return 0;
;}
break;
case 3:
{
CSearchExpr* pexpr = new CSearchExpr(yyvsp[0].pstr);
ParsedSearchExpression(pexpr);
delete pexpr;
delete yyvsp[0].pstr;
return 0;
;}
break;
case 4:
{
yyerror(GetResString(IDS_SEARCH_GENERALERROR));
delete yyvsp[-1].pexpr;
return 1;
;}
break;
case 6:
{
CSearchExpr* pexpr = new CSearchExpr;
pexpr->Add(SEARCHOP_AND);
pexpr->Add(yyvsp[-2].pexpr);
pexpr->Add(yyvsp[0].pexpr);
yyval.pexpr = pexpr;
delete yyvsp[-2].pexpr;
delete yyvsp[0].pexpr;
;}
break;
case 7:
{
CSearchExpr* pexpr = new CSearchExpr;
pexpr->Add(SEARCHOP_OR);
pexpr->Add(yyvsp[-2].pexpr);
pexpr->Add(yyvsp[0].pexpr);
yyval.pexpr = pexpr;
delete yyvsp[-2].pexpr;
delete yyvsp[0].pexpr;
;}
break;
case 8:
{
CSearchExpr* pexpr = new CSearchExpr;
pexpr->Add(SEARCHOP_NOT);
pexpr->Add(yyvsp[-2].pexpr);
pexpr->Add(yyvsp[0].pexpr);
yyval.pexpr = pexpr;
delete yyvsp[-2].pexpr;
delete yyvsp[0].pexpr;
;}
break;
case 9:
{
yyval.pexpr = yyvsp[-1].pexpr;
;}
break;
case 10:
{
yyerror(GetResString(IDS_SEARCH_MISSINGORRIGHT));
delete yyvsp[-2].pexpr;
return 1;
;}
break;
case 11:
{
yyerror(GetResString(IDS_SEARCH_MISSINGNOTRIGHT));
delete yyvsp[-2].pexpr;
return 1;
;}
break;
case 12:
{
yyerror(GetResString(IDS_SEARCH_MISSINGEXPRPARANT));
return 1;
;}
break;
case 13:
{
yyerror(GetResString(IDS_SEARCH_MISSINGCLOSINGPARANT));
delete yyvsp[-1].pexpr;
return 1;
;}
break;
case 14:
{
yyerror(GetResString(IDS_SEARCH_MISSINGANDLEFT));
return 1;
;}
break;
case 15:
{
yyerror(GetResString(IDS_SEARCH_MISSINGORLEFT));
return 1;
;}
break;
case 16:
{
yyerror(GetResString(IDS_SEARCH_MISSINGNOTLEFT));
return 1;
;}
break;
case 17:
{
yyval.pexpr = new CSearchExpr(yyvsp[0].pstr);
delete yyvsp[0].pstr;
;}
break;
case 18:
{
/*$1->Concatenate($2);
delete $2;*/
CSearchExpr* pexpr = new CSearchExpr;
pexpr->Add(SEARCHOP_AND);
pexpr->Add(yyvsp[-1].pexpr);
pexpr->Add(yyvsp[0].pstr);
yyval.pexpr = pexpr;
delete yyvsp[-1].pexpr;
delete yyvsp[0].pstr;
;}
break;
}
/* Line 991 of yacc.c. */
yyvsp -= yylen;
yyssp -= yylen;
YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
/* Now `shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTOKENS];
goto yynewstate;
/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
#if YYERROR_VERBOSE
yyn = yypact[yystate];
if (YYPACT_NINF < yyn && yyn < YYLAST)
{
YYSIZE_T yysize = 0;
int yytype = YYTRANSLATE (yychar);
char *yymsg;
int yyx, yycount;
yycount = 0;
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. */
for (yyx = yyn < 0 ? -yyn : 0;
yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
yysize += yystrlen (yytname[yyx]) + 15, yycount++;
yysize += yystrlen ("syntax error, unexpected ") + 1;
yysize += yystrlen (yytname[yytype]);
yymsg = (char *) YYSTACK_ALLOC (yysize);
if (yymsg != 0)
{
char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
yyp = yystpcpy (yyp, yytname[yytype]);
if (yycount < 5)
{
yycount = 0;
for (yyx = yyn < 0 ? -yyn : 0;
yyx < (int) (sizeof (yytname) / sizeof (char *));
yyx++)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
{
const char *yyq = ! yycount ? ", expecting " : " or ";
yyp = yystpcpy (yyp, yyq);
yyp = yystpcpy (yyp, yytname[yyx]);
yycount++;
}
}
yyerror (yymsg);
YYSTACK_FREE (yymsg);
}
else
yyerror ("syntax error; also virtual memory exhausted");
}
else
#endif /* YYERROR_VERBOSE */
yyerror ("syntax error");
}
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
/* Return failure if at end of input. */
if (yychar == YYEOF)
{
/* Pop the error token. */
YYPOPSTACK;
/* Pop the rest of the stack. */
while (yyss < yyssp)
{
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
yydestruct (yystos[*yyssp], yyvsp);
YYPOPSTACK;
}
YYABORT;
}
YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
yydestruct (yytoken, &yylval);
yychar = YYEMPTY;
}
/* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab2;
/*----------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action. |
`----------------------------------------------------*/
yyerrlab1:
/* Suppress GCC warning that yyerrlab1 is unused when no action
invokes YYERROR. */
#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
__attribute__ ((__unused__))
#endif
goto yyerrlab2;
/*---------------------------------------------------------------.
| yyerrlab2 -- pop states until the error token can be shifted. |
`---------------------------------------------------------------*/
yyerrlab2:
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (yyn != YYPACT_NINF)
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
YYABORT;
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
yydestruct (yystos[yystate], yyvsp);
yyvsp--;
yystate = *--yyssp;
YY_STACK_PRINT (yyss, yyssp);
}
if (yyn == YYFINAL)
YYACCEPT;
YYDPRINTF ((stderr, "Shifting error token, "));
*++yyvsp = yylval;
yystate = yyn;
goto yynewstate;
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
#ifndef yyoverflow
/*----------------------------------------------.
| yyoverflowlab -- parser overflow comes here. |
`----------------------------------------------*/
yyoverflowlab:
yyerror ("parser stack overflow");
yyresult = 2;
/* Fall through. */
#endif
yyreturn:
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif
return yyresult;
}
int yyerror(const char* errstr)
{
// Errors created by yacc generated code
//yyerror ("syntax error: cannot back up");
//yyerror ("syntax error; also virtual memory exhausted");
//yyerror ("syntax error");
//yyerror ("parser stack overflow");
USES_CONVERSION;
_astrParserErrors.Add(A2CT(errstr));
return EXIT_FAILURE;
}
#ifdef _UNICODE
int yyerror(LPCTSTR errstr)
{
_astrParserErrors.Add(errstr);
return EXIT_FAILURE;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -