freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

編譯原理課程設(shè)計--c-編譯器詞法分析與語法分析的實現(xiàn)-資料下載頁

2025-06-04 12:19本頁面
  

【正文】 || (token == EQ) || (token == NEQ)) { TreeNode * p = newExpNode(OpK)。 if(p!=NULL) { p child[0] = t。 p = token。 t = p。 } match(token)。 if(t != NULL) tchild[1] = additive_expression()。 } return t。 } TreeNode * additive_expression(void) { TreeNode * t = term()。 // fprintf(listing,\nits addi time\n)。 // fprintf(listing,\n+++++%s+++++\n,tokenString)。 while( (token == PLUS) || (token == MINUS) ) { TreeNode * p = newExpNode(OpK)。 if( p != NULL ) { pchild[0] = t。 p = token。 t = p。 match(token)。 tchild[1] = term()。 } } return t。 } TreeNode * term(void) { TreeNode * t = factor()。 // fprintf(listing,\nits term time\n)。 // fprintf(listing,\n+++++%s+++++\n,tokenString)。 while( (token == TIMES) || (token == OVER) ) { TreeNode * p = newExpNode(OpK)。 if( p != NULL ) { pchild[0] = t。 p = token。 t = p。 match(token)。 tchild[1] = factor()。 } } return t。 } TreeNode * factor(void) {//還有這里是個難點,很糾結(jié),最后去網(wǎng)上借鑒了一下,才把 call 給去掉 char * varToken。 TreeNode * t = NULL。 /// fprintf(listing,\nits fact time\n)。 // fprintf(listing,\n+++++%s+++++\n,tokenString)。 switch(token) { case NUM: t = newExpNode(ConstK)。 if( (t!=NULL) amp。amp。 (token==NUM) ) { t = atoi(tokenString)。 } match(NUM)。 break。 case LPAREN_3: match(LPAREN_3)。 t = expression()。 match(RPAREN_3)。 break。 case ID: varToken = copyString(tokenString)。 match(ID)。 switch(token) { case LPAREN_3: t = newExpNode(CallK)。 t = copyString(varToken)。 match(LPAREN_3)。 t child[0] = args()。 match(RPAREN_3)。 break。 case LPAREN_2: t = newExpNode(IdK)。 match(LPAREN_2)。 t = copyString(varToken)。 t child[0] = expression()。 match(RPAREN_2)。 break。 default: t = newExpNode(IdK)。 t = copyString(varToken)。 break。 } break。 default: syntaxError(unexprected token in facor )。 printToken(token ,tokenString)。 token = getToken()。 break。 } return t。 } TreeNode * args(void) { TreeNode * t = NULL。 // fprintf(listing,\nits args time\n)。 // fprintf(listing,\n+++++%s+++++\n,tokenString)。 if(token != RPAREN_3) t = arg_list()。 return t。 } TreeNode * arg_list(void) { TreeNode * t = expression()。 TreeNode * p = t。 // fprintf(listing,\nits arg_l time\n)。 // fprintf(listing,\n+++++%s+++++\n,tokenString)。 while(token == COM) { TreeNode * q。 match(COM)。 q = expression()。 if(q != NULL) { if( t == NULL) t = p = q。 else { psibling = q。 p = q。 } } } return t。 } 、輸出與結(jié)點的建立(在 ) 其中部分代碼因為參照附錄 B 中內(nèi)容而未修改,所以略去。 void printToken( TokenType token, const char* tokenString ) {//printToken和 printTree的修改很簡單,直接根據(jù) C 的 token和結(jié)點類型來判斷輸出就行 switch(token) { case IF: case ELSE: case INT: case RETURN: case VOID: case WHILE: fprintf(listing, reserved word: %s,tokenString )。 break。 case RPAREN_3: fprintf(listing,))。 break。 case LPAREN_3: fprintf(listing,()。 break。 case RPAREN_2: fprintf(listing,])。 break。 case LPAREN_2: fprintf(listing,[)。 break。 case COM: fprintf(listing,)。 break。 case SEMI: fprintf(listing,。)。 break。 case RPAREN_1: fprintf(listing,})。 break。 case LPAREN_1: fprintf(listing,{)。 break。 case NEQ: fprintf(listing,!=)。 break。 case EQ: fprintf(listing,==)。 break。 case BET: fprintf(listing,=)。 break。 case BT: fprintf(listing,)。 break。 case LET: fprintf(listing,=)。 break。 case LT: fprintf(listing,)。 break。 case OVER: fprintf(listing,/)。 break。 case TIMES: fprintf(listing,*)。 break。 case MINUS: fprintf(listing,)。 break。 case PLUS: fprintf(listing,+)。 break。 case ASSIGN: fprintf(listing,=)。 break。 case ENDFILE: fprintf(listing,EOF)。 break。 case NUM: fprintf(listing,NUM, val= %s,tokenString)。 break。 case ID: fprintf(listing,ID, name= %s, tokenString)。 break。 case ERROR: fprintf(listing,ERROR: %s,tokenString)。 break。 default: fprintf(listing,Unknown token: %d, token)。 } } void printTree( TreeNode * tree ) { int i。 INDENT。 while (tree != NULL) { printSpaces()。 if (treenodekind==StmtK) { switch (tree) { case IterationK: fprintf(listing,While:\n)。 break。 case SelectionK: fprintf(listing,Selection:\n)。 break。 case CompoundK: fprintf(listing,Compound:\n)。 break。 case ReturnK: fprintf(listing,Return:\n)。 break。 case ExpressionK: fprintf(listing,Expression:\n)。 break。 default: fprintf(listing,Unknown ExpNode statement kind\n)。 break。 } } else if (treenodekind==ExpK) { switch (tree) { case OpK: fprintf(listing,Op: )。 printToken(tree,\0)。 break。 case ConstK: fprintf(listing,Const: %d\n,tree)。 break。 case IdK: fprintf(listing,Id: %s\n,tree)。 break。 case CallK: fprintf(listing,call: %s\n,tree)。 break。 default: fprintf(listing,Unknown ExpNode expression kind\n)。 break。 } } else if (treenodekind == DecK) { switch(tree) { case VarK: fprintf(listing,Var_dec: )。 fprintf(listing, %s\n,tree)。 break。 case ArrayK: fprintf(listing,Array_dec: )。 fprintf(listing, %s\n,tree)。 case FunK: fprintf(listing,Fun_dec: )。 fprintf(listing, %s\n,tree)。 break。 default: fprintf(listing,Unknown declaration kind\n)。 break。 } } else if (treenodekind == ParamK) { switch(tree) { case Var: fprintf(listin
點擊復(fù)制文檔內(nèi)容
畢業(yè)設(shè)計相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1