y_attr.cpp
来自「Pegasus is an open-source implementation」· C++ 代码 · 共 1,414 行 · 第 1/3 页
CPP
1,414 行
{ yyval._atl = lslpAllocAttr(yyvsp[-1]._s, tag, NULL, 0); if (NULL != yyval._atl) { _LSLP_INSERT_BEFORE(yyval._atl, &inProcessAttr); } ; break;}case 5:#line 119 "attr.y"{ yyval._atl = lslpAllocAttr(yyvsp[-2]._s, tag, NULL, 0); if (NULL != yyval._atl) { _LSLP_INSERT_BEFORE(yyval._atl, &inProcessAttr); } ; break;}case 6:#line 127 "attr.y"{ yyval._atl = inProcessTag.next; while (! _LSLP_IS_HEAD(yyval._atl)) { yyval._atl->name = strdup(yyvsp[-3]._s); _LSLP_UNLINK(yyval._atl); _LSLP_INSERT_BEFORE(yyval._atl, &inProcessAttr); yyval._atl = inProcessTag.next; } ; break;}case 7:#line 139 "attr.y"{ if(NULL != yyvsp[0]._atl) { _LSLP_INSERT(yyvsp[0]._atl, &inProcessTag); } ; break;}case 8:#line 146 "attr.y"{ if (NULL != yyvsp[0]._atl) { _LSLP_INSERT_BEFORE(yyvsp[0]._atl, &inProcessTag); } ; break;}case 9:#line 153 "attr.y"{ yyval._atl = lslpAllocAttr(NULL, bool_type, &bt, sizeof(BOOL)); ; break;}case 10:#line 156 "attr.y"{ yyval._atl = lslpAllocAttr(NULL, bool_type, &bf, sizeof(BOOL)); ; break;}case 11:#line 159 "attr.y"{ yyval._atl = lslpAllocAttr(NULL, opaque, yyvsp[0]._s, (int16)(strlen(yyvsp[0]._s) + 1)); ; break;}case 12:#line 162 "attr.y"{ if(strlen(yyvsp[0]._s) > 5 ) { if( *(yyvsp[0]._s) == '\\' && ((*(yyvsp[0]._s + 1) == 'f') || (*(yyvsp[0]._s + 1) == 'F')) && ((*(yyvsp[0]._s + 2) == 'f') || (*(yyvsp[0]._s + 2) == 'F'))) { yyval._atl = lslpAllocAttr(NULL, opaque, yyvsp[0]._s, (int16)(strlen(yyvsp[0]._s) + 1)); } else { yyval._atl = lslpAllocAttr(NULL, string, yyvsp[0]._s, (int16)(strlen(yyvsp[0]._s) + 1)); } } else { yyval._atl = lslpAllocAttr(NULL, string, yyvsp[0]._s, (int16)(strlen(yyvsp[0]._s) + 1)); } ; break;}case 13:#line 176 "attr.y"{ yyval._atl = lslpAllocAttr(NULL, integer, &(yyvsp[0]._i), sizeof(int32)); ; break;}}#line 705 "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 181 "attr.y"void _lslpInitInternalAttrList(void){ attrHead.next = attrHead.prev = &attrHead; attrHead.isHead = TRUE; inProcessAttr.next = inProcessAttr.prev = &inProcessAttr; inProcessAttr.isHead = TRUE; inProcessTag.next = inProcessTag.prev = &inProcessTag; inProcessTag.isHead = TRUE; return;}lslpAttrList *_lslpDecodeAttrString(char *s){ uint32 lexer = 0; lslpAttrList *temp = NULL; assert(s != NULL); _lslpInitInternalAttrList(); if (s != NULL) { if(NULL != (temp = lslpAllocAttrList())) { if ((0 != (lexer = attr_init_lexer(s))) && attrparse()) { lslpFreeAttrList(temp, TRUE); while (! _LSLP_IS_HEAD(inProcessTag.next)) { temp = inProcessTag.next; _LSLP_UNLINK(temp); lslpFreeAttr(temp); } while (! _LSLP_IS_HEAD(inProcessAttr.next)) { temp = inProcessAttr.next; _LSLP_UNLINK(temp); lslpFreeAttr(temp); } while (! _LSLP_IS_HEAD(attrHead.next)) { temp = attrHead.next; _LSLP_UNLINK(temp); lslpFreeAttr(temp); } attr_close_lexer(lexer); return(NULL); } if (! _LSLP_IS_EMPTY(&attrHead)) { temp->attr_string_len = strlen(s); temp->attr_string = (char *)malloc(temp->attr_string_len + 1); if(temp->attr_string != NULL) { memcpy(temp->attr_string, s, temp->attr_string_len); temp->attr_string[temp->attr_string_len] = 0x00; } _LSLP_LINK_HEAD(temp, &attrHead); } if(lexer != 0) attr_close_lexer(lexer); } } return(temp);}lslpAttrList *lslpAllocAttr(const char *name, char type, const void *val, int16 len){ lslpAttrList *attr; if (NULL != (attr = (lslpAttrList *)calloc(1, sizeof(lslpAttrList)))) { if (name != NULL) { if (NULL == (attr->name = strdup(name))) { free(attr); return(NULL); } } attr->type = type; if (type == head) /* listhead */ return(attr); if (val != NULL) { attr->attr_len = len; switch (type) { case string: if ( NULL != (attr->val.stringVal = strdup((const char *)val))) return(attr); break; case integer: attr->val.intVal = *(const uint32 *)val; break; case bool_type: attr->val.boolVal = *(const BOOL *)val; break; case opaque: if ( NULL != (attr->val.opaqueVal = strdup((const char *)val))) return(attr); break; default: break; } } } return(attr);}lslpAttrList *lslpAllocAttrList(void){ lslpAttrList *temp; if (NULL != (temp = lslpAllocAttr(NULL, head, NULL, 0))) { temp->next = temp->prev = temp; temp->isHead = TRUE; } return(temp);}/* attr MUST be unlinked from its list ! */void lslpFreeAttr(lslpAttrList *attr){ assert(attr != NULL); if (attr->name != NULL) free(attr->name); if(attr->attr_string != NULL) free(attr->attr_string); if (attr->type == string && attr->val.stringVal != NULL) free(attr->val.stringVal); else if (attr->type == opaque && attr->val.opaqueVal != NULL) free(attr->val.opaqueVal); free(attr);}void lslpFreeAttrList(lslpAttrList *list, BOOL staticFlag){ lslpAttrList *temp; assert(list != NULL); assert(_LSLP_IS_HEAD(list)); while(! (_LSLP_IS_EMPTY(list))) { temp = list->next; _LSLP_UNLINK(temp); lslpFreeAttr(temp); } if(staticFlag == TRUE) lslpFreeAttr(list); return;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?