【正文】
函數(shù),完成顯示功能 CODE: (0L,LVS_SHOWSELALWAYS)。 m_RecordsetPtr=(strSQL)。 ()。 程序死循環(huán)的中斷處理算法 考試類型與評(píng)卷算法的描述 在設(shè)計(jì)這個(gè)算法時(shí),為便于機(jī)器閱卷 , 本文中對(duì)試卷類型的要求做出以下規(guī)定: (1) 源程序中主程序與所有子程序均存入同一文件且只能取規(guī)定的文件名 。為了避免因考生的被評(píng)程序中可能含有死循環(huán)而使評(píng)卷無(wú)法繼續(xù) , 算法中采取了修改定時(shí)中斷的方法。其中主 循環(huán)又嵌有一個(gè)子循環(huán) , 它用于對(duì)同一個(gè)考生的各道題評(píng)分。 而中斷服務(wù)子程序 HANDL ER 用來(lái)檢查考生的被評(píng)程序相應(yīng)進(jìn)程已持續(xù)運(yùn)行的時(shí)間 , 若超過(guò)限度 , 則立即終止該被評(píng)程序相應(yīng)進(jìn)程 , 返回評(píng)卷程序。 //3 關(guān)中斷 3 246。 if (count= 5460)//3 已達(dá) 5 分鐘 , 中斷 1092 次約 1 分鐘 3 246。//3 連接到原 8 號(hào)中斷 3 } 界面設(shè)計(jì)風(fēng)格說(shuō)明 為了模擬 VC++ 的風(fēng)格,本程序使用了當(dāng)前比較流行的界面庫(kù) ,并修改了CrystalView 的高亮顯示方式, 仿照著名的 linux下的編輯工具 emacs 進(jìn)行開(kāi)發(fā)。 圖 評(píng)分完成圖 圖 評(píng)分成績(jī)查看界面 程序的調(diào)試 由于本系統(tǒng)的核心為對(duì) C語(yǔ)言源程序進(jìn)行解析,得到其錯(cuò)誤數(shù)目與 錯(cuò)誤類型。從檢測(cè)結(jié)果上看,本系統(tǒng)能夠正確地判斷所有 C 語(yǔ)言單純的語(yǔ)法、詞法、類型匹配等錯(cuò)誤,并準(zhǔn)確地給出得分功能強(qiáng)大。通過(guò)大量測(cè)試完成了課題需要實(shí)現(xiàn)的所有功能。在日后的工作學(xué)習(xí)中,將結(jié)合人工智能等相關(guān)算法以改進(jìn)本系統(tǒng)中的評(píng)分算法,務(wù)求更加完善。 and they sang before him, and he was glad. But for a long while they sang only each alone, or but few together, while the rest hearkened。 Then the voices of the Ainur, like unto harps and lutes, and pipes and trumpets, and viols and ans, and like unto countless choirs singing with words, began to fashion the theme of Il 鷙 atar to a great music。 and he lifted up his left hand, and a new theme began amid the storm, like and yet unlike to the former theme, and it gathered power and had new beauty. But the discord of Melkor rose in uproar and contended with it, and again there was a war of sound more violent than before, until many of the Ainur were dismayed and。 for desire grew hot within him to br ing into Being things of his own, and it seemed to him that Il 鷙 atar took no thought for the Void, and he was impatient of its emptiness. Yet he found not the Fire, for it is w ith I l 鷙 atar. But being alone he had begun to conceive thoughts of his own unlike those of his brethren. Some of these thoughts he now wove into his music, and straightway discord arose about him, and many that sang nigh him grew despondent, and their thought was disturbed and their music faltered。 and the glory of its beginning and the splendour of its end amazed the Ainur, so that they bowed before Il 鷙 atar and were silent. Then Il 鷙 atar said to them: 39。 Christopher Tolkien AINULINDAL? The Music of the Ainur There was Eru, the One, who in Arda is called Il 鷙 atar。智能系統(tǒng)自動(dòng)系統(tǒng)的運(yùn)行往往是遵循一定算法的,這樣就不可能做到由人操作時(shí)的精準(zhǔn),與人性化。 6. 結(jié)論與展望 本文中所設(shè)計(jì)的編程考試機(jī)器評(píng)卷系統(tǒng)能夠自動(dòng)地對(duì) C 語(yǔ)言編程考試的源程序進(jìn)行解析,模擬 VC++ 的設(shè)計(jì)風(fēng)格,鈕邊框規(guī)范統(tǒng)一,顏色淡雅、清爽,整體有新穎感。因此,程序調(diào)試的主要任務(wù)為,調(diào)試 C 語(yǔ)言程序中的錯(cuò)誤是否能夠正確地被檢測(cè)出來(lái)。 5. 程序的運(yùn)行與調(diào)試 程序的運(yùn)行 程序運(yùn)行后打開(kāi)需要評(píng)閱的 C語(yǔ)言源程序的主界面如下圖: 圖 程序主界面 用戶選擇好需要評(píng)閱的程序后, C語(yǔ)言源程序會(huì)顯示在系統(tǒng)的主界面上,關(guān)鍵字高亮。 /*3 下面修改中斷服務(wù)程序的返回地址 , 為強(qiáng) 制終止被評(píng)進(jìn)程作準(zhǔn)備 3*/ asm { push bp push di push es mov bp, sp mov word p tr[bp+ 24 ], 0 push ax push bx mov ah, 62h int 21h mov di, bx pop bx pop ax mov [bp+ 26 ], di pop es pop di pop bp } } } enable () 。 { count+ + 。 本文采用了在 C 語(yǔ)言中直接嵌入?yún)R編指令的方法 [ 4 ]. 以下為修改后的 8 號(hào)中斷服務(wù)子程序。先檢查有無(wú)相應(yīng)的源程序 , 沒(méi)有 , 則記 0 分 , 否則進(jìn)行編譯、連接。 當(dāng)考生的一個(gè)程序被評(píng)分后 , 就可以對(duì)該考生的下一個(gè)程序或下一個(gè)考生開(kāi)始評(píng)分,算法的形式描述如下: BEGIN HANDL ER I← 1 WH IL E I≤考生人數(shù) DO BEGIN 取第 I 個(gè)考生試題信息 SCORE← 0。 (3) 所有的輸出結(jié)果均按指定的格式存入一 個(gè)與試題相應(yīng)的文件中 1 對(duì)考生編制的每個(gè)源程序的分析過(guò)程包括編譯、連接、運(yùn)行和按結(jié)果評(píng)分。 (j, FieldName, LVCFMT_CENTER, 150)。jm_RecordsetPtrGetFields()GetCount()。 //從成員詳細(xì)表讀出字段名稱到列表控件中; CString strSQL,FieldName。 ()。 for(int i=0。 } for(int n=0。 rstMoveFirst()。 CString FieldName。 成績(jī)查看功能 圖 評(píng)分成績(jī)的查看界面 上圖為評(píng)分成績(jī)的查看界面,用列表的方式將數(shù)據(jù)庫(kù)中的題目對(duì)應(yīng)的分?jǐn)?shù)與評(píng)語(yǔ)現(xiàn)實(shí)給用戶。,39。 (insert into 成績(jī)表 values(39。 } return PY。amp。 } if (score90 amp。 if (score==100) PY = 非常不錯(cuò),請(qǐng)?jiān)俳釉賲枺?。評(píng)語(yǔ)的書(shū)寫(xiě)即完成這個(gè)數(shù)據(jù)分析的功能,使整個(gè)系統(tǒng)更加合理,體現(xiàn)出人性化設(shè)計(jì)。 redefinition, tlineno, (LPCTSTR)tszName )。 // add it to function declaration list ( t )。 因此實(shí)現(xiàn)時(shí)在系統(tǒng)的主線程文件 : CCProgrammeExaminationGradeSystemApp中增加一個(gè)整形的全局變量: int score,初始化為 100 分。 分?jǐn)?shù)的得出 在評(píng)分系統(tǒng)中分?jǐn)?shù)的得出是最為重要的部分,但不是最核心的部分。 類型檢測(cè): 類型檢測(cè)的功能是由 Class Canalyzer 來(lái)完成的, Canalyzer 包括兩個(gè)部分: ? 類型匹配: 函數(shù)或變量聲明時(shí)檢測(cè)是否已聲明,如已聲明則拋出錯(cuò)誤;函數(shù)調(diào)用或變量使用時(shí)檢測(cè)是否已聲明,如未聲明則拋出錯(cuò)誤。 符號(hào)表的建立也是由兩個(gè)主要類來(lái)實(shí)現(xiàn)的。amp。` 38. continue_stmt`continue` `。` | expression_stmt 32. if_stmt`if` `(` expression `)` pound_stmt 33. | `if` `(` expression `)` pound_stmt `else` pound_stmt 34. while_stmt`while` `(` expression `)` pound_stmt 35. for_stmt`for` `(` var `=` expression `。` | `。` 5. type_specifier`int` | `void` | `char`, actually this step is in declaration_list() 6. fun_declarationtype_specifier ID `(` params `)` pound_stmt 7. paramsparam_list | `void` | empty, `void` is thought as empty 8. param_listparam_list `,` param | param 9. paramtype_specifier ID | type_specifier ID `[` `]` 10. pound_stmt`{` loal_declarations statement_list `}` | expression_stmt 11. local_declarationslocal_declarations var_declaration | var_declaration 12. `read` `(` var `)` `。 // is this an array declaration int iArraySize。 enum TokenType type。 NodeKind nodekind。 CODE: define MAX_CHILDREN 3 class CTreeNode { public: CTreeNode* child[ MAX_CHILDREN ]。 語(yǔ)法分析: 本系統(tǒng)中語(yǔ)法分析的功能是由類 Cparser 來(lái)完成的。例如:當(dāng)系統(tǒng)查找到‘ +’時(shí),自動(dòng)把它翻譯成 Token 類型 PLUS。amp。 ? Class CScaner: 這個(gè)類 的作用為:獲取 C語(yǔ)言源程序中具體具體的的 token 類型。39。在本程序中也同樣建立了一個(gè)關(guān)于 C語(yǔ)言關(guān)鍵字的對(duì)應(yīng)表 詞法分析功能主要由以下兩個(gè)類來(lái)完成: ? Class CTokenizer: 這個(gè)類的主要作用為:從一個(gè)字符串中(這里把一個(gè)文件看作是一個(gè)字符串, MFC中CFileCstring 獲取用戶調(diào)入 的 C 語(yǔ)言源程序)分離出一個(gè)一個(gè) token 來(lái),配上簡(jiǎn)單的類型再通過(guò) NextToken()獲取返回值。標(biāo)識(shí)符必須以字母或下劃線開(kāi)頭。編譯原理的基礎(chǔ)知識(shí)在本文的第二部分已做了介紹,這里就不再重復(fù)。 語(yǔ)法樹(shù)結(jié)構(gòu)的定義是本步驟的重點(diǎn)。在這里如果檢測(cè)到構(gòu)詞法的錯(cuò)誤,則記錄該錯(cuò)誤的位置 token,并通過(guò)給出錯(cuò)誤的輸出。在完成上述查找翻譯詞法檢測(cè)之后,在這個(gè)部分還有一個(gè)特殊的功能。詞法分析大致分為兩個(gè)部分: C 語(yǔ)言保留字的查找特殊字符的查找與翻譯 (翻譯成 token 字符 ),變量、函數(shù)等程序?qū)ο蟮脑~ 法檢測(cè)。存儲(chǔ)到 MFC 為文件提供的專用 BUFFER 中,注意這個(gè)時(shí)候文件的存儲(chǔ)是以一個(gè)一個(gè)字符的形式存儲(chǔ)的。在這一章中,本章中將重點(diǎn)從全局的角度對(duì)本系統(tǒng)主算法進(jìn)行一個(gè)分析與實(shí)現(xiàn)的說(shuō)明。///關(guān)閉連接 本系統(tǒng)在設(shè)計(jì)對(duì) Access 進(jìn)行操作時(shí)為了方便將上 述操作寫(xiě)成了一個(gè)類。參數(shù) RecordsAffected 是操作完成后所影響的行數(shù) , 參數(shù) Options表示 CommandText中內(nèi)容的類型, Options可以取如下值之一:adCmdText 表明 CommandText 是文本命令; adCmdTable 表明 CommandText 是一個(gè)表名; adCmdProc 表明 CommandText 是一個(gè)存儲(chǔ)過(guò)程; adCmdUnknown 表明CommandText