📄 analysis.c.svn-base
字号:
case 6:#line 28 "sh.y" {cmd_flag=PIPE_CMD;resettoppipe();} break; case 7:#line 30 "sh.y" {} break; case 8:#line 32 "sh.y" {storepipe();reset();} break; case 10:#line 35 "sh.y" {storepipe();reset();} break; case 11:#line 37 "sh.y" {storepipe();reset();} break; case 12:#line 39 "sh.y" {} break; case 14:#line 42 "sh.y" {pushio();storefile();cmd_flag=REDIRECT_CMD;io_flag=FD_READ;} break; case 16:#line 45 "sh.y" {pushio();storefile();cmd_flag=REDIRECT_CMD;io_flag=FD_WRITE;} break; case 17:#line 47 "sh.y" {pushcmd();} break; case 19:#line 50 "sh.y" {pushpara();} break;/* Line 1267 of yacc.c. */#line 1395 "analysis.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; 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 yyerror (YY_("syntax error"));#else { YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) { YYSIZE_T yyalloc = 2 * yysize; if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) yyalloc = YYSTACK_ALLOC_MAXIMUM; if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yyalloc); if (yymsg) yymsg_alloc = yyalloc; else { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; } } if (0 < yysize && yysize <= yymsg_alloc) { (void) yysyntax_error (yymsg, yystate, yychar); yyerror (yymsg); } else { yyerror (YY_("syntax error")); if (yysize != 0) goto yyexhaustedlab; } }#endif } if (yyerrstatus == 3) { /* If just tried and failed to reuse look-ahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse look-ahead token after shifting the error token. */ goto yyerrlab1;/*---------------------------------------------------.| yyerrorlab -- error raised explicitly by YYERROR. |`---------------------------------------------------*/yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); 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; yydestruct ("Error: popping", yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } if (yyn == YYFINAL) YYACCEPT; *++yyvsp = yylval; /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate;/*-------------------------------------.| yyacceptlab -- YYACCEPT comes here. |`-------------------------------------*/yyacceptlab: yyresult = 0; goto yyreturn;/*-----------------------------------.| yyabortlab -- YYABORT comes here. |`-----------------------------------*/yyabortlab: yyresult = 1; goto yyreturn;#ifndef yyoverflow/*-------------------------------------------------.| yyexhaustedlab -- memory exhaustion comes here. |`-------------------------------------------------*/yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */#endifyyreturn: if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp); YYPOPSTACK (1); }#ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss);#endif#if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg);#endif /* Make sure YYID is used. */ return YYID (yyresult);}#line 53 "sh.y"char *backjobs="&";char *pipejobs="|";char *injobs="<";char *outjobs=">";char *stackpara[LEN];char *stackcmd[LEN];char *stackfile[LEN];char buf[100];char *p = buf;int lineno = 0;int topcmd = 0;int toppara=0;int topfile=0;int toppipe=0; /**********************************************************************************************************/ yylex(){ int c; p = buf; while((c = getchar()) == ' ' || c == '\t'); if(c == '\n'){ return 0; } if(c != '\n') { do { *p++ = c; c = getchar(); }while(c != ' ' && c != '\t' && c != '\n'); ungetc(c,stdin); *p = '\0'; yylval.sym = buf; if(!strcmp(buf,backjobs)) return '&'; else if(!strcmp(buf,injobs)) return '<'; else if(!strcmp(buf,outjobs)) return '>'; else if(!strcmp(buf,pipejobs)) return '|'; else return String; } else { lineno ++; } return c;} /**********************************************************************************************************/ yyerror(char *s){ warning(s, (char *)0);} /**********************************************************************************************************/ warning(char *s,char *t){ } /**********************************************************************************************************/ reset(){ int i; for(i = 0; i < topcmd; i++) { free(stackcmd[i]); stackcmd[i] = NULL; } topcmd = 0; for(i = 0; i < toppara; i++) { free(stackpara[i]); stackpara[i] = NULL; } toppara=0; for(i=0;i<topfile;i++){ free(stackfile[i]); stackfile[i]=NULL; } topfile=0;} /**********************************************************************************************************/ pushcmd(){ char *temp = NULL; if(topcmd == 0) temp = (char *)malloc(sizeof(char) * 10); else temp = (char *)malloc(strlen(buf) + 1); strcpy(temp,buf); stackcmd[topcmd] = temp; topcmd++;} /**********************************************************************************************************/ pushpara(){ char *temp = NULL; if(toppara == 0) temp = (char *)malloc(sizeof(char) * 30); else temp = (char *)malloc(strlen(buf) + 1); strcpy(temp,buf); stackpara[toppara] = temp; toppara++;} /**********************************************************************************************************/ pushio(){ char *temp = NULL; if(topfile == 0) temp = (char *)malloc(sizeof(char) * 30); else temp = (char *)malloc(strlen(buf) + 1); strcpy(temp,buf); stackfile[topfile] = temp; topfile++;} /**********************************************************************************************************/ storesimple(){ int i=0; if(topcmd) { cmdStr.cmd=(char *)malloc(sizeof(char) * 10); strcpy(cmdStr.cmd,stackcmd[0]); } for(i=0;i<toppara;i++){ cmdStr.para[i]=(char *)malloc(sizeof(char) * 10); strcpy(cmdStr.para[i],stackpara[i]); cmdStr.para[i+1]=NULL; }}/**********************************************************************************************************/storefile(){ cmdStr.filename=(char*)malloc(sizeof(char)*50); strcpy(cmdStr.filename,stackfile[0]); } /**********************************************************************************************************/ storepipe(){ int i=0; if(topcmd) { pipeStr[toppipe].cmd=(char *)malloc(sizeof(char) * 10); strcpy(pipeStr[toppipe].cmd,stackcmd[0]); } for(i=0;i<toppara;i++){ pipeStr[toppipe].para[i]=(char *)malloc(sizeof(char) * 10); strcpy(pipeStr[toppipe].para[i],stackpara[i]); } if(stackfile[0]!=NULL){ pipeStr[toppipe].filename=(char *)malloc(sizeof(char) * 50); strcpy(pipeStr[toppipe].filename,stackfile[0]); } pipeStr[toppipe].io_flag = io_flag; io_flag = NO_IO; toppipe++; pipe_len=toppipe;}/****************************************************************************************************************/resettoppipe(){toppipe=0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -