imp.c
来自「db.* (pronounced dee-be star) is an adva」· C语言 代码 · 共 1,636 行 · 第 1/3 页
C
1,636 行
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 3:#line 58 "imp.y" { int i; /* open up the database and read in the ddl tables */ vtstrcpy( imp_g.dbname, yyvsp[-1].tstr.str ); d_on_opt( READNAMES, imp_g.dbtask ); if ( d_open_sg( imp_g.dbname, DB_TEXT("o"), imp_g.sg, imp_g.dbtask ) != S_OKAY ) { dbimp_abort( DB_TEXT("unable to open database\n") ); return 1; } /* allocate space for the 'current record' table */ imp_g.currecs = (DB_ADDR *)calloc( imp_g.dbtask->size_rt, sizeof(DB_ADDR) ); if ( imp_g.currecs == NULL ) { dbimp_abort( DB_TEXT("out of memory\n") ); return 1; } for ( i=0; i<imp_g.dbtask->size_rt; i++ ) imp_g.currecs[i] = (DB_ADDR)-1L; } break; case 8:#line 89 "imp.y" { /* a for loop has been fully recognized, terminate the definition */ imp_g.loop_lvl--; imp_g.curspec->sp_next = new_spec( ENDLOOP ); if (imp_g.curspec->sp_next == NULL) return 1; imp_g.curspec = imp_g.curspec->sp_next; imp_g.curspec->u.sp_endptr = new_end( imp_g.curloop[imp_g.loop_lvl] ); if (imp_g.curspec->u.sp_endptr == NULL) return 1; } break; case 9:#line 101 "imp.y" { dderror( DB_TEXT("error in 'foreach' statment"), yyvsp[-2].tnum.numline ); } break; case 10:#line 106 "imp.y" { /* create a new for loop specification, linked into the list */ if (imp_g.specstart == NULL) { imp_g.specstart = new_spec( LOOP ); if (imp_g.specstart == NULL) return 1; imp_g.curspec = imp_g.specstart; } else { imp_g.curspec->sp_next = new_spec( LOOP ); if (imp_g.curspec->sp_next == NULL) return 1; imp_g.curspec = imp_g.curspec->sp_next; } /* start a new loop at the next level */ imp_g.curspec->u.sp_looptr = new_loop( yyvsp[-1].tstr.str ); if (imp_g.curspec->u.sp_looptr == NULL) return 1; imp_g.curloop[imp_g.loop_lvl] = imp_g.curspec; imp_g.loop_lvl++; } break; case 16:#line 139 "imp.y" { /* link in the start of a record specification */ if (imp_g.specstart == NULL) { imp_g.specstart = new_spec( RECORD ); if (imp_g.specstart == NULL) return 1; imp_g.curspec = imp_g.specstart; } else { imp_g.curspec->sp_next = new_spec( RECORD ); if (imp_g.curspec->sp_next == NULL) return 1; imp_g.curspec = imp_g.curspec->sp_next; } /* locate the record type */ imp_g.curspec->u.sp_recptr = new_rec( yyvsp[-2].tnum.num, imp_g.hlist, imp_g.fldlist ); if (imp_g.curspec->u.sp_recptr == NULL) return 1; imp_g.curspec->u.sp_recptr->rec_ndx = imp_g.recndx; if ( imp_g.curspec->u.sp_recptr->rec_ndx < 0 ) { vftprintf(stderr, DB_TEXT("**WARNING** record name '%s' not found in schema\n"), yyvsp[-3].tstr.str); imp_g.tot_warnings++; } /* initialize the field and handling list headers */ imp_g.fldlist = NULL; imp_g.hlist = NULL; } break; case 17:#line 174 "imp.y" { dderror( DB_TEXT("invalid record spec"), yyvsp[-2].tnum.numline ); } break; case 18:#line 179 "imp.y" { /* save the record type name */ vtstrcpy(yyval.tstr.str, yyvsp[-1].tstr.str); imp_g.recndx = getrec(yyvsp[-1].tstr.str, imp_g.dbtask); } break; case 19:#line 185 "imp.y" { dderror( DB_TEXT("invalid record spec"), yyvsp[-2].tnum.numline ); } break; case 20:#line 190 "imp.y" { yyval.tnum.num = DBIMP_AUTO; } break; case 21:#line 192 "imp.y" { yyval.tnum.num = DBIMP_UPDATE; } break; case 22:#line 194 "imp.y" { yyval.tnum.num = DBIMP_CREATE; } break; case 23:#line 196 "imp.y" { yyval.tnum.num = DBIMP_FIND; } break; case 27:#line 205 "imp.y" { /* the handling list is only one element now */ imp_g.hlist = new_hand( imp_g.curloop[imp_g.loop_lvl-1]->u.sp_looptr->l_fname, yyvsp[0].tnum.num ); if (imp_g.hlist == NULL) return 1; } break; case 30:#line 216 "imp.y" { imp_g.fldlist = NULL; } break; case 33:#line 224 "imp.y" { imp_g.newfld->fld_next = imp_g.fldlist; imp_g.fldlist = imp_g.newfld; } break; case 34:#line 229 "imp.y" { dderror( DB_TEXT("bad field specification"), yyvsp[-2].tnum.numline ); } break; case 35:#line 234 "imp.y" { /* create the field structure, with zero offset */ imp_g.newfld = new_fld( DB_TEXT(""), NULL, 0, yyvsp[-1].tstr.str, dim[0], dims[0] ); if (imp_g.newfld == NULL) return 1; } break; case 36:#line 241 "imp.y" { /* create the field structure, with offset for subscript */ imp_g.newfld = new_fld( yyvsp[-4].tstr.str, dim[0], dims[0], yyvsp[-1].tstr.str, dim[1], dims[1] ); if (imp_g.newfld == NULL) return 1; } break; case 37:#line 249 "imp.y" { fsinit = -1; } break; case 40:#line 257 "imp.y" { int i; fsinit++; dims[fsinit] = 0; for ( i=0; i<MAXDIMS; i++ ) dim[fsinit][i] = 0; } break; case 43:#line 268 "imp.y" { if ( dims[fsinit] >= MAXDIMS ) dderror( DB_TEXT("too many dimensions"), yyvsp[-1].tnum.numline ); else dim[fsinit][dims[fsinit]++] = yyvsp[-1].tnum.num; } break; case 44:#line 276 "imp.y" { /* assume that this number refers to the current file */ vtstrcpy( imp_g.newfld->fld_file, imp_g.curloop[imp_g.loop_lvl-1]->u.sp_looptr->l_fname ); imp_g.newfld->fld_name = yyvsp[0].tnum.num; } break; case 45:#line 282 "imp.y" { /* save the explicit file name and number */ vtstrcpy( imp_g.newfld->fld_file, yyvsp[-2].tstr.str ); imp_g.newfld->fld_name = yyvsp[0].tnum.num; } break; case 46:#line 289 "imp.y" { /* save the connect specification on the list */ imp_g.curspec->sp_next = new_spec( CONNECT ); if (imp_g.curspec->sp_next == NULL) return 1; imp_g.curspec = imp_g.curspec->sp_next; imp_g.curspec->u.sp_conptr = new_con(); if (imp_g.curspec->u.sp_conptr == NULL) return 1; imp_g.curspec->u.sp_conptr->con_ndx = getset( yyvsp[-1].tstr.str, imp_g.dbtask ); if ( imp_g.curspec->u.sp_conptr->con_ndx < 0 ) { vftprintf(stderr, DB_TEXT("**WARNING** set '%s' not found in schema\n"), yyvsp[-1].tstr.str); imp_g.tot_warnings++; } } break; case 47:#line 308 "imp.y" { dderror( DB_TEXT("invalid connect spec"), yyvsp[-2].tnum.numline ); } break; case 48:#line 313 "imp.y" { d_close(imp_g.dbtask); } break; case 49:#line 317 "imp.y" { d_close(imp_g.dbtask); } break; }/* Line 1000 of yacc.c. */#line 1408 "imp.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); const char* yyprefix; char *yymsg; int yyx; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yycount = 0; yyprefix = ", expecting "; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); yycount += 1; if (yycount == 5) { yysize = 0; break; } } yysize += (sizeof ("syntax error, unexpected ") + 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) { yyprefix = ", expecting "; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { yyp = yystpcpy (yyp, yyprefix); yyp = yystpcpy (yyp, yytname[yyx]); yyprefix = " or "; } } 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. */ if (yychar <= YYEOF) { /* If at end of input, pop the error token, then the rest of the stack, then return failure. */ if (yychar == YYEOF) for (;;) { YYPOPSTACK; if (yyssp == yyss) YYABORT; YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); yydestruct (yystos[*yyssp], yyvsp); } } else { YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); yydestruct (yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1;/*---------------------------------------------------.| yyerrorlab -- error raised explicitly by YYERROR. |`---------------------------------------------------*/yyerrorlab:#ifdef __GNUC__ /* Pacify GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (0) goto yyerrorlab;#endif yyvsp -= yylen; yyssp -= yylen; yystate = *yyssp; goto yyerrlab1;/*-------------------------------------------------------------.| yyerrlab1 -- common code for both syntax error and YYERROR. |`-------------------------------------------------------------*/yyerrlab1: 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); YYPOPSTACK; 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. */#endifyyreturn:#ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss);#endif return yyresult;}#line 321 "imp.y"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?