📄 cql.c
字号:
case 4:#line 62 "cql.y"{ cql_node_destroy(yyvsp[-1].cql); yyval.cql = 0;} break;case 6:#line 71 "cql.y"{ yyval.rel = yyvsp[-2].rel; } break;case 7:#line 73 "cql.y"{ struct cql_node *cn = cql_node_mk_boolean(yyvsp[-2].buf); cn->u.boolean.modifiers = yyvsp[-2].rel; cn->u.boolean.left = yyvsp[-3].cql; cn->u.boolean.right = yyvsp[0].cql; yyval.cql = cn; } break;case 8:#line 85 "cql.y"{ yyval.rel = yyvsp[-1].rel; } break;case 9:#line 88 "cql.y"{ yyval.cql = yyvsp[-1].cql; } break;case 10:#line 92 "cql.y"{ struct cql_node *st = cql_node_dup (yyvsp[-1].rel); st->u.st.term = strdup(yyvsp[0].buf); yyval.cql = st; } break;case 11:#line 98 "cql.y"{ yyval.rel = yyvsp[0].rel; yyval.rel->u.st.index = strdup(yyvsp[-1].buf); } break;case 12:#line 101 "cql.y"{ yyval.cql = yyvsp[0].cql; cql_node_destroy(yyvsp[-2].rel); } break;case 13:#line 105 "cql.y"{ yyval.rel = yyvsp[-4].rel; } break;case 14:#line 107 "cql.y"{ yyval.cql = cql_node_prefix(yyvsp[0].cql, yyvsp[-4].buf, yyvsp[-2].buf); } break;case 15:#line 110 "cql.y"{ yyval.rel = yyvsp[-2].rel; } break;case 16:#line 112 "cql.y"{ yyval.cql = cql_node_prefix(yyvsp[0].cql, 0, yyvsp[-2].buf); } break;case 20:#line 120 "cql.y"{ yyval = yyvsp[-1]; yyval.rel = yyvsp[0].rel; } break;case 21:#line 127 "cql.y"{ yyval.rel = cql_node_mk_proxargs (yyvsp[0].buf, 0, 0, 0); } break;case 22:#line 131 "cql.y"{ yyval.rel = cql_node_mk_proxargs (yyvsp[-1].buf, yyvsp[0].buf, 0, 0); } break;case 23:#line 135 "cql.y"{ yyval.rel = cql_node_mk_proxargs (yyvsp[-2].buf, yyvsp[-1].buf, yyvsp[0].buf, 0); } break;case 24:#line 139 "cql.y"{ yyval.rel = cql_node_mk_proxargs (yyvsp[-3].buf, yyvsp[-2].buf, yyvsp[-1].buf, yyvsp[0].buf); } break;case 25:#line 143 "cql.y"{ yyval.rel = 0; } break;case 26:#line 146 "cql.y"{ yyval = yyvsp[0]; } break;case 27:#line 151 "cql.y"{ yyval = yyvsp[0]; } break;case 28:#line 155 "cql.y"{ yyval.buf[0] = 0; } break;case 29:#line 157 "cql.y"{ yyval = yyvsp[0];} break;case 30:#line 161 "cql.y"{ yyval = yyvsp[0];} break;case 31:#line 164 "cql.y"{ yyval.buf[0] = 0; } break;case 32:#line 166 "cql.y"{ yyval = yyvsp[0];} break;case 33:#line 171 "cql.y"{ yyval = yyvsp[0];} break;case 34:#line 174 "cql.y"{ yyval.buf[0] = 0; } break;case 35:#line 176 "cql.y"{ yyval = yyvsp[0];} break;case 36:#line 181 "cql.y"{ struct cql_node *st = cql_node_mk_sc(/* index */ 0, /* relation */ yyvsp[-1].buf, /* term */ 0); st->u.st.modifiers = yyvsp[0].cql; yyval.rel = st;} break;case 37:#line 192 "cql.y"{ struct cql_node *mod = cql_node_mk_mod(0, yyvsp[-1].buf); mod->u.mod.next = yyvsp[0].cql; yyval.cql = mod;} break;case 38:#line 199 "cql.y"{ yyval.cql = 0;} break;}#line 705 "/usr/share/bison/bison.simple" yyvsp -= yylen; yyssp -= yylen;#if YYLSP_NEEDED yylsp -= yylen;#endif#if YYDEBUG if (yydebug) { short *yyssp1 = yyss - 1; YYFPRINTF (stderr, "state stack now"); while (yyssp1 != yyssp) YYFPRINTF (stderr, " %d", *++yyssp1); YYFPRINTF (stderr, "\n"); }#endif *++yyvsp = yyval;#if YYLSP_NEEDED *++yylsp = yyloc;#endif /* 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 - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate;/*------------------------------------.| yyerrlab -- here on detecting error |`------------------------------------*/yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs;#ifdef YYERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { YYSIZE_T yysize = 0; 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) yysize += yystrlen (yytname[yyx]) + 15, yycount++; yysize += yystrlen ("parse error, unexpected ") + 1; yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { char *yyp = yystpcpy (yymsg, "parse error, unexpected "); yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); if (yycount < 5) { yycount = 0; for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx) { const char *yyq = ! yycount ? ", expecting " : " or "; yyp = yystpcpy (yyp, yyq); yyp = yystpcpy (yyp, yytname[yyx]); yycount++; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else yyerror ("parse error; also virtual memory exhausted"); } else#endif /* defined (YYERROR_VERBOSE) */ yyerror ("parse error"); } goto yyerrlab1;/*--------------------------------------------------.| yyerrlab1 -- error raised explicitly by an action |`--------------------------------------------------*/yyerrlab1: 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) YYABORT; YYDPRINTF ((stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1])); yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ goto yyerrhandle;/*-------------------------------------------------------------------.| yyerrdefault -- current state does not do anything special for the || error token. |`-------------------------------------------------------------------*/yyerrdefault:#if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ /* If its default is to accept any token, ok. Otherwise pop it. */ yyn = yydefact[yystate]; if (yyn) goto yydefault;#endif/*---------------------------------------------------------------.| yyerrpop -- pop the current state because it cannot handle the || error token |`---------------------------------------------------------------*/yyerrpop: if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp;#if YYLSP_NEEDED yylsp--;#endif#if YYDEBUG if (yydebug) { short *yyssp1 = yyss - 1; YYFPRINTF (stderr, "Error: state stack now"); while (yyssp1 != yyssp) YYFPRINTF (stderr, " %d", *++yyssp1); YYFPRINTF (stderr, "\n"); }#endif/*--------------.| yyerrhandle. |`--------------*/yyerrhandle: yyn = yypact[yystate]; if (yyn == YYFLAG) goto yyerrdefault; yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) goto yyerrdefault; yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) goto yyerrpop; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; YYDPRINTF ((stderr, "Shifting error token, ")); *++yyvsp = yylval;#if YYLSP_NEEDED *++yylsp = yylloc;#endif yystate = yyn; goto yynewstate;/*-------------------------------------.| yyacceptlab -- YYACCEPT comes here. |`-------------------------------------*/yyacceptlab: yyresult = 0; goto yyreturn;/*-----------------------------------.| yyabortlab -- YYABORT comes here. |`-----------------------------------*/yyabortlab: yyresult = 1; goto yyreturn;/*---------------------------------------------.| yyoverflowab -- parser overflow comes here. |`---------------------------------------------*/yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */yyreturn:#ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss);#endif return yyresult;}#line 225 "cql.y"int yyerror(char *s){ return 0;}#include "lexer.c"int cql_parser_stream(CQL_parser cp, int (*getbyte)(void *client_data), void (*ungetbyte)(int b, void *client_data), void *client_data){ cp->getbyte = getbyte; cp->ungetbyte = ungetbyte; cp->client_data = client_data; if (cp->top) cql_node_destroy(cp->top); cql_parse(cp); if (cp->top) return 0; return -1;}CQL_parser cql_parser_create(void){ CQL_parser cp = (CQL_parser) malloc (sizeof(*cp)); cp->top = 0; cp->getbyte = 0; cp->ungetbyte = 0; cp->client_data = 0; cp->last_error = 0; cp->last_pos = 0; cp->nmem = nmem_create(); return cp;}void cql_parser_destroy(CQL_parser cp){ cql_node_destroy(cp->top); nmem_destroy(cp->nmem); free (cp);}struct cql_node *cql_parser_result(CQL_parser cp){ return cp->top;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -